ltmain.sh revision 52fd71cd
152fd71cdSmrg#! /bin/sh 252fd71cdSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 352fd71cdSmrg## by inline-source v2014-01-03.01 4d63fdb69Smrg 552fd71cdSmrg# libtool (GNU libtool) 2.4.6 652fd71cdSmrg# Provide generalized library-building support services. 7d63fdb69Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8d63fdb69Smrg 952fd71cdSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10d63fdb69Smrg# This is free software; see the source for copying conditions. There is NO 11d63fdb69Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12d63fdb69Smrg 13d63fdb69Smrg# GNU Libtool is free software; you can redistribute it and/or modify 143da084b3Smrg# it under the terms of the GNU General Public License as published by 153da084b3Smrg# the Free Software Foundation; either version 2 of the License, or 163da084b3Smrg# (at your option) any later version. 173da084b3Smrg# 18d63fdb69Smrg# As a special exception to the GNU General Public License, 19d63fdb69Smrg# if you distribute this file as part of a program or library that 20d63fdb69Smrg# is built using GNU Libtool, you may include this file under the 21d63fdb69Smrg# same distribution terms that you use for the rest of that program. 22d63fdb69Smrg# 23d63fdb69Smrg# GNU Libtool is distributed in the hope that it will be useful, but 243da084b3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 253da084b3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 263da084b3Smrg# General Public License for more details. 273da084b3Smrg# 283da084b3Smrg# You should have received a copy of the GNU General Public License 2952fd71cdSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30d63fdb69Smrg 31d63fdb69Smrg 3255acc8fcSmrgPROGRAM=libtool 33d63fdb69SmrgPACKAGE=libtool 3452fd71cdSmrgVERSION=2.4.6 3552fd71cdSmrgpackage_revision=2.4.6 36d63fdb69Smrg 3752fd71cdSmrg 3852fd71cdSmrg## ------ ## 3952fd71cdSmrg## Usage. ## 4052fd71cdSmrg## ------ ## 4152fd71cdSmrg 4252fd71cdSmrg# Run './libtool --help' for help with using this script from the 4352fd71cdSmrg# command line. 4452fd71cdSmrg 4552fd71cdSmrg 4652fd71cdSmrg## ------------------------------- ## 4752fd71cdSmrg## User overridable command paths. ## 4852fd71cdSmrg## ------------------------------- ## 4952fd71cdSmrg 5052fd71cdSmrg# After configure completes, it has a better idea of some of the 5152fd71cdSmrg# shell tools we need than the defaults used by the functions shared 5252fd71cdSmrg# with bootstrap, so set those here where they can still be over- 5352fd71cdSmrg# ridden by the user, but otherwise take precedence. 5452fd71cdSmrg 5552fd71cdSmrg: ${AUTOCONF="autoconf"} 5652fd71cdSmrg: ${AUTOMAKE="automake"} 5752fd71cdSmrg 5852fd71cdSmrg 5952fd71cdSmrg## -------------------------- ## 6052fd71cdSmrg## Source external libraries. ## 6152fd71cdSmrg## -------------------------- ## 6252fd71cdSmrg 6352fd71cdSmrg# Much of our low-level functionality needs to be sourced from external 6452fd71cdSmrg# libraries, which are installed to $pkgauxdir. 6552fd71cdSmrg 6652fd71cdSmrg# Set a version string for this script. 6752fd71cdSmrgscriptversion=2015-01-20.17; # UTC 6852fd71cdSmrg 6952fd71cdSmrg# General shell script boiler plate, and helper functions. 7052fd71cdSmrg# Written by Gary V. Vaughan, 2004 7152fd71cdSmrg 7252fd71cdSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7352fd71cdSmrg# This is free software; see the source for copying conditions. There is NO 7452fd71cdSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7552fd71cdSmrg 7652fd71cdSmrg# This program is free software; you can redistribute it and/or modify 7752fd71cdSmrg# it under the terms of the GNU General Public License as published by 7852fd71cdSmrg# the Free Software Foundation; either version 3 of the License, or 7952fd71cdSmrg# (at your option) any later version. 8052fd71cdSmrg 8152fd71cdSmrg# As a special exception to the GNU General Public License, if you distribute 8252fd71cdSmrg# this file as part of a program or library that is built using GNU Libtool, 8352fd71cdSmrg# you may include this file under the same distribution terms that you use 8452fd71cdSmrg# for the rest of that program. 8552fd71cdSmrg 8652fd71cdSmrg# This program is distributed in the hope that it will be useful, 8752fd71cdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8852fd71cdSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8952fd71cdSmrg# General Public License for more details. 9052fd71cdSmrg 9152fd71cdSmrg# You should have received a copy of the GNU General Public License 9252fd71cdSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9352fd71cdSmrg 9452fd71cdSmrg# Please report bugs or propose patches to gary@gnu.org. 9552fd71cdSmrg 9652fd71cdSmrg 9752fd71cdSmrg## ------ ## 9852fd71cdSmrg## Usage. ## 9952fd71cdSmrg## ------ ## 10052fd71cdSmrg 10152fd71cdSmrg# Evaluate this file near the top of your script to gain access to 10252fd71cdSmrg# the functions and variables defined here: 10352fd71cdSmrg# 10452fd71cdSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10552fd71cdSmrg# 10652fd71cdSmrg# If you need to override any of the default environment variable 10752fd71cdSmrg# settings, do that before evaluating this file. 10852fd71cdSmrg 10952fd71cdSmrg 11052fd71cdSmrg## -------------------- ## 11152fd71cdSmrg## Shell normalisation. ## 11252fd71cdSmrg## -------------------- ## 11352fd71cdSmrg 11452fd71cdSmrg# Some shells need a little help to be as Bourne compatible as possible. 11552fd71cdSmrg# Before doing anything else, make sure all that help has been provided! 11652fd71cdSmrg 11752fd71cdSmrgDUALCASE=1; export DUALCASE # for MKS sh 11852fd71cdSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119d63fdb69Smrg emulate sh 120d63fdb69Smrg NULLCMD=: 12152fd71cdSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122d63fdb69Smrg # is contrary to our usage. Disable this feature. 123d63fdb69Smrg alias -g '${1+"$@"}'='"$@"' 124d63fdb69Smrg setopt NO_GLOB_SUBST 125d63fdb69Smrgelse 12652fd71cdSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127d63fdb69Smrgfi 12855acc8fcSmrg 12952fd71cdSmrg# NLS nuisances: We save the old values in case they are required later. 13052fd71cdSmrg_G_user_locale= 13152fd71cdSmrg_G_safe_locale= 13252fd71cdSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133d63fdb69Smrgdo 13452fd71cdSmrg eval "if test set = \"\${$_G_var+set}\"; then 13552fd71cdSmrg save_$_G_var=\$$_G_var 13652fd71cdSmrg $_G_var=C 13752fd71cdSmrg export $_G_var 13852fd71cdSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13952fd71cdSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140d63fdb69Smrg fi" 141d63fdb69Smrgdone 142d63fdb69Smrg 14352fd71cdSmrg# CDPATH. 14452fd71cdSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145d63fdb69Smrg 14652fd71cdSmrg# Make sure IFS has a sensible default 14752fd71cdSmrgsp=' ' 14852fd71cdSmrgnl=' 14952fd71cdSmrg' 15052fd71cdSmrgIFS="$sp $nl" 15152fd71cdSmrg 15252fd71cdSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 15352fd71cdSmrgif test "${PATH_SEPARATOR+set}" != set; then 15452fd71cdSmrg PATH_SEPARATOR=: 15552fd71cdSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15652fd71cdSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15752fd71cdSmrg PATH_SEPARATOR=';' 15852fd71cdSmrg } 15952fd71cdSmrgfi 160d63fdb69Smrg 161d63fdb69Smrg 162d63fdb69Smrg 16352fd71cdSmrg## ------------------------- ## 16452fd71cdSmrg## Locate command utilities. ## 16552fd71cdSmrg## ------------------------- ## 16652fd71cdSmrg 16752fd71cdSmrg 16852fd71cdSmrg# func_executable_p FILE 16952fd71cdSmrg# ---------------------- 17052fd71cdSmrg# Check that FILE is an executable regular file. 17152fd71cdSmrgfunc_executable_p () 17252fd71cdSmrg{ 17352fd71cdSmrg test -f "$1" && test -x "$1" 17452fd71cdSmrg} 17552fd71cdSmrg 17652fd71cdSmrg 17752fd71cdSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17852fd71cdSmrg# -------------------------------------------- 17952fd71cdSmrg# Search for either a program that responds to --version with output 18052fd71cdSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18152fd71cdSmrg# trying all the directories in PATH with each of the elements of 18252fd71cdSmrg# PROGS_LIST. 18352fd71cdSmrg# 18452fd71cdSmrg# CHECK_FUNC should accept the path to a candidate program, and 18552fd71cdSmrg# set $func_check_prog_result if it truncates its output less than 18652fd71cdSmrg# $_G_path_prog_max characters. 18752fd71cdSmrgfunc_path_progs () 18852fd71cdSmrg{ 18952fd71cdSmrg _G_progs_list=$1 19052fd71cdSmrg _G_check_func=$2 19152fd71cdSmrg _G_PATH=${3-"$PATH"} 19252fd71cdSmrg 19352fd71cdSmrg _G_path_prog_max=0 19452fd71cdSmrg _G_path_prog_found=false 19552fd71cdSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19652fd71cdSmrg for _G_dir in $_G_PATH; do 19752fd71cdSmrg IFS=$_G_save_IFS 19852fd71cdSmrg test -z "$_G_dir" && _G_dir=. 19952fd71cdSmrg for _G_prog_name in $_G_progs_list; do 20052fd71cdSmrg for _exeext in '' .EXE; do 20152fd71cdSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20252fd71cdSmrg func_executable_p "$_G_path_prog" || continue 20352fd71cdSmrg case `"$_G_path_prog" --version 2>&1` in 20452fd71cdSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20552fd71cdSmrg *) $_G_check_func $_G_path_prog 20652fd71cdSmrg func_path_progs_result=$func_check_prog_result 20752fd71cdSmrg ;; 20852fd71cdSmrg esac 20952fd71cdSmrg $_G_path_prog_found && break 3 21052fd71cdSmrg done 21152fd71cdSmrg done 21252fd71cdSmrg done 21352fd71cdSmrg IFS=$_G_save_IFS 21452fd71cdSmrg test -z "$func_path_progs_result" && { 21552fd71cdSmrg echo "no acceptable sed could be found in \$PATH" >&2 21652fd71cdSmrg exit 1 21752fd71cdSmrg } 21852fd71cdSmrg} 21952fd71cdSmrg 22052fd71cdSmrg 22152fd71cdSmrg# We want to be able to use the functions in this file before configure 22252fd71cdSmrg# has figured out where the best binaries are kept, which means we have 22352fd71cdSmrg# to search for them ourselves - except when the results are already set 22452fd71cdSmrg# where we skip the searches. 22552fd71cdSmrg 22652fd71cdSmrg# Unless the user overrides by setting SED, search the path for either GNU 22752fd71cdSmrg# sed, or the sed that truncates its output the least. 22852fd71cdSmrgtest -z "$SED" && { 22952fd71cdSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23052fd71cdSmrg for _G_i in 1 2 3 4 5 6 7; do 23152fd71cdSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23252fd71cdSmrg done 23352fd71cdSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23452fd71cdSmrg _G_sed_script= 23552fd71cdSmrg 23652fd71cdSmrg func_check_prog_sed () 23752fd71cdSmrg { 23852fd71cdSmrg _G_path_prog=$1 23952fd71cdSmrg 24052fd71cdSmrg _G_count=0 24152fd71cdSmrg printf 0123456789 >conftest.in 24252fd71cdSmrg while : 24352fd71cdSmrg do 24452fd71cdSmrg cat conftest.in conftest.in >conftest.tmp 24552fd71cdSmrg mv conftest.tmp conftest.in 24652fd71cdSmrg cp conftest.in conftest.nl 24752fd71cdSmrg echo '' >> conftest.nl 24852fd71cdSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24952fd71cdSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25052fd71cdSmrg _G_count=`expr $_G_count + 1` 25152fd71cdSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25252fd71cdSmrg # Best one so far, save it but keep looking for a better one 25352fd71cdSmrg func_check_prog_result=$_G_path_prog 25452fd71cdSmrg _G_path_prog_max=$_G_count 25552fd71cdSmrg fi 25652fd71cdSmrg # 10*(2^10) chars as input seems more than enough 25752fd71cdSmrg test 10 -lt "$_G_count" && break 25852fd71cdSmrg done 25952fd71cdSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26052fd71cdSmrg } 26152fd71cdSmrg 26252fd71cdSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26352fd71cdSmrg rm -f conftest.sed 26452fd71cdSmrg SED=$func_path_progs_result 26552fd71cdSmrg} 26652fd71cdSmrg 26752fd71cdSmrg 26852fd71cdSmrg# Unless the user overrides by setting GREP, search the path for either GNU 26952fd71cdSmrg# grep, or the grep that truncates its output the least. 27052fd71cdSmrgtest -z "$GREP" && { 27152fd71cdSmrg func_check_prog_grep () 27252fd71cdSmrg { 27352fd71cdSmrg _G_path_prog=$1 27452fd71cdSmrg 27552fd71cdSmrg _G_count=0 27652fd71cdSmrg _G_path_prog_max=0 27752fd71cdSmrg printf 0123456789 >conftest.in 27852fd71cdSmrg while : 27952fd71cdSmrg do 28052fd71cdSmrg cat conftest.in conftest.in >conftest.tmp 28152fd71cdSmrg mv conftest.tmp conftest.in 28252fd71cdSmrg cp conftest.in conftest.nl 28352fd71cdSmrg echo 'GREP' >> conftest.nl 28452fd71cdSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28552fd71cdSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28652fd71cdSmrg _G_count=`expr $_G_count + 1` 28752fd71cdSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28852fd71cdSmrg # Best one so far, save it but keep looking for a better one 28952fd71cdSmrg func_check_prog_result=$_G_path_prog 29052fd71cdSmrg _G_path_prog_max=$_G_count 29152fd71cdSmrg fi 29252fd71cdSmrg # 10*(2^10) chars as input seems more than enough 29352fd71cdSmrg test 10 -lt "$_G_count" && break 29452fd71cdSmrg done 29552fd71cdSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29652fd71cdSmrg } 29752fd71cdSmrg 29852fd71cdSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29952fd71cdSmrg GREP=$func_path_progs_result 30052fd71cdSmrg} 30152fd71cdSmrg 30252fd71cdSmrg 30352fd71cdSmrg## ------------------------------- ## 30452fd71cdSmrg## User overridable command paths. ## 30552fd71cdSmrg## ------------------------------- ## 30652fd71cdSmrg 30752fd71cdSmrg# All uppercase variable names are used for environment variables. These 30852fd71cdSmrg# variables can be overridden by the user before calling a script that 30952fd71cdSmrg# uses them if a suitable command of that name is not already available 31052fd71cdSmrg# in the command search PATH. 311d63fdb69Smrg 312d63fdb69Smrg: ${CP="cp -f"} 31352fd71cdSmrg: ${ECHO="printf %s\n"} 31452fd71cdSmrg: ${EGREP="$GREP -E"} 31552fd71cdSmrg: ${FGREP="$GREP -F"} 31652fd71cdSmrg: ${LN_S="ln -s"} 317d63fdb69Smrg: ${MAKE="make"} 318d63fdb69Smrg: ${MKDIR="mkdir"} 319d63fdb69Smrg: ${MV="mv -f"} 320d63fdb69Smrg: ${RM="rm -f"} 321d63fdb69Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322d63fdb69Smrg 323d63fdb69Smrg 32452fd71cdSmrg## -------------------- ## 32552fd71cdSmrg## Useful sed snippets. ## 32652fd71cdSmrg## -------------------- ## 32748c85eb7Smrg 32852fd71cdSmrgsed_dirname='s|/[^/]*$||' 32952fd71cdSmrgsed_basename='s|^.*/||' 33048c85eb7Smrg 33152fd71cdSmrg# Sed substitution that helps us do robust quoting. It backslashifies 33252fd71cdSmrg# metacharacters that are still active within double-quoted strings. 33352fd71cdSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33448c85eb7Smrg 33552fd71cdSmrg# Same as above, but do not quote variable references. 33652fd71cdSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33748c85eb7Smrg 33852fd71cdSmrg# Sed substitution that turns a string into a regex matching for the 33952fd71cdSmrg# string literally. 34052fd71cdSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34148c85eb7Smrg 34252fd71cdSmrg# Sed substitution that converts a w32 file name or path 34352fd71cdSmrg# that contains forward slashes, into one that contains 34452fd71cdSmrg# (escaped) backslashes. A very naive implementation. 34552fd71cdSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34652fd71cdSmrg 34752fd71cdSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34852fd71cdSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34952fd71cdSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35052fd71cdSmrg# expansion. Since each input '\' is now two '\'s, look for any number 35152fd71cdSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35252fd71cdSmrg_G_bs='\\' 35352fd71cdSmrg_G_bs2='\\\\' 35452fd71cdSmrg_G_bs4='\\\\\\\\' 35552fd71cdSmrg_G_dollar='\$' 35652fd71cdSmrgsed_double_backslash="\ 35752fd71cdSmrg s/$_G_bs4/&\\ 35852fd71cdSmrg/g 35952fd71cdSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36052fd71cdSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36152fd71cdSmrg s/\n//g" 36248c85eb7Smrg 363d63fdb69Smrg 36452fd71cdSmrg## ----------------- ## 36552fd71cdSmrg## Global variables. ## 36652fd71cdSmrg## ----------------- ## 3673da084b3Smrg 36852fd71cdSmrg# Except for the global variables explicitly listed below, the following 36952fd71cdSmrg# functions in the '^func_' namespace, and the '^require_' namespace 37052fd71cdSmrg# variables initialised in the 'Resource management' section, sourcing 37152fd71cdSmrg# this file will not pollute your global namespace with anything 37252fd71cdSmrg# else. There's no portable way to scope variables in Bourne shell 37352fd71cdSmrg# though, so actually running these functions will sometimes place 37452fd71cdSmrg# results into a variable named after the function, and often use 37552fd71cdSmrg# temporary variables in the '^_G_' namespace. If you are careful to 37652fd71cdSmrg# avoid using those namespaces casually in your sourcing script, things 37752fd71cdSmrg# should continue to work as you expect. And, of course, you can freely 37852fd71cdSmrg# overwrite any of the functions or variables defined here before 37952fd71cdSmrg# calling anything to customize them. 38055acc8fcSmrg 38152fd71cdSmrgEXIT_SUCCESS=0 38252fd71cdSmrgEXIT_FAILURE=1 38352fd71cdSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38452fd71cdSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38555acc8fcSmrg 38652fd71cdSmrg# Allow overriding, eg assuming that you follow the convention of 38752fd71cdSmrg# putting '$debug_cmd' at the start of all your functions, you can get 38852fd71cdSmrg# bash to show function call trace with: 38952fd71cdSmrg# 39052fd71cdSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39152fd71cdSmrgdebug_cmd=${debug_cmd-":"} 39252fd71cdSmrgexit_cmd=: 39355acc8fcSmrg 39452fd71cdSmrg# By convention, finish your script with: 39552fd71cdSmrg# 39652fd71cdSmrg# exit $exit_status 39752fd71cdSmrg# 39852fd71cdSmrg# so that you can set exit_status to non-zero if you want to indicate 39952fd71cdSmrg# something went wrong during execution without actually bailing out at 40052fd71cdSmrg# the point of failure. 40152fd71cdSmrgexit_status=$EXIT_SUCCESS 40255acc8fcSmrg 40352fd71cdSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40452fd71cdSmrg# is ksh but when the shell is invoked as "sh" and the current value of 40552fd71cdSmrg# the _XPG environment variable is not equal to 1 (one), the special 40652fd71cdSmrg# positional parameter $0, within a function call, is the name of the 40752fd71cdSmrg# function. 40852fd71cdSmrgprogpath=$0 4093da084b3Smrg 41052fd71cdSmrg# The name of this program. 41152fd71cdSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4123da084b3Smrg 41352fd71cdSmrg# Make sure we have an absolute progpath for reexecution: 414d63fdb69Smrgcase $progpath in 415d63fdb69Smrg [\\/]*|[A-Za-z]:\\*) ;; 416d63fdb69Smrg *[\\/]*) 41752fd71cdSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418d63fdb69Smrg progdir=`cd "$progdir" && pwd` 41952fd71cdSmrg progpath=$progdir/$progname 420d63fdb69Smrg ;; 421d63fdb69Smrg *) 42252fd71cdSmrg _G_IFS=$IFS 42348c85eb7Smrg IFS=${PATH_SEPARATOR-:} 424d63fdb69Smrg for progdir in $PATH; do 42552fd71cdSmrg IFS=$_G_IFS 426d63fdb69Smrg test -x "$progdir/$progname" && break 427d63fdb69Smrg done 42852fd71cdSmrg IFS=$_G_IFS 429d63fdb69Smrg test -n "$progdir" || progdir=`pwd` 43052fd71cdSmrg progpath=$progdir/$progname 431d63fdb69Smrg ;; 432d63fdb69Smrgesac 4333da084b3Smrg 434d63fdb69Smrg 43552fd71cdSmrg## ----------------- ## 43652fd71cdSmrg## Standard options. ## 43752fd71cdSmrg## ----------------- ## 43848c85eb7Smrg 43952fd71cdSmrg# The following options affect the operation of the functions defined 44052fd71cdSmrg# below, and should be set appropriately depending on run-time para- 44152fd71cdSmrg# meters passed on the command line. 442d63fdb69Smrg 443d63fdb69Smrgopt_dry_run=false 444d63fdb69Smrgopt_quiet=false 445d63fdb69Smrgopt_verbose=false 446d63fdb69Smrg 44752fd71cdSmrg# Categories 'all' and 'none' are always available. Append any others 44852fd71cdSmrg# you will pass as the first argument to func_warning from your own 44952fd71cdSmrg# code. 45052fd71cdSmrgwarning_categories= 4513da084b3Smrg 45252fd71cdSmrg# By default, display warnings according to 'opt_warning_types'. Set 45352fd71cdSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45452fd71cdSmrg# treat the next displayed warning as a fatal error. 45552fd71cdSmrgwarning_func=func_warn_and_continue 4563da084b3Smrg 45752fd71cdSmrg# Set to 'all' to display all warnings, 'none' to suppress all 45852fd71cdSmrg# warnings, or a space delimited list of some subset of 45952fd71cdSmrg# 'warning_categories' to display only the listed warnings. 46052fd71cdSmrgopt_warning_types=all 4613da084b3Smrg 46255acc8fcSmrg 46352fd71cdSmrg## -------------------- ## 46452fd71cdSmrg## Resource management. ## 46552fd71cdSmrg## -------------------- ## 4663da084b3Smrg 46752fd71cdSmrg# This section contains definitions for functions that each ensure a 46852fd71cdSmrg# particular resource (a file, or a non-empty configuration variable for 46952fd71cdSmrg# example) is available, and if appropriate to extract default values 47052fd71cdSmrg# from pertinent package files. Call them using their associated 47152fd71cdSmrg# 'require_*' variable to ensure that they are executed, at most, once. 47252fd71cdSmrg# 47352fd71cdSmrg# It's entirely deliberate that calling these functions can set 47452fd71cdSmrg# variables that don't obey the namespace limitations obeyed by the rest 47552fd71cdSmrg# of this file, in order that that they be as useful as possible to 47652fd71cdSmrg# callers. 4773da084b3Smrg 4783da084b3Smrg 47952fd71cdSmrg# require_term_colors 48052fd71cdSmrg# ------------------- 48152fd71cdSmrg# Allow display of bold text on terminals that support it. 48252fd71cdSmrgrequire_term_colors=func_require_term_colors 48352fd71cdSmrgfunc_require_term_colors () 484d63fdb69Smrg{ 48552fd71cdSmrg $debug_cmd 48652fd71cdSmrg 48752fd71cdSmrg test -t 1 && { 48852fd71cdSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 48952fd71cdSmrg # precedence, because most terminfo databases neglect to describe 49052fd71cdSmrg # whether color sequences are supported. 49152fd71cdSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49252fd71cdSmrg 49352fd71cdSmrg if test 1 = "$USE_ANSI_COLORS"; then 49452fd71cdSmrg # Standard ANSI escape sequences 49552fd71cdSmrg tc_reset='[0m' 49652fd71cdSmrg tc_bold='[1m'; tc_standout='[7m' 49752fd71cdSmrg tc_red='[31m'; tc_green='[32m' 49852fd71cdSmrg tc_blue='[34m'; tc_cyan='[36m' 49952fd71cdSmrg else 50052fd71cdSmrg # Otherwise trust the terminfo database after all. 50152fd71cdSmrg test -n "`tput sgr0 2>/dev/null`" && { 50252fd71cdSmrg tc_reset=`tput sgr0` 50352fd71cdSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50452fd71cdSmrg tc_standout=$tc_bold 50552fd71cdSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50652fd71cdSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50752fd71cdSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50852fd71cdSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50952fd71cdSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51052fd71cdSmrg } 51152fd71cdSmrg fi 51252fd71cdSmrg } 5133da084b3Smrg 51452fd71cdSmrg require_term_colors=: 515d63fdb69Smrg} 5163da084b3Smrg 5173da084b3Smrg 51852fd71cdSmrg## ----------------- ## 51952fd71cdSmrg## Function library. ## 52052fd71cdSmrg## ----------------- ## 52152fd71cdSmrg 52252fd71cdSmrg# This section contains a variety of useful functions to call in your 52352fd71cdSmrg# scripts. Take note of the portable wrappers for features provided by 52452fd71cdSmrg# some modern shells, which will fall back to slower equivalents on 52552fd71cdSmrg# less featureful shells. 52652fd71cdSmrg 52752fd71cdSmrg 52852fd71cdSmrg# func_append VAR VALUE 52952fd71cdSmrg# --------------------- 53052fd71cdSmrg# Append VALUE onto the existing contents of VAR. 53152fd71cdSmrg 53252fd71cdSmrg # We should try to minimise forks, especially on Windows where they are 53352fd71cdSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 53452fd71cdSmrg # being used: 53552fd71cdSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53652fd71cdSmrg : ${_G_HAVE_ARITH_OP="yes"} 53752fd71cdSmrg : ${_G_HAVE_XSI_OPS="yes"} 53852fd71cdSmrg # The += operator was introduced in bash 3.1 53952fd71cdSmrg case $BASH_VERSION in 54052fd71cdSmrg [12].* | 3.0 | 3.0*) ;; 54152fd71cdSmrg *) 54252fd71cdSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54352fd71cdSmrg ;; 54452fd71cdSmrg esac 54552fd71cdSmrg fi 54652fd71cdSmrg 54752fd71cdSmrg # _G_HAVE_PLUSEQ_OP 54852fd71cdSmrg # Can be empty, in which case the shell is probed, "yes" if += is 54952fd71cdSmrg # useable or anything else if it does not work. 55052fd71cdSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55152fd71cdSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55252fd71cdSmrg && _G_HAVE_PLUSEQ_OP=yes 55352fd71cdSmrg 55452fd71cdSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55552fd71cdSmrgthen 55652fd71cdSmrg # This is an XSI compatible shell, allowing a faster implementation... 55752fd71cdSmrg eval 'func_append () 55852fd71cdSmrg { 55952fd71cdSmrg $debug_cmd 56052fd71cdSmrg 56152fd71cdSmrg eval "$1+=\$2" 56252fd71cdSmrg }' 56352fd71cdSmrgelse 56452fd71cdSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 56552fd71cdSmrg func_append () 56652fd71cdSmrg { 56752fd71cdSmrg $debug_cmd 56852fd71cdSmrg 56952fd71cdSmrg eval "$1=\$$1\$2" 57052fd71cdSmrg } 57152fd71cdSmrgfi 57252fd71cdSmrg 57352fd71cdSmrg 57452fd71cdSmrg# func_append_quoted VAR VALUE 57552fd71cdSmrg# ---------------------------- 57652fd71cdSmrg# Quote VALUE and append to the end of shell variable VAR, separated 57752fd71cdSmrg# by a space. 57852fd71cdSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57952fd71cdSmrg eval 'func_append_quoted () 58052fd71cdSmrg { 58152fd71cdSmrg $debug_cmd 58252fd71cdSmrg 58352fd71cdSmrg func_quote_for_eval "$2" 58452fd71cdSmrg eval "$1+=\\ \$func_quote_for_eval_result" 58552fd71cdSmrg }' 58652fd71cdSmrgelse 58752fd71cdSmrg func_append_quoted () 58852fd71cdSmrg { 58952fd71cdSmrg $debug_cmd 59052fd71cdSmrg 59152fd71cdSmrg func_quote_for_eval "$2" 59252fd71cdSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59352fd71cdSmrg } 59452fd71cdSmrgfi 59552fd71cdSmrg 59652fd71cdSmrg 59752fd71cdSmrg# func_append_uniq VAR VALUE 59852fd71cdSmrg# -------------------------- 59952fd71cdSmrg# Append unique VALUE onto the existing contents of VAR, assuming 60052fd71cdSmrg# entries are delimited by the first character of VALUE. For example: 60152fd71cdSmrg# 60252fd71cdSmrg# func_append_uniq options " --another-option option-argument" 60352fd71cdSmrg# 60452fd71cdSmrg# will only append to $options if " --another-option option-argument " 60552fd71cdSmrg# is not already present somewhere in $options already (note spaces at 60652fd71cdSmrg# each end implied by leading space in second argument). 60752fd71cdSmrgfunc_append_uniq () 60852fd71cdSmrg{ 60952fd71cdSmrg $debug_cmd 61052fd71cdSmrg 61152fd71cdSmrg eval _G_current_value='`$ECHO $'$1'`' 61252fd71cdSmrg _G_delim=`expr "$2" : '\(.\)'` 61352fd71cdSmrg 61452fd71cdSmrg case $_G_delim$_G_current_value$_G_delim in 61552fd71cdSmrg *"$2$_G_delim"*) ;; 61652fd71cdSmrg *) func_append "$@" ;; 61752fd71cdSmrg esac 61852fd71cdSmrg} 61952fd71cdSmrg 62052fd71cdSmrg 62152fd71cdSmrg# func_arith TERM... 62252fd71cdSmrg# ------------------ 62352fd71cdSmrg# Set func_arith_result to the result of evaluating TERMs. 62452fd71cdSmrg test -z "$_G_HAVE_ARITH_OP" \ 62552fd71cdSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62652fd71cdSmrg && _G_HAVE_ARITH_OP=yes 62752fd71cdSmrg 62852fd71cdSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 62952fd71cdSmrg eval 'func_arith () 63052fd71cdSmrg { 63152fd71cdSmrg $debug_cmd 63252fd71cdSmrg 63352fd71cdSmrg func_arith_result=$(( $* )) 63452fd71cdSmrg }' 63552fd71cdSmrgelse 63652fd71cdSmrg func_arith () 63752fd71cdSmrg { 63852fd71cdSmrg $debug_cmd 63952fd71cdSmrg 64052fd71cdSmrg func_arith_result=`expr "$@"` 64152fd71cdSmrg } 64252fd71cdSmrgfi 64352fd71cdSmrg 64452fd71cdSmrg 64552fd71cdSmrg# func_basename FILE 64652fd71cdSmrg# ------------------ 64752fd71cdSmrg# Set func_basename_result to FILE with everything up to and including 64852fd71cdSmrg# the last / stripped. 64952fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 65052fd71cdSmrg # If this shell supports suffix pattern removal, then use it to avoid 65152fd71cdSmrg # forking. Hide the definitions single quotes in case the shell chokes 65252fd71cdSmrg # on unsupported syntax... 65352fd71cdSmrg _b='func_basename_result=${1##*/}' 65452fd71cdSmrg _d='case $1 in 65552fd71cdSmrg */*) func_dirname_result=${1%/*}$2 ;; 65652fd71cdSmrg * ) func_dirname_result=$3 ;; 65752fd71cdSmrg esac' 65852fd71cdSmrg 65952fd71cdSmrgelse 66052fd71cdSmrg # ...otherwise fall back to using sed. 66152fd71cdSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66252fd71cdSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66352fd71cdSmrg if test "X$func_dirname_result" = "X$1"; then 66452fd71cdSmrg func_dirname_result=$3 66552fd71cdSmrg else 66652fd71cdSmrg func_append func_dirname_result "$2" 66752fd71cdSmrg fi' 66852fd71cdSmrgfi 66952fd71cdSmrg 67052fd71cdSmrgeval 'func_basename () 67152fd71cdSmrg{ 67252fd71cdSmrg $debug_cmd 67352fd71cdSmrg 67452fd71cdSmrg '"$_b"' 67552fd71cdSmrg}' 67652fd71cdSmrg 67752fd71cdSmrg 67852fd71cdSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67952fd71cdSmrg# ------------------------------------------- 68052fd71cdSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68152fd71cdSmrg# otherwise set result to NONDIR_REPLACEMENT. 68252fd71cdSmrgeval 'func_dirname () 68352fd71cdSmrg{ 68452fd71cdSmrg $debug_cmd 68552fd71cdSmrg 68652fd71cdSmrg '"$_d"' 68752fd71cdSmrg}' 68852fd71cdSmrg 68952fd71cdSmrg 69052fd71cdSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69152fd71cdSmrg# -------------------------------------------------------- 69252fd71cdSmrg# Perform func_basename and func_dirname in a single function 69352fd71cdSmrg# call: 69452fd71cdSmrg# dirname: Compute the dirname of FILE. If nonempty, 69552fd71cdSmrg# add APPEND to the result, otherwise set result 69652fd71cdSmrg# to NONDIR_REPLACEMENT. 69752fd71cdSmrg# value returned in "$func_dirname_result" 69852fd71cdSmrg# basename: Compute filename of FILE. 69952fd71cdSmrg# value retuned in "$func_basename_result" 70052fd71cdSmrg# For efficiency, we do not delegate to the functions above but instead 70152fd71cdSmrg# duplicate the functionality here. 70252fd71cdSmrgeval 'func_dirname_and_basename () 70352fd71cdSmrg{ 70452fd71cdSmrg $debug_cmd 70552fd71cdSmrg 70652fd71cdSmrg '"$_b"' 70752fd71cdSmrg '"$_d"' 70852fd71cdSmrg}' 70952fd71cdSmrg 71052fd71cdSmrg 71152fd71cdSmrg# func_echo ARG... 71252fd71cdSmrg# ---------------- 71352fd71cdSmrg# Echo program name prefixed message. 71452fd71cdSmrgfunc_echo () 71552fd71cdSmrg{ 71652fd71cdSmrg $debug_cmd 71752fd71cdSmrg 71852fd71cdSmrg _G_message=$* 71952fd71cdSmrg 72052fd71cdSmrg func_echo_IFS=$IFS 72152fd71cdSmrg IFS=$nl 72252fd71cdSmrg for _G_line in $_G_message; do 72352fd71cdSmrg IFS=$func_echo_IFS 72452fd71cdSmrg $ECHO "$progname: $_G_line" 72552fd71cdSmrg done 72652fd71cdSmrg IFS=$func_echo_IFS 72752fd71cdSmrg} 72852fd71cdSmrg 72952fd71cdSmrg 73052fd71cdSmrg# func_echo_all ARG... 73152fd71cdSmrg# -------------------- 73252fd71cdSmrg# Invoke $ECHO with all args, space-separated. 73352fd71cdSmrgfunc_echo_all () 73452fd71cdSmrg{ 73552fd71cdSmrg $ECHO "$*" 73652fd71cdSmrg} 73752fd71cdSmrg 73852fd71cdSmrg 73952fd71cdSmrg# func_echo_infix_1 INFIX ARG... 74052fd71cdSmrg# ------------------------------ 74152fd71cdSmrg# Echo program name, followed by INFIX on the first line, with any 74252fd71cdSmrg# additional lines not showing INFIX. 74352fd71cdSmrgfunc_echo_infix_1 () 74452fd71cdSmrg{ 74552fd71cdSmrg $debug_cmd 74652fd71cdSmrg 74752fd71cdSmrg $require_term_colors 74852fd71cdSmrg 74952fd71cdSmrg _G_infix=$1; shift 75052fd71cdSmrg _G_indent=$_G_infix 75152fd71cdSmrg _G_prefix="$progname: $_G_infix: " 75252fd71cdSmrg _G_message=$* 75352fd71cdSmrg 75452fd71cdSmrg # Strip color escape sequences before counting printable length 75552fd71cdSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75652fd71cdSmrg do 75752fd71cdSmrg test -n "$_G_tc" && { 75852fd71cdSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75952fd71cdSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76052fd71cdSmrg } 76152fd71cdSmrg done 76252fd71cdSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76352fd71cdSmrg 76452fd71cdSmrg func_echo_infix_1_IFS=$IFS 76552fd71cdSmrg IFS=$nl 76652fd71cdSmrg for _G_line in $_G_message; do 76752fd71cdSmrg IFS=$func_echo_infix_1_IFS 76852fd71cdSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76952fd71cdSmrg _G_prefix=$_G_indent 77052fd71cdSmrg done 77152fd71cdSmrg IFS=$func_echo_infix_1_IFS 77252fd71cdSmrg} 77352fd71cdSmrg 77452fd71cdSmrg 77552fd71cdSmrg# func_error ARG... 77652fd71cdSmrg# ----------------- 77752fd71cdSmrg# Echo program name prefixed message to standard error. 77852fd71cdSmrgfunc_error () 77952fd71cdSmrg{ 78052fd71cdSmrg $debug_cmd 78152fd71cdSmrg 78252fd71cdSmrg $require_term_colors 78352fd71cdSmrg 78452fd71cdSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78552fd71cdSmrg} 78652fd71cdSmrg 78752fd71cdSmrg 78852fd71cdSmrg# func_fatal_error ARG... 78952fd71cdSmrg# ----------------------- 79052fd71cdSmrg# Echo program name prefixed message to standard error, and exit. 79152fd71cdSmrgfunc_fatal_error () 79252fd71cdSmrg{ 79352fd71cdSmrg $debug_cmd 79452fd71cdSmrg 79552fd71cdSmrg func_error "$*" 79652fd71cdSmrg exit $EXIT_FAILURE 79752fd71cdSmrg} 79852fd71cdSmrg 79952fd71cdSmrg 80052fd71cdSmrg# func_grep EXPRESSION FILENAME 80152fd71cdSmrg# ----------------------------- 802d63fdb69Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803d63fdb69Smrgfunc_grep () 804d63fdb69Smrg{ 80552fd71cdSmrg $debug_cmd 80652fd71cdSmrg 807d63fdb69Smrg $GREP "$1" "$2" >/dev/null 2>&1 808d63fdb69Smrg} 809d63fdb69Smrg 810d63fdb69Smrg 81152fd71cdSmrg# func_len STRING 81252fd71cdSmrg# --------------- 81352fd71cdSmrg# Set func_len_result to the length of STRING. STRING may not 81452fd71cdSmrg# start with a hyphen. 81552fd71cdSmrg test -z "$_G_HAVE_XSI_OPS" \ 81652fd71cdSmrg && (eval 'x=a/b/c; 81752fd71cdSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81852fd71cdSmrg && _G_HAVE_XSI_OPS=yes 81952fd71cdSmrg 82052fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 82152fd71cdSmrg eval 'func_len () 82252fd71cdSmrg { 82352fd71cdSmrg $debug_cmd 82452fd71cdSmrg 82552fd71cdSmrg func_len_result=${#1} 82652fd71cdSmrg }' 82752fd71cdSmrgelse 82852fd71cdSmrg func_len () 82952fd71cdSmrg { 83052fd71cdSmrg $debug_cmd 83152fd71cdSmrg 83252fd71cdSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83352fd71cdSmrg } 83452fd71cdSmrgfi 83552fd71cdSmrg 83652fd71cdSmrg 83752fd71cdSmrg# func_mkdir_p DIRECTORY-PATH 83852fd71cdSmrg# --------------------------- 839d63fdb69Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840d63fdb69Smrgfunc_mkdir_p () 841d63fdb69Smrg{ 84252fd71cdSmrg $debug_cmd 843d63fdb69Smrg 84452fd71cdSmrg _G_directory_path=$1 84552fd71cdSmrg _G_dir_list= 846d63fdb69Smrg 84752fd71cdSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84852fd71cdSmrg 84952fd71cdSmrg # Protect directory names starting with '-' 85052fd71cdSmrg case $_G_directory_path in 85152fd71cdSmrg -*) _G_directory_path=./$_G_directory_path ;; 852d63fdb69Smrg esac 853d63fdb69Smrg 854d63fdb69Smrg # While some portion of DIR does not yet exist... 85552fd71cdSmrg while test ! -d "$_G_directory_path"; do 856d63fdb69Smrg # ...make a list in topmost first order. Use a colon delimited 857d63fdb69Smrg # list incase some portion of path contains whitespace. 85852fd71cdSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 859d63fdb69Smrg 860d63fdb69Smrg # If the last portion added has no slash in it, the list is done 86152fd71cdSmrg case $_G_directory_path in */*) ;; *) break ;; esac 862d63fdb69Smrg 863d63fdb69Smrg # ...otherwise throw away the child directory and loop 86452fd71cdSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865d63fdb69Smrg done 86652fd71cdSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867d63fdb69Smrg 86852fd71cdSmrg func_mkdir_p_IFS=$IFS; IFS=: 86952fd71cdSmrg for _G_dir in $_G_dir_list; do 87052fd71cdSmrg IFS=$func_mkdir_p_IFS 87152fd71cdSmrg # mkdir can fail with a 'File exist' error if two processes 872d63fdb69Smrg # try to create one of the directories concurrently. Don't 873d63fdb69Smrg # stop in that case! 87452fd71cdSmrg $MKDIR "$_G_dir" 2>/dev/null || : 875d63fdb69Smrg done 87652fd71cdSmrg IFS=$func_mkdir_p_IFS 877d63fdb69Smrg 878d63fdb69Smrg # Bail out if we (or some other process) failed to create a directory. 87952fd71cdSmrg test -d "$_G_directory_path" || \ 88052fd71cdSmrg func_fatal_error "Failed to create '$1'" 881d63fdb69Smrg fi 882d63fdb69Smrg} 8833da084b3Smrg 8843da084b3Smrg 88552fd71cdSmrg# func_mktempdir [BASENAME] 88652fd71cdSmrg# ------------------------- 8873da084b3Smrg# Make a temporary directory that won't clash with other running 8883da084b3Smrg# libtool processes, and avoids race conditions if possible. If 88952fd71cdSmrg# given, BASENAME is the basename for that directory. 8903da084b3Smrgfunc_mktempdir () 8913da084b3Smrg{ 89252fd71cdSmrg $debug_cmd 89352fd71cdSmrg 89452fd71cdSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 8953da084b3Smrg 89652fd71cdSmrg if test : = "$opt_dry_run"; then 8973da084b3Smrg # Return a directory name, but don't create it in dry-run mode 89852fd71cdSmrg _G_tmpdir=$_G_template-$$ 8993da084b3Smrg else 9003da084b3Smrg 9013da084b3Smrg # If mktemp works, use that first and foremost 90252fd71cdSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9033da084b3Smrg 90452fd71cdSmrg if test ! -d "$_G_tmpdir"; then 905d63fdb69Smrg # Failing that, at least try and use $RANDOM to avoid a race 90652fd71cdSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9073da084b3Smrg 90852fd71cdSmrg func_mktempdir_umask=`umask` 909d63fdb69Smrg umask 0077 91052fd71cdSmrg $MKDIR "$_G_tmpdir" 91152fd71cdSmrg umask $func_mktempdir_umask 9123da084b3Smrg fi 9133da084b3Smrg 9143da084b3Smrg # If we're not in dry-run mode, bomb out on failure 91552fd71cdSmrg test -d "$_G_tmpdir" || \ 91652fd71cdSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91752fd71cdSmrg fi 91852fd71cdSmrg 91952fd71cdSmrg $ECHO "$_G_tmpdir" 92052fd71cdSmrg} 92152fd71cdSmrg 92252fd71cdSmrg 92352fd71cdSmrg# func_normal_abspath PATH 92452fd71cdSmrg# ------------------------ 92552fd71cdSmrg# Remove doubled-up and trailing slashes, "." path components, 92652fd71cdSmrg# and cancel out any ".." path components in PATH after making 92752fd71cdSmrg# it an absolute path. 92852fd71cdSmrgfunc_normal_abspath () 92952fd71cdSmrg{ 93052fd71cdSmrg $debug_cmd 93152fd71cdSmrg 93252fd71cdSmrg # These SED scripts presuppose an absolute path with a trailing slash. 93352fd71cdSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93452fd71cdSmrg _G_pathcdr='s|^/[^/]*||' 93552fd71cdSmrg _G_removedotparts=':dotsl 93652fd71cdSmrg s|/\./|/|g 93752fd71cdSmrg t dotsl 93852fd71cdSmrg s|/\.$|/|' 93952fd71cdSmrg _G_collapseslashes='s|/\{1,\}|/|g' 94052fd71cdSmrg _G_finalslash='s|/*$|/|' 94152fd71cdSmrg 94252fd71cdSmrg # Start from root dir and reassemble the path. 94352fd71cdSmrg func_normal_abspath_result= 94452fd71cdSmrg func_normal_abspath_tpath=$1 94552fd71cdSmrg func_normal_abspath_altnamespace= 94652fd71cdSmrg case $func_normal_abspath_tpath in 94752fd71cdSmrg "") 94852fd71cdSmrg # Empty path, that just means $cwd. 94952fd71cdSmrg func_stripname '' '/' "`pwd`" 95052fd71cdSmrg func_normal_abspath_result=$func_stripname_result 95152fd71cdSmrg return 95252fd71cdSmrg ;; 95352fd71cdSmrg # The next three entries are used to spot a run of precisely 95452fd71cdSmrg # two leading slashes without using negated character classes; 95552fd71cdSmrg # we take advantage of case's first-match behaviour. 95652fd71cdSmrg ///*) 95752fd71cdSmrg # Unusual form of absolute path, do nothing. 95852fd71cdSmrg ;; 95952fd71cdSmrg //*) 96052fd71cdSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96152fd71cdSmrg # and for example Cygwin uses it to access remote file shares 96252fd71cdSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 96352fd71cdSmrg func_normal_abspath_altnamespace=/ 96452fd71cdSmrg ;; 96552fd71cdSmrg /*) 96652fd71cdSmrg # Absolute path, do nothing. 96752fd71cdSmrg ;; 96852fd71cdSmrg *) 96952fd71cdSmrg # Relative path, prepend $cwd. 97052fd71cdSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97152fd71cdSmrg ;; 97252fd71cdSmrg esac 97352fd71cdSmrg 97452fd71cdSmrg # Cancel out all the simple stuff to save iterations. We also want 97552fd71cdSmrg # the path to end with a slash for ease of parsing, so make sure 97652fd71cdSmrg # there is one (and only one) here. 97752fd71cdSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97852fd71cdSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97952fd71cdSmrg while :; do 98052fd71cdSmrg # Processed it all yet? 98152fd71cdSmrg if test / = "$func_normal_abspath_tpath"; then 98252fd71cdSmrg # If we ascended to the root using ".." the result may be empty now. 98352fd71cdSmrg if test -z "$func_normal_abspath_result"; then 98452fd71cdSmrg func_normal_abspath_result=/ 98552fd71cdSmrg fi 98652fd71cdSmrg break 98752fd71cdSmrg fi 98852fd71cdSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98952fd71cdSmrg -e "$_G_pathcar"` 99052fd71cdSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99152fd71cdSmrg -e "$_G_pathcdr"` 99252fd71cdSmrg # Figure out what to do with it 99352fd71cdSmrg case $func_normal_abspath_tcomponent in 99452fd71cdSmrg "") 99552fd71cdSmrg # Trailing empty path component, ignore it. 99652fd71cdSmrg ;; 99752fd71cdSmrg ..) 99852fd71cdSmrg # Parent dir; strip last assembled component from result. 99952fd71cdSmrg func_dirname "$func_normal_abspath_result" 100052fd71cdSmrg func_normal_abspath_result=$func_dirname_result 100152fd71cdSmrg ;; 100252fd71cdSmrg *) 100352fd71cdSmrg # Actual path component, append it. 100452fd71cdSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100552fd71cdSmrg ;; 100652fd71cdSmrg esac 100752fd71cdSmrg done 100852fd71cdSmrg # Restore leading double-slash if one was found on entry. 100952fd71cdSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101052fd71cdSmrg} 101152fd71cdSmrg 101252fd71cdSmrg 101352fd71cdSmrg# func_notquiet ARG... 101452fd71cdSmrg# -------------------- 101552fd71cdSmrg# Echo program name prefixed message only when not in quiet mode. 101652fd71cdSmrgfunc_notquiet () 101752fd71cdSmrg{ 101852fd71cdSmrg $debug_cmd 101952fd71cdSmrg 102052fd71cdSmrg $opt_quiet || func_echo ${1+"$@"} 102152fd71cdSmrg 102252fd71cdSmrg # A bug in bash halts the script if the last line of a function 102352fd71cdSmrg # fails when set -e is in force, so we need another command to 102452fd71cdSmrg # work around that: 102552fd71cdSmrg : 102652fd71cdSmrg} 102752fd71cdSmrg 102852fd71cdSmrg 102952fd71cdSmrg# func_relative_path SRCDIR DSTDIR 103052fd71cdSmrg# -------------------------------- 103152fd71cdSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103252fd71cdSmrgfunc_relative_path () 103352fd71cdSmrg{ 103452fd71cdSmrg $debug_cmd 103552fd71cdSmrg 103652fd71cdSmrg func_relative_path_result= 103752fd71cdSmrg func_normal_abspath "$1" 103852fd71cdSmrg func_relative_path_tlibdir=$func_normal_abspath_result 103952fd71cdSmrg func_normal_abspath "$2" 104052fd71cdSmrg func_relative_path_tbindir=$func_normal_abspath_result 104152fd71cdSmrg 104252fd71cdSmrg # Ascend the tree starting from libdir 104352fd71cdSmrg while :; do 104452fd71cdSmrg # check if we have found a prefix of bindir 104552fd71cdSmrg case $func_relative_path_tbindir in 104652fd71cdSmrg $func_relative_path_tlibdir) 104752fd71cdSmrg # found an exact match 104852fd71cdSmrg func_relative_path_tcancelled= 104952fd71cdSmrg break 105052fd71cdSmrg ;; 105152fd71cdSmrg $func_relative_path_tlibdir*) 105252fd71cdSmrg # found a matching prefix 105352fd71cdSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105452fd71cdSmrg func_relative_path_tcancelled=$func_stripname_result 105552fd71cdSmrg if test -z "$func_relative_path_result"; then 105652fd71cdSmrg func_relative_path_result=. 105752fd71cdSmrg fi 105852fd71cdSmrg break 105952fd71cdSmrg ;; 106052fd71cdSmrg *) 106152fd71cdSmrg func_dirname $func_relative_path_tlibdir 106252fd71cdSmrg func_relative_path_tlibdir=$func_dirname_result 106352fd71cdSmrg if test -z "$func_relative_path_tlibdir"; then 106452fd71cdSmrg # Have to descend all the way to the root! 106552fd71cdSmrg func_relative_path_result=../$func_relative_path_result 106652fd71cdSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 106752fd71cdSmrg break 106852fd71cdSmrg fi 106952fd71cdSmrg func_relative_path_result=../$func_relative_path_result 107052fd71cdSmrg ;; 107152fd71cdSmrg esac 107252fd71cdSmrg done 107352fd71cdSmrg 107452fd71cdSmrg # Now calculate path; take care to avoid doubling-up slashes. 107552fd71cdSmrg func_stripname '' '/' "$func_relative_path_result" 107652fd71cdSmrg func_relative_path_result=$func_stripname_result 107752fd71cdSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107852fd71cdSmrg if test -n "$func_stripname_result"; then 107952fd71cdSmrg func_append func_relative_path_result "/$func_stripname_result" 108052fd71cdSmrg fi 108152fd71cdSmrg 108252fd71cdSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 108352fd71cdSmrg if test -n "$func_relative_path_result"; then 108452fd71cdSmrg func_stripname './' '' "$func_relative_path_result" 108552fd71cdSmrg func_relative_path_result=$func_stripname_result 10863da084b3Smrg fi 10873da084b3Smrg 108852fd71cdSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 108952fd71cdSmrg 109052fd71cdSmrg : 109152fd71cdSmrg} 109252fd71cdSmrg 109352fd71cdSmrg 109452fd71cdSmrg# func_quote_for_eval ARG... 109552fd71cdSmrg# -------------------------- 109652fd71cdSmrg# Aesthetically quote ARGs to be evaled later. 109752fd71cdSmrg# This function returns two values: 109852fd71cdSmrg# i) func_quote_for_eval_result 109952fd71cdSmrg# double-quoted, suitable for a subsequent eval 110052fd71cdSmrg# ii) func_quote_for_eval_unquoted_result 110152fd71cdSmrg# has all characters that are still active within double 110252fd71cdSmrg# quotes backslashified. 110352fd71cdSmrgfunc_quote_for_eval () 110452fd71cdSmrg{ 110552fd71cdSmrg $debug_cmd 110652fd71cdSmrg 110752fd71cdSmrg func_quote_for_eval_unquoted_result= 110852fd71cdSmrg func_quote_for_eval_result= 110952fd71cdSmrg while test 0 -lt $#; do 111052fd71cdSmrg case $1 in 111152fd71cdSmrg *[\\\`\"\$]*) 111252fd71cdSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111352fd71cdSmrg *) 111452fd71cdSmrg _G_unquoted_arg=$1 ;; 111552fd71cdSmrg esac 111652fd71cdSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 111752fd71cdSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111852fd71cdSmrg else 111952fd71cdSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112052fd71cdSmrg fi 112152fd71cdSmrg 112252fd71cdSmrg case $_G_unquoted_arg in 112352fd71cdSmrg # Double-quote args containing shell metacharacters to delay 112452fd71cdSmrg # word splitting, command substitution and variable expansion 112552fd71cdSmrg # for a subsequent eval. 112652fd71cdSmrg # Many Bourne shells cannot handle close brackets correctly 112752fd71cdSmrg # in scan sets, so we specify it separately. 112852fd71cdSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112952fd71cdSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 113052fd71cdSmrg ;; 113152fd71cdSmrg *) 113252fd71cdSmrg _G_quoted_arg=$_G_unquoted_arg 113352fd71cdSmrg ;; 113452fd71cdSmrg esac 113552fd71cdSmrg 113652fd71cdSmrg if test -n "$func_quote_for_eval_result"; then 113752fd71cdSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113852fd71cdSmrg else 113952fd71cdSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114052fd71cdSmrg fi 114152fd71cdSmrg shift 114252fd71cdSmrg done 114352fd71cdSmrg} 114452fd71cdSmrg 114552fd71cdSmrg 114652fd71cdSmrg# func_quote_for_expand ARG 114752fd71cdSmrg# ------------------------- 114852fd71cdSmrg# Aesthetically quote ARG to be evaled later; same as above, 114952fd71cdSmrg# but do not quote variable references. 115052fd71cdSmrgfunc_quote_for_expand () 115152fd71cdSmrg{ 115252fd71cdSmrg $debug_cmd 115352fd71cdSmrg 115452fd71cdSmrg case $1 in 115552fd71cdSmrg *[\\\`\"]*) 115652fd71cdSmrg _G_arg=`$ECHO "$1" | $SED \ 115752fd71cdSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115852fd71cdSmrg *) 115952fd71cdSmrg _G_arg=$1 ;; 116052fd71cdSmrg esac 116152fd71cdSmrg 116252fd71cdSmrg case $_G_arg in 116352fd71cdSmrg # Double-quote args containing shell metacharacters to delay 116452fd71cdSmrg # word splitting and command substitution for a subsequent eval. 116552fd71cdSmrg # Many Bourne shells cannot handle close brackets correctly 116652fd71cdSmrg # in scan sets, so we specify it separately. 116752fd71cdSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116852fd71cdSmrg _G_arg=\"$_G_arg\" 116952fd71cdSmrg ;; 117052fd71cdSmrg esac 117152fd71cdSmrg 117252fd71cdSmrg func_quote_for_expand_result=$_G_arg 117352fd71cdSmrg} 117452fd71cdSmrg 117552fd71cdSmrg 117652fd71cdSmrg# func_stripname PREFIX SUFFIX NAME 117752fd71cdSmrg# --------------------------------- 117852fd71cdSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117952fd71cdSmrg# PREFIX and SUFFIX must not contain globbing or regex special 118052fd71cdSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118152fd71cdSmrg# dot (in which case that matches only a dot). 118252fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 118352fd71cdSmrg eval 'func_stripname () 118452fd71cdSmrg { 118552fd71cdSmrg $debug_cmd 118652fd71cdSmrg 118752fd71cdSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118852fd71cdSmrg # positional parameters, so assign one to ordinary variable first. 118952fd71cdSmrg func_stripname_result=$3 119052fd71cdSmrg func_stripname_result=${func_stripname_result#"$1"} 119152fd71cdSmrg func_stripname_result=${func_stripname_result%"$2"} 119252fd71cdSmrg }' 119352fd71cdSmrgelse 119452fd71cdSmrg func_stripname () 119552fd71cdSmrg { 119652fd71cdSmrg $debug_cmd 119752fd71cdSmrg 119852fd71cdSmrg case $2 in 119952fd71cdSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120052fd71cdSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120152fd71cdSmrg esac 120252fd71cdSmrg } 120352fd71cdSmrgfi 120452fd71cdSmrg 120552fd71cdSmrg 120652fd71cdSmrg# func_show_eval CMD [FAIL_EXP] 120752fd71cdSmrg# ----------------------------- 120852fd71cdSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120952fd71cdSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121052fd71cdSmrg# is given, then evaluate it. 121152fd71cdSmrgfunc_show_eval () 121252fd71cdSmrg{ 121352fd71cdSmrg $debug_cmd 121452fd71cdSmrg 121552fd71cdSmrg _G_cmd=$1 121652fd71cdSmrg _G_fail_exp=${2-':'} 121752fd71cdSmrg 121852fd71cdSmrg func_quote_for_expand "$_G_cmd" 121952fd71cdSmrg eval "func_notquiet $func_quote_for_expand_result" 122052fd71cdSmrg 122152fd71cdSmrg $opt_dry_run || { 122252fd71cdSmrg eval "$_G_cmd" 122352fd71cdSmrg _G_status=$? 122452fd71cdSmrg if test 0 -ne "$_G_status"; then 122552fd71cdSmrg eval "(exit $_G_status); $_G_fail_exp" 122652fd71cdSmrg fi 122752fd71cdSmrg } 122852fd71cdSmrg} 122952fd71cdSmrg 123052fd71cdSmrg 123152fd71cdSmrg# func_show_eval_locale CMD [FAIL_EXP] 123252fd71cdSmrg# ------------------------------------ 123352fd71cdSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123452fd71cdSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123552fd71cdSmrg# is given, then evaluate it. Use the saved locale for evaluation. 123652fd71cdSmrgfunc_show_eval_locale () 123752fd71cdSmrg{ 123852fd71cdSmrg $debug_cmd 123952fd71cdSmrg 124052fd71cdSmrg _G_cmd=$1 124152fd71cdSmrg _G_fail_exp=${2-':'} 124252fd71cdSmrg 124352fd71cdSmrg $opt_quiet || { 124452fd71cdSmrg func_quote_for_expand "$_G_cmd" 124552fd71cdSmrg eval "func_echo $func_quote_for_expand_result" 124652fd71cdSmrg } 124752fd71cdSmrg 124852fd71cdSmrg $opt_dry_run || { 124952fd71cdSmrg eval "$_G_user_locale 125052fd71cdSmrg $_G_cmd" 125152fd71cdSmrg _G_status=$? 125252fd71cdSmrg eval "$_G_safe_locale" 125352fd71cdSmrg if test 0 -ne "$_G_status"; then 125452fd71cdSmrg eval "(exit $_G_status); $_G_fail_exp" 125552fd71cdSmrg fi 125652fd71cdSmrg } 125752fd71cdSmrg} 125852fd71cdSmrg 125952fd71cdSmrg 126052fd71cdSmrg# func_tr_sh 126152fd71cdSmrg# ---------- 126252fd71cdSmrg# Turn $1 into a string suitable for a shell variable name. 126352fd71cdSmrg# Result is stored in $func_tr_sh_result. All characters 126452fd71cdSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126552fd71cdSmrg# if $1 begins with a digit, a '_' is prepended as well. 126652fd71cdSmrgfunc_tr_sh () 126752fd71cdSmrg{ 126852fd71cdSmrg $debug_cmd 126952fd71cdSmrg 127052fd71cdSmrg case $1 in 127152fd71cdSmrg [0-9]* | *[!a-zA-Z0-9_]*) 127252fd71cdSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127352fd71cdSmrg ;; 127452fd71cdSmrg * ) 127552fd71cdSmrg func_tr_sh_result=$1 127652fd71cdSmrg ;; 127752fd71cdSmrg esac 127852fd71cdSmrg} 127952fd71cdSmrg 128052fd71cdSmrg 128152fd71cdSmrg# func_verbose ARG... 128252fd71cdSmrg# ------------------- 128352fd71cdSmrg# Echo program name prefixed message in verbose mode only. 128452fd71cdSmrgfunc_verbose () 128552fd71cdSmrg{ 128652fd71cdSmrg $debug_cmd 128752fd71cdSmrg 128852fd71cdSmrg $opt_verbose && func_echo "$*" 128952fd71cdSmrg 129052fd71cdSmrg : 129152fd71cdSmrg} 129252fd71cdSmrg 129352fd71cdSmrg 129452fd71cdSmrg# func_warn_and_continue ARG... 129552fd71cdSmrg# ----------------------------- 129652fd71cdSmrg# Echo program name prefixed warning message to standard error. 129752fd71cdSmrgfunc_warn_and_continue () 129852fd71cdSmrg{ 129952fd71cdSmrg $debug_cmd 130052fd71cdSmrg 130152fd71cdSmrg $require_term_colors 130252fd71cdSmrg 130352fd71cdSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130452fd71cdSmrg} 130552fd71cdSmrg 130652fd71cdSmrg 130752fd71cdSmrg# func_warning CATEGORY ARG... 130852fd71cdSmrg# ---------------------------- 130952fd71cdSmrg# Echo program name prefixed warning message to standard error. Warning 131052fd71cdSmrg# messages can be filtered according to CATEGORY, where this function 131152fd71cdSmrg# elides messages where CATEGORY is not listed in the global variable 131252fd71cdSmrg# 'opt_warning_types'. 131352fd71cdSmrgfunc_warning () 131452fd71cdSmrg{ 131552fd71cdSmrg $debug_cmd 131652fd71cdSmrg 131752fd71cdSmrg # CATEGORY must be in the warning_categories list! 131852fd71cdSmrg case " $warning_categories " in 131952fd71cdSmrg *" $1 "*) ;; 132052fd71cdSmrg *) func_internal_error "invalid warning category '$1'" ;; 132152fd71cdSmrg esac 132252fd71cdSmrg 132352fd71cdSmrg _G_category=$1 132452fd71cdSmrg shift 132552fd71cdSmrg 132652fd71cdSmrg case " $opt_warning_types " in 132752fd71cdSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132852fd71cdSmrg esac 132952fd71cdSmrg} 133052fd71cdSmrg 133152fd71cdSmrg 133252fd71cdSmrg# func_sort_ver VER1 VER2 133352fd71cdSmrg# ----------------------- 133452fd71cdSmrg# 'sort -V' is not generally available. 133552fd71cdSmrg# Note this deviates from the version comparison in automake 133652fd71cdSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133752fd71cdSmrg# but this should suffice as we won't be specifying old 133852fd71cdSmrg# version formats or redundant trailing .0 in bootstrap.conf. 133952fd71cdSmrg# If we did want full compatibility then we should probably 134052fd71cdSmrg# use m4_version_compare from autoconf. 134152fd71cdSmrgfunc_sort_ver () 134252fd71cdSmrg{ 134352fd71cdSmrg $debug_cmd 134452fd71cdSmrg 134552fd71cdSmrg printf '%s\n%s\n' "$1" "$2" \ 134652fd71cdSmrg | 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 134752fd71cdSmrg} 134852fd71cdSmrg 134952fd71cdSmrg# func_lt_ver PREV CURR 135052fd71cdSmrg# --------------------- 135152fd71cdSmrg# Return true if PREV and CURR are in the correct order according to 135252fd71cdSmrg# func_sort_ver, otherwise false. Use it like this: 135352fd71cdSmrg# 135452fd71cdSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135552fd71cdSmrgfunc_lt_ver () 135652fd71cdSmrg{ 135752fd71cdSmrg $debug_cmd 135852fd71cdSmrg 135952fd71cdSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136052fd71cdSmrg} 136152fd71cdSmrg 136252fd71cdSmrg 136352fd71cdSmrg# Local variables: 136452fd71cdSmrg# mode: shell-script 136552fd71cdSmrg# sh-indentation: 2 136652fd71cdSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 136752fd71cdSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136852fd71cdSmrg# time-stamp-time-zone: "UTC" 136952fd71cdSmrg# End: 137052fd71cdSmrg#! /bin/sh 137152fd71cdSmrg 137252fd71cdSmrg# Set a version string for this script. 137352fd71cdSmrgscriptversion=2014-01-07.03; # UTC 137452fd71cdSmrg 137552fd71cdSmrg# A portable, pluggable option parser for Bourne shell. 137652fd71cdSmrg# Written by Gary V. Vaughan, 2010 137752fd71cdSmrg 137852fd71cdSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137952fd71cdSmrg# This is free software; see the source for copying conditions. There is NO 138052fd71cdSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138152fd71cdSmrg 138252fd71cdSmrg# This program is free software: you can redistribute it and/or modify 138352fd71cdSmrg# it under the terms of the GNU General Public License as published by 138452fd71cdSmrg# the Free Software Foundation, either version 3 of the License, or 138552fd71cdSmrg# (at your option) any later version. 138652fd71cdSmrg 138752fd71cdSmrg# This program is distributed in the hope that it will be useful, 138852fd71cdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138952fd71cdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139052fd71cdSmrg# GNU General Public License for more details. 139152fd71cdSmrg 139252fd71cdSmrg# You should have received a copy of the GNU General Public License 139352fd71cdSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139452fd71cdSmrg 139552fd71cdSmrg# Please report bugs or propose patches to gary@gnu.org. 139652fd71cdSmrg 139752fd71cdSmrg 139852fd71cdSmrg## ------ ## 139952fd71cdSmrg## Usage. ## 140052fd71cdSmrg## ------ ## 140152fd71cdSmrg 140252fd71cdSmrg# This file is a library for parsing options in your shell scripts along 140352fd71cdSmrg# with assorted other useful supporting features that you can make use 140452fd71cdSmrg# of too. 140552fd71cdSmrg# 140652fd71cdSmrg# For the simplest scripts you might need only: 140752fd71cdSmrg# 140852fd71cdSmrg# #!/bin/sh 140952fd71cdSmrg# . relative/path/to/funclib.sh 141052fd71cdSmrg# . relative/path/to/options-parser 141152fd71cdSmrg# scriptversion=1.0 141252fd71cdSmrg# func_options ${1+"$@"} 141352fd71cdSmrg# eval set dummy "$func_options_result"; shift 141452fd71cdSmrg# ...rest of your script... 141552fd71cdSmrg# 141652fd71cdSmrg# In order for the '--version' option to work, you will need to have a 141752fd71cdSmrg# suitably formatted comment like the one at the top of this file 141852fd71cdSmrg# starting with '# Written by ' and ending with '# warranty; '. 141952fd71cdSmrg# 142052fd71cdSmrg# For '-h' and '--help' to work, you will also need a one line 142152fd71cdSmrg# description of your script's purpose in a comment directly above the 142252fd71cdSmrg# '# Written by ' line, like the one at the top of this file. 142352fd71cdSmrg# 142452fd71cdSmrg# The default options also support '--debug', which will turn on shell 142552fd71cdSmrg# execution tracing (see the comment above debug_cmd below for another 142652fd71cdSmrg# use), and '--verbose' and the func_verbose function to allow your script 142752fd71cdSmrg# to display verbose messages only when your user has specified 142852fd71cdSmrg# '--verbose'. 142952fd71cdSmrg# 143052fd71cdSmrg# After sourcing this file, you can plug processing for additional 143152fd71cdSmrg# options by amending the variables from the 'Configuration' section 143252fd71cdSmrg# below, and following the instructions in the 'Option parsing' 143352fd71cdSmrg# section further down. 143452fd71cdSmrg 143552fd71cdSmrg## -------------- ## 143652fd71cdSmrg## Configuration. ## 143752fd71cdSmrg## -------------- ## 143852fd71cdSmrg 143952fd71cdSmrg# You should override these variables in your script after sourcing this 144052fd71cdSmrg# file so that they reflect the customisations you have added to the 144152fd71cdSmrg# option parser. 144252fd71cdSmrg 144352fd71cdSmrg# The usage line for option parsing errors and the start of '-h' and 144452fd71cdSmrg# '--help' output messages. You can embed shell variables for delayed 144552fd71cdSmrg# expansion at the time the message is displayed, but you will need to 144652fd71cdSmrg# quote other shell meta-characters carefully to prevent them being 144752fd71cdSmrg# expanded when the contents are evaled. 144852fd71cdSmrgusage='$progpath [OPTION]...' 144952fd71cdSmrg 145052fd71cdSmrg# Short help message in response to '-h' and '--help'. Add to this or 145152fd71cdSmrg# override it after sourcing this library to reflect the full set of 145252fd71cdSmrg# options your script accepts. 145352fd71cdSmrgusage_message="\ 145452fd71cdSmrg --debug enable verbose shell tracing 145552fd71cdSmrg -W, --warnings=CATEGORY 145652fd71cdSmrg report the warnings falling in CATEGORY [all] 145752fd71cdSmrg -v, --verbose verbosely report processing 145852fd71cdSmrg --version print version information and exit 145952fd71cdSmrg -h, --help print short or long help message and exit 146052fd71cdSmrg" 146152fd71cdSmrg 146252fd71cdSmrg# Additional text appended to 'usage_message' in response to '--help'. 146352fd71cdSmrglong_help_message=" 146452fd71cdSmrgWarning categories include: 146552fd71cdSmrg 'all' show all warnings 146652fd71cdSmrg 'none' turn off all the warnings 146752fd71cdSmrg 'error' warnings are treated as fatal errors" 146852fd71cdSmrg 146952fd71cdSmrg# Help message printed before fatal option parsing errors. 147052fd71cdSmrgfatal_help="Try '\$progname --help' for more information." 147152fd71cdSmrg 147252fd71cdSmrg 147352fd71cdSmrg 147452fd71cdSmrg## ------------------------- ## 147552fd71cdSmrg## Hook function management. ## 147652fd71cdSmrg## ------------------------- ## 147752fd71cdSmrg 147852fd71cdSmrg# This section contains functions for adding, removing, and running hooks 147952fd71cdSmrg# to the main code. A hook is just a named list of of function, that can 148052fd71cdSmrg# be run in order later on. 148152fd71cdSmrg 148252fd71cdSmrg# func_hookable FUNC_NAME 148352fd71cdSmrg# ----------------------- 148452fd71cdSmrg# Declare that FUNC_NAME will run hooks added with 148552fd71cdSmrg# 'func_add_hook FUNC_NAME ...'. 148652fd71cdSmrgfunc_hookable () 148752fd71cdSmrg{ 148852fd71cdSmrg $debug_cmd 148952fd71cdSmrg 149052fd71cdSmrg func_append hookable_fns " $1" 149152fd71cdSmrg} 149252fd71cdSmrg 149352fd71cdSmrg 149452fd71cdSmrg# func_add_hook FUNC_NAME HOOK_FUNC 149552fd71cdSmrg# --------------------------------- 149652fd71cdSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149752fd71cdSmrg# first have been declared "hookable" by a call to 'func_hookable'. 149852fd71cdSmrgfunc_add_hook () 149952fd71cdSmrg{ 150052fd71cdSmrg $debug_cmd 150152fd71cdSmrg 150252fd71cdSmrg case " $hookable_fns " in 150352fd71cdSmrg *" $1 "*) ;; 150452fd71cdSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150552fd71cdSmrg esac 150652fd71cdSmrg 150752fd71cdSmrg eval func_append ${1}_hooks '" $2"' 150852fd71cdSmrg} 150952fd71cdSmrg 151052fd71cdSmrg 151152fd71cdSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 151252fd71cdSmrg# ------------------------------------ 151352fd71cdSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151452fd71cdSmrgfunc_remove_hook () 151552fd71cdSmrg{ 151652fd71cdSmrg $debug_cmd 151752fd71cdSmrg 151852fd71cdSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151952fd71cdSmrg} 152052fd71cdSmrg 152152fd71cdSmrg 152252fd71cdSmrg# func_run_hooks FUNC_NAME [ARG]... 152352fd71cdSmrg# --------------------------------- 152452fd71cdSmrg# Run all hook functions registered to FUNC_NAME. 152552fd71cdSmrg# It is assumed that the list of hook functions contains nothing more 152652fd71cdSmrg# than a whitespace-delimited list of legal shell function names, and 152752fd71cdSmrg# no effort is wasted trying to catch shell meta-characters or preserve 152852fd71cdSmrg# whitespace. 152952fd71cdSmrgfunc_run_hooks () 153052fd71cdSmrg{ 153152fd71cdSmrg $debug_cmd 153252fd71cdSmrg 153352fd71cdSmrg case " $hookable_fns " in 153452fd71cdSmrg *" $1 "*) ;; 153552fd71cdSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153652fd71cdSmrg esac 153752fd71cdSmrg 153852fd71cdSmrg eval _G_hook_fns=\$$1_hooks; shift 153952fd71cdSmrg 154052fd71cdSmrg for _G_hook in $_G_hook_fns; do 154152fd71cdSmrg eval $_G_hook '"$@"' 154252fd71cdSmrg 154352fd71cdSmrg # store returned options list back into positional 154452fd71cdSmrg # parameters for next 'cmd' execution. 154552fd71cdSmrg eval _G_hook_result=\$${_G_hook}_result 154652fd71cdSmrg eval set dummy "$_G_hook_result"; shift 154752fd71cdSmrg done 154852fd71cdSmrg 154952fd71cdSmrg func_quote_for_eval ${1+"$@"} 155052fd71cdSmrg func_run_hooks_result=$func_quote_for_eval_result 155152fd71cdSmrg} 155252fd71cdSmrg 155352fd71cdSmrg 155452fd71cdSmrg 155552fd71cdSmrg## --------------- ## 155652fd71cdSmrg## Option parsing. ## 155752fd71cdSmrg## --------------- ## 155852fd71cdSmrg 155952fd71cdSmrg# In order to add your own option parsing hooks, you must accept the 156052fd71cdSmrg# full positional parameter list in your hook function, remove any 156152fd71cdSmrg# options that you action, and then pass back the remaining unprocessed 156252fd71cdSmrg# options in '<hooked_function_name>_result', escaped suitably for 156352fd71cdSmrg# 'eval'. Like this: 156452fd71cdSmrg# 156552fd71cdSmrg# my_options_prep () 156652fd71cdSmrg# { 156752fd71cdSmrg# $debug_cmd 156852fd71cdSmrg# 156952fd71cdSmrg# # Extend the existing usage message. 157052fd71cdSmrg# usage_message=$usage_message' 157152fd71cdSmrg# -s, --silent don'\''t print informational messages 157252fd71cdSmrg# ' 157352fd71cdSmrg# 157452fd71cdSmrg# func_quote_for_eval ${1+"$@"} 157552fd71cdSmrg# my_options_prep_result=$func_quote_for_eval_result 157652fd71cdSmrg# } 157752fd71cdSmrg# func_add_hook func_options_prep my_options_prep 157852fd71cdSmrg# 157952fd71cdSmrg# 158052fd71cdSmrg# my_silent_option () 158152fd71cdSmrg# { 158252fd71cdSmrg# $debug_cmd 158352fd71cdSmrg# 158452fd71cdSmrg# # Note that for efficiency, we parse as many options as we can 158552fd71cdSmrg# # recognise in a loop before passing the remainder back to the 158652fd71cdSmrg# # caller on the first unrecognised argument we encounter. 158752fd71cdSmrg# while test $# -gt 0; do 158852fd71cdSmrg# opt=$1; shift 158952fd71cdSmrg# case $opt in 159052fd71cdSmrg# --silent|-s) opt_silent=: ;; 159152fd71cdSmrg# # Separate non-argument short options: 159252fd71cdSmrg# -s*) func_split_short_opt "$_G_opt" 159352fd71cdSmrg# set dummy "$func_split_short_opt_name" \ 159452fd71cdSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 159552fd71cdSmrg# shift 159652fd71cdSmrg# ;; 159752fd71cdSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159852fd71cdSmrg# esac 159952fd71cdSmrg# done 160052fd71cdSmrg# 160152fd71cdSmrg# func_quote_for_eval ${1+"$@"} 160252fd71cdSmrg# my_silent_option_result=$func_quote_for_eval_result 160352fd71cdSmrg# } 160452fd71cdSmrg# func_add_hook func_parse_options my_silent_option 160552fd71cdSmrg# 160652fd71cdSmrg# 160752fd71cdSmrg# my_option_validation () 160852fd71cdSmrg# { 160952fd71cdSmrg# $debug_cmd 161052fd71cdSmrg# 161152fd71cdSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161252fd71cdSmrg# '--silent' and '--verbose' options are mutually exclusive." 161352fd71cdSmrg# 161452fd71cdSmrg# func_quote_for_eval ${1+"$@"} 161552fd71cdSmrg# my_option_validation_result=$func_quote_for_eval_result 161652fd71cdSmrg# } 161752fd71cdSmrg# func_add_hook func_validate_options my_option_validation 161852fd71cdSmrg# 161952fd71cdSmrg# You'll alse need to manually amend $usage_message to reflect the extra 162052fd71cdSmrg# options you parse. It's preferable to append if you can, so that 162152fd71cdSmrg# multiple option parsing hooks can be added safely. 162252fd71cdSmrg 162352fd71cdSmrg 162452fd71cdSmrg# func_options [ARG]... 162552fd71cdSmrg# --------------------- 162652fd71cdSmrg# All the functions called inside func_options are hookable. See the 162752fd71cdSmrg# individual implementations for details. 162852fd71cdSmrgfunc_hookable func_options 162952fd71cdSmrgfunc_options () 163052fd71cdSmrg{ 163152fd71cdSmrg $debug_cmd 163252fd71cdSmrg 163352fd71cdSmrg func_options_prep ${1+"$@"} 163452fd71cdSmrg eval func_parse_options \ 163552fd71cdSmrg ${func_options_prep_result+"$func_options_prep_result"} 163652fd71cdSmrg eval func_validate_options \ 163752fd71cdSmrg ${func_parse_options_result+"$func_parse_options_result"} 163852fd71cdSmrg 163952fd71cdSmrg eval func_run_hooks func_options \ 164052fd71cdSmrg ${func_validate_options_result+"$func_validate_options_result"} 164152fd71cdSmrg 164252fd71cdSmrg # save modified positional parameters for caller 164352fd71cdSmrg func_options_result=$func_run_hooks_result 16443da084b3Smrg} 16453da084b3Smrg 16463da084b3Smrg 164752fd71cdSmrg# func_options_prep [ARG]... 164852fd71cdSmrg# -------------------------- 164952fd71cdSmrg# All initialisations required before starting the option parse loop. 165052fd71cdSmrg# Note that when calling hook functions, we pass through the list of 165152fd71cdSmrg# positional parameters. If a hook function modifies that list, and 165252fd71cdSmrg# needs to propogate that back to rest of this script, then the complete 165352fd71cdSmrg# modified list must be put in 'func_run_hooks_result' before 165452fd71cdSmrg# returning. 165552fd71cdSmrgfunc_hookable func_options_prep 165652fd71cdSmrgfunc_options_prep () 16573da084b3Smrg{ 165852fd71cdSmrg $debug_cmd 1659d63fdb69Smrg 166052fd71cdSmrg # Option defaults: 166152fd71cdSmrg opt_verbose=false 166252fd71cdSmrg opt_warning_types= 166352fd71cdSmrg 166452fd71cdSmrg func_run_hooks func_options_prep ${1+"$@"} 166552fd71cdSmrg 166652fd71cdSmrg # save modified positional parameters for caller 166752fd71cdSmrg func_options_prep_result=$func_run_hooks_result 16683da084b3Smrg} 16693da084b3Smrg 16703da084b3Smrg 167152fd71cdSmrg# func_parse_options [ARG]... 167252fd71cdSmrg# --------------------------- 167352fd71cdSmrg# The main option parsing loop. 167452fd71cdSmrgfunc_hookable func_parse_options 167552fd71cdSmrgfunc_parse_options () 16763da084b3Smrg{ 167752fd71cdSmrg $debug_cmd 1678d63fdb69Smrg 167952fd71cdSmrg func_parse_options_result= 1680d63fdb69Smrg 168152fd71cdSmrg # this just eases exit handling 168252fd71cdSmrg while test $# -gt 0; do 168352fd71cdSmrg # Defer to hook functions for initial option parsing, so they 168452fd71cdSmrg # get priority in the event of reusing an option name. 168552fd71cdSmrg func_run_hooks func_parse_options ${1+"$@"} 16863da084b3Smrg 168752fd71cdSmrg # Adjust func_parse_options positional parameters to match 168852fd71cdSmrg eval set dummy "$func_run_hooks_result"; shift 16893da084b3Smrg 169052fd71cdSmrg # Break out of the loop if we already parsed every option. 169152fd71cdSmrg test $# -gt 0 || break 16923da084b3Smrg 169352fd71cdSmrg _G_opt=$1 169452fd71cdSmrg shift 169552fd71cdSmrg case $_G_opt in 169652fd71cdSmrg --debug|-x) debug_cmd='set -x' 169752fd71cdSmrg func_echo "enabling shell trace mode" 169852fd71cdSmrg $debug_cmd 169952fd71cdSmrg ;; 170052fd71cdSmrg 170152fd71cdSmrg --no-warnings|--no-warning|--no-warn) 170252fd71cdSmrg set dummy --warnings none ${1+"$@"} 170352fd71cdSmrg shift 170452fd71cdSmrg ;; 1705d63fdb69Smrg 170652fd71cdSmrg --warnings|--warning|-W) 170752fd71cdSmrg test $# = 0 && func_missing_arg $_G_opt && break 170852fd71cdSmrg case " $warning_categories $1" in 170952fd71cdSmrg *" $1 "*) 171052fd71cdSmrg # trailing space prevents matching last $1 above 171152fd71cdSmrg func_append_uniq opt_warning_types " $1" 171252fd71cdSmrg ;; 171352fd71cdSmrg *all) 171452fd71cdSmrg opt_warning_types=$warning_categories 171552fd71cdSmrg ;; 171652fd71cdSmrg *none) 171752fd71cdSmrg opt_warning_types=none 171852fd71cdSmrg warning_func=: 171952fd71cdSmrg ;; 172052fd71cdSmrg *error) 172152fd71cdSmrg opt_warning_types=$warning_categories 172252fd71cdSmrg warning_func=func_fatal_error 172352fd71cdSmrg ;; 172452fd71cdSmrg *) 172552fd71cdSmrg func_fatal_error \ 172652fd71cdSmrg "unsupported warning category: '$1'" 172752fd71cdSmrg ;; 172852fd71cdSmrg esac 172952fd71cdSmrg shift 173052fd71cdSmrg ;; 173152fd71cdSmrg 173252fd71cdSmrg --verbose|-v) opt_verbose=: ;; 173352fd71cdSmrg --version) func_version ;; 173452fd71cdSmrg -\?|-h) func_usage ;; 173552fd71cdSmrg --help) func_help ;; 173652fd71cdSmrg 173752fd71cdSmrg # Separate optargs to long options (plugins may need this): 173852fd71cdSmrg --*=*) func_split_equals "$_G_opt" 173952fd71cdSmrg set dummy "$func_split_equals_lhs" \ 174052fd71cdSmrg "$func_split_equals_rhs" ${1+"$@"} 174152fd71cdSmrg shift 174252fd71cdSmrg ;; 174352fd71cdSmrg 174452fd71cdSmrg # Separate optargs to short options: 174552fd71cdSmrg -W*) 174652fd71cdSmrg func_split_short_opt "$_G_opt" 174752fd71cdSmrg set dummy "$func_split_short_opt_name" \ 174852fd71cdSmrg "$func_split_short_opt_arg" ${1+"$@"} 174952fd71cdSmrg shift 175052fd71cdSmrg ;; 175152fd71cdSmrg 175252fd71cdSmrg # Separate non-argument short options: 175352fd71cdSmrg -\?*|-h*|-v*|-x*) 175452fd71cdSmrg func_split_short_opt "$_G_opt" 175552fd71cdSmrg set dummy "$func_split_short_opt_name" \ 175652fd71cdSmrg "-$func_split_short_opt_arg" ${1+"$@"} 175752fd71cdSmrg shift 175852fd71cdSmrg ;; 175952fd71cdSmrg 176052fd71cdSmrg --) break ;; 176152fd71cdSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176252fd71cdSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176352fd71cdSmrg esac 176452fd71cdSmrg done 176552fd71cdSmrg 176652fd71cdSmrg # save modified positional parameters for caller 176752fd71cdSmrg func_quote_for_eval ${1+"$@"} 176852fd71cdSmrg func_parse_options_result=$func_quote_for_eval_result 17693da084b3Smrg} 17703da084b3Smrg 1771d63fdb69Smrg 177252fd71cdSmrg# func_validate_options [ARG]... 177352fd71cdSmrg# ------------------------------ 177452fd71cdSmrg# Perform any sanity checks on option settings and/or unconsumed 177552fd71cdSmrg# arguments. 177652fd71cdSmrgfunc_hookable func_validate_options 177752fd71cdSmrgfunc_validate_options () 17783da084b3Smrg{ 177952fd71cdSmrg $debug_cmd 17803da084b3Smrg 178152fd71cdSmrg # Display all warnings if -W was not given. 178252fd71cdSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783d63fdb69Smrg 178452fd71cdSmrg func_run_hooks func_validate_options ${1+"$@"} 17853da084b3Smrg 178652fd71cdSmrg # Bail if the options were screwed! 178752fd71cdSmrg $exit_cmd $EXIT_FAILURE 178852fd71cdSmrg 178952fd71cdSmrg # save modified positional parameters for caller 179052fd71cdSmrg func_validate_options_result=$func_run_hooks_result 179148c85eb7Smrg} 179248c85eb7Smrg 17933da084b3Smrg 179448c85eb7Smrg 179552fd71cdSmrg## ----------------- ## 179652fd71cdSmrg## Helper functions. ## 179752fd71cdSmrg## ----------------- ## 1798d63fdb69Smrg 179952fd71cdSmrg# This section contains the helper functions used by the rest of the 180052fd71cdSmrg# hookable option parser framework in ascii-betical order. 180152fd71cdSmrg 180252fd71cdSmrg 180352fd71cdSmrg# func_fatal_help ARG... 180452fd71cdSmrg# ---------------------- 180552fd71cdSmrg# Echo program name prefixed message to standard error, followed by 180652fd71cdSmrg# a help hint, and exit. 180752fd71cdSmrgfunc_fatal_help () 1808d63fdb69Smrg{ 180952fd71cdSmrg $debug_cmd 181048c85eb7Smrg 181152fd71cdSmrg eval \$ECHO \""Usage: $usage"\" 181252fd71cdSmrg eval \$ECHO \""$fatal_help"\" 181352fd71cdSmrg func_error ${1+"$@"} 181452fd71cdSmrg exit $EXIT_FAILURE 1815d63fdb69Smrg} 1816d63fdb69Smrg 181752fd71cdSmrg 181852fd71cdSmrg# func_help 181952fd71cdSmrg# --------- 182052fd71cdSmrg# Echo long help message to standard output and exit. 1821d63fdb69Smrgfunc_help () 1822d63fdb69Smrg{ 182352fd71cdSmrg $debug_cmd 182452fd71cdSmrg 182552fd71cdSmrg func_usage_message 182652fd71cdSmrg $ECHO "$long_help_message" 182752fd71cdSmrg exit 0 1828d63fdb69Smrg} 1829d63fdb69Smrg 183052fd71cdSmrg 183152fd71cdSmrg# func_missing_arg ARGNAME 183252fd71cdSmrg# ------------------------ 1833d63fdb69Smrg# Echo program name prefixed message to standard error and set global 1834d63fdb69Smrg# exit_cmd. 1835d63fdb69Smrgfunc_missing_arg () 1836d63fdb69Smrg{ 183752fd71cdSmrg $debug_cmd 183848c85eb7Smrg 183952fd71cdSmrg func_error "Missing argument for '$1'." 1840d63fdb69Smrg exit_cmd=exit 1841d63fdb69Smrg} 1842d63fdb69Smrg 1843d63fdb69Smrg 184452fd71cdSmrg# func_split_equals STRING 184552fd71cdSmrg# ------------------------ 184652fd71cdSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184752fd71cdSmrg# splitting STRING at the '=' sign. 184852fd71cdSmrgtest -z "$_G_HAVE_XSI_OPS" \ 184952fd71cdSmrg && (eval 'x=a/b/c; 185052fd71cdSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185152fd71cdSmrg && _G_HAVE_XSI_OPS=yes 185252fd71cdSmrg 185352fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS" 185452fd71cdSmrgthen 185552fd71cdSmrg # This is an XSI compatible shell, allowing a faster implementation... 185652fd71cdSmrg eval 'func_split_equals () 185752fd71cdSmrg { 185852fd71cdSmrg $debug_cmd 185952fd71cdSmrg 186052fd71cdSmrg func_split_equals_lhs=${1%%=*} 186152fd71cdSmrg func_split_equals_rhs=${1#*=} 186252fd71cdSmrg test "x$func_split_equals_lhs" = "x$1" \ 186352fd71cdSmrg && func_split_equals_rhs= 186452fd71cdSmrg }' 186552fd71cdSmrgelse 186652fd71cdSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 186752fd71cdSmrg func_split_equals () 186852fd71cdSmrg { 186952fd71cdSmrg $debug_cmd 187052fd71cdSmrg 187152fd71cdSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187252fd71cdSmrg func_split_equals_rhs= 187352fd71cdSmrg test "x$func_split_equals_lhs" = "x$1" \ 187452fd71cdSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187552fd71cdSmrg } 187652fd71cdSmrgfi #func_split_equals 187752fd71cdSmrg 187852fd71cdSmrg 187952fd71cdSmrg# func_split_short_opt SHORTOPT 188052fd71cdSmrg# ----------------------------- 188148c85eb7Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188248c85eb7Smrg# variables after splitting SHORTOPT after the 2nd character. 188352fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS" 188452fd71cdSmrgthen 188552fd71cdSmrg # This is an XSI compatible shell, allowing a faster implementation... 188652fd71cdSmrg eval 'func_split_short_opt () 188752fd71cdSmrg { 188852fd71cdSmrg $debug_cmd 188952fd71cdSmrg 189052fd71cdSmrg func_split_short_opt_arg=${1#??} 189152fd71cdSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189252fd71cdSmrg }' 189352fd71cdSmrgelse 189452fd71cdSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 189552fd71cdSmrg func_split_short_opt () 189652fd71cdSmrg { 189752fd71cdSmrg $debug_cmd 189852fd71cdSmrg 189952fd71cdSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190052fd71cdSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190152fd71cdSmrg } 190252fd71cdSmrgfi #func_split_short_opt 190352fd71cdSmrg 190452fd71cdSmrg 190552fd71cdSmrg# func_usage 190652fd71cdSmrg# ---------- 190752fd71cdSmrg# Echo short help message to standard output and exit. 190852fd71cdSmrgfunc_usage () 190948c85eb7Smrg{ 191052fd71cdSmrg $debug_cmd 191148c85eb7Smrg 191252fd71cdSmrg func_usage_message 191352fd71cdSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191452fd71cdSmrg exit 0 191552fd71cdSmrg} 191648c85eb7Smrg 191748c85eb7Smrg 191852fd71cdSmrg# func_usage_message 191952fd71cdSmrg# ------------------ 192052fd71cdSmrg# Echo short help message to standard output. 192152fd71cdSmrgfunc_usage_message () 192248c85eb7Smrg{ 192352fd71cdSmrg $debug_cmd 192448c85eb7Smrg 192552fd71cdSmrg eval \$ECHO \""Usage: $usage"\" 192652fd71cdSmrg echo 192752fd71cdSmrg $SED -n 's|^# || 192852fd71cdSmrg /^Written by/{ 192952fd71cdSmrg x;p;x 193052fd71cdSmrg } 193152fd71cdSmrg h 193252fd71cdSmrg /^Written by/q' < "$progpath" 193352fd71cdSmrg echo 193452fd71cdSmrg eval \$ECHO \""$usage_message"\" 193552fd71cdSmrg} 193648c85eb7Smrg 1937d63fdb69Smrg 193852fd71cdSmrg# func_version 193952fd71cdSmrg# ------------ 194052fd71cdSmrg# Echo version message to standard output and exit. 194152fd71cdSmrgfunc_version () 194252fd71cdSmrg{ 194352fd71cdSmrg $debug_cmd 1944d63fdb69Smrg 194552fd71cdSmrg printf '%s\n' "$progname $scriptversion" 194652fd71cdSmrg $SED -n ' 194752fd71cdSmrg /(C)/!b go 194852fd71cdSmrg :more 194952fd71cdSmrg /\./!{ 195052fd71cdSmrg N 195152fd71cdSmrg s|\n# | | 195252fd71cdSmrg b more 195352fd71cdSmrg } 195452fd71cdSmrg :go 195552fd71cdSmrg /^# Written by /,/# warranty; / { 195652fd71cdSmrg s|^# || 195752fd71cdSmrg s|^# *$|| 195852fd71cdSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195952fd71cdSmrg p 196052fd71cdSmrg } 196152fd71cdSmrg /^# Written by / { 196252fd71cdSmrg s|^# || 196352fd71cdSmrg p 196452fd71cdSmrg } 196552fd71cdSmrg /^warranty; /q' < "$progpath" 1966d63fdb69Smrg 196752fd71cdSmrg exit $? 196852fd71cdSmrg} 1969d63fdb69Smrg 19703da084b3Smrg 197152fd71cdSmrg# Local variables: 197252fd71cdSmrg# mode: shell-script 197352fd71cdSmrg# sh-indentation: 2 197452fd71cdSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 197552fd71cdSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197652fd71cdSmrg# time-stamp-time-zone: "UTC" 197752fd71cdSmrg# End: 19783da084b3Smrg 197952fd71cdSmrg# Set a version string. 198052fd71cdSmrgscriptversion='(GNU libtool) 2.4.6' 19813da084b3Smrg 19823da084b3Smrg 198352fd71cdSmrg# func_echo ARG... 198452fd71cdSmrg# ---------------- 198552fd71cdSmrg# Libtool also displays the current mode in messages, so override 198652fd71cdSmrg# funclib.sh func_echo with this custom definition. 198752fd71cdSmrgfunc_echo () 198848c85eb7Smrg{ 198952fd71cdSmrg $debug_cmd 199048c85eb7Smrg 199152fd71cdSmrg _G_message=$* 199248c85eb7Smrg 199352fd71cdSmrg func_echo_IFS=$IFS 199452fd71cdSmrg IFS=$nl 199552fd71cdSmrg for _G_line in $_G_message; do 199652fd71cdSmrg IFS=$func_echo_IFS 199752fd71cdSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199852fd71cdSmrg done 199952fd71cdSmrg IFS=$func_echo_IFS 200052fd71cdSmrg} 200148c85eb7Smrg 200252fd71cdSmrg 200352fd71cdSmrg# func_warning ARG... 200452fd71cdSmrg# ------------------- 200552fd71cdSmrg# Libtool warnings are not categorized, so override funclib.sh 200652fd71cdSmrg# func_warning with this simpler definition. 200752fd71cdSmrgfunc_warning () 200848c85eb7Smrg{ 200952fd71cdSmrg $debug_cmd 201048c85eb7Smrg 201152fd71cdSmrg $warning_func ${1+"$@"} 201252fd71cdSmrg} 201348c85eb7Smrg 201448c85eb7Smrg 201552fd71cdSmrg## ---------------- ## 201652fd71cdSmrg## Options parsing. ## 201752fd71cdSmrg## ---------------- ## 201852fd71cdSmrg 201952fd71cdSmrg# Hook in the functions to make sure our own options are parsed during 202052fd71cdSmrg# the option parsing loop. 202152fd71cdSmrg 202252fd71cdSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 202352fd71cdSmrg 202452fd71cdSmrg# Short help message in response to '-h'. 202552fd71cdSmrgusage_message="Options: 202652fd71cdSmrg --config show all configuration variables 202752fd71cdSmrg --debug enable verbose shell tracing 202852fd71cdSmrg -n, --dry-run display commands without modifying any files 202952fd71cdSmrg --features display basic configuration information and exit 203052fd71cdSmrg --mode=MODE use operation mode MODE 203152fd71cdSmrg --no-warnings equivalent to '-Wnone' 203252fd71cdSmrg --preserve-dup-deps don't remove duplicate dependency libraries 203352fd71cdSmrg --quiet, --silent don't print informational messages 203452fd71cdSmrg --tag=TAG use configuration variables from tag TAG 203552fd71cdSmrg -v, --verbose print more informational messages than default 203652fd71cdSmrg --version print version information 203752fd71cdSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203852fd71cdSmrg -h, --help, --help-all print short, long, or detailed help message 203952fd71cdSmrg" 204048c85eb7Smrg 204152fd71cdSmrg# Additional text appended to 'usage_message' in response to '--help'. 204252fd71cdSmrgfunc_help () 204348c85eb7Smrg{ 204452fd71cdSmrg $debug_cmd 204552fd71cdSmrg 204652fd71cdSmrg func_usage_message 204752fd71cdSmrg $ECHO "$long_help_message 204852fd71cdSmrg 204952fd71cdSmrgMODE must be one of the following: 205052fd71cdSmrg 205152fd71cdSmrg clean remove files from the build directory 205252fd71cdSmrg compile compile a source file into a libtool object 205352fd71cdSmrg execute automatically set library path, then run a program 205452fd71cdSmrg finish complete the installation of libtool libraries 205552fd71cdSmrg install install libraries or executables 205652fd71cdSmrg link create a library or an executable 205752fd71cdSmrg uninstall remove libraries from an installed directory 205852fd71cdSmrg 205952fd71cdSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206052fd71cdSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206152fd71cdSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206252fd71cdSmrg 206352fd71cdSmrgWhen reporting a bug, please describe a test case to reproduce it and 206452fd71cdSmrginclude the following information: 206552fd71cdSmrg 206652fd71cdSmrg host-triplet: $host 206752fd71cdSmrg shell: $SHELL 206852fd71cdSmrg compiler: $LTCC 206952fd71cdSmrg compiler flags: $LTCFLAGS 207052fd71cdSmrg linker: $LD (gnu? $with_gnu_ld) 207152fd71cdSmrg version: $progname (GNU libtool) 2.4.6 207252fd71cdSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207352fd71cdSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207452fd71cdSmrg 207552fd71cdSmrgReport bugs to <bug-libtool@gnu.org>. 207652fd71cdSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 207752fd71cdSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207852fd71cdSmrg exit 0 207952fd71cdSmrg} 208048c85eb7Smrg 208148c85eb7Smrg 208252fd71cdSmrg# func_lo2o OBJECT-NAME 208352fd71cdSmrg# --------------------- 208452fd71cdSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208552fd71cdSmrg# object suffix. 208652fd71cdSmrg 208752fd71cdSmrglo2o=s/\\.lo\$/.$objext/ 208852fd71cdSmrgo2lo=s/\\.$objext\$/.lo/ 208952fd71cdSmrg 209052fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 209152fd71cdSmrg eval 'func_lo2o () 209252fd71cdSmrg { 209352fd71cdSmrg case $1 in 209452fd71cdSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209552fd71cdSmrg * ) func_lo2o_result=$1 ;; 209652fd71cdSmrg esac 209752fd71cdSmrg }' 209852fd71cdSmrg 209952fd71cdSmrg # func_xform LIBOBJ-OR-SOURCE 210052fd71cdSmrg # --------------------------- 210152fd71cdSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210252fd71cdSmrg # suffix to a '.lo' libtool-object suffix. 210352fd71cdSmrg eval 'func_xform () 210452fd71cdSmrg { 210552fd71cdSmrg func_xform_result=${1%.*}.lo 210652fd71cdSmrg }' 210752fd71cdSmrgelse 210852fd71cdSmrg # ...otherwise fall back to using sed. 210952fd71cdSmrg func_lo2o () 211052fd71cdSmrg { 211152fd71cdSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211252fd71cdSmrg } 211352fd71cdSmrg 211452fd71cdSmrg func_xform () 211552fd71cdSmrg { 211652fd71cdSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211752fd71cdSmrg } 211852fd71cdSmrgfi 211948c85eb7Smrg 212048c85eb7Smrg 212152fd71cdSmrg# func_fatal_configuration ARG... 212252fd71cdSmrg# ------------------------------- 2123d63fdb69Smrg# Echo program name prefixed message to standard error, followed by 2124d63fdb69Smrg# a configuration failure hint, and exit. 2125d63fdb69Smrgfunc_fatal_configuration () 2126d63fdb69Smrg{ 212752fd71cdSmrg func__fatal_error ${1+"$@"} \ 212852fd71cdSmrg "See the $PACKAGE documentation for more information." \ 212952fd71cdSmrg "Fatal configuration error." 2130d63fdb69Smrg} 2131d63fdb69Smrg 2132d63fdb69Smrg 2133d63fdb69Smrg# func_config 213452fd71cdSmrg# ----------- 2135d63fdb69Smrg# Display the configuration for all the tags in this script. 2136d63fdb69Smrgfunc_config () 2137d63fdb69Smrg{ 2138d63fdb69Smrg re_begincf='^# ### BEGIN LIBTOOL' 2139d63fdb69Smrg re_endcf='^# ### END LIBTOOL' 2140d63fdb69Smrg 2141d63fdb69Smrg # Default configuration. 2142d63fdb69Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 21433da084b3Smrg 21443da084b3Smrg # Now print the configurations for the tags. 21453da084b3Smrg for tagname in $taglist; do 2146d63fdb69Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 21473da084b3Smrg done 21483da084b3Smrg 2149d63fdb69Smrg exit $? 2150d63fdb69Smrg} 21513da084b3Smrg 215252fd71cdSmrg 2153d63fdb69Smrg# func_features 215452fd71cdSmrg# ------------- 2155d63fdb69Smrg# Display the features supported by this script. 2156d63fdb69Smrgfunc_features () 2157d63fdb69Smrg{ 215855acc8fcSmrg echo "host: $host" 215952fd71cdSmrg if test yes = "$build_libtool_libs"; then 216055acc8fcSmrg echo "enable shared libraries" 21613da084b3Smrg else 216255acc8fcSmrg echo "disable shared libraries" 21633da084b3Smrg fi 216452fd71cdSmrg if test yes = "$build_old_libs"; then 216555acc8fcSmrg echo "enable static libraries" 21663da084b3Smrg else 216755acc8fcSmrg echo "disable static libraries" 21683da084b3Smrg fi 2169d63fdb69Smrg 21703da084b3Smrg exit $? 2171d63fdb69Smrg} 2172d63fdb69Smrg 217352fd71cdSmrg 217452fd71cdSmrg# func_enable_tag TAGNAME 217552fd71cdSmrg# ----------------------- 2176d63fdb69Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177d63fdb69Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178d63fdb69Smrg# variable here. 2179d63fdb69Smrgfunc_enable_tag () 2180d63fdb69Smrg{ 218152fd71cdSmrg # Global variable: 218252fd71cdSmrg tagname=$1 21833da084b3Smrg 218452fd71cdSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218552fd71cdSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218652fd71cdSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 21873da084b3Smrg 218852fd71cdSmrg # Validate tagname. 218952fd71cdSmrg case $tagname in 219052fd71cdSmrg *[!-_A-Za-z0-9,/]*) 219152fd71cdSmrg func_fatal_error "invalid tag name: $tagname" 219252fd71cdSmrg ;; 219352fd71cdSmrg esac 21943da084b3Smrg 219552fd71cdSmrg # Don't test for the "default" C tag, as we know it's 219652fd71cdSmrg # there but not specially marked. 219752fd71cdSmrg case $tagname in 219852fd71cdSmrg CC) ;; 2199d63fdb69Smrg *) 220052fd71cdSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220152fd71cdSmrg taglist="$taglist $tagname" 220252fd71cdSmrg 220352fd71cdSmrg # Evaluate the configuration. Be careful to quote the path 220452fd71cdSmrg # and the sed script, to avoid splitting on whitespace, but 220552fd71cdSmrg # also don't use non-portable quotes within backquotes within 220652fd71cdSmrg # quotes we have to do it in 2 steps: 220752fd71cdSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220852fd71cdSmrg eval "$extractedcf" 220952fd71cdSmrg else 221052fd71cdSmrg func_error "ignoring unknown tag $tagname" 221152fd71cdSmrg fi 221252fd71cdSmrg ;; 221352fd71cdSmrg esac 2214d63fdb69Smrg} 22153da084b3Smrg 221652fd71cdSmrg 221748c85eb7Smrg# func_check_version_match 221852fd71cdSmrg# ------------------------ 221948c85eb7Smrg# Ensure that we are using m4 macros, and libtool script from the same 222048c85eb7Smrg# release of libtool. 222148c85eb7Smrgfunc_check_version_match () 2222d63fdb69Smrg{ 222352fd71cdSmrg if test "$package_revision" != "$macro_revision"; then 222452fd71cdSmrg if test "$VERSION" != "$macro_version"; then 222552fd71cdSmrg if test -z "$macro_version"; then 222652fd71cdSmrg cat >&2 <<_LT_EOF 222748c85eb7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222848c85eb7Smrg$progname: definition of this LT_INIT comes from an older release. 222948c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223048c85eb7Smrg$progname: and run autoconf again. 223148c85eb7Smrg_LT_EOF 223252fd71cdSmrg else 223352fd71cdSmrg cat >&2 <<_LT_EOF 223448c85eb7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223548c85eb7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223648c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223748c85eb7Smrg$progname: and run autoconf again. 223848c85eb7Smrg_LT_EOF 223952fd71cdSmrg fi 224052fd71cdSmrg else 224152fd71cdSmrg cat >&2 <<_LT_EOF 224248c85eb7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224348c85eb7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224448c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224548c85eb7Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 224648c85eb7Smrg_LT_EOF 224752fd71cdSmrg fi 224848c85eb7Smrg 224952fd71cdSmrg exit $EXIT_MISMATCH 225052fd71cdSmrg fi 225148c85eb7Smrg} 225248c85eb7Smrg 225348c85eb7Smrg 225452fd71cdSmrg# libtool_options_prep [ARG]... 225552fd71cdSmrg# ----------------------------- 225652fd71cdSmrg# Preparation for options parsed by libtool. 225752fd71cdSmrglibtool_options_prep () 225852fd71cdSmrg{ 225952fd71cdSmrg $debug_mode 226048c85eb7Smrg 226152fd71cdSmrg # Option defaults: 226252fd71cdSmrg opt_config=false 226352fd71cdSmrg opt_dlopen= 226452fd71cdSmrg opt_dry_run=false 226552fd71cdSmrg opt_help=false 226652fd71cdSmrg opt_mode= 226752fd71cdSmrg opt_preserve_dup_deps=false 226852fd71cdSmrg opt_quiet=false 226948c85eb7Smrg 227052fd71cdSmrg nonopt= 227152fd71cdSmrg preserve_args= 227248c85eb7Smrg 227352fd71cdSmrg # Shorthand for --mode=foo, only valid as the first argument 227452fd71cdSmrg case $1 in 227552fd71cdSmrg clean|clea|cle|cl) 227652fd71cdSmrg shift; set dummy --mode clean ${1+"$@"}; shift 227752fd71cdSmrg ;; 227852fd71cdSmrg compile|compil|compi|comp|com|co|c) 227952fd71cdSmrg shift; set dummy --mode compile ${1+"$@"}; shift 228052fd71cdSmrg ;; 228152fd71cdSmrg execute|execut|execu|exec|exe|ex|e) 228252fd71cdSmrg shift; set dummy --mode execute ${1+"$@"}; shift 228352fd71cdSmrg ;; 228452fd71cdSmrg finish|finis|fini|fin|fi|f) 228552fd71cdSmrg shift; set dummy --mode finish ${1+"$@"}; shift 228652fd71cdSmrg ;; 228752fd71cdSmrg install|instal|insta|inst|ins|in|i) 228852fd71cdSmrg shift; set dummy --mode install ${1+"$@"}; shift 228952fd71cdSmrg ;; 229052fd71cdSmrg link|lin|li|l) 229152fd71cdSmrg shift; set dummy --mode link ${1+"$@"}; shift 229252fd71cdSmrg ;; 229352fd71cdSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229452fd71cdSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229552fd71cdSmrg ;; 229652fd71cdSmrg esac 229752fd71cdSmrg 229852fd71cdSmrg # Pass back the list of options. 229952fd71cdSmrg func_quote_for_eval ${1+"$@"} 230052fd71cdSmrg libtool_options_prep_result=$func_quote_for_eval_result 230152fd71cdSmrg} 230252fd71cdSmrgfunc_add_hook func_options_prep libtool_options_prep 23033da084b3Smrg 23043da084b3Smrg 230552fd71cdSmrg# libtool_parse_options [ARG]... 230652fd71cdSmrg# --------------------------------- 230752fd71cdSmrg# Provide handling for libtool specific options. 230852fd71cdSmrglibtool_parse_options () 230948c85eb7Smrg{ 231052fd71cdSmrg $debug_cmd 2311d63fdb69Smrg 231252fd71cdSmrg # Perform our own loop to consume as many options as possible in 231352fd71cdSmrg # each iteration. 231452fd71cdSmrg while test $# -gt 0; do 231552fd71cdSmrg _G_opt=$1 231652fd71cdSmrg shift 231752fd71cdSmrg case $_G_opt in 231852fd71cdSmrg --dry-run|--dryrun|-n) 231952fd71cdSmrg opt_dry_run=: 232052fd71cdSmrg ;; 232152fd71cdSmrg 232252fd71cdSmrg --config) func_config ;; 232352fd71cdSmrg 232452fd71cdSmrg --dlopen|-dlopen) 232552fd71cdSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 232652fd71cdSmrg}$1" 232752fd71cdSmrg shift 232852fd71cdSmrg ;; 232952fd71cdSmrg 233052fd71cdSmrg --preserve-dup-deps) 233152fd71cdSmrg opt_preserve_dup_deps=: ;; 233252fd71cdSmrg 233352fd71cdSmrg --features) func_features ;; 233452fd71cdSmrg 233552fd71cdSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233652fd71cdSmrg 233752fd71cdSmrg --help) opt_help=: ;; 233852fd71cdSmrg 233952fd71cdSmrg --help-all) opt_help=': help-all' ;; 234052fd71cdSmrg 234152fd71cdSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234252fd71cdSmrg opt_mode=$1 234352fd71cdSmrg case $1 in 234452fd71cdSmrg # Valid mode arguments: 234552fd71cdSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234652fd71cdSmrg 234752fd71cdSmrg # Catch anything else as an error 234852fd71cdSmrg *) func_error "invalid argument for $_G_opt" 234952fd71cdSmrg exit_cmd=exit 235052fd71cdSmrg break 235152fd71cdSmrg ;; 235252fd71cdSmrg esac 235352fd71cdSmrg shift 235452fd71cdSmrg ;; 235552fd71cdSmrg 235652fd71cdSmrg --no-silent|--no-quiet) 235752fd71cdSmrg opt_quiet=false 235852fd71cdSmrg func_append preserve_args " $_G_opt" 235952fd71cdSmrg ;; 236052fd71cdSmrg 236152fd71cdSmrg --no-warnings|--no-warning|--no-warn) 236252fd71cdSmrg opt_warning=false 236352fd71cdSmrg func_append preserve_args " $_G_opt" 236452fd71cdSmrg ;; 236552fd71cdSmrg 236652fd71cdSmrg --no-verbose) 236752fd71cdSmrg opt_verbose=false 236852fd71cdSmrg func_append preserve_args " $_G_opt" 236952fd71cdSmrg ;; 237052fd71cdSmrg 237152fd71cdSmrg --silent|--quiet) 237252fd71cdSmrg opt_quiet=: 237352fd71cdSmrg opt_verbose=false 237452fd71cdSmrg func_append preserve_args " $_G_opt" 237552fd71cdSmrg ;; 237652fd71cdSmrg 237752fd71cdSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237852fd71cdSmrg opt_tag=$1 237952fd71cdSmrg func_append preserve_args " $_G_opt $1" 238052fd71cdSmrg func_enable_tag "$1" 238152fd71cdSmrg shift 238252fd71cdSmrg ;; 238352fd71cdSmrg 238452fd71cdSmrg --verbose|-v) opt_quiet=false 238552fd71cdSmrg opt_verbose=: 238652fd71cdSmrg func_append preserve_args " $_G_opt" 238752fd71cdSmrg ;; 238852fd71cdSmrg 238952fd71cdSmrg # An option not handled by this hook function: 239052fd71cdSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239152fd71cdSmrg esac 239252fd71cdSmrg done 239348c85eb7Smrg 239448c85eb7Smrg 239552fd71cdSmrg # save modified positional parameters for caller 239652fd71cdSmrg func_quote_for_eval ${1+"$@"} 239752fd71cdSmrg libtool_parse_options_result=$func_quote_for_eval_result 239852fd71cdSmrg} 239952fd71cdSmrgfunc_add_hook func_parse_options libtool_parse_options 2400d63fdb69Smrg 24013da084b3Smrg 2402d63fdb69Smrg 240352fd71cdSmrg# libtool_validate_options [ARG]... 240452fd71cdSmrg# --------------------------------- 240552fd71cdSmrg# Perform any sanity checks on option settings and/or unconsumed 240652fd71cdSmrg# arguments. 240752fd71cdSmrglibtool_validate_options () 240852fd71cdSmrg{ 240952fd71cdSmrg # save first non-option argument 241052fd71cdSmrg if test 0 -lt $#; then 241152fd71cdSmrg nonopt=$1 241252fd71cdSmrg shift 2413d63fdb69Smrg fi 2414d63fdb69Smrg 241552fd71cdSmrg # preserve --debug 241652fd71cdSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417d63fdb69Smrg 241852fd71cdSmrg case $host in 241952fd71cdSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242052fd71cdSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242152fd71cdSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242252fd71cdSmrg # don't eliminate duplications in $postdeps and $predeps 242352fd71cdSmrg opt_duplicate_compiler_generated_deps=: 242452fd71cdSmrg ;; 242552fd71cdSmrg *) 242652fd71cdSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242752fd71cdSmrg ;; 242852fd71cdSmrg esac 2429d63fdb69Smrg 243052fd71cdSmrg $opt_help || { 243152fd71cdSmrg # Sanity checks first: 243252fd71cdSmrg func_check_version_match 243352fd71cdSmrg 243452fd71cdSmrg test yes != "$build_libtool_libs" \ 243552fd71cdSmrg && test yes != "$build_old_libs" \ 243652fd71cdSmrg && func_fatal_configuration "not configured to build any kind of library" 243752fd71cdSmrg 243852fd71cdSmrg # Darwin sucks 243952fd71cdSmrg eval std_shrext=\"$shrext_cmds\" 244052fd71cdSmrg 244152fd71cdSmrg # Only execute mode is allowed to have -dlopen flags. 244252fd71cdSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244352fd71cdSmrg func_error "unrecognized option '-dlopen'" 244452fd71cdSmrg $ECHO "$help" 1>&2 244552fd71cdSmrg exit $EXIT_FAILURE 244652fd71cdSmrg fi 2447d63fdb69Smrg 244852fd71cdSmrg # Change the help message to a mode-specific one. 244952fd71cdSmrg generic_help=$help 245052fd71cdSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 245152fd71cdSmrg } 2452d63fdb69Smrg 245352fd71cdSmrg # Pass back the unparsed argument list 245452fd71cdSmrg func_quote_for_eval ${1+"$@"} 245552fd71cdSmrg libtool_validate_options_result=$func_quote_for_eval_result 245648c85eb7Smrg} 245752fd71cdSmrgfunc_add_hook func_validate_options libtool_validate_options 2458d63fdb69Smrg 2459d63fdb69Smrg 246052fd71cdSmrg# Process options as early as possible so that --help and --version 246152fd71cdSmrg# can return quickly. 246252fd71cdSmrgfunc_options ${1+"$@"} 246352fd71cdSmrgeval set dummy "$func_options_result"; shift 246452fd71cdSmrg 24653da084b3Smrg 24663da084b3Smrg 246748c85eb7Smrg## ----------- ## 246848c85eb7Smrg## Main. ## 246948c85eb7Smrg## ----------- ## 24703da084b3Smrg 247152fd71cdSmrgmagic='%%%MAGIC variable%%%' 247252fd71cdSmrgmagic_exe='%%%MAGIC EXE variable%%%' 247352fd71cdSmrg 247452fd71cdSmrg# Global variables. 247552fd71cdSmrgextracted_archives= 247652fd71cdSmrgextracted_serial=0 247752fd71cdSmrg 247852fd71cdSmrg# If this variable is set in any of the actions, the command in it 247952fd71cdSmrg# will be execed at the end. This prevents here-documents from being 248052fd71cdSmrg# left over by shells. 248152fd71cdSmrgexec_cmd= 248252fd71cdSmrg 248352fd71cdSmrg 248452fd71cdSmrg# A function that is used when there is no print builtin or printf. 248552fd71cdSmrgfunc_fallback_echo () 248652fd71cdSmrg{ 248752fd71cdSmrg eval 'cat <<_LTECHO_EOF 248852fd71cdSmrg$1 248952fd71cdSmrg_LTECHO_EOF' 249052fd71cdSmrg} 249152fd71cdSmrg 249252fd71cdSmrg# func_generated_by_libtool 249352fd71cdSmrg# True iff stdin has been generated by Libtool. This function is only 249452fd71cdSmrg# a basic sanity check; it will hardly flush out determined imposters. 249552fd71cdSmrgfunc_generated_by_libtool_p () 249652fd71cdSmrg{ 249752fd71cdSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249852fd71cdSmrg} 249952fd71cdSmrg 2500d63fdb69Smrg# func_lalib_p file 250152fd71cdSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2503d63fdb69Smrg# determined imposters. 2504d63fdb69Smrgfunc_lalib_p () 2505d63fdb69Smrg{ 2506d63fdb69Smrg test -f "$1" && 250752fd71cdSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508d63fdb69Smrg} 25093da084b3Smrg 2510d63fdb69Smrg# func_lalib_unsafe_p file 251152fd71cdSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512d63fdb69Smrg# This function implements the same check as func_lalib_p without 2513d63fdb69Smrg# resorting to external programs. To this end, it redirects stdin and 2514d63fdb69Smrg# closes it afterwards, without saving the original file descriptor. 2515d63fdb69Smrg# As a safety measure, use it only where a negative result would be 251652fd71cdSmrg# fatal anyway. Works if 'file' does not exist. 2517d63fdb69Smrgfunc_lalib_unsafe_p () 2518d63fdb69Smrg{ 2519d63fdb69Smrg lalib_p=no 2520d63fdb69Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521d63fdb69Smrg for lalib_p_l in 1 2 3 4 2522d63fdb69Smrg do 2523d63fdb69Smrg read lalib_p_line 252452fd71cdSmrg case $lalib_p_line in 2525d63fdb69Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526d63fdb69Smrg esac 2527d63fdb69Smrg done 2528d63fdb69Smrg exec 0<&5 5<&- 2529d63fdb69Smrg fi 253052fd71cdSmrg test yes = "$lalib_p" 2531d63fdb69Smrg} 25323da084b3Smrg 2533d63fdb69Smrg# func_ltwrapper_script_p file 2534d63fdb69Smrg# True iff FILE is a libtool wrapper script 2535d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2536d63fdb69Smrg# determined imposters. 2537d63fdb69Smrgfunc_ltwrapper_script_p () 2538d63fdb69Smrg{ 253952fd71cdSmrg test -f "$1" && 254052fd71cdSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541d63fdb69Smrg} 25423da084b3Smrg 2543d63fdb69Smrg# func_ltwrapper_executable_p file 2544d63fdb69Smrg# True iff FILE is a libtool wrapper executable 2545d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2546d63fdb69Smrg# determined imposters. 2547d63fdb69Smrgfunc_ltwrapper_executable_p () 2548d63fdb69Smrg{ 2549d63fdb69Smrg func_ltwrapper_exec_suffix= 2550d63fdb69Smrg case $1 in 2551d63fdb69Smrg *.exe) ;; 2552d63fdb69Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553d63fdb69Smrg esac 2554d63fdb69Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555d63fdb69Smrg} 25563da084b3Smrg 2557d63fdb69Smrg# func_ltwrapper_scriptname file 2558d63fdb69Smrg# Assumes file is an ltwrapper_executable 2559d63fdb69Smrg# uses $file to determine the appropriate filename for a 2560d63fdb69Smrg# temporary ltwrapper_script. 2561d63fdb69Smrgfunc_ltwrapper_scriptname () 2562d63fdb69Smrg{ 256348c85eb7Smrg func_dirname_and_basename "$1" "" "." 256448c85eb7Smrg func_stripname '' '.exe' "$func_basename_result" 256552fd71cdSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566d63fdb69Smrg} 25673da084b3Smrg 2568d63fdb69Smrg# func_ltwrapper_p file 2569d63fdb69Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2570d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2571d63fdb69Smrg# determined imposters. 2572d63fdb69Smrgfunc_ltwrapper_p () 2573d63fdb69Smrg{ 2574d63fdb69Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575d63fdb69Smrg} 25763da084b3Smrg 25773da084b3Smrg 2578d63fdb69Smrg# func_execute_cmds commands fail_cmd 2579d63fdb69Smrg# Execute tilde-delimited COMMANDS. 2580d63fdb69Smrg# If FAIL_CMD is given, eval that upon failure. 2581d63fdb69Smrg# FAIL_CMD may read-access the current command in variable CMD! 2582d63fdb69Smrgfunc_execute_cmds () 2583d63fdb69Smrg{ 258452fd71cdSmrg $debug_cmd 258552fd71cdSmrg 2586d63fdb69Smrg save_ifs=$IFS; IFS='~' 2587d63fdb69Smrg for cmd in $1; do 258852fd71cdSmrg IFS=$sp$nl 2589d63fdb69Smrg eval cmd=\"$cmd\" 259052fd71cdSmrg IFS=$save_ifs 2591d63fdb69Smrg func_show_eval "$cmd" "${2-:}" 2592d63fdb69Smrg done 2593d63fdb69Smrg IFS=$save_ifs 2594d63fdb69Smrg} 2595d63fdb69Smrg 2596d63fdb69Smrg 2597d63fdb69Smrg# func_source file 2598d63fdb69Smrg# Source FILE, adding directory component if necessary. 2599d63fdb69Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600d63fdb69Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601d63fdb69Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260252fd71cdSmrg# 'FILE.' does not work on cygwin managed mounts. 2603d63fdb69Smrgfunc_source () 2604d63fdb69Smrg{ 260552fd71cdSmrg $debug_cmd 260652fd71cdSmrg 2607d63fdb69Smrg case $1 in 2608d63fdb69Smrg */* | *\\*) . "$1" ;; 2609d63fdb69Smrg *) . "./$1" ;; 2610d63fdb69Smrg esac 2611d63fdb69Smrg} 2612d63fdb69Smrg 2613d63fdb69Smrg 261448c85eb7Smrg# func_resolve_sysroot PATH 261548c85eb7Smrg# Replace a leading = in PATH with a sysroot. Store the result into 261648c85eb7Smrg# func_resolve_sysroot_result 261748c85eb7Smrgfunc_resolve_sysroot () 261848c85eb7Smrg{ 261948c85eb7Smrg func_resolve_sysroot_result=$1 262048c85eb7Smrg case $func_resolve_sysroot_result in 262148c85eb7Smrg =*) 262248c85eb7Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 262348c85eb7Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262448c85eb7Smrg ;; 262548c85eb7Smrg esac 262648c85eb7Smrg} 262748c85eb7Smrg 262848c85eb7Smrg# func_replace_sysroot PATH 262948c85eb7Smrg# If PATH begins with the sysroot, replace it with = and 263048c85eb7Smrg# store the result into func_replace_sysroot_result. 263148c85eb7Smrgfunc_replace_sysroot () 263248c85eb7Smrg{ 263352fd71cdSmrg case $lt_sysroot:$1 in 263448c85eb7Smrg ?*:"$lt_sysroot"*) 263548c85eb7Smrg func_stripname "$lt_sysroot" '' "$1" 263652fd71cdSmrg func_replace_sysroot_result='='$func_stripname_result 263748c85eb7Smrg ;; 263848c85eb7Smrg *) 263948c85eb7Smrg # Including no sysroot. 264048c85eb7Smrg func_replace_sysroot_result=$1 264148c85eb7Smrg ;; 264248c85eb7Smrg esac 264348c85eb7Smrg} 264448c85eb7Smrg 2645d63fdb69Smrg# func_infer_tag arg 2646d63fdb69Smrg# Infer tagged configuration to use if any are available and 2647d63fdb69Smrg# if one wasn't chosen via the "--tag" command line option. 2648d63fdb69Smrg# Only attempt this if the compiler in the base compile 2649d63fdb69Smrg# command doesn't match the default compiler. 2650d63fdb69Smrg# arg is usually of the form 'gcc ...' 2651d63fdb69Smrgfunc_infer_tag () 2652d63fdb69Smrg{ 265352fd71cdSmrg $debug_cmd 265452fd71cdSmrg 2655d63fdb69Smrg if test -n "$available_tags" && test -z "$tagname"; then 2656d63fdb69Smrg CC_quoted= 2657d63fdb69Smrg for arg in $CC; do 265848c85eb7Smrg func_append_quoted CC_quoted "$arg" 2659d63fdb69Smrg done 266055acc8fcSmrg CC_expanded=`func_echo_all $CC` 266155acc8fcSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662d63fdb69Smrg case $@ in 2663d63fdb69Smrg # Blanks in the command may have been stripped by the calling shell, 2664d63fdb69Smrg # but not from the CC environment variable when configure was run. 266555acc8fcSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266655acc8fcSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667d63fdb69Smrg # Blanks at the start of $base_compile will cause this to fail 2668d63fdb69Smrg # if we don't check for them as well. 2669d63fdb69Smrg *) 2670d63fdb69Smrg for z in $available_tags; do 2671d63fdb69Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672d63fdb69Smrg # Evaluate the configuration. 267352fd71cdSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674d63fdb69Smrg CC_quoted= 2675d63fdb69Smrg for arg in $CC; do 2676d63fdb69Smrg # Double-quote args containing other shell metacharacters. 267748c85eb7Smrg func_append_quoted CC_quoted "$arg" 2678d63fdb69Smrg done 267955acc8fcSmrg CC_expanded=`func_echo_all $CC` 268055acc8fcSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681d63fdb69Smrg case "$@ " in 268255acc8fcSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268355acc8fcSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684d63fdb69Smrg # The compiler in the base compile command matches 2685d63fdb69Smrg # the one in the tagged configuration. 2686d63fdb69Smrg # Assume this is the tagged configuration we want. 2687d63fdb69Smrg tagname=$z 2688d63fdb69Smrg break 2689d63fdb69Smrg ;; 26903da084b3Smrg esac 2691d63fdb69Smrg fi 2692d63fdb69Smrg done 2693d63fdb69Smrg # If $tagname still isn't set, then no tagged configuration 2694d63fdb69Smrg # was found and let the user know that the "--tag" command 2695d63fdb69Smrg # line option must be used. 2696d63fdb69Smrg if test -z "$tagname"; then 2697d63fdb69Smrg func_echo "unable to infer tagged configuration" 269852fd71cdSmrg func_fatal_error "specify a tag with '--tag'" 2699d63fdb69Smrg# else 2700d63fdb69Smrg# func_verbose "using $tagname tagged configuration" 2701d63fdb69Smrg fi 2702d63fdb69Smrg ;; 2703d63fdb69Smrg esac 2704d63fdb69Smrg fi 2705d63fdb69Smrg} 2706d63fdb69Smrg 2707d63fdb69Smrg 270848c85eb7Smrg 270948c85eb7Smrg# func_write_libtool_object output_name pic_name nonpic_name 271048c85eb7Smrg# Create a libtool object file (analogous to a ".la" file), 271148c85eb7Smrg# but don't create it if we're doing a dry run. 271248c85eb7Smrgfunc_write_libtool_object () 271348c85eb7Smrg{ 271452fd71cdSmrg write_libobj=$1 271552fd71cdSmrg if test yes = "$build_libtool_libs"; then 271652fd71cdSmrg write_lobj=\'$2\' 271748c85eb7Smrg else 271848c85eb7Smrg write_lobj=none 271948c85eb7Smrg fi 272048c85eb7Smrg 272152fd71cdSmrg if test yes = "$build_old_libs"; then 272252fd71cdSmrg write_oldobj=\'$3\' 272348c85eb7Smrg else 272448c85eb7Smrg write_oldobj=none 272548c85eb7Smrg fi 272648c85eb7Smrg 272748c85eb7Smrg $opt_dry_run || { 272848c85eb7Smrg cat >${write_libobj}T <<EOF 272948c85eb7Smrg# $write_libobj - a libtool object file 273052fd71cdSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 273148c85eb7Smrg# 273248c85eb7Smrg# Please DO NOT delete this file! 273348c85eb7Smrg# It is necessary for linking the library. 273448c85eb7Smrg 273548c85eb7Smrg# Name of the PIC object. 273648c85eb7Smrgpic_object=$write_lobj 273748c85eb7Smrg 273848c85eb7Smrg# Name of the non-PIC object 273948c85eb7Smrgnon_pic_object=$write_oldobj 274048c85eb7Smrg 274148c85eb7SmrgEOF 274252fd71cdSmrg $MV "${write_libobj}T" "$write_libobj" 274348c85eb7Smrg } 274448c85eb7Smrg} 274548c85eb7Smrg 274648c85eb7Smrg 274748c85eb7Smrg################################################## 274848c85eb7Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274948c85eb7Smrg################################################## 275048c85eb7Smrg 275148c85eb7Smrg# func_convert_core_file_wine_to_w32 ARG 275248c85eb7Smrg# Helper function used by file name conversion functions when $build is *nix, 275348c85eb7Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275448c85eb7Smrg# correctly configured wine environment available, with the winepath program 275548c85eb7Smrg# in $build's $PATH. 275648c85eb7Smrg# 275748c85eb7Smrg# ARG is the $build file name to be converted to w32 format. 275848c85eb7Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275948c85eb7Smrg# be empty on error (or when ARG is empty) 276048c85eb7Smrgfunc_convert_core_file_wine_to_w32 () 276148c85eb7Smrg{ 276252fd71cdSmrg $debug_cmd 276352fd71cdSmrg 276452fd71cdSmrg func_convert_core_file_wine_to_w32_result=$1 276548c85eb7Smrg if test -n "$1"; then 276648c85eb7Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276748c85eb7Smrg # are forced to check the contents of stdout. On the other hand, if the 276848c85eb7Smrg # command is not found, the shell will set an exit code of 127 and print 276948c85eb7Smrg # *an error message* to stdout. So we must check for both error code of 277048c85eb7Smrg # zero AND non-empty stdout, which explains the odd construction: 277148c85eb7Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277252fd71cdSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277348c85eb7Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277452fd71cdSmrg $SED -e "$sed_naive_backslashify"` 277548c85eb7Smrg else 277648c85eb7Smrg func_convert_core_file_wine_to_w32_result= 277748c85eb7Smrg fi 277848c85eb7Smrg fi 277948c85eb7Smrg} 278048c85eb7Smrg# end: func_convert_core_file_wine_to_w32 278148c85eb7Smrg 278248c85eb7Smrg 278348c85eb7Smrg# func_convert_core_path_wine_to_w32 ARG 278448c85eb7Smrg# Helper function used by path conversion functions when $build is *nix, and 278548c85eb7Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278648c85eb7Smrg# configured wine environment available, with the winepath program in $build's 278748c85eb7Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278848c85eb7Smrg# 278948c85eb7Smrg# ARG is path to be converted from $build format to win32. 279048c85eb7Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279148c85eb7Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279248c85eb7Smrg# are convertible, then the result may be empty. 279348c85eb7Smrgfunc_convert_core_path_wine_to_w32 () 279448c85eb7Smrg{ 279552fd71cdSmrg $debug_cmd 279652fd71cdSmrg 279748c85eb7Smrg # unfortunately, winepath doesn't convert paths, only file names 279852fd71cdSmrg func_convert_core_path_wine_to_w32_result= 279948c85eb7Smrg if test -n "$1"; then 280048c85eb7Smrg oldIFS=$IFS 280148c85eb7Smrg IFS=: 280248c85eb7Smrg for func_convert_core_path_wine_to_w32_f in $1; do 280348c85eb7Smrg IFS=$oldIFS 280448c85eb7Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280552fd71cdSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280648c85eb7Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280752fd71cdSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280848c85eb7Smrg else 280948c85eb7Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281048c85eb7Smrg fi 281148c85eb7Smrg fi 281248c85eb7Smrg done 281348c85eb7Smrg IFS=$oldIFS 281448c85eb7Smrg fi 281548c85eb7Smrg} 281648c85eb7Smrg# end: func_convert_core_path_wine_to_w32 281748c85eb7Smrg 281848c85eb7Smrg 281948c85eb7Smrg# func_cygpath ARGS... 282048c85eb7Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282148c85eb7Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282248c85eb7Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282348c85eb7Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282448c85eb7Smrg# file name or path is assumed to be in w32 format, as previously converted 282548c85eb7Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282648c85eb7Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 282748c85eb7Smrg# Cygwin format). Returns an empty string on error. 282848c85eb7Smrg# 282948c85eb7Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 283048c85eb7Smrg# be converted. 283148c85eb7Smrg# 283248c85eb7Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283348c85eb7Smrg# environment variable; do not put it in $PATH. 283448c85eb7Smrgfunc_cygpath () 283548c85eb7Smrg{ 283652fd71cdSmrg $debug_cmd 283752fd71cdSmrg 283848c85eb7Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283948c85eb7Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284048c85eb7Smrg if test "$?" -ne 0; then 284148c85eb7Smrg # on failure, ensure result is empty 284248c85eb7Smrg func_cygpath_result= 284348c85eb7Smrg fi 284448c85eb7Smrg else 284548c85eb7Smrg func_cygpath_result= 284652fd71cdSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284748c85eb7Smrg fi 284848c85eb7Smrg} 284948c85eb7Smrg#end: func_cygpath 285048c85eb7Smrg 285148c85eb7Smrg 285248c85eb7Smrg# func_convert_core_msys_to_w32 ARG 285348c85eb7Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 285448c85eb7Smrg# result in func_convert_core_msys_to_w32_result. 285548c85eb7Smrgfunc_convert_core_msys_to_w32 () 285648c85eb7Smrg{ 285752fd71cdSmrg $debug_cmd 285852fd71cdSmrg 285948c85eb7Smrg # awkward: cmd appends spaces to result 286048c85eb7Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286152fd71cdSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286248c85eb7Smrg} 286348c85eb7Smrg#end: func_convert_core_msys_to_w32 286448c85eb7Smrg 286548c85eb7Smrg 286648c85eb7Smrg# func_convert_file_check ARG1 ARG2 286748c85eb7Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 286848c85eb7Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286948c85eb7Smrg# func_to_host_file_result to ARG1). 287048c85eb7Smrgfunc_convert_file_check () 287148c85eb7Smrg{ 287252fd71cdSmrg $debug_cmd 287352fd71cdSmrg 287452fd71cdSmrg if test -z "$2" && test -n "$1"; then 287548c85eb7Smrg func_error "Could not determine host file name corresponding to" 287652fd71cdSmrg func_error " '$1'" 287748c85eb7Smrg func_error "Continuing, but uninstalled executables may not work." 287848c85eb7Smrg # Fallback: 287952fd71cdSmrg func_to_host_file_result=$1 288048c85eb7Smrg fi 288148c85eb7Smrg} 288248c85eb7Smrg# end func_convert_file_check 288348c85eb7Smrg 288448c85eb7Smrg 288548c85eb7Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288648c85eb7Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288748c85eb7Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288848c85eb7Smrg# func_to_host_file_result to a simplistic fallback value (see below). 288948c85eb7Smrgfunc_convert_path_check () 289048c85eb7Smrg{ 289152fd71cdSmrg $debug_cmd 289252fd71cdSmrg 289348c85eb7Smrg if test -z "$4" && test -n "$3"; then 289448c85eb7Smrg func_error "Could not determine the host path corresponding to" 289552fd71cdSmrg func_error " '$3'" 289648c85eb7Smrg func_error "Continuing, but uninstalled executables may not work." 289748c85eb7Smrg # Fallback. This is a deliberately simplistic "conversion" and 289848c85eb7Smrg # should not be "improved". See libtool.info. 289948c85eb7Smrg if test "x$1" != "x$2"; then 290048c85eb7Smrg lt_replace_pathsep_chars="s|$1|$2|g" 290148c85eb7Smrg func_to_host_path_result=`echo "$3" | 290248c85eb7Smrg $SED -e "$lt_replace_pathsep_chars"` 290348c85eb7Smrg else 290452fd71cdSmrg func_to_host_path_result=$3 290548c85eb7Smrg fi 290648c85eb7Smrg fi 290748c85eb7Smrg} 290848c85eb7Smrg# end func_convert_path_check 290948c85eb7Smrg 291048c85eb7Smrg 291148c85eb7Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291248c85eb7Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291348c85eb7Smrg# and appending REPL if ORIG matches BACKPAT. 291448c85eb7Smrgfunc_convert_path_front_back_pathsep () 291548c85eb7Smrg{ 291652fd71cdSmrg $debug_cmd 291752fd71cdSmrg 291848c85eb7Smrg case $4 in 291952fd71cdSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292048c85eb7Smrg ;; 292148c85eb7Smrg esac 292248c85eb7Smrg case $4 in 292348c85eb7Smrg $2 ) func_append func_to_host_path_result "$3" 292448c85eb7Smrg ;; 292548c85eb7Smrg esac 292648c85eb7Smrg} 292748c85eb7Smrg# end func_convert_path_front_back_pathsep 292848c85eb7Smrg 292948c85eb7Smrg 293048c85eb7Smrg################################################## 293148c85eb7Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293248c85eb7Smrg################################################## 293352fd71cdSmrg# invoked via '$to_host_file_cmd ARG' 293448c85eb7Smrg# 293548c85eb7Smrg# In each case, ARG is the path to be converted from $build to $host format. 293648c85eb7Smrg# Result will be available in $func_to_host_file_result. 293748c85eb7Smrg 293848c85eb7Smrg 293948c85eb7Smrg# func_to_host_file ARG 294048c85eb7Smrg# Converts the file name ARG from $build format to $host format. Return result 294148c85eb7Smrg# in func_to_host_file_result. 294248c85eb7Smrgfunc_to_host_file () 294348c85eb7Smrg{ 294452fd71cdSmrg $debug_cmd 294552fd71cdSmrg 294648c85eb7Smrg $to_host_file_cmd "$1" 294748c85eb7Smrg} 294848c85eb7Smrg# end func_to_host_file 294948c85eb7Smrg 295048c85eb7Smrg 295148c85eb7Smrg# func_to_tool_file ARG LAZY 295248c85eb7Smrg# converts the file name ARG from $build format to toolchain format. Return 295348c85eb7Smrg# result in func_to_tool_file_result. If the conversion in use is listed 295448c85eb7Smrg# in (the comma separated) LAZY, no conversion takes place. 295548c85eb7Smrgfunc_to_tool_file () 295648c85eb7Smrg{ 295752fd71cdSmrg $debug_cmd 295852fd71cdSmrg 295948c85eb7Smrg case ,$2, in 296048c85eb7Smrg *,"$to_tool_file_cmd",*) 296148c85eb7Smrg func_to_tool_file_result=$1 296248c85eb7Smrg ;; 296348c85eb7Smrg *) 296448c85eb7Smrg $to_tool_file_cmd "$1" 296548c85eb7Smrg func_to_tool_file_result=$func_to_host_file_result 296648c85eb7Smrg ;; 296748c85eb7Smrg esac 296848c85eb7Smrg} 296948c85eb7Smrg# end func_to_tool_file 297048c85eb7Smrg 297148c85eb7Smrg 297248c85eb7Smrg# func_convert_file_noop ARG 297348c85eb7Smrg# Copy ARG to func_to_host_file_result. 297448c85eb7Smrgfunc_convert_file_noop () 297548c85eb7Smrg{ 297652fd71cdSmrg func_to_host_file_result=$1 297748c85eb7Smrg} 297848c85eb7Smrg# end func_convert_file_noop 297948c85eb7Smrg 298048c85eb7Smrg 298148c85eb7Smrg# func_convert_file_msys_to_w32 ARG 298248c85eb7Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298348c85eb7Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 298448c85eb7Smrg# func_to_host_file_result. 298548c85eb7Smrgfunc_convert_file_msys_to_w32 () 298648c85eb7Smrg{ 298752fd71cdSmrg $debug_cmd 298852fd71cdSmrg 298952fd71cdSmrg func_to_host_file_result=$1 299048c85eb7Smrg if test -n "$1"; then 299148c85eb7Smrg func_convert_core_msys_to_w32 "$1" 299252fd71cdSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299348c85eb7Smrg fi 299448c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299548c85eb7Smrg} 299648c85eb7Smrg# end func_convert_file_msys_to_w32 299748c85eb7Smrg 299848c85eb7Smrg 299948c85eb7Smrg# func_convert_file_cygwin_to_w32 ARG 300048c85eb7Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300148c85eb7Smrg# func_to_host_file_result. 300248c85eb7Smrgfunc_convert_file_cygwin_to_w32 () 300348c85eb7Smrg{ 300452fd71cdSmrg $debug_cmd 300552fd71cdSmrg 300652fd71cdSmrg func_to_host_file_result=$1 300748c85eb7Smrg if test -n "$1"; then 300848c85eb7Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300948c85eb7Smrg # LT_CYGPATH in this case. 301048c85eb7Smrg func_to_host_file_result=`cygpath -m "$1"` 301148c85eb7Smrg fi 301248c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 301348c85eb7Smrg} 301448c85eb7Smrg# end func_convert_file_cygwin_to_w32 301548c85eb7Smrg 301648c85eb7Smrg 301748c85eb7Smrg# func_convert_file_nix_to_w32 ARG 301848c85eb7Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301948c85eb7Smrg# and a working winepath. Returns result in func_to_host_file_result. 302048c85eb7Smrgfunc_convert_file_nix_to_w32 () 302148c85eb7Smrg{ 302252fd71cdSmrg $debug_cmd 302352fd71cdSmrg 302452fd71cdSmrg func_to_host_file_result=$1 302548c85eb7Smrg if test -n "$1"; then 302648c85eb7Smrg func_convert_core_file_wine_to_w32 "$1" 302752fd71cdSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302848c85eb7Smrg fi 302948c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303048c85eb7Smrg} 303148c85eb7Smrg# end func_convert_file_nix_to_w32 303248c85eb7Smrg 303348c85eb7Smrg 303448c85eb7Smrg# func_convert_file_msys_to_cygwin ARG 303548c85eb7Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303648c85eb7Smrg# Returns result in func_to_host_file_result. 303748c85eb7Smrgfunc_convert_file_msys_to_cygwin () 303848c85eb7Smrg{ 303952fd71cdSmrg $debug_cmd 304052fd71cdSmrg 304152fd71cdSmrg func_to_host_file_result=$1 304248c85eb7Smrg if test -n "$1"; then 304348c85eb7Smrg func_convert_core_msys_to_w32 "$1" 304448c85eb7Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304552fd71cdSmrg func_to_host_file_result=$func_cygpath_result 304648c85eb7Smrg fi 304748c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304848c85eb7Smrg} 304948c85eb7Smrg# end func_convert_file_msys_to_cygwin 305048c85eb7Smrg 305148c85eb7Smrg 305248c85eb7Smrg# func_convert_file_nix_to_cygwin ARG 305348c85eb7Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305448c85eb7Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305548c85eb7Smrg# in func_to_host_file_result. 305648c85eb7Smrgfunc_convert_file_nix_to_cygwin () 305748c85eb7Smrg{ 305852fd71cdSmrg $debug_cmd 305952fd71cdSmrg 306052fd71cdSmrg func_to_host_file_result=$1 306148c85eb7Smrg if test -n "$1"; then 306248c85eb7Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306348c85eb7Smrg func_convert_core_file_wine_to_w32 "$1" 306448c85eb7Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306552fd71cdSmrg func_to_host_file_result=$func_cygpath_result 306648c85eb7Smrg fi 306748c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306848c85eb7Smrg} 306948c85eb7Smrg# end func_convert_file_nix_to_cygwin 307048c85eb7Smrg 307148c85eb7Smrg 307248c85eb7Smrg############################################# 307348c85eb7Smrg# $build to $host PATH CONVERSION FUNCTIONS # 307448c85eb7Smrg############################################# 307552fd71cdSmrg# invoked via '$to_host_path_cmd ARG' 307648c85eb7Smrg# 307748c85eb7Smrg# In each case, ARG is the path to be converted from $build to $host format. 307848c85eb7Smrg# The result will be available in $func_to_host_path_result. 307948c85eb7Smrg# 308048c85eb7Smrg# Path separators are also converted from $build format to $host format. If 308148c85eb7Smrg# ARG begins or ends with a path separator character, it is preserved (but 308248c85eb7Smrg# converted to $host format) on output. 308348c85eb7Smrg# 308448c85eb7Smrg# All path conversion functions are named using the following convention: 308548c85eb7Smrg# file name conversion function : func_convert_file_X_to_Y () 308648c85eb7Smrg# path conversion function : func_convert_path_X_to_Y () 308748c85eb7Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308848c85eb7Smrg# same. If conversion functions are added for new $build/$host combinations, 308948c85eb7Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309048c85eb7Smrg# will break. 309148c85eb7Smrg 309248c85eb7Smrg 309348c85eb7Smrg# func_init_to_host_path_cmd 309448c85eb7Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309548c85eb7Smrg# appropriate value, based on the value of $to_host_file_cmd. 309648c85eb7Smrgto_host_path_cmd= 309748c85eb7Smrgfunc_init_to_host_path_cmd () 309848c85eb7Smrg{ 309952fd71cdSmrg $debug_cmd 310052fd71cdSmrg 310148c85eb7Smrg if test -z "$to_host_path_cmd"; then 310248c85eb7Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310352fd71cdSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 310448c85eb7Smrg fi 310548c85eb7Smrg} 310648c85eb7Smrg 310748c85eb7Smrg 310848c85eb7Smrg# func_to_host_path ARG 310948c85eb7Smrg# Converts the path ARG from $build format to $host format. Return result 311048c85eb7Smrg# in func_to_host_path_result. 311148c85eb7Smrgfunc_to_host_path () 311248c85eb7Smrg{ 311352fd71cdSmrg $debug_cmd 311452fd71cdSmrg 311548c85eb7Smrg func_init_to_host_path_cmd 311648c85eb7Smrg $to_host_path_cmd "$1" 311748c85eb7Smrg} 311848c85eb7Smrg# end func_to_host_path 311948c85eb7Smrg 312048c85eb7Smrg 312148c85eb7Smrg# func_convert_path_noop ARG 312248c85eb7Smrg# Copy ARG to func_to_host_path_result. 312348c85eb7Smrgfunc_convert_path_noop () 312448c85eb7Smrg{ 312552fd71cdSmrg func_to_host_path_result=$1 312648c85eb7Smrg} 312748c85eb7Smrg# end func_convert_path_noop 312848c85eb7Smrg 312948c85eb7Smrg 313048c85eb7Smrg# func_convert_path_msys_to_w32 ARG 313148c85eb7Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313248c85eb7Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 313348c85eb7Smrg# func_to_host_path_result. 313448c85eb7Smrgfunc_convert_path_msys_to_w32 () 313548c85eb7Smrg{ 313652fd71cdSmrg $debug_cmd 313752fd71cdSmrg 313852fd71cdSmrg func_to_host_path_result=$1 313948c85eb7Smrg if test -n "$1"; then 314048c85eb7Smrg # Remove leading and trailing path separator characters from ARG. MSYS 314148c85eb7Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314248c85eb7Smrg # and winepath ignores them completely. 314348c85eb7Smrg func_stripname : : "$1" 314448c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 314548c85eb7Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314652fd71cdSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314748c85eb7Smrg func_convert_path_check : ";" \ 314848c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314948c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315048c85eb7Smrg fi 315148c85eb7Smrg} 315248c85eb7Smrg# end func_convert_path_msys_to_w32 315348c85eb7Smrg 315448c85eb7Smrg 315548c85eb7Smrg# func_convert_path_cygwin_to_w32 ARG 315648c85eb7Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 315748c85eb7Smrg# func_to_host_file_result. 315848c85eb7Smrgfunc_convert_path_cygwin_to_w32 () 315948c85eb7Smrg{ 316052fd71cdSmrg $debug_cmd 316152fd71cdSmrg 316252fd71cdSmrg func_to_host_path_result=$1 316348c85eb7Smrg if test -n "$1"; then 316448c85eb7Smrg # See func_convert_path_msys_to_w32: 316548c85eb7Smrg func_stripname : : "$1" 316648c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 316748c85eb7Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316848c85eb7Smrg func_convert_path_check : ";" \ 316948c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317048c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317148c85eb7Smrg fi 317248c85eb7Smrg} 317348c85eb7Smrg# end func_convert_path_cygwin_to_w32 317448c85eb7Smrg 317548c85eb7Smrg 317648c85eb7Smrg# func_convert_path_nix_to_w32 ARG 317748c85eb7Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317848c85eb7Smrg# a working winepath. Returns result in func_to_host_file_result. 317948c85eb7Smrgfunc_convert_path_nix_to_w32 () 3180d63fdb69Smrg{ 318152fd71cdSmrg $debug_cmd 318252fd71cdSmrg 318352fd71cdSmrg func_to_host_path_result=$1 318448c85eb7Smrg if test -n "$1"; then 318548c85eb7Smrg # See func_convert_path_msys_to_w32: 318648c85eb7Smrg func_stripname : : "$1" 318748c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 318848c85eb7Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318952fd71cdSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319048c85eb7Smrg func_convert_path_check : ";" \ 319148c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319248c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319348c85eb7Smrg fi 319448c85eb7Smrg} 319548c85eb7Smrg# end func_convert_path_nix_to_w32 3196d63fdb69Smrg 3197d63fdb69Smrg 319848c85eb7Smrg# func_convert_path_msys_to_cygwin ARG 319948c85eb7Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320048c85eb7Smrg# Returns result in func_to_host_file_result. 320148c85eb7Smrgfunc_convert_path_msys_to_cygwin () 320248c85eb7Smrg{ 320352fd71cdSmrg $debug_cmd 320452fd71cdSmrg 320552fd71cdSmrg func_to_host_path_result=$1 320648c85eb7Smrg if test -n "$1"; then 320748c85eb7Smrg # See func_convert_path_msys_to_w32: 320848c85eb7Smrg func_stripname : : "$1" 320948c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 321048c85eb7Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321148c85eb7Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321252fd71cdSmrg func_to_host_path_result=$func_cygpath_result 321348c85eb7Smrg func_convert_path_check : : \ 321448c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321548c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321648c85eb7Smrg fi 321748c85eb7Smrg} 321848c85eb7Smrg# end func_convert_path_msys_to_cygwin 3219d63fdb69Smrg 3220d63fdb69Smrg 322148c85eb7Smrg# func_convert_path_nix_to_cygwin ARG 322248c85eb7Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322348c85eb7Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322448c85eb7Smrg# func_to_host_file_result. 322548c85eb7Smrgfunc_convert_path_nix_to_cygwin () 322648c85eb7Smrg{ 322752fd71cdSmrg $debug_cmd 322852fd71cdSmrg 322952fd71cdSmrg func_to_host_path_result=$1 323048c85eb7Smrg if test -n "$1"; then 323148c85eb7Smrg # Remove leading and trailing path separator characters from 323248c85eb7Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 323348c85eb7Smrg # into '.;' and ';.', and winepath ignores them completely. 323448c85eb7Smrg func_stripname : : "$1" 323548c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 323648c85eb7Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323748c85eb7Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323852fd71cdSmrg func_to_host_path_result=$func_cygpath_result 323948c85eb7Smrg func_convert_path_check : : \ 324048c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324148c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324248c85eb7Smrg fi 3243d63fdb69Smrg} 324448c85eb7Smrg# end func_convert_path_nix_to_cygwin 324548c85eb7Smrg 3246d63fdb69Smrg 324752fd71cdSmrg# func_dll_def_p FILE 324852fd71cdSmrg# True iff FILE is a Windows DLL '.def' file. 324952fd71cdSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325052fd71cdSmrgfunc_dll_def_p () 325152fd71cdSmrg{ 325252fd71cdSmrg $debug_cmd 325352fd71cdSmrg 325452fd71cdSmrg func_dll_def_p_tmp=`$SED -n \ 325552fd71cdSmrg -e 's/^[ ]*//' \ 325652fd71cdSmrg -e '/^\(;.*\)*$/d' \ 325752fd71cdSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325852fd71cdSmrg -e q \ 325952fd71cdSmrg "$1"` 326052fd71cdSmrg test DEF = "$func_dll_def_p_tmp" 326152fd71cdSmrg} 326252fd71cdSmrg 326352fd71cdSmrg 3264d63fdb69Smrg# func_mode_compile arg... 3265d63fdb69Smrgfunc_mode_compile () 3266d63fdb69Smrg{ 326752fd71cdSmrg $debug_cmd 326852fd71cdSmrg 3269d63fdb69Smrg # Get the compilation command and the source file. 3270d63fdb69Smrg base_compile= 327152fd71cdSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272d63fdb69Smrg suppress_opt=yes 3273d63fdb69Smrg suppress_output= 3274d63fdb69Smrg arg_mode=normal 3275d63fdb69Smrg libobj= 3276d63fdb69Smrg later= 3277d63fdb69Smrg pie_flag= 3278d63fdb69Smrg 3279d63fdb69Smrg for arg 3280d63fdb69Smrg do 3281d63fdb69Smrg case $arg_mode in 3282d63fdb69Smrg arg ) 3283d63fdb69Smrg # do not "continue". Instead, add this to base_compile 328452fd71cdSmrg lastarg=$arg 3285d63fdb69Smrg arg_mode=normal 3286d63fdb69Smrg ;; 3287d63fdb69Smrg 3288d63fdb69Smrg target ) 328952fd71cdSmrg libobj=$arg 3290d63fdb69Smrg arg_mode=normal 3291d63fdb69Smrg continue 3292d63fdb69Smrg ;; 3293d63fdb69Smrg 3294d63fdb69Smrg normal ) 3295d63fdb69Smrg # Accept any command-line options. 3296d63fdb69Smrg case $arg in 3297d63fdb69Smrg -o) 3298d63fdb69Smrg test -n "$libobj" && \ 329952fd71cdSmrg func_fatal_error "you cannot specify '-o' more than once" 3300d63fdb69Smrg arg_mode=target 3301d63fdb69Smrg continue 3302d63fdb69Smrg ;; 3303d63fdb69Smrg 3304d63fdb69Smrg -pie | -fpie | -fPIE) 330548c85eb7Smrg func_append pie_flag " $arg" 3306d63fdb69Smrg continue 3307d63fdb69Smrg ;; 3308d63fdb69Smrg 3309d63fdb69Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 331048c85eb7Smrg func_append later " $arg" 3311d63fdb69Smrg continue 3312d63fdb69Smrg ;; 3313d63fdb69Smrg 3314d63fdb69Smrg -no-suppress) 3315d63fdb69Smrg suppress_opt=no 3316d63fdb69Smrg continue 3317d63fdb69Smrg ;; 3318d63fdb69Smrg 3319d63fdb69Smrg -Xcompiler) 3320d63fdb69Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321d63fdb69Smrg continue # The current "srcfile" will either be retained or 3322d63fdb69Smrg ;; # replaced later. I would guess that would be a bug. 3323d63fdb69Smrg 3324d63fdb69Smrg -Wc,*) 3325d63fdb69Smrg func_stripname '-Wc,' '' "$arg" 3326d63fdb69Smrg args=$func_stripname_result 3327d63fdb69Smrg lastarg= 332852fd71cdSmrg save_ifs=$IFS; IFS=, 3329d63fdb69Smrg for arg in $args; do 333052fd71cdSmrg IFS=$save_ifs 333148c85eb7Smrg func_append_quoted lastarg "$arg" 33323da084b3Smrg done 333352fd71cdSmrg IFS=$save_ifs 3334d63fdb69Smrg func_stripname ' ' '' "$lastarg" 3335d63fdb69Smrg lastarg=$func_stripname_result 33363da084b3Smrg 33373da084b3Smrg # Add the arguments to base_compile. 333848c85eb7Smrg func_append base_compile " $lastarg" 33393da084b3Smrg continue 33403da084b3Smrg ;; 33413da084b3Smrg 3342d63fdb69Smrg *) 33433da084b3Smrg # Accept the current argument as the source file. 33443da084b3Smrg # The previous "srcfile" becomes the current argument. 33453da084b3Smrg # 334652fd71cdSmrg lastarg=$srcfile 334752fd71cdSmrg srcfile=$arg 33483da084b3Smrg ;; 33493da084b3Smrg esac # case $arg 33503da084b3Smrg ;; 33513da084b3Smrg esac # case $arg_mode 33523da084b3Smrg 33533da084b3Smrg # Aesthetically quote the previous argument. 335448c85eb7Smrg func_append_quoted base_compile "$lastarg" 33553da084b3Smrg done # for arg 33563da084b3Smrg 33573da084b3Smrg case $arg_mode in 33583da084b3Smrg arg) 3359d63fdb69Smrg func_fatal_error "you must specify an argument for -Xcompile" 33603da084b3Smrg ;; 33613da084b3Smrg target) 336252fd71cdSmrg func_fatal_error "you must specify a target with '-o'" 33633da084b3Smrg ;; 33643da084b3Smrg *) 33653da084b3Smrg # Get the name of the library object. 3366d63fdb69Smrg test -z "$libobj" && { 3367d63fdb69Smrg func_basename "$srcfile" 336852fd71cdSmrg libobj=$func_basename_result 3369d63fdb69Smrg } 33703da084b3Smrg ;; 33713da084b3Smrg esac 33723da084b3Smrg 33733da084b3Smrg # Recognize several different file suffixes. 33743da084b3Smrg # If the user specifies -o file.o, it is replaced with file.lo 33753da084b3Smrg case $libobj in 3376d63fdb69Smrg *.[cCFSifmso] | \ 3377d63fdb69Smrg *.ada | *.adb | *.ads | *.asm | \ 3378d63fdb69Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 337948c85eb7Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380d63fdb69Smrg func_xform "$libobj" 3381d63fdb69Smrg libobj=$func_xform_result 3382d63fdb69Smrg ;; 33833da084b3Smrg esac 33843da084b3Smrg 33853da084b3Smrg case $libobj in 3386d63fdb69Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 33873da084b3Smrg *) 338852fd71cdSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 33893da084b3Smrg ;; 33903da084b3Smrg esac 33913da084b3Smrg 33923da084b3Smrg func_infer_tag $base_compile 33933da084b3Smrg 33943da084b3Smrg for arg in $later; do 33953da084b3Smrg case $arg in 3396d63fdb69Smrg -shared) 339752fd71cdSmrg test yes = "$build_libtool_libs" \ 339852fd71cdSmrg || func_fatal_configuration "cannot build a shared library" 3399d63fdb69Smrg build_old_libs=no 3400d63fdb69Smrg continue 3401d63fdb69Smrg ;; 3402d63fdb69Smrg 34033da084b3Smrg -static) 3404d63fdb69Smrg build_libtool_libs=no 34053da084b3Smrg build_old_libs=yes 34063da084b3Smrg continue 34073da084b3Smrg ;; 34083da084b3Smrg 34093da084b3Smrg -prefer-pic) 34103da084b3Smrg pic_mode=yes 34113da084b3Smrg continue 34123da084b3Smrg ;; 34133da084b3Smrg 34143da084b3Smrg -prefer-non-pic) 34153da084b3Smrg pic_mode=no 34163da084b3Smrg continue 34173da084b3Smrg ;; 34183da084b3Smrg esac 34193da084b3Smrg done 34203da084b3Smrg 3421d63fdb69Smrg func_quote_for_eval "$libobj" 3422d63fdb69Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423d63fdb69Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342452fd71cdSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425d63fdb69Smrg func_dirname_and_basename "$obj" "/" "" 342652fd71cdSmrg objname=$func_basename_result 342752fd71cdSmrg xdir=$func_dirname_result 342852fd71cdSmrg lobj=$xdir$objdir/$objname 34293da084b3Smrg 3430d63fdb69Smrg test -z "$base_compile" && \ 3431d63fdb69Smrg func_fatal_help "you must specify a compilation command" 34323da084b3Smrg 34333da084b3Smrg # Delete any leftover library objects. 343452fd71cdSmrg if test yes = "$build_old_libs"; then 34353da084b3Smrg removelist="$obj $lobj $libobj ${libobj}T" 34363da084b3Smrg else 34373da084b3Smrg removelist="$lobj $libobj ${libobj}T" 34383da084b3Smrg fi 34393da084b3Smrg 34403da084b3Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 34413da084b3Smrg case $host_os in 3442d63fdb69Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 34433da084b3Smrg pic_mode=default 34443da084b3Smrg ;; 34453da084b3Smrg esac 344652fd71cdSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 34473da084b3Smrg # non-PIC code in shared libraries is not supported 34483da084b3Smrg pic_mode=default 34493da084b3Smrg fi 34503da084b3Smrg 34513da084b3Smrg # Calculate the filename of the output object if compiler does 34523da084b3Smrg # not support -o with -c 345352fd71cdSmrg if test no = "$compiler_c_o"; then 345452fd71cdSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345552fd71cdSmrg lockfile=$output_obj.lock 34563da084b3Smrg else 34573da084b3Smrg output_obj= 34583da084b3Smrg need_locks=no 34593da084b3Smrg lockfile= 34603da084b3Smrg fi 34613da084b3Smrg 34623da084b3Smrg # Lock this critical section if it is needed 34633da084b3Smrg # We use this script file to make the link, it avoids creating a new file 346452fd71cdSmrg if test yes = "$need_locks"; then 3465d63fdb69Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466d63fdb69Smrg func_echo "Waiting for $lockfile to be removed" 34673da084b3Smrg sleep 2 34683da084b3Smrg done 346952fd71cdSmrg elif test warn = "$need_locks"; then 34703da084b3Smrg if test -f "$lockfile"; then 3471d63fdb69Smrg $ECHO "\ 34723da084b3Smrg*** ERROR, $lockfile exists and contains: 34733da084b3Smrg`cat $lockfile 2>/dev/null` 34743da084b3Smrg 34753da084b3SmrgThis indicates that another process is trying to use the same 34763da084b3Smrgtemporary object file, and libtool could not work around it because 347752fd71cdSmrgyour compiler does not support '-c' and '-o' together. If you 34783da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better 34793da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better 34803da084b3Smrgcompiler." 34813da084b3Smrg 3482d63fdb69Smrg $opt_dry_run || $RM $removelist 34833da084b3Smrg exit $EXIT_FAILURE 34843da084b3Smrg fi 348548c85eb7Smrg func_append removelist " $output_obj" 3486d63fdb69Smrg $ECHO "$srcfile" > "$lockfile" 34873da084b3Smrg fi 34883da084b3Smrg 3489d63fdb69Smrg $opt_dry_run || $RM $removelist 349048c85eb7Smrg func_append removelist " $lockfile" 3491d63fdb69Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492d63fdb69Smrg 349348c85eb7Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349448c85eb7Smrg srcfile=$func_to_tool_file_result 3495d63fdb69Smrg func_quote_for_eval "$srcfile" 3496d63fdb69Smrg qsrcfile=$func_quote_for_eval_result 34973da084b3Smrg 34983da084b3Smrg # Only build a PIC object if we are building libtool libraries. 349952fd71cdSmrg if test yes = "$build_libtool_libs"; then 35003da084b3Smrg # Without this assignment, base_compile gets emptied. 35013da084b3Smrg fbsd_hideous_sh_bug=$base_compile 35023da084b3Smrg 350352fd71cdSmrg if test no != "$pic_mode"; then 35043da084b3Smrg command="$base_compile $qsrcfile $pic_flag" 35053da084b3Smrg else 35063da084b3Smrg # Don't build PIC code 35073da084b3Smrg command="$base_compile $qsrcfile" 35083da084b3Smrg fi 35093da084b3Smrg 3510d63fdb69Smrg func_mkdir_p "$xdir$objdir" 35113da084b3Smrg 35123da084b3Smrg if test -z "$output_obj"; then 35133da084b3Smrg # Place PIC objects in $objdir 351448c85eb7Smrg func_append command " -o $lobj" 35153da084b3Smrg fi 35163da084b3Smrg 3517d63fdb69Smrg func_show_eval_locale "$command" \ 3518d63fdb69Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 35193da084b3Smrg 352052fd71cdSmrg if test warn = "$need_locks" && 35213da084b3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522d63fdb69Smrg $ECHO "\ 35233da084b3Smrg*** ERROR, $lockfile contains: 35243da084b3Smrg`cat $lockfile 2>/dev/null` 35253da084b3Smrg 35263da084b3Smrgbut it should contain: 35273da084b3Smrg$srcfile 35283da084b3Smrg 35293da084b3SmrgThis indicates that another process is trying to use the same 35303da084b3Smrgtemporary object file, and libtool could not work around it because 353152fd71cdSmrgyour compiler does not support '-c' and '-o' together. If you 35323da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better 35333da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better 35343da084b3Smrgcompiler." 35353da084b3Smrg 3536d63fdb69Smrg $opt_dry_run || $RM $removelist 35373da084b3Smrg exit $EXIT_FAILURE 35383da084b3Smrg fi 35393da084b3Smrg 35403da084b3Smrg # Just move the object if needed, then go on to compile the next one 35413da084b3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542d63fdb69Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543d63fdb69Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35443da084b3Smrg fi 35453da084b3Smrg 35463da084b3Smrg # Allow error messages only from the first compilation. 354752fd71cdSmrg if test yes = "$suppress_opt"; then 3548d63fdb69Smrg suppress_output=' >/dev/null 2>&1' 35493da084b3Smrg fi 35503da084b3Smrg fi 35513da084b3Smrg 35523da084b3Smrg # Only build a position-dependent object if we build old libraries. 355352fd71cdSmrg if test yes = "$build_old_libs"; then 355452fd71cdSmrg if test yes != "$pic_mode"; then 35553da084b3Smrg # Don't build PIC code 3556d63fdb69Smrg command="$base_compile $qsrcfile$pie_flag" 35573da084b3Smrg else 35583da084b3Smrg command="$base_compile $qsrcfile $pic_flag" 35593da084b3Smrg fi 356052fd71cdSmrg if test yes = "$compiler_c_o"; then 356148c85eb7Smrg func_append command " -o $obj" 35623da084b3Smrg fi 35633da084b3Smrg 35643da084b3Smrg # Suppress compiler output if we already did a PIC compilation. 356548c85eb7Smrg func_append command "$suppress_output" 3566d63fdb69Smrg func_show_eval_locale "$command" \ 3567d63fdb69Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 35683da084b3Smrg 356952fd71cdSmrg if test warn = "$need_locks" && 35703da084b3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571d63fdb69Smrg $ECHO "\ 35723da084b3Smrg*** ERROR, $lockfile contains: 35733da084b3Smrg`cat $lockfile 2>/dev/null` 35743da084b3Smrg 35753da084b3Smrgbut it should contain: 35763da084b3Smrg$srcfile 35773da084b3Smrg 35783da084b3SmrgThis indicates that another process is trying to use the same 35793da084b3Smrgtemporary object file, and libtool could not work around it because 358052fd71cdSmrgyour compiler does not support '-c' and '-o' together. If you 35813da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better 35823da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better 35833da084b3Smrgcompiler." 35843da084b3Smrg 3585d63fdb69Smrg $opt_dry_run || $RM $removelist 35863da084b3Smrg exit $EXIT_FAILURE 35873da084b3Smrg fi 35883da084b3Smrg 35893da084b3Smrg # Just move the object if needed 35903da084b3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591d63fdb69Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592d63fdb69Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35933da084b3Smrg fi 35943da084b3Smrg fi 35953da084b3Smrg 3596d63fdb69Smrg $opt_dry_run || { 3597d63fdb69Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 35983da084b3Smrg 3599d63fdb69Smrg # Unlock the critical section if it was locked 360052fd71cdSmrg if test no != "$need_locks"; then 3601d63fdb69Smrg removelist=$lockfile 3602d63fdb69Smrg $RM "$lockfile" 3603d63fdb69Smrg fi 3604d63fdb69Smrg } 36053da084b3Smrg 36063da084b3Smrg exit $EXIT_SUCCESS 3607d63fdb69Smrg} 36083da084b3Smrg 3609d63fdb69Smrg$opt_help || { 361052fd71cdSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611d63fdb69Smrg} 36123da084b3Smrg 3613d63fdb69Smrgfunc_mode_help () 3614d63fdb69Smrg{ 3615d63fdb69Smrg # We need to display help for each of the modes. 361648c85eb7Smrg case $opt_mode in 3617d63fdb69Smrg "") 3618d63fdb69Smrg # Generic help is extracted from the usage comments 3619d63fdb69Smrg # at the start of this file. 3620d63fdb69Smrg func_help 3621d63fdb69Smrg ;; 36223da084b3Smrg 3623d63fdb69Smrg clean) 3624d63fdb69Smrg $ECHO \ 3625d63fdb69Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 36263da084b3Smrg 3627d63fdb69SmrgRemove files from the build directory. 36283da084b3Smrg 3629d63fdb69SmrgRM is the name of the program to use to delete files associated with each FILE 363052fd71cdSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631d63fdb69Smrgto RM. 36323da084b3Smrg 3633d63fdb69SmrgIf FILE is a libtool library, object or program, all the files associated 3634d63fdb69Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635d63fdb69Smrg ;; 36363da084b3Smrg 3637d63fdb69Smrg compile) 3638d63fdb69Smrg $ECHO \ 3639d63fdb69Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 36403da084b3Smrg 3641d63fdb69SmrgCompile a source file into a libtool library object. 36423da084b3Smrg 3643d63fdb69SmrgThis mode accepts the following additional options: 36443da084b3Smrg 3645d63fdb69Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646d63fdb69Smrg -no-suppress do not suppress compiler output for multiple passes 364755acc8fcSmrg -prefer-pic try to build PIC objects only 364855acc8fcSmrg -prefer-non-pic try to build non-PIC objects only 364952fd71cdSmrg -shared do not build a '.o' file suitable for static linking 365052fd71cdSmrg -static only build a '.o' file suitable for static linking 365155acc8fcSmrg -Wc,FLAG pass FLAG directly to the compiler 36523da084b3Smrg 365352fd71cdSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654d63fdb69Smrgfrom the given SOURCEFILE. 36553da084b3Smrg 3656d63fdb69SmrgThe output file name is determined by removing the directory component from 365752fd71cdSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365852fd71cdSmrglibrary object suffix, '.lo'." 3659d63fdb69Smrg ;; 36603da084b3Smrg 3661d63fdb69Smrg execute) 3662d63fdb69Smrg $ECHO \ 3663d63fdb69Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 36643da084b3Smrg 3665d63fdb69SmrgAutomatically set library path, then run a program. 36663da084b3Smrg 3667d63fdb69SmrgThis mode accepts the following additional options: 36683da084b3Smrg 3669d63fdb69Smrg -dlopen FILE add the directory containing FILE to the library path 36703da084b3Smrg 367152fd71cdSmrgThis mode sets the library path environment variable according to '-dlopen' 3672d63fdb69Smrgflags. 36733da084b3Smrg 3674d63fdb69SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675d63fdb69Smrginto their corresponding uninstalled binary, and any of their required library 3676d63fdb69Smrgdirectories are added to the library path. 36773da084b3Smrg 3678d63fdb69SmrgThen, COMMAND is executed, with ARGS as arguments." 3679d63fdb69Smrg ;; 36803da084b3Smrg 3681d63fdb69Smrg finish) 3682d63fdb69Smrg $ECHO \ 3683d63fdb69Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 36843da084b3Smrg 3685d63fdb69SmrgComplete the installation of libtool libraries. 36863da084b3Smrg 3687d63fdb69SmrgEach LIBDIR is a directory that contains libtool libraries. 36883da084b3Smrg 3689d63fdb69SmrgThe commands that this mode executes may require superuser privileges. Use 369052fd71cdSmrgthe '--dry-run' option if you just want to see what would be executed." 3691d63fdb69Smrg ;; 36923da084b3Smrg 3693d63fdb69Smrg install) 3694d63fdb69Smrg $ECHO \ 3695d63fdb69Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 36963da084b3Smrg 3697d63fdb69SmrgInstall executables or libraries. 36983da084b3Smrg 3699d63fdb69SmrgINSTALL-COMMAND is the installation command. The first component should be 370052fd71cdSmrgeither the 'install' or 'cp' program. 37013da084b3Smrg 3702d63fdb69SmrgThe following components of INSTALL-COMMAND are treated specially: 37033da084b3Smrg 370455acc8fcSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 37053da084b3Smrg 3706d63fdb69SmrgThe rest of the components are interpreted as arguments to that command (only 3707d63fdb69SmrgBSD-compatible install options are recognized)." 3708d63fdb69Smrg ;; 37093da084b3Smrg 3710d63fdb69Smrg link) 3711d63fdb69Smrg $ECHO \ 3712d63fdb69Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 37133da084b3Smrg 3714d63fdb69SmrgLink object files or libraries together to form another library, or to 3715d63fdb69Smrgcreate an executable program. 37163da084b3Smrg 3717d63fdb69SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718d63fdb69Smrga program from several object files. 37193da084b3Smrg 3720d63fdb69SmrgThe following components of LINK-COMMAND are treated specially: 37213da084b3Smrg 3722d63fdb69Smrg -all-static do not do any dynamic linking at all 3723d63fdb69Smrg -avoid-version do not add a version suffix if possible 372455acc8fcSmrg -bindir BINDIR specify path to binaries directory (for systems where 372555acc8fcSmrg libraries must be found in the PATH setting at runtime) 372652fd71cdSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727d63fdb69Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728d63fdb69Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729d63fdb69Smrg -export-symbols SYMFILE 3730d63fdb69Smrg try to export only the symbols listed in SYMFILE 3731d63fdb69Smrg -export-symbols-regex REGEX 3732d63fdb69Smrg try to export only the symbols matching REGEX 3733d63fdb69Smrg -LLIBDIR search LIBDIR for required installed libraries 3734d63fdb69Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735d63fdb69Smrg -module build a library that can dlopened 3736d63fdb69Smrg -no-fast-install disable the fast-install mode 3737d63fdb69Smrg -no-install link a not-installable executable 3738d63fdb69Smrg -no-undefined declare that a library does not refer to external symbols 3739d63fdb69Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374052fd71cdSmrg -objectlist FILE use a list of object files found in FILE to specify objects 374152fd71cdSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742d63fdb69Smrg -precious-files-regex REGEX 3743d63fdb69Smrg don't remove output files matching REGEX 3744d63fdb69Smrg -release RELEASE specify package release information 3745d63fdb69Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746d63fdb69Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747d63fdb69Smrg -shared only do dynamic linking of libtool libraries 3748d63fdb69Smrg -shrext SUFFIX override the standard shared library file extension 3749d63fdb69Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3750d63fdb69Smrg -static-libtool-libs 3751d63fdb69Smrg do not do any dynamic linking of libtool libraries 3752d63fdb69Smrg -version-info CURRENT[:REVISION[:AGE]] 3753d63fdb69Smrg specify library version info [each variable defaults to 0] 3754d63fdb69Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 375555acc8fcSmrg -Wc,FLAG 375655acc8fcSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375755acc8fcSmrg -Wl,FLAG 375855acc8fcSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375955acc8fcSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 37603da084b3Smrg 376152fd71cdSmrgAll other options (arguments beginning with '-') are ignored. 37623da084b3Smrg 376352fd71cdSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764d63fdb69Smrgtreated as uninstalled libtool libraries, other files are standard or library 3765d63fdb69Smrgobject files. 37663da084b3Smrg 376752fd71cdSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376852fd71cdSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769d63fdb69Smrgrequired, except when creating a convenience library. 37703da084b3Smrg 377152fd71cdSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377252fd71cdSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 37733da084b3Smrg 377452fd71cdSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775d63fdb69Smrgis created, otherwise an executable program is created." 37763da084b3Smrg ;; 37773da084b3Smrg 3778d63fdb69Smrg uninstall) 3779d63fdb69Smrg $ECHO \ 3780d63fdb69Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 37813da084b3Smrg 3782d63fdb69SmrgRemove libraries from an installation directory. 37833da084b3Smrg 3784d63fdb69SmrgRM is the name of the program to use to delete files associated with each FILE 378552fd71cdSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786d63fdb69Smrgto RM. 37873da084b3Smrg 3788d63fdb69SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789d63fdb69SmrgOtherwise, only FILE itself is deleted using RM." 3790d63fdb69Smrg ;; 37913da084b3Smrg 3792d63fdb69Smrg *) 379352fd71cdSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3794d63fdb69Smrg ;; 3795d63fdb69Smrg esac 37963da084b3Smrg 379755acc8fcSmrg echo 379852fd71cdSmrg $ECHO "Try '$progname --help' for more information about other modes." 3799d63fdb69Smrg} 38003da084b3Smrg 380155acc8fcSmrg# Now that we've collected a possible --mode arg, show help if necessary 380255acc8fcSmrgif $opt_help; then 380352fd71cdSmrg if test : = "$opt_help"; then 380455acc8fcSmrg func_mode_help 380555acc8fcSmrg else 380655acc8fcSmrg { 380755acc8fcSmrg func_help noexit 380848c85eb7Smrg for opt_mode in compile link execute install finish uninstall clean; do 380955acc8fcSmrg func_mode_help 381055acc8fcSmrg done 381152fd71cdSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381255acc8fcSmrg { 381355acc8fcSmrg func_help noexit 381448c85eb7Smrg for opt_mode in compile link execute install finish uninstall clean; do 381555acc8fcSmrg echo 381655acc8fcSmrg func_mode_help 381755acc8fcSmrg done 381855acc8fcSmrg } | 381952fd71cdSmrg $SED '1d 382055acc8fcSmrg /^When reporting/,/^Report/{ 382155acc8fcSmrg H 382255acc8fcSmrg d 382355acc8fcSmrg } 382455acc8fcSmrg $x 382555acc8fcSmrg /information about other modes/d 382655acc8fcSmrg /more detailed .*MODE/d 382755acc8fcSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382855acc8fcSmrg fi 382955acc8fcSmrg exit $? 383055acc8fcSmrgfi 38313da084b3Smrg 38323da084b3Smrg 3833d63fdb69Smrg# func_mode_execute arg... 3834d63fdb69Smrgfunc_mode_execute () 3835d63fdb69Smrg{ 383652fd71cdSmrg $debug_cmd 383752fd71cdSmrg 3838d63fdb69Smrg # The first argument is the command name. 383952fd71cdSmrg cmd=$nonopt 3840d63fdb69Smrg test -z "$cmd" && \ 3841d63fdb69Smrg func_fatal_help "you must specify a COMMAND" 38423da084b3Smrg 3843d63fdb69Smrg # Handle -dlopen flags immediately. 384448c85eb7Smrg for file in $opt_dlopen; do 3845d63fdb69Smrg test -f "$file" \ 384652fd71cdSmrg || func_fatal_help "'$file' is not a file" 38473da084b3Smrg 3848d63fdb69Smrg dir= 3849d63fdb69Smrg case $file in 3850d63fdb69Smrg *.la) 385148c85eb7Smrg func_resolve_sysroot "$file" 385248c85eb7Smrg file=$func_resolve_sysroot_result 385348c85eb7Smrg 3854d63fdb69Smrg # Check to see that this really is a libtool archive. 3855d63fdb69Smrg func_lalib_unsafe_p "$file" \ 385652fd71cdSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 38573da084b3Smrg 3858d63fdb69Smrg # Read the libtool library. 3859d63fdb69Smrg dlname= 3860d63fdb69Smrg library_names= 3861d63fdb69Smrg func_source "$file" 38623da084b3Smrg 3863d63fdb69Smrg # Skip this library if it cannot be dlopened. 3864d63fdb69Smrg if test -z "$dlname"; then 3865d63fdb69Smrg # Warn if it was a shared library. 3866d63fdb69Smrg test -n "$library_names" && \ 386752fd71cdSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3868d63fdb69Smrg continue 3869d63fdb69Smrg fi 38703da084b3Smrg 3871d63fdb69Smrg func_dirname "$file" "" "." 387252fd71cdSmrg dir=$func_dirname_result 38733da084b3Smrg 3874d63fdb69Smrg if test -f "$dir/$objdir/$dlname"; then 387548c85eb7Smrg func_append dir "/$objdir" 3876d63fdb69Smrg else 3877d63fdb69Smrg if test ! -f "$dir/$dlname"; then 387852fd71cdSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879d63fdb69Smrg fi 3880d63fdb69Smrg fi 38813da084b3Smrg ;; 38823da084b3Smrg 3883d63fdb69Smrg *.lo) 3884d63fdb69Smrg # Just add the directory containing the .lo file. 3885d63fdb69Smrg func_dirname "$file" "" "." 388652fd71cdSmrg dir=$func_dirname_result 38873da084b3Smrg ;; 38883da084b3Smrg 3889d63fdb69Smrg *) 389052fd71cdSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 38913da084b3Smrg continue 38923da084b3Smrg ;; 3893d63fdb69Smrg esac 38943da084b3Smrg 3895d63fdb69Smrg # Get the absolute pathname. 3896d63fdb69Smrg absdir=`cd "$dir" && pwd` 389752fd71cdSmrg test -n "$absdir" && dir=$absdir 38983da084b3Smrg 3899d63fdb69Smrg # Now add the directory to shlibpath_var. 3900d63fdb69Smrg if eval "test -z \"\$$shlibpath_var\""; then 3901d63fdb69Smrg eval "$shlibpath_var=\"\$dir\"" 3902d63fdb69Smrg else 3903d63fdb69Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904d63fdb69Smrg fi 3905d63fdb69Smrg done 39063da084b3Smrg 3907d63fdb69Smrg # This variable tells wrapper scripts just to set shlibpath_var 3908d63fdb69Smrg # rather than running their programs. 390952fd71cdSmrg libtool_execute_magic=$magic 39103da084b3Smrg 3911d63fdb69Smrg # Check if any of the arguments is a wrapper script. 3912d63fdb69Smrg args= 3913d63fdb69Smrg for file 3914d63fdb69Smrg do 3915d63fdb69Smrg case $file in 391655acc8fcSmrg -* | *.la | *.lo ) ;; 3917d63fdb69Smrg *) 3918d63fdb69Smrg # Do a test to see if this is really a libtool program. 3919d63fdb69Smrg if func_ltwrapper_script_p "$file"; then 3920d63fdb69Smrg func_source "$file" 3921d63fdb69Smrg # Transform arg to wrapped name. 392252fd71cdSmrg file=$progdir/$program 3923d63fdb69Smrg elif func_ltwrapper_executable_p "$file"; then 3924d63fdb69Smrg func_ltwrapper_scriptname "$file" 3925d63fdb69Smrg func_source "$func_ltwrapper_scriptname_result" 3926d63fdb69Smrg # Transform arg to wrapped name. 392752fd71cdSmrg file=$progdir/$program 3928d63fdb69Smrg fi 3929d63fdb69Smrg ;; 3930d63fdb69Smrg esac 3931d63fdb69Smrg # Quote arguments (to preserve shell metacharacters). 393248c85eb7Smrg func_append_quoted args "$file" 3933d63fdb69Smrg done 39343da084b3Smrg 393552fd71cdSmrg if $opt_dry_run; then 393652fd71cdSmrg # Display what would be done. 393752fd71cdSmrg if test -n "$shlibpath_var"; then 393852fd71cdSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393952fd71cdSmrg echo "export $shlibpath_var" 394052fd71cdSmrg fi 394152fd71cdSmrg $ECHO "$cmd$args" 394252fd71cdSmrg exit $EXIT_SUCCESS 394352fd71cdSmrg else 3944d63fdb69Smrg if test -n "$shlibpath_var"; then 3945d63fdb69Smrg # Export the shlibpath_var. 3946d63fdb69Smrg eval "export $shlibpath_var" 3947d63fdb69Smrg fi 39483da084b3Smrg 3949d63fdb69Smrg # Restore saved environment variables 3950d63fdb69Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951d63fdb69Smrg do 3952d63fdb69Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953d63fdb69Smrg $lt_var=\$save_$lt_var; export $lt_var 3954d63fdb69Smrg else 3955d63fdb69Smrg $lt_unset $lt_var 3956d63fdb69Smrg fi" 3957d63fdb69Smrg done 39583da084b3Smrg 3959d63fdb69Smrg # Now prepare to actually exec the command. 396052fd71cdSmrg exec_cmd=\$cmd$args 3961d63fdb69Smrg fi 3962d63fdb69Smrg} 39633da084b3Smrg 396452fd71cdSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 39653da084b3Smrg 39663da084b3Smrg 3967d63fdb69Smrg# func_mode_finish arg... 3968d63fdb69Smrgfunc_mode_finish () 3969d63fdb69Smrg{ 397052fd71cdSmrg $debug_cmd 397152fd71cdSmrg 397248c85eb7Smrg libs= 397348c85eb7Smrg libdirs= 3974d63fdb69Smrg admincmds= 39753da084b3Smrg 397648c85eb7Smrg for opt in "$nonopt" ${1+"$@"} 397748c85eb7Smrg do 397848c85eb7Smrg if test -d "$opt"; then 397948c85eb7Smrg func_append libdirs " $opt" 398048c85eb7Smrg 398148c85eb7Smrg elif test -f "$opt"; then 398248c85eb7Smrg if func_lalib_unsafe_p "$opt"; then 398348c85eb7Smrg func_append libs " $opt" 398448c85eb7Smrg else 398552fd71cdSmrg func_warning "'$opt' is not a valid libtool archive" 398648c85eb7Smrg fi 398748c85eb7Smrg 398848c85eb7Smrg else 398952fd71cdSmrg func_fatal_error "invalid argument '$opt'" 399048c85eb7Smrg fi 399148c85eb7Smrg done 399248c85eb7Smrg 399348c85eb7Smrg if test -n "$libs"; then 399448c85eb7Smrg if test -n "$lt_sysroot"; then 399548c85eb7Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399648c85eb7Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399748c85eb7Smrg else 399848c85eb7Smrg sysroot_cmd= 399948c85eb7Smrg fi 400048c85eb7Smrg 400148c85eb7Smrg # Remove sysroot references 400248c85eb7Smrg if $opt_dry_run; then 400348c85eb7Smrg for lib in $libs; do 400452fd71cdSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400548c85eb7Smrg done 400648c85eb7Smrg else 400748c85eb7Smrg tmpdir=`func_mktempdir` 400848c85eb7Smrg for lib in $libs; do 400952fd71cdSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401048c85eb7Smrg > $tmpdir/tmp-la 401148c85eb7Smrg mv -f $tmpdir/tmp-la $lib 401248c85eb7Smrg done 401348c85eb7Smrg ${RM}r "$tmpdir" 401448c85eb7Smrg fi 401548c85eb7Smrg fi 40163da084b3Smrg 401748c85eb7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018d63fdb69Smrg for libdir in $libdirs; do 4019d63fdb69Smrg if test -n "$finish_cmds"; then 4020d63fdb69Smrg # Do each command in the finish commands. 4021d63fdb69Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022d63fdb69Smrg'"$cmd"'"' 4023d63fdb69Smrg fi 4024d63fdb69Smrg if test -n "$finish_eval"; then 4025d63fdb69Smrg # Do the single finish_eval. 4026d63fdb69Smrg eval cmds=\"$finish_eval\" 402748c85eb7Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028d63fdb69Smrg $cmds" 4029d63fdb69Smrg fi 4030d63fdb69Smrg done 4031d63fdb69Smrg fi 40323da084b3Smrg 4033d63fdb69Smrg # Exit here if they wanted silent mode. 403452fd71cdSmrg $opt_quiet && exit $EXIT_SUCCESS 40353da084b3Smrg 403648c85eb7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403748c85eb7Smrg echo "----------------------------------------------------------------------" 403848c85eb7Smrg echo "Libraries have been installed in:" 403948c85eb7Smrg for libdir in $libdirs; do 404048c85eb7Smrg $ECHO " $libdir" 404148c85eb7Smrg done 404248c85eb7Smrg echo 404348c85eb7Smrg echo "If you ever happen to want to link against installed libraries" 404448c85eb7Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404552fd71cdSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404648c85eb7Smrg echo "flag during linking and do at least one of the following:" 404748c85eb7Smrg if test -n "$shlibpath_var"; then 404852fd71cdSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404948c85eb7Smrg echo " during execution" 405048c85eb7Smrg fi 405148c85eb7Smrg if test -n "$runpath_var"; then 405252fd71cdSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405348c85eb7Smrg echo " during linking" 405448c85eb7Smrg fi 405548c85eb7Smrg if test -n "$hardcode_libdir_flag_spec"; then 405648c85eb7Smrg libdir=LIBDIR 405748c85eb7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 40583da084b3Smrg 405952fd71cdSmrg $ECHO " - use the '$flag' linker flag" 406048c85eb7Smrg fi 406148c85eb7Smrg if test -n "$admincmds"; then 406248c85eb7Smrg $ECHO " - have your system administrator run these commands:$admincmds" 406348c85eb7Smrg fi 406448c85eb7Smrg if test -f /etc/ld.so.conf; then 406552fd71cdSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406648c85eb7Smrg fi 406748c85eb7Smrg echo 40683da084b3Smrg 406948c85eb7Smrg echo "See any operating system documentation about shared libraries for" 407048c85eb7Smrg case $host in 407148c85eb7Smrg solaris2.[6789]|solaris2.1[0-9]) 407248c85eb7Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407348c85eb7Smrg echo "pages." 407448c85eb7Smrg ;; 407548c85eb7Smrg *) 407648c85eb7Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 407748c85eb7Smrg ;; 407848c85eb7Smrg esac 407948c85eb7Smrg echo "----------------------------------------------------------------------" 408048c85eb7Smrg fi 4081d63fdb69Smrg exit $EXIT_SUCCESS 4082d63fdb69Smrg} 40833da084b3Smrg 408452fd71cdSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 40853da084b3Smrg 40863da084b3Smrg 4087d63fdb69Smrg# func_mode_install arg... 4088d63fdb69Smrgfunc_mode_install () 4089d63fdb69Smrg{ 409052fd71cdSmrg $debug_cmd 409152fd71cdSmrg 4092d63fdb69Smrg # There may be an optional sh(1) argument at the beginning of 4093d63fdb69Smrg # install_prog (especially on Windows NT). 409452fd71cdSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095d63fdb69Smrg # Allow the use of GNU shtool's install command. 409652fd71cdSmrg case $nonopt in *shtool*) :;; *) false;; esac 409752fd71cdSmrg then 4098d63fdb69Smrg # Aesthetically quote it. 4099d63fdb69Smrg func_quote_for_eval "$nonopt" 4100d63fdb69Smrg install_prog="$func_quote_for_eval_result " 4101d63fdb69Smrg arg=$1 4102d63fdb69Smrg shift 4103d63fdb69Smrg else 4104d63fdb69Smrg install_prog= 4105d63fdb69Smrg arg=$nonopt 4106d63fdb69Smrg fi 41073da084b3Smrg 4108d63fdb69Smrg # The real first argument should be the name of the installation program. 4109d63fdb69Smrg # Aesthetically quote it. 4110d63fdb69Smrg func_quote_for_eval "$arg" 411148c85eb7Smrg func_append install_prog "$func_quote_for_eval_result" 411255acc8fcSmrg install_shared_prog=$install_prog 411355acc8fcSmrg case " $install_prog " in 411455acc8fcSmrg *[\\\ /]cp\ *) install_cp=: ;; 411555acc8fcSmrg *) install_cp=false ;; 411655acc8fcSmrg esac 4117d63fdb69Smrg 4118d63fdb69Smrg # We need to accept at least all the BSD install flags. 4119d63fdb69Smrg dest= 4120d63fdb69Smrg files= 4121d63fdb69Smrg opts= 4122d63fdb69Smrg prev= 4123d63fdb69Smrg install_type= 412452fd71cdSmrg isdir=false 4125d63fdb69Smrg stripme= 412655acc8fcSmrg no_mode=: 4127d63fdb69Smrg for arg 4128d63fdb69Smrg do 412955acc8fcSmrg arg2= 4130d63fdb69Smrg if test -n "$dest"; then 413148c85eb7Smrg func_append files " $dest" 4132d63fdb69Smrg dest=$arg 4133d63fdb69Smrg continue 41343da084b3Smrg fi 41353da084b3Smrg 4136d63fdb69Smrg case $arg in 413752fd71cdSmrg -d) isdir=: ;; 4138d63fdb69Smrg -f) 413955acc8fcSmrg if $install_cp; then :; else 414055acc8fcSmrg prev=$arg 414155acc8fcSmrg fi 4142d63fdb69Smrg ;; 4143d63fdb69Smrg -g | -m | -o) 4144d63fdb69Smrg prev=$arg 4145d63fdb69Smrg ;; 4146d63fdb69Smrg -s) 4147d63fdb69Smrg stripme=" -s" 4148d63fdb69Smrg continue 4149d63fdb69Smrg ;; 4150d63fdb69Smrg -*) 4151d63fdb69Smrg ;; 4152d63fdb69Smrg *) 4153d63fdb69Smrg # If the previous option needed an argument, then skip it. 4154d63fdb69Smrg if test -n "$prev"; then 415552fd71cdSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415655acc8fcSmrg arg2=$install_override_mode 415755acc8fcSmrg no_mode=false 415855acc8fcSmrg fi 4159d63fdb69Smrg prev= 4160d63fdb69Smrg else 4161d63fdb69Smrg dest=$arg 4162d63fdb69Smrg continue 4163d63fdb69Smrg fi 4164d63fdb69Smrg ;; 4165d63fdb69Smrg esac 41663da084b3Smrg 4167d63fdb69Smrg # Aesthetically quote the argument. 4168d63fdb69Smrg func_quote_for_eval "$arg" 416948c85eb7Smrg func_append install_prog " $func_quote_for_eval_result" 417055acc8fcSmrg if test -n "$arg2"; then 417155acc8fcSmrg func_quote_for_eval "$arg2" 417255acc8fcSmrg fi 417348c85eb7Smrg func_append install_shared_prog " $func_quote_for_eval_result" 4174d63fdb69Smrg done 41753da084b3Smrg 4176d63fdb69Smrg test -z "$install_prog" && \ 4177d63fdb69Smrg func_fatal_help "you must specify an install program" 41783da084b3Smrg 4179d63fdb69Smrg test -n "$prev" && \ 418052fd71cdSmrg func_fatal_help "the '$prev' option requires an argument" 41813da084b3Smrg 418255acc8fcSmrg if test -n "$install_override_mode" && $no_mode; then 418355acc8fcSmrg if $install_cp; then :; else 418455acc8fcSmrg func_quote_for_eval "$install_override_mode" 418548c85eb7Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418655acc8fcSmrg fi 418755acc8fcSmrg fi 418855acc8fcSmrg 4189d63fdb69Smrg if test -z "$files"; then 4190d63fdb69Smrg if test -z "$dest"; then 4191d63fdb69Smrg func_fatal_help "no file or destination specified" 4192d63fdb69Smrg else 4193d63fdb69Smrg func_fatal_help "you must specify a destination" 41943da084b3Smrg fi 41953da084b3Smrg fi 41963da084b3Smrg 4197d63fdb69Smrg # Strip any trailing slash from the destination. 4198d63fdb69Smrg func_stripname '' '/' "$dest" 4199d63fdb69Smrg dest=$func_stripname_result 42003da084b3Smrg 4201d63fdb69Smrg # Check to see that the destination is a directory. 420252fd71cdSmrg test -d "$dest" && isdir=: 420352fd71cdSmrg if $isdir; then 420452fd71cdSmrg destdir=$dest 4205d63fdb69Smrg destname= 4206d63fdb69Smrg else 4207d63fdb69Smrg func_dirname_and_basename "$dest" "" "." 420852fd71cdSmrg destdir=$func_dirname_result 420952fd71cdSmrg destname=$func_basename_result 4210d63fdb69Smrg 4211d63fdb69Smrg # Not a directory, so check to see that there is only one file specified. 4212d63fdb69Smrg set dummy $files; shift 4213d63fdb69Smrg test "$#" -gt 1 && \ 421452fd71cdSmrg func_fatal_help "'$dest' is not a directory" 4215d63fdb69Smrg fi 4216d63fdb69Smrg case $destdir in 4217d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 42183da084b3Smrg *) 4219d63fdb69Smrg for file in $files; do 4220d63fdb69Smrg case $file in 4221d63fdb69Smrg *.lo) ;; 4222d63fdb69Smrg *) 422352fd71cdSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4224d63fdb69Smrg ;; 4225d63fdb69Smrg esac 4226d63fdb69Smrg done 42273da084b3Smrg ;; 42283da084b3Smrg esac 42293da084b3Smrg 4230d63fdb69Smrg # This variable tells wrapper scripts just to set variables rather 4231d63fdb69Smrg # than running their programs. 423252fd71cdSmrg libtool_install_magic=$magic 42333da084b3Smrg 4234d63fdb69Smrg staticlibs= 4235d63fdb69Smrg future_libdirs= 4236d63fdb69Smrg current_libdirs= 4237d63fdb69Smrg for file in $files; do 42383da084b3Smrg 4239d63fdb69Smrg # Do each installation. 4240d63fdb69Smrg case $file in 4241d63fdb69Smrg *.$libext) 4242d63fdb69Smrg # Do the static libraries later. 424348c85eb7Smrg func_append staticlibs " $file" 4244d63fdb69Smrg ;; 4245d63fdb69Smrg 4246d63fdb69Smrg *.la) 424748c85eb7Smrg func_resolve_sysroot "$file" 424848c85eb7Smrg file=$func_resolve_sysroot_result 424948c85eb7Smrg 4250d63fdb69Smrg # Check to see that this really is a libtool archive. 4251d63fdb69Smrg func_lalib_unsafe_p "$file" \ 425252fd71cdSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4253d63fdb69Smrg 4254d63fdb69Smrg library_names= 4255d63fdb69Smrg old_library= 4256d63fdb69Smrg relink_command= 4257d63fdb69Smrg func_source "$file" 4258d63fdb69Smrg 4259d63fdb69Smrg # Add the libdir to current_libdirs if it is the destination. 4260d63fdb69Smrg if test "X$destdir" = "X$libdir"; then 4261d63fdb69Smrg case "$current_libdirs " in 4262d63fdb69Smrg *" $libdir "*) ;; 426348c85eb7Smrg *) func_append current_libdirs " $libdir" ;; 42643da084b3Smrg esac 4265d63fdb69Smrg else 4266d63fdb69Smrg # Note the libdir as a future libdir. 4267d63fdb69Smrg case "$future_libdirs " in 4268d63fdb69Smrg *" $libdir "*) ;; 426948c85eb7Smrg *) func_append future_libdirs " $libdir" ;; 4270d63fdb69Smrg esac 4271d63fdb69Smrg fi 42723da084b3Smrg 4273d63fdb69Smrg func_dirname "$file" "/" "" 427452fd71cdSmrg dir=$func_dirname_result 427548c85eb7Smrg func_append dir "$objdir" 4276d63fdb69Smrg 4277d63fdb69Smrg if test -n "$relink_command"; then 4278d63fdb69Smrg # Determine the prefix the user has applied to our future dir. 427955acc8fcSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280d63fdb69Smrg 4281d63fdb69Smrg # Don't allow the user to place us outside of our expected 4282d63fdb69Smrg # location b/c this prevents finding dependent libraries that 4283d63fdb69Smrg # are installed to the same prefix. 4284d63fdb69Smrg # At present, this check doesn't affect windows .dll's that 4285d63fdb69Smrg # are installed into $libdir/../bin (currently, that works fine) 4286d63fdb69Smrg # but it's something to keep an eye on. 4287d63fdb69Smrg test "$inst_prefix_dir" = "$destdir" && \ 428852fd71cdSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289d63fdb69Smrg 4290d63fdb69Smrg if test -n "$inst_prefix_dir"; then 4291d63fdb69Smrg # Stick the inst_prefix_dir data into the link command. 429255acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293d63fdb69Smrg else 429455acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295d63fdb69Smrg fi 4296d63fdb69Smrg 429752fd71cdSmrg func_warning "relinking '$file'" 4298d63fdb69Smrg func_show_eval "$relink_command" \ 429952fd71cdSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300d63fdb69Smrg fi 4301d63fdb69Smrg 4302d63fdb69Smrg # See the names of the shared library. 4303d63fdb69Smrg set dummy $library_names; shift 4304d63fdb69Smrg if test -n "$1"; then 430552fd71cdSmrg realname=$1 4306d63fdb69Smrg shift 4307d63fdb69Smrg 430852fd71cdSmrg srcname=$realname 430952fd71cdSmrg test -n "$relink_command" && srcname=${realname}T 4310d63fdb69Smrg 4311d63fdb69Smrg # Install the shared library and build the symlinks. 431255acc8fcSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313d63fdb69Smrg 'exit $?' 431452fd71cdSmrg tstripme=$stripme 4315d63fdb69Smrg case $host_os in 4316d63fdb69Smrg cygwin* | mingw* | pw32* | cegcc*) 4317d63fdb69Smrg case $realname in 4318d63fdb69Smrg *.dll.a) 431952fd71cdSmrg tstripme= 432052fd71cdSmrg ;; 432152fd71cdSmrg esac 432252fd71cdSmrg ;; 432352fd71cdSmrg os2*) 432452fd71cdSmrg case $realname in 432552fd71cdSmrg *_dll.a) 432652fd71cdSmrg tstripme= 4327d63fdb69Smrg ;; 4328d63fdb69Smrg esac 43293da084b3Smrg ;; 43303da084b3Smrg esac 4331d63fdb69Smrg if test -n "$tstripme" && test -n "$striplib"; then 4332d63fdb69Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 43333da084b3Smrg fi 4334d63fdb69Smrg 4335d63fdb69Smrg if test "$#" -gt 0; then 4336d63fdb69Smrg # Delete the old symlinks, and create new ones. 433752fd71cdSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338d63fdb69Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339d63fdb69Smrg # so we also need to try rm && ln -s. 4340d63fdb69Smrg for linkname 4341d63fdb69Smrg do 4342d63fdb69Smrg test "$linkname" != "$realname" \ 4343d63fdb69Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 43443da084b3Smrg done 43453da084b3Smrg fi 43463da084b3Smrg 4347d63fdb69Smrg # Do each command in the postinstall commands. 434852fd71cdSmrg lib=$destdir/$realname 4349d63fdb69Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 43503da084b3Smrg fi 43513da084b3Smrg 4352d63fdb69Smrg # Install the pseudo-library for information purposes. 4353d63fdb69Smrg func_basename "$file" 435452fd71cdSmrg name=$func_basename_result 435552fd71cdSmrg instname=$dir/${name}i 4356d63fdb69Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 43573da084b3Smrg 4358d63fdb69Smrg # Maybe install the static library, too. 435948c85eb7Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360d63fdb69Smrg ;; 43613da084b3Smrg 4362d63fdb69Smrg *.lo) 4363d63fdb69Smrg # Install (i.e. copy) a libtool object. 43643da084b3Smrg 4365d63fdb69Smrg # Figure out destination file name, if it wasn't already specified. 4366d63fdb69Smrg if test -n "$destname"; then 436752fd71cdSmrg destfile=$destdir/$destname 4368d63fdb69Smrg else 4369d63fdb69Smrg func_basename "$file" 437052fd71cdSmrg destfile=$func_basename_result 437152fd71cdSmrg destfile=$destdir/$destfile 4372d63fdb69Smrg fi 4373d63fdb69Smrg 4374d63fdb69Smrg # Deduce the name of the destination old-style object file. 4375d63fdb69Smrg case $destfile in 4376d63fdb69Smrg *.lo) 4377d63fdb69Smrg func_lo2o "$destfile" 4378d63fdb69Smrg staticdest=$func_lo2o_result 4379d63fdb69Smrg ;; 4380d63fdb69Smrg *.$objext) 438152fd71cdSmrg staticdest=$destfile 4382d63fdb69Smrg destfile= 4383d63fdb69Smrg ;; 4384d63fdb69Smrg *) 438552fd71cdSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386d63fdb69Smrg ;; 43873da084b3Smrg esac 43883da084b3Smrg 4389d63fdb69Smrg # Install the libtool object if requested. 4390d63fdb69Smrg test -n "$destfile" && \ 4391d63fdb69Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392d63fdb69Smrg 4393d63fdb69Smrg # Install the old object if enabled. 439452fd71cdSmrg if test yes = "$build_old_libs"; then 4395d63fdb69Smrg # Deduce the name of the old-style object file. 4396d63fdb69Smrg func_lo2o "$file" 4397d63fdb69Smrg staticobj=$func_lo2o_result 4398d63fdb69Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 43993da084b3Smrg fi 4400d63fdb69Smrg exit $EXIT_SUCCESS 4401d63fdb69Smrg ;; 44023da084b3Smrg 4403d63fdb69Smrg *) 4404d63fdb69Smrg # Figure out destination file name, if it wasn't already specified. 4405d63fdb69Smrg if test -n "$destname"; then 440652fd71cdSmrg destfile=$destdir/$destname 4407d63fdb69Smrg else 4408d63fdb69Smrg func_basename "$file" 440952fd71cdSmrg destfile=$func_basename_result 441052fd71cdSmrg destfile=$destdir/$destfile 4411d63fdb69Smrg fi 4412d63fdb69Smrg 4413d63fdb69Smrg # If the file is missing, and there is a .exe on the end, strip it 4414d63fdb69Smrg # because it is most likely a libtool script we actually want to 4415d63fdb69Smrg # install 441652fd71cdSmrg stripped_ext= 4417d63fdb69Smrg case $file in 4418d63fdb69Smrg *.exe) 4419d63fdb69Smrg if test ! -f "$file"; then 4420d63fdb69Smrg func_stripname '' '.exe' "$file" 4421d63fdb69Smrg file=$func_stripname_result 442252fd71cdSmrg stripped_ext=.exe 44233da084b3Smrg fi 4424d63fdb69Smrg ;; 4425d63fdb69Smrg esac 44263da084b3Smrg 4427d63fdb69Smrg # Do a test to see if this is really a libtool program. 4428d63fdb69Smrg case $host in 4429d63fdb69Smrg *cygwin* | *mingw*) 4430d63fdb69Smrg if func_ltwrapper_executable_p "$file"; then 4431d63fdb69Smrg func_ltwrapper_scriptname "$file" 4432d63fdb69Smrg wrapper=$func_ltwrapper_scriptname_result 4433d63fdb69Smrg else 4434d63fdb69Smrg func_stripname '' '.exe' "$file" 4435d63fdb69Smrg wrapper=$func_stripname_result 4436d63fdb69Smrg fi 4437d63fdb69Smrg ;; 4438d63fdb69Smrg *) 4439d63fdb69Smrg wrapper=$file 4440d63fdb69Smrg ;; 4441d63fdb69Smrg esac 4442d63fdb69Smrg if func_ltwrapper_script_p "$wrapper"; then 4443d63fdb69Smrg notinst_deplibs= 4444d63fdb69Smrg relink_command= 44453da084b3Smrg 4446d63fdb69Smrg func_source "$wrapper" 44473da084b3Smrg 4448d63fdb69Smrg # Check the variables that should have been set. 4449d63fdb69Smrg test -z "$generated_by_libtool_version" && \ 445052fd71cdSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451d63fdb69Smrg 445252fd71cdSmrg finalize=: 4453d63fdb69Smrg for lib in $notinst_deplibs; do 4454d63fdb69Smrg # Check to see that each library is installed. 4455d63fdb69Smrg libdir= 4456d63fdb69Smrg if test -f "$lib"; then 4457d63fdb69Smrg func_source "$lib" 4458d63fdb69Smrg fi 445952fd71cdSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460d63fdb69Smrg if test -n "$libdir" && test ! -f "$libfile"; then 446152fd71cdSmrg func_warning "'$lib' has not been installed in '$libdir'" 446252fd71cdSmrg finalize=false 4463d63fdb69Smrg fi 4464d63fdb69Smrg done 4465d63fdb69Smrg 4466d63fdb69Smrg relink_command= 4467d63fdb69Smrg func_source "$wrapper" 4468d63fdb69Smrg 4469d63fdb69Smrg outputname= 447052fd71cdSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4471d63fdb69Smrg $opt_dry_run || { 447252fd71cdSmrg if $finalize; then 4473d63fdb69Smrg tmpdir=`func_mktempdir` 4474d63fdb69Smrg func_basename "$file$stripped_ext" 447552fd71cdSmrg file=$func_basename_result 447652fd71cdSmrg outputname=$tmpdir/$file 4477d63fdb69Smrg # Replace the output file specification. 447855acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479d63fdb69Smrg 448052fd71cdSmrg $opt_quiet || { 4481d63fdb69Smrg func_quote_for_expand "$relink_command" 4482d63fdb69Smrg eval "func_echo $func_quote_for_expand_result" 4483d63fdb69Smrg } 4484d63fdb69Smrg if eval "$relink_command"; then : 4485d63fdb69Smrg else 448652fd71cdSmrg func_error "error: relink '$file' with the above command before installing it" 4487d63fdb69Smrg $opt_dry_run || ${RM}r "$tmpdir" 4488d63fdb69Smrg continue 4489d63fdb69Smrg fi 449052fd71cdSmrg file=$outputname 4491d63fdb69Smrg else 449252fd71cdSmrg func_warning "cannot relink '$file'" 4493d63fdb69Smrg fi 4494d63fdb69Smrg } 44953da084b3Smrg else 4496d63fdb69Smrg # Install the binary that we compiled earlier. 449755acc8fcSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 44983da084b3Smrg fi 4499d63fdb69Smrg fi 45003da084b3Smrg 4501d63fdb69Smrg # remove .exe since cygwin /usr/bin/install will append another 4502d63fdb69Smrg # one anyway 4503d63fdb69Smrg case $install_prog,$host in 4504d63fdb69Smrg */usr/bin/install*,*cygwin*) 4505d63fdb69Smrg case $file:$destfile in 4506d63fdb69Smrg *.exe:*.exe) 4507d63fdb69Smrg # this is ok 4508d63fdb69Smrg ;; 4509d63fdb69Smrg *.exe:*) 4510d63fdb69Smrg destfile=$destfile.exe 4511d63fdb69Smrg ;; 4512d63fdb69Smrg *:*.exe) 4513d63fdb69Smrg func_stripname '' '.exe' "$destfile" 4514d63fdb69Smrg destfile=$func_stripname_result 4515d63fdb69Smrg ;; 4516d63fdb69Smrg esac 45173da084b3Smrg ;; 45183da084b3Smrg esac 4519d63fdb69Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520d63fdb69Smrg $opt_dry_run || if test -n "$outputname"; then 4521d63fdb69Smrg ${RM}r "$tmpdir" 4522d63fdb69Smrg fi 4523d63fdb69Smrg ;; 4524d63fdb69Smrg esac 4525d63fdb69Smrg done 45263da084b3Smrg 4527d63fdb69Smrg for file in $staticlibs; do 4528d63fdb69Smrg func_basename "$file" 452952fd71cdSmrg name=$func_basename_result 45303da084b3Smrg 4531d63fdb69Smrg # Set up the ranlib parameters. 453252fd71cdSmrg oldlib=$destdir/$name 453348c85eb7Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 453448c85eb7Smrg tool_oldlib=$func_to_tool_file_result 45353da084b3Smrg 4536d63fdb69Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45373da084b3Smrg 4538d63fdb69Smrg if test -n "$stripme" && test -n "$old_striplib"; then 453948c85eb7Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540d63fdb69Smrg fi 45413da084b3Smrg 4542d63fdb69Smrg # Do each command in the postinstall commands. 4543d63fdb69Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544d63fdb69Smrg done 45453da084b3Smrg 4546d63fdb69Smrg test -n "$future_libdirs" && \ 454752fd71cdSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 45483da084b3Smrg 4549d63fdb69Smrg if test -n "$current_libdirs"; then 4550d63fdb69Smrg # Maybe just do a dry run. 4551d63fdb69Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455252fd71cdSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553d63fdb69Smrg else 4554d63fdb69Smrg exit $EXIT_SUCCESS 4555d63fdb69Smrg fi 4556d63fdb69Smrg} 45573da084b3Smrg 455852fd71cdSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45593da084b3Smrg 45603da084b3Smrg 4561d63fdb69Smrg# func_generate_dlsyms outputname originator pic_p 4562d63fdb69Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563d63fdb69Smrg# a dlpreopen symbol table. 4564d63fdb69Smrgfunc_generate_dlsyms () 4565d63fdb69Smrg{ 456652fd71cdSmrg $debug_cmd 456752fd71cdSmrg 456852fd71cdSmrg my_outputname=$1 456952fd71cdSmrg my_originator=$2 457052fd71cdSmrg my_pic_p=${3-false} 457152fd71cdSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572d63fdb69Smrg my_dlsyms= 4573d63fdb69Smrg 457452fd71cdSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575d63fdb69Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457652fd71cdSmrg my_dlsyms=${my_outputname}S.c 4577d63fdb69Smrg else 4578d63fdb69Smrg func_error "not configured to extract global symbols from dlpreopened files" 4579d63fdb69Smrg fi 4580d63fdb69Smrg fi 45813da084b3Smrg 4582d63fdb69Smrg if test -n "$my_dlsyms"; then 4583d63fdb69Smrg case $my_dlsyms in 4584d63fdb69Smrg "") ;; 4585d63fdb69Smrg *.c) 4586d63fdb69Smrg # Discover the nlist of each of the dlfiles. 458752fd71cdSmrg nlist=$output_objdir/$my_outputname.nm 4588d63fdb69Smrg 4589d63fdb69Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590d63fdb69Smrg 4591d63fdb69Smrg # Parse the name list into a source file. 4592d63fdb69Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593d63fdb69Smrg 4594d63fdb69Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459552fd71cdSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459652fd71cdSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597d63fdb69Smrg 4598d63fdb69Smrg#ifdef __cplusplus 4599d63fdb69Smrgextern \"C\" { 4600d63fdb69Smrg#endif 4601d63fdb69Smrg 460252fd71cdSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460355acc8fcSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460455acc8fcSmrg#endif 460555acc8fcSmrg 460648c85eb7Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460752fd71cdSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460852fd71cdSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460948c85eb7Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461048c85eb7Smrg# define LT_DLSYM_CONST 461152fd71cdSmrg#elif defined __osf__ 461248c85eb7Smrg/* This system does not cope well with relocations in const data. */ 461348c85eb7Smrg# define LT_DLSYM_CONST 461448c85eb7Smrg#else 461548c85eb7Smrg# define LT_DLSYM_CONST const 461648c85eb7Smrg#endif 461748c85eb7Smrg 461852fd71cdSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461952fd71cdSmrg 4620d63fdb69Smrg/* External symbol declarations for the compiler. */\ 4621d63fdb69Smrg" 4622d63fdb69Smrg 462352fd71cdSmrg if test yes = "$dlself"; then 462452fd71cdSmrg func_verbose "generating symbol list for '$output'" 4625d63fdb69Smrg 4626d63fdb69Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627d63fdb69Smrg 4628d63fdb69Smrg # Add our own program objects to the symbol list. 462955acc8fcSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630d63fdb69Smrg for progfile in $progfiles; do 463148c85eb7Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463252fd71cdSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463348c85eb7Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634d63fdb69Smrg done 4635d63fdb69Smrg 4636d63fdb69Smrg if test -n "$exclude_expsyms"; then 4637d63fdb69Smrg $opt_dry_run || { 4638d63fdb69Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639d63fdb69Smrg eval '$MV "$nlist"T "$nlist"' 4640d63fdb69Smrg } 46413da084b3Smrg fi 46423da084b3Smrg 4643d63fdb69Smrg if test -n "$export_symbols_regex"; then 4644d63fdb69Smrg $opt_dry_run || { 4645d63fdb69Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646d63fdb69Smrg eval '$MV "$nlist"T "$nlist"' 4647d63fdb69Smrg } 46483da084b3Smrg fi 4649d63fdb69Smrg 4650d63fdb69Smrg # Prepare the list of exported symbols 4651d63fdb69Smrg if test -z "$export_symbols"; then 465252fd71cdSmrg export_symbols=$output_objdir/$outputname.exp 4653d63fdb69Smrg $opt_dry_run || { 4654d63fdb69Smrg $RM $export_symbols 465552fd71cdSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656d63fdb69Smrg case $host in 4657d63fdb69Smrg *cygwin* | *mingw* | *cegcc* ) 4658d63fdb69Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659d63fdb69Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660d63fdb69Smrg ;; 46613da084b3Smrg esac 4662d63fdb69Smrg } 4663d63fdb69Smrg else 4664d63fdb69Smrg $opt_dry_run || { 466552fd71cdSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666d63fdb69Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667d63fdb69Smrg eval '$MV "$nlist"T "$nlist"' 4668d63fdb69Smrg case $host in 466955acc8fcSmrg *cygwin* | *mingw* | *cegcc* ) 4670d63fdb69Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671d63fdb69Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672d63fdb69Smrg ;; 46733da084b3Smrg esac 4674d63fdb69Smrg } 46753da084b3Smrg fi 4676d63fdb69Smrg fi 46773da084b3Smrg 4678d63fdb69Smrg for dlprefile in $dlprefiles; do 467952fd71cdSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4680d63fdb69Smrg func_basename "$dlprefile" 468152fd71cdSmrg name=$func_basename_result 468248c85eb7Smrg case $host in 468348c85eb7Smrg *cygwin* | *mingw* | *cegcc* ) 468448c85eb7Smrg # if an import library, we need to obtain dlname 468548c85eb7Smrg if func_win32_import_lib_p "$dlprefile"; then 468648c85eb7Smrg func_tr_sh "$dlprefile" 468748c85eb7Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468852fd71cdSmrg dlprefile_dlbasename= 468948c85eb7Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469048c85eb7Smrg # Use subshell, to avoid clobbering current variable values 469148c85eb7Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469252fd71cdSmrg if test -n "$dlprefile_dlname"; then 469348c85eb7Smrg func_basename "$dlprefile_dlname" 469452fd71cdSmrg dlprefile_dlbasename=$func_basename_result 469548c85eb7Smrg else 469648c85eb7Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 469748c85eb7Smrg $sharedlib_from_linklib_cmd "$dlprefile" 469848c85eb7Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469948c85eb7Smrg fi 470048c85eb7Smrg fi 470148c85eb7Smrg $opt_dry_run || { 470252fd71cdSmrg if test -n "$dlprefile_dlbasename"; then 470348c85eb7Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470448c85eb7Smrg else 470548c85eb7Smrg func_warning "Could not compute DLL name from $name" 470648c85eb7Smrg eval '$ECHO ": $name " >> "$nlist"' 470748c85eb7Smrg fi 470848c85eb7Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470948c85eb7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471048c85eb7Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471148c85eb7Smrg } 471248c85eb7Smrg else # not an import lib 471348c85eb7Smrg $opt_dry_run || { 471448c85eb7Smrg eval '$ECHO ": $name " >> "$nlist"' 471548c85eb7Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471648c85eb7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471748c85eb7Smrg } 471848c85eb7Smrg fi 471948c85eb7Smrg ;; 472048c85eb7Smrg *) 472148c85eb7Smrg $opt_dry_run || { 472248c85eb7Smrg eval '$ECHO ": $name " >> "$nlist"' 472348c85eb7Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472448c85eb7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472548c85eb7Smrg } 472648c85eb7Smrg ;; 472748c85eb7Smrg esac 4728d63fdb69Smrg done 47293da084b3Smrg 4730d63fdb69Smrg $opt_dry_run || { 4731d63fdb69Smrg # Make sure we have at least an empty file. 4732d63fdb69Smrg test -f "$nlist" || : > "$nlist" 47333da084b3Smrg 4734d63fdb69Smrg if test -n "$exclude_expsyms"; then 4735d63fdb69Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736d63fdb69Smrg $MV "$nlist"T "$nlist" 47373da084b3Smrg fi 47383da084b3Smrg 4739d63fdb69Smrg # Try sorting and uniquifying the output. 4740d63fdb69Smrg if $GREP -v "^: " < "$nlist" | 4741d63fdb69Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742d63fdb69Smrg sort -k 3 47433da084b3Smrg else 4744d63fdb69Smrg sort +2 4745d63fdb69Smrg fi | 4746d63fdb69Smrg uniq > "$nlist"S; then 4747d63fdb69Smrg : 47483da084b3Smrg else 4749d63fdb69Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 47503da084b3Smrg fi 47513da084b3Smrg 4752d63fdb69Smrg if test -f "$nlist"S; then 4753d63fdb69Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 47543da084b3Smrg else 475555acc8fcSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 47563da084b3Smrg fi 47573da084b3Smrg 475852fd71cdSmrg func_show_eval '$RM "${nlist}I"' 475952fd71cdSmrg if test -n "$global_symbol_to_import"; then 476052fd71cdSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476152fd71cdSmrg fi 476252fd71cdSmrg 476355acc8fcSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47643da084b3Smrg 4765d63fdb69Smrg/* The mapping between symbol names and symbols. */ 4766d63fdb69Smrgtypedef struct { 4767d63fdb69Smrg const char *name; 4768d63fdb69Smrg void *address; 4769d63fdb69Smrg} lt_dlsymlist; 477048c85eb7Smrgextern LT_DLSYM_CONST lt_dlsymlist 477152fd71cdSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477252fd71cdSmrg" 477352fd71cdSmrg 477452fd71cdSmrg if test -s "$nlist"I; then 477552fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 477652fd71cdSmrgstatic void lt_syminit(void) 477752fd71cdSmrg{ 477852fd71cdSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477952fd71cdSmrg for (; symbol->name; ++symbol) 478052fd71cdSmrg {" 478152fd71cdSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478252fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 478352fd71cdSmrg } 478452fd71cdSmrg}" 478552fd71cdSmrg fi 478652fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 478748c85eb7SmrgLT_DLSYM_CONST lt_dlsymlist 4788d63fdb69Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 478952fd71cdSmrg{ {\"$my_originator\", (void *) 0}," 479052fd71cdSmrg 479152fd71cdSmrg if test -s "$nlist"I; then 479252fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 479352fd71cdSmrg {\"@INIT@\", (void *) <_syminit}," 479452fd71cdSmrg fi 4795d63fdb69Smrg 4796d63fdb69Smrg case $need_lib_prefix in 4797d63fdb69Smrg no) 4798d63fdb69Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799d63fdb69Smrg ;; 4800d63fdb69Smrg *) 4801d63fdb69Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802d63fdb69Smrg ;; 4803d63fdb69Smrg esac 480455acc8fcSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4805d63fdb69Smrg {0, (void *) 0} 4806d63fdb69Smrg}; 4807d63fdb69Smrg 4808d63fdb69Smrg/* This works around a problem in FreeBSD linker */ 4809d63fdb69Smrg#ifdef FREEBSD_WORKAROUND 4810d63fdb69Smrgstatic const void *lt_preloaded_setup() { 4811d63fdb69Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812d63fdb69Smrg} 4813d63fdb69Smrg#endif 4814d63fdb69Smrg 4815d63fdb69Smrg#ifdef __cplusplus 4816d63fdb69Smrg} 4817d63fdb69Smrg#endif\ 4818d63fdb69Smrg" 4819d63fdb69Smrg } # !$opt_dry_run 4820d63fdb69Smrg 4821d63fdb69Smrg pic_flag_for_symtable= 4822d63fdb69Smrg case "$compile_command " in 4823d63fdb69Smrg *" -static "*) ;; 4824d63fdb69Smrg *) 4825d63fdb69Smrg case $host in 4826d63fdb69Smrg # compiling the symbol table file with pic_flag works around 4827d63fdb69Smrg # a FreeBSD bug that causes programs to crash when -lm is 4828d63fdb69Smrg # linked before any other PIC object. But we must not use 4829d63fdb69Smrg # pic_flag when linking with -static. The problem exists in 4830d63fdb69Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 483148c85eb7Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832d63fdb69Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833d63fdb69Smrg *-*-hpux*) 4834d63fdb69Smrg pic_flag_for_symtable=" $pic_flag" ;; 4835d63fdb69Smrg *) 483652fd71cdSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837d63fdb69Smrg ;; 4838d63fdb69Smrg esac 4839d63fdb69Smrg ;; 4840d63fdb69Smrg esac 4841d63fdb69Smrg symtab_cflags= 4842d63fdb69Smrg for arg in $LTCFLAGS; do 4843d63fdb69Smrg case $arg in 4844d63fdb69Smrg -pie | -fpie | -fPIE) ;; 484548c85eb7Smrg *) func_append symtab_cflags " $arg" ;; 4846d63fdb69Smrg esac 4847d63fdb69Smrg done 48483da084b3Smrg 4849d63fdb69Smrg # Now compile the dynamic symbol file. 4850d63fdb69Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 48513da084b3Smrg 4852d63fdb69Smrg # Clean up the generated files. 485352fd71cdSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854d63fdb69Smrg 4855d63fdb69Smrg # Transform the symbol file into the correct name. 485652fd71cdSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857d63fdb69Smrg case $host in 4858d63fdb69Smrg *cygwin* | *mingw* | *cegcc* ) 4859d63fdb69Smrg if test -f "$output_objdir/$my_outputname.def"; then 486055acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486155acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862d63fdb69Smrg else 486355acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486455acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865d63fdb69Smrg fi 4866d63fdb69Smrg ;; 4867d63fdb69Smrg *) 486855acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486955acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48703da084b3Smrg ;; 48713da084b3Smrg esac 4872d63fdb69Smrg ;; 4873d63fdb69Smrg *) 487452fd71cdSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875d63fdb69Smrg ;; 4876d63fdb69Smrg esac 4877d63fdb69Smrg else 4878d63fdb69Smrg # We keep going just in case the user didn't refer to 4879d63fdb69Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880d63fdb69Smrg # really was required. 4881d63fdb69Smrg 4882d63fdb69Smrg # Nullify the symbol file. 488355acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488455acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48853da084b3Smrg fi 4886d63fdb69Smrg} 48873da084b3Smrg 488852fd71cdSmrg# func_cygming_gnu_implib_p ARG 488952fd71cdSmrg# This predicate returns with zero status (TRUE) if 489052fd71cdSmrg# ARG is a GNU/binutils-style import library. Returns 489152fd71cdSmrg# with nonzero status (FALSE) otherwise. 489252fd71cdSmrgfunc_cygming_gnu_implib_p () 489352fd71cdSmrg{ 489452fd71cdSmrg $debug_cmd 489552fd71cdSmrg 489652fd71cdSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489752fd71cdSmrg 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)$'` 489852fd71cdSmrg test -n "$func_cygming_gnu_implib_tmp" 489952fd71cdSmrg} 490052fd71cdSmrg 490152fd71cdSmrg# func_cygming_ms_implib_p ARG 490252fd71cdSmrg# This predicate returns with zero status (TRUE) if 490352fd71cdSmrg# ARG is an MS-style import library. Returns 490452fd71cdSmrg# with nonzero status (FALSE) otherwise. 490552fd71cdSmrgfunc_cygming_ms_implib_p () 490652fd71cdSmrg{ 490752fd71cdSmrg $debug_cmd 490852fd71cdSmrg 490952fd71cdSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491052fd71cdSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491152fd71cdSmrg test -n "$func_cygming_ms_implib_tmp" 491252fd71cdSmrg} 491352fd71cdSmrg 4914d63fdb69Smrg# func_win32_libid arg 4915d63fdb69Smrg# return the library type of file 'arg' 4916d63fdb69Smrg# 4917d63fdb69Smrg# Need a lot of goo to handle *both* DLLs and import libs 4918d63fdb69Smrg# Has to be a shell function in order to 'eat' the argument 4919d63fdb69Smrg# that is supplied when $file_magic_command is called. 492055acc8fcSmrg# Despite the name, also deal with 64 bit binaries. 4921d63fdb69Smrgfunc_win32_libid () 4922d63fdb69Smrg{ 492352fd71cdSmrg $debug_cmd 492452fd71cdSmrg 492552fd71cdSmrg win32_libid_type=unknown 4926d63fdb69Smrg win32_fileres=`file -L $1 2>/dev/null` 4927d63fdb69Smrg case $win32_fileres in 4928d63fdb69Smrg *ar\ archive\ import\ library*) # definitely import 4929d63fdb69Smrg win32_libid_type="x86 archive import" 4930d63fdb69Smrg ;; 4931d63fdb69Smrg *ar\ archive*) # could be an import, or static 493255acc8fcSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933d63fdb69Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493455acc8fcSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493552fd71cdSmrg case $nm_interface in 493652fd71cdSmrg "MS dumpbin") 493752fd71cdSmrg if func_cygming_ms_implib_p "$1" || 493852fd71cdSmrg func_cygming_gnu_implib_p "$1" 493952fd71cdSmrg then 494052fd71cdSmrg win32_nmres=import 494152fd71cdSmrg else 494252fd71cdSmrg win32_nmres= 494352fd71cdSmrg fi 494452fd71cdSmrg ;; 494552fd71cdSmrg *) 494652fd71cdSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494752fd71cdSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494852fd71cdSmrg $SED -n -e ' 4949d63fdb69Smrg 1,100{ 4950d63fdb69Smrg / I /{ 495152fd71cdSmrg s|.*|import| 4952d63fdb69Smrg p 4953d63fdb69Smrg q 4954d63fdb69Smrg } 4955d63fdb69Smrg }'` 495652fd71cdSmrg ;; 495752fd71cdSmrg esac 4958d63fdb69Smrg case $win32_nmres in 4959d63fdb69Smrg import*) win32_libid_type="x86 archive import";; 4960d63fdb69Smrg *) win32_libid_type="x86 archive static";; 4961d63fdb69Smrg esac 4962d63fdb69Smrg fi 4963d63fdb69Smrg ;; 4964d63fdb69Smrg *DLL*) 4965d63fdb69Smrg win32_libid_type="x86 DLL" 4966d63fdb69Smrg ;; 4967d63fdb69Smrg *executable*) # but shell scripts are "executable" too... 4968d63fdb69Smrg case $win32_fileres in 4969d63fdb69Smrg *MS\ Windows\ PE\ Intel*) 4970d63fdb69Smrg win32_libid_type="x86 DLL" 4971d63fdb69Smrg ;; 4972d63fdb69Smrg esac 4973d63fdb69Smrg ;; 4974d63fdb69Smrg esac 4975d63fdb69Smrg $ECHO "$win32_libid_type" 4976d63fdb69Smrg} 49773da084b3Smrg 497848c85eb7Smrg# func_cygming_dll_for_implib ARG 497948c85eb7Smrg# 498048c85eb7Smrg# Platform-specific function to extract the 498148c85eb7Smrg# name of the DLL associated with the specified 498248c85eb7Smrg# import library ARG. 498348c85eb7Smrg# Invoked by eval'ing the libtool variable 498448c85eb7Smrg# $sharedlib_from_linklib_cmd 498548c85eb7Smrg# Result is available in the variable 498648c85eb7Smrg# $sharedlib_from_linklib_result 498748c85eb7Smrgfunc_cygming_dll_for_implib () 498848c85eb7Smrg{ 498952fd71cdSmrg $debug_cmd 499052fd71cdSmrg 499148c85eb7Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499248c85eb7Smrg} 499348c85eb7Smrg 499448c85eb7Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499548c85eb7Smrg# 499648c85eb7Smrg# The is the core of a fallback implementation of a 499748c85eb7Smrg# platform-specific function to extract the name of the 499848c85eb7Smrg# DLL associated with the specified import library LIBNAME. 499948c85eb7Smrg# 500048c85eb7Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500148c85eb7Smrg# on the platform and compiler that created the implib. 500248c85eb7Smrg# 500348c85eb7Smrg# Echos the name of the DLL associated with the 500448c85eb7Smrg# specified import library. 500548c85eb7Smrgfunc_cygming_dll_for_implib_fallback_core () 500648c85eb7Smrg{ 500752fd71cdSmrg $debug_cmd 500852fd71cdSmrg 500948c85eb7Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501048c85eb7Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501148c85eb7Smrg $SED '/^Contents of section '"$match_literal"':/{ 501248c85eb7Smrg # Place marker at beginning of archive member dllname section 501348c85eb7Smrg s/.*/====MARK====/ 501448c85eb7Smrg p 501548c85eb7Smrg d 501648c85eb7Smrg } 501748c85eb7Smrg # These lines can sometimes be longer than 43 characters, but 501848c85eb7Smrg # are always uninteresting 501948c85eb7Smrg /:[ ]*file format pe[i]\{,1\}-/d 502048c85eb7Smrg /^In archive [^:]*:/d 502148c85eb7Smrg # Ensure marker is printed 502248c85eb7Smrg /^====MARK====/p 502348c85eb7Smrg # Remove all lines with less than 43 characters 502448c85eb7Smrg /^.\{43\}/!d 502548c85eb7Smrg # From remaining lines, remove first 43 characters 502648c85eb7Smrg s/^.\{43\}//' | 502748c85eb7Smrg $SED -n ' 502848c85eb7Smrg # Join marker and all lines until next marker into a single line 502948c85eb7Smrg /^====MARK====/ b para 503048c85eb7Smrg H 503148c85eb7Smrg $ b para 503248c85eb7Smrg b 503348c85eb7Smrg :para 503448c85eb7Smrg x 503548c85eb7Smrg s/\n//g 503648c85eb7Smrg # Remove the marker 503748c85eb7Smrg s/^====MARK====// 503848c85eb7Smrg # Remove trailing dots and whitespace 503948c85eb7Smrg s/[\. \t]*$// 504048c85eb7Smrg # Print 504148c85eb7Smrg /./p' | 504248c85eb7Smrg # we now have a list, one entry per line, of the stringified 504348c85eb7Smrg # contents of the appropriate section of all members of the 504452fd71cdSmrg # archive that possess that section. Heuristic: eliminate 504552fd71cdSmrg # all those that have a first or second character that is 504648c85eb7Smrg # a '.' (that is, objdump's representation of an unprintable 504748c85eb7Smrg # character.) This should work for all archives with less than 504848c85eb7Smrg # 0x302f exports -- but will fail for DLLs whose name actually 504948c85eb7Smrg # begins with a literal '.' or a single character followed by 505048c85eb7Smrg # a '.'. 505148c85eb7Smrg # 505248c85eb7Smrg # Of those that remain, print the first one. 505348c85eb7Smrg $SED -e '/^\./d;/^.\./d;q' 505448c85eb7Smrg} 505548c85eb7Smrg 505648c85eb7Smrg# func_cygming_dll_for_implib_fallback ARG 505748c85eb7Smrg# Platform-specific function to extract the 505848c85eb7Smrg# name of the DLL associated with the specified 505948c85eb7Smrg# import library ARG. 506048c85eb7Smrg# 506148c85eb7Smrg# This fallback implementation is for use when $DLLTOOL 506248c85eb7Smrg# does not support the --identify-strict option. 506348c85eb7Smrg# Invoked by eval'ing the libtool variable 506448c85eb7Smrg# $sharedlib_from_linklib_cmd 506548c85eb7Smrg# Result is available in the variable 506648c85eb7Smrg# $sharedlib_from_linklib_result 506748c85eb7Smrgfunc_cygming_dll_for_implib_fallback () 506848c85eb7Smrg{ 506952fd71cdSmrg $debug_cmd 507052fd71cdSmrg 507152fd71cdSmrg if func_cygming_gnu_implib_p "$1"; then 507248c85eb7Smrg # binutils import library 507348c85eb7Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507452fd71cdSmrg elif func_cygming_ms_implib_p "$1"; then 507548c85eb7Smrg # ms-generated import library 507648c85eb7Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507748c85eb7Smrg else 507848c85eb7Smrg # unknown 507952fd71cdSmrg sharedlib_from_linklib_result= 508048c85eb7Smrg fi 508148c85eb7Smrg} 50823da084b3Smrg 50833da084b3Smrg 5084d63fdb69Smrg# func_extract_an_archive dir oldlib 5085d63fdb69Smrgfunc_extract_an_archive () 5086d63fdb69Smrg{ 508752fd71cdSmrg $debug_cmd 508852fd71cdSmrg 508952fd71cdSmrg f_ex_an_ar_dir=$1; shift 509052fd71cdSmrg f_ex_an_ar_oldlib=$1 509152fd71cdSmrg if test yes = "$lock_old_archive_extraction"; then 509255acc8fcSmrg lockfile=$f_ex_an_ar_oldlib.lock 509355acc8fcSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509455acc8fcSmrg func_echo "Waiting for $lockfile to be removed" 509555acc8fcSmrg sleep 2 509655acc8fcSmrg done 509755acc8fcSmrg fi 509855acc8fcSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509955acc8fcSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510052fd71cdSmrg if test yes = "$lock_old_archive_extraction"; then 510155acc8fcSmrg $opt_dry_run || rm -f "$lockfile" 510255acc8fcSmrg fi 5103d63fdb69Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104d63fdb69Smrg : 5105d63fdb69Smrg else 5106d63fdb69Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107d63fdb69Smrg fi 5108d63fdb69Smrg} 51093da084b3Smrg 51103da084b3Smrg 5111d63fdb69Smrg# func_extract_archives gentop oldlib ... 5112d63fdb69Smrgfunc_extract_archives () 5113d63fdb69Smrg{ 511452fd71cdSmrg $debug_cmd 511552fd71cdSmrg 511652fd71cdSmrg my_gentop=$1; shift 5117d63fdb69Smrg my_oldlibs=${1+"$@"} 511852fd71cdSmrg my_oldobjs= 511952fd71cdSmrg my_xlib= 512052fd71cdSmrg my_xabs= 512152fd71cdSmrg my_xdir= 51223da084b3Smrg 5123d63fdb69Smrg for my_xlib in $my_oldlibs; do 5124d63fdb69Smrg # Extract the objects. 5125d63fdb69Smrg case $my_xlib in 512652fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127d63fdb69Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128d63fdb69Smrg esac 5129d63fdb69Smrg func_basename "$my_xlib" 513052fd71cdSmrg my_xlib=$func_basename_result 5131d63fdb69Smrg my_xlib_u=$my_xlib 5132d63fdb69Smrg while :; do 5133d63fdb69Smrg case " $extracted_archives " in 5134d63fdb69Smrg *" $my_xlib_u "*) 5135d63fdb69Smrg func_arith $extracted_serial + 1 5136d63fdb69Smrg extracted_serial=$func_arith_result 5137d63fdb69Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138d63fdb69Smrg *) break ;; 5139d63fdb69Smrg esac 5140d63fdb69Smrg done 5141d63fdb69Smrg extracted_archives="$extracted_archives $my_xlib_u" 514252fd71cdSmrg my_xdir=$my_gentop/$my_xlib_u 51433da084b3Smrg 5144d63fdb69Smrg func_mkdir_p "$my_xdir" 51453da084b3Smrg 5146d63fdb69Smrg case $host in 5147d63fdb69Smrg *-darwin*) 5148d63fdb69Smrg func_verbose "Extracting $my_xabs" 5149d63fdb69Smrg # Do not bother doing anything if just a dry run 5150d63fdb69Smrg $opt_dry_run || { 5151d63fdb69Smrg darwin_orig_dir=`pwd` 5152d63fdb69Smrg cd $my_xdir || exit $? 5153d63fdb69Smrg darwin_archive=$my_xabs 5154d63fdb69Smrg darwin_curdir=`pwd` 515552fd71cdSmrg func_basename "$darwin_archive" 515652fd71cdSmrg darwin_base_archive=$func_basename_result 5157d63fdb69Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158d63fdb69Smrg if test -n "$darwin_arches"; then 5159d63fdb69Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160d63fdb69Smrg darwin_arch= 5161d63fdb69Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516252fd71cdSmrg for darwin_arch in $darwin_arches; do 516352fd71cdSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516452fd71cdSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516552fd71cdSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516652fd71cdSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167d63fdb69Smrg cd "$darwin_curdir" 516852fd71cdSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169d63fdb69Smrg done # $darwin_arches 5170d63fdb69Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517152fd71cdSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172d63fdb69Smrg darwin_file= 5173d63fdb69Smrg darwin_files= 5174d63fdb69Smrg for darwin_file in $darwin_filelist; do 517555acc8fcSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176d63fdb69Smrg $LIPO -create -output "$darwin_file" $darwin_files 5177d63fdb69Smrg done # $darwin_filelist 5178d63fdb69Smrg $RM -rf unfat-$$ 5179d63fdb69Smrg cd "$darwin_orig_dir" 5180d63fdb69Smrg else 5181d63fdb69Smrg cd $darwin_orig_dir 5182d63fdb69Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183d63fdb69Smrg fi # $darwin_arches 5184d63fdb69Smrg } # !$opt_dry_run 5185d63fdb69Smrg ;; 5186d63fdb69Smrg *) 5187d63fdb69Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188d63fdb69Smrg ;; 51893da084b3Smrg esac 519055acc8fcSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191d63fdb69Smrg done 51923da084b3Smrg 519352fd71cdSmrg func_extract_archives_result=$my_oldobjs 5194d63fdb69Smrg} 51953da084b3Smrg 51963da084b3Smrg 519755acc8fcSmrg# func_emit_wrapper [arg=no] 519855acc8fcSmrg# 519955acc8fcSmrg# Emit a libtool wrapper script on stdout. 520055acc8fcSmrg# Don't directly open a file because we may want to 520155acc8fcSmrg# incorporate the script contents within a cygwin/mingw 520255acc8fcSmrg# wrapper executable. Must ONLY be called from within 520355acc8fcSmrg# func_mode_link because it depends on a number of variables 520455acc8fcSmrg# set therein. 5205d63fdb69Smrg# 520655acc8fcSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520755acc8fcSmrg# variable will take. If 'yes', then the emitted script 520852fd71cdSmrg# will assume that the directory where it is stored is 520955acc8fcSmrg# the $objdir directory. This is a cygwin/mingw-specific 521055acc8fcSmrg# behavior. 521155acc8fcSmrgfunc_emit_wrapper () 5212d63fdb69Smrg{ 521355acc8fcSmrg func_emit_wrapper_arg1=${1-no} 52143da084b3Smrg 5215d63fdb69Smrg $ECHO "\ 5216d63fdb69Smrg#! $SHELL 52173da084b3Smrg 5218d63fdb69Smrg# $output - temporary wrapper script for $objdir/$outputname 521952fd71cdSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220d63fdb69Smrg# 5221d63fdb69Smrg# The $output program cannot be directly executed until all the libtool 5222d63fdb69Smrg# libraries that it depends on are installed. 5223d63fdb69Smrg# 5224d63fdb69Smrg# This wrapper script should never be moved out of the build directory. 5225d63fdb69Smrg# If it is, it will not operate correctly. 52263da084b3Smrg 5227d63fdb69Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5228d63fdb69Smrg# metacharacters that are still active within double-quoted strings. 5229d63fdb69Smrgsed_quote_subst='$sed_quote_subst' 52303da084b3Smrg 5231d63fdb69Smrg# Be Bourne compatible 5232d63fdb69Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233d63fdb69Smrg emulate sh 5234d63fdb69Smrg NULLCMD=: 5235d63fdb69Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236d63fdb69Smrg # is contrary to our usage. Disable this feature. 5237d63fdb69Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238d63fdb69Smrg setopt NO_GLOB_SUBST 5239d63fdb69Smrgelse 5240d63fdb69Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241d63fdb69Smrgfi 5242d63fdb69SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243d63fdb69SmrgDUALCASE=1; export DUALCASE # for MKS sh 52443da084b3Smrg 5245d63fdb69Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246d63fdb69Smrg# if CDPATH is set. 5247d63fdb69Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 52483da084b3Smrg 5249d63fdb69Smrgrelink_command=\"$relink_command\" 52503da084b3Smrg 5251d63fdb69Smrg# This environment variable determines our operation mode. 5252d63fdb69Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253d63fdb69Smrg # install mode needs the following variables: 5254d63fdb69Smrg generated_by_libtool_version='$macro_version' 5255d63fdb69Smrg notinst_deplibs='$notinst_deplibs' 5256d63fdb69Smrgelse 5257d63fdb69Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258d63fdb69Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525955acc8fcSmrg file=\"\$0\"" 526055acc8fcSmrg 526155acc8fcSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526255acc8fcSmrg $ECHO "\ 526355acc8fcSmrg 526455acc8fcSmrg# A function that is used when there is no print builtin or printf. 526555acc8fcSmrgfunc_fallback_echo () 526655acc8fcSmrg{ 526755acc8fcSmrg eval 'cat <<_LTECHO_EOF 526855acc8fcSmrg\$1 526955acc8fcSmrg_LTECHO_EOF' 527055acc8fcSmrg} 527155acc8fcSmrg ECHO=\"$qECHO\" 527255acc8fcSmrg fi 527355acc8fcSmrg 527455acc8fcSmrg# Very basic option parsing. These options are (a) specific to 527555acc8fcSmrg# the libtool wrapper, (b) are identical between the wrapper 527652fd71cdSmrg# /script/ and the wrapper /executable/ that is used only on 527755acc8fcSmrg# windows platforms, and (c) all begin with the string "--lt-" 527852fd71cdSmrg# (application programs are unlikely to have options that match 527955acc8fcSmrg# this pattern). 528055acc8fcSmrg# 528155acc8fcSmrg# There are only two supported options: --lt-debug and 528255acc8fcSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 528355acc8fcSmrg# 528455acc8fcSmrg# The first argument to this parsing function should be the 528555acc8fcSmrg# script's $0 value, followed by "$@". 528655acc8fcSmrglt_option_debug= 528755acc8fcSmrgfunc_parse_lt_options () 528855acc8fcSmrg{ 528955acc8fcSmrg lt_script_arg0=\$0 529055acc8fcSmrg shift 529155acc8fcSmrg for lt_opt 529255acc8fcSmrg do 529355acc8fcSmrg case \"\$lt_opt\" in 529455acc8fcSmrg --lt-debug) lt_option_debug=1 ;; 529555acc8fcSmrg --lt-dump-script) 529655acc8fcSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529755acc8fcSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529855acc8fcSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529955acc8fcSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 530055acc8fcSmrg exit 0 530155acc8fcSmrg ;; 530255acc8fcSmrg --lt-*) 530355acc8fcSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530455acc8fcSmrg exit 1 530555acc8fcSmrg ;; 530655acc8fcSmrg esac 530755acc8fcSmrg done 530855acc8fcSmrg 530955acc8fcSmrg # Print the debug banner immediately: 531055acc8fcSmrg if test -n \"\$lt_option_debug\"; then 531152fd71cdSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531255acc8fcSmrg fi 531355acc8fcSmrg} 531455acc8fcSmrg 531555acc8fcSmrg# Used when --lt-debug. Prints its arguments to stdout 531655acc8fcSmrg# (redirection is the responsibility of the caller) 531755acc8fcSmrgfunc_lt_dump_args () 531855acc8fcSmrg{ 531955acc8fcSmrg lt_dump_args_N=1; 532055acc8fcSmrg for lt_arg 532155acc8fcSmrg do 532252fd71cdSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532355acc8fcSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532455acc8fcSmrg done 532555acc8fcSmrg} 532655acc8fcSmrg 532755acc8fcSmrg# Core function for launching the target application 532855acc8fcSmrgfunc_exec_program_core () 532955acc8fcSmrg{ 5330d63fdb69Smrg" 533155acc8fcSmrg case $host in 533255acc8fcSmrg # Backslashes separate directories on plain windows 533355acc8fcSmrg *-*-mingw | *-*-os2* | *-cegcc*) 533455acc8fcSmrg $ECHO "\ 533555acc8fcSmrg if test -n \"\$lt_option_debug\"; then 533652fd71cdSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533755acc8fcSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533855acc8fcSmrg fi 533955acc8fcSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534055acc8fcSmrg" 534155acc8fcSmrg ;; 534255acc8fcSmrg 534355acc8fcSmrg *) 534455acc8fcSmrg $ECHO "\ 534555acc8fcSmrg if test -n \"\$lt_option_debug\"; then 534652fd71cdSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534755acc8fcSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534855acc8fcSmrg fi 534955acc8fcSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535055acc8fcSmrg" 535155acc8fcSmrg ;; 535255acc8fcSmrg esac 535355acc8fcSmrg $ECHO "\ 535455acc8fcSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535555acc8fcSmrg exit 1 535655acc8fcSmrg} 535755acc8fcSmrg 535855acc8fcSmrg# A function to encapsulate launching the target application 535955acc8fcSmrg# Strips options in the --lt-* namespace from \$@ and 536055acc8fcSmrg# launches target application with the remaining arguments. 536155acc8fcSmrgfunc_exec_program () 536255acc8fcSmrg{ 536348c85eb7Smrg case \" \$* \" in 536448c85eb7Smrg *\\ --lt-*) 536548c85eb7Smrg for lt_wr_arg 536648c85eb7Smrg do 536748c85eb7Smrg case \$lt_wr_arg in 536848c85eb7Smrg --lt-*) ;; 536948c85eb7Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 537048c85eb7Smrg esac 537148c85eb7Smrg shift 537248c85eb7Smrg done ;; 537348c85eb7Smrg esac 537455acc8fcSmrg func_exec_program_core \${1+\"\$@\"} 537555acc8fcSmrg} 537655acc8fcSmrg 537755acc8fcSmrg # Parse options 537855acc8fcSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 53793da084b3Smrg 5380d63fdb69Smrg # Find the directory that this script lives in. 538155acc8fcSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382d63fdb69Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 53833da084b3Smrg 5384d63fdb69Smrg # Follow symbolic links until we get to the real thisdir. 538555acc8fcSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386d63fdb69Smrg while test -n \"\$file\"; do 538755acc8fcSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 53883da084b3Smrg 5389d63fdb69Smrg # If there was a directory component, then change thisdir. 5390d63fdb69Smrg if test \"x\$destdir\" != \"x\$file\"; then 5391d63fdb69Smrg case \"\$destdir\" in 5392d63fdb69Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393d63fdb69Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394d63fdb69Smrg esac 5395d63fdb69Smrg fi 53963da084b3Smrg 539755acc8fcSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539855acc8fcSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399d63fdb69Smrg done 54003da084b3Smrg 5401d63fdb69Smrg # Usually 'no', except on cygwin/mingw when embedded into 5402d63fdb69Smrg # the cwrapper. 540355acc8fcSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404d63fdb69Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405d63fdb69Smrg # special case for '.' 5406d63fdb69Smrg if test \"\$thisdir\" = \".\"; then 5407d63fdb69Smrg thisdir=\`pwd\` 5408d63fdb69Smrg fi 5409d63fdb69Smrg # remove .libs from thisdir 5410d63fdb69Smrg case \"\$thisdir\" in 541155acc8fcSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412d63fdb69Smrg $objdir ) thisdir=. ;; 5413d63fdb69Smrg esac 5414d63fdb69Smrg fi 54153da084b3Smrg 5416d63fdb69Smrg # Try to get the absolute directory name. 5417d63fdb69Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5418d63fdb69Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419d63fdb69Smrg" 54203da084b3Smrg 542152fd71cdSmrg if test yes = "$fast_install"; then 5422d63fdb69Smrg $ECHO "\ 5423d63fdb69Smrg program=lt-'$outputname'$exeext 5424d63fdb69Smrg progdir=\"\$thisdir/$objdir\" 54253da084b3Smrg 5426d63fdb69Smrg if test ! -f \"\$progdir/\$program\" || 542752fd71cdSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428d63fdb69Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 54293da084b3Smrg 5430d63fdb69Smrg file=\"\$\$-\$program\" 54313da084b3Smrg 5432d63fdb69Smrg if test ! -d \"\$progdir\"; then 5433d63fdb69Smrg $MKDIR \"\$progdir\" 5434d63fdb69Smrg else 5435d63fdb69Smrg $RM \"\$progdir/\$file\" 5436d63fdb69Smrg fi" 54373da084b3Smrg 5438d63fdb69Smrg $ECHO "\ 54393da084b3Smrg 5440d63fdb69Smrg # relink executable if necessary 5441d63fdb69Smrg if test -n \"\$relink_command\"; then 5442d63fdb69Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443d63fdb69Smrg else 544452fd71cdSmrg \$ECHO \"\$relink_command_output\" >&2 5445d63fdb69Smrg $RM \"\$progdir/\$file\" 5446d63fdb69Smrg exit 1 5447d63fdb69Smrg fi 5448d63fdb69Smrg fi 54493da084b3Smrg 5450d63fdb69Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451d63fdb69Smrg { $RM \"\$progdir/\$program\"; 5452d63fdb69Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453d63fdb69Smrg $RM \"\$progdir/\$file\" 5454d63fdb69Smrg fi" 5455d63fdb69Smrg else 5456d63fdb69Smrg $ECHO "\ 5457d63fdb69Smrg program='$outputname' 5458d63fdb69Smrg progdir=\"\$thisdir/$objdir\" 5459d63fdb69Smrg" 5460d63fdb69Smrg fi 54613da084b3Smrg 5462d63fdb69Smrg $ECHO "\ 54633da084b3Smrg 5464d63fdb69Smrg if test -f \"\$progdir/\$program\"; then" 54653da084b3Smrg 546648c85eb7Smrg # fixup the dll searchpath if we need to. 546748c85eb7Smrg # 546848c85eb7Smrg # Fix the DLL searchpath if we need to. Do this before prepending 546948c85eb7Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 547048c85eb7Smrg # libraries must come first. 547148c85eb7Smrg if test -n "$dllsearchpath"; then 547248c85eb7Smrg $ECHO "\ 547348c85eb7Smrg # Add the dll search path components to the executable PATH 547448c85eb7Smrg PATH=$dllsearchpath:\$PATH 547548c85eb7Smrg" 547648c85eb7Smrg fi 547748c85eb7Smrg 5478d63fdb69Smrg # Export our shlibpath_var if we have one. 547952fd71cdSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480d63fdb69Smrg $ECHO "\ 5481d63fdb69Smrg # Add our own library path to $shlibpath_var 5482d63fdb69Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 54833da084b3Smrg 5484d63fdb69Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485d63fdb69Smrg # The second colon is a workaround for a bug in BeOS R4 sed 548655acc8fcSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 54873da084b3Smrg 5488d63fdb69Smrg export $shlibpath_var 5489d63fdb69Smrg" 54903da084b3Smrg fi 54913da084b3Smrg 5492d63fdb69Smrg $ECHO "\ 5493d63fdb69Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494d63fdb69Smrg # Run the actual program with our arguments. 549555acc8fcSmrg func_exec_program \${1+\"\$@\"} 5496d63fdb69Smrg fi 5497d63fdb69Smrg else 5498d63fdb69Smrg # The program doesn't exist. 549952fd71cdSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500d63fdb69Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550155acc8fcSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502d63fdb69Smrg exit 1 5503d63fdb69Smrg fi 5504d63fdb69Smrgfi\ 5505d63fdb69Smrg" 5506d63fdb69Smrg} 55073da084b3Smrg 55083da084b3Smrg 5509d63fdb69Smrg# func_emit_cwrapperexe_src 5510d63fdb69Smrg# emit the source code for a wrapper executable on stdout 5511d63fdb69Smrg# Must ONLY be called from within func_mode_link because 5512d63fdb69Smrg# it depends on a number of variable set therein. 5513d63fdb69Smrgfunc_emit_cwrapperexe_src () 5514d63fdb69Smrg{ 5515d63fdb69Smrg cat <<EOF 55163da084b3Smrg 5517d63fdb69Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551852fd71cdSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 55193da084b3Smrg 5520d63fdb69Smrg The $output program cannot be directly executed until all the libtool 5521d63fdb69Smrg libraries that it depends on are installed. 55223da084b3Smrg 5523d63fdb69Smrg This wrapper executable should never be moved out of the build directory. 5524d63fdb69Smrg If it is, it will not operate correctly. 5525d63fdb69Smrg*/ 5526d63fdb69SmrgEOF 5527d63fdb69Smrg cat <<"EOF" 552855acc8fcSmrg#ifdef _MSC_VER 552955acc8fcSmrg# define _CRT_SECURE_NO_DEPRECATE 1 553055acc8fcSmrg#endif 5531d63fdb69Smrg#include <stdio.h> 5532d63fdb69Smrg#include <stdlib.h> 5533d63fdb69Smrg#ifdef _MSC_VER 5534d63fdb69Smrg# include <direct.h> 5535d63fdb69Smrg# include <process.h> 5536d63fdb69Smrg# include <io.h> 5537d63fdb69Smrg#else 5538d63fdb69Smrg# include <unistd.h> 5539d63fdb69Smrg# include <stdint.h> 5540d63fdb69Smrg# ifdef __CYGWIN__ 5541d63fdb69Smrg# include <io.h> 5542d63fdb69Smrg# endif 5543d63fdb69Smrg#endif 5544d63fdb69Smrg#include <malloc.h> 5545d63fdb69Smrg#include <stdarg.h> 5546d63fdb69Smrg#include <assert.h> 5547d63fdb69Smrg#include <string.h> 5548d63fdb69Smrg#include <ctype.h> 5549d63fdb69Smrg#include <errno.h> 5550d63fdb69Smrg#include <fcntl.h> 5551d63fdb69Smrg#include <sys/stat.h> 5552d63fdb69Smrg 555352fd71cdSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555452fd71cdSmrg 555555acc8fcSmrg/* declarations of non-ANSI functions */ 555652fd71cdSmrg#if defined __MINGW32__ 555755acc8fcSmrg# ifdef __STRICT_ANSI__ 555855acc8fcSmrgint _putenv (const char *); 555955acc8fcSmrg# endif 556052fd71cdSmrg#elif defined __CYGWIN__ 556155acc8fcSmrg# ifdef __STRICT_ANSI__ 556255acc8fcSmrgchar *realpath (const char *, char *); 556355acc8fcSmrgint putenv (char *); 556455acc8fcSmrgint setenv (const char *, const char *, int); 556555acc8fcSmrg# endif 556652fd71cdSmrg/* #elif defined other_platform || defined ... */ 556755acc8fcSmrg#endif 556855acc8fcSmrg 556955acc8fcSmrg/* portability defines, excluding path handling macros */ 557052fd71cdSmrg#if defined _MSC_VER 557155acc8fcSmrg# define setmode _setmode 557255acc8fcSmrg# define stat _stat 557355acc8fcSmrg# define chmod _chmod 557455acc8fcSmrg# define getcwd _getcwd 557555acc8fcSmrg# define putenv _putenv 557655acc8fcSmrg# define S_IXUSR _S_IEXEC 557752fd71cdSmrg#elif defined __MINGW32__ 557855acc8fcSmrg# define setmode _setmode 557955acc8fcSmrg# define stat _stat 558055acc8fcSmrg# define chmod _chmod 558155acc8fcSmrg# define getcwd _getcwd 558255acc8fcSmrg# define putenv _putenv 558352fd71cdSmrg#elif defined __CYGWIN__ 558455acc8fcSmrg# define HAVE_SETENV 558555acc8fcSmrg# define FOPEN_WB "wb" 558652fd71cdSmrg/* #elif defined other platforms ... */ 558755acc8fcSmrg#endif 558855acc8fcSmrg 558952fd71cdSmrg#if defined PATH_MAX 5590d63fdb69Smrg# define LT_PATHMAX PATH_MAX 559152fd71cdSmrg#elif defined MAXPATHLEN 5592d63fdb69Smrg# define LT_PATHMAX MAXPATHLEN 5593d63fdb69Smrg#else 5594d63fdb69Smrg# define LT_PATHMAX 1024 5595d63fdb69Smrg#endif 5596d63fdb69Smrg 5597d63fdb69Smrg#ifndef S_IXOTH 5598d63fdb69Smrg# define S_IXOTH 0 5599d63fdb69Smrg#endif 5600d63fdb69Smrg#ifndef S_IXGRP 5601d63fdb69Smrg# define S_IXGRP 0 5602d63fdb69Smrg#endif 5603d63fdb69Smrg 560455acc8fcSmrg/* path handling portability macros */ 5605d63fdb69Smrg#ifndef DIR_SEPARATOR 5606d63fdb69Smrg# define DIR_SEPARATOR '/' 5607d63fdb69Smrg# define PATH_SEPARATOR ':' 5608d63fdb69Smrg#endif 5609d63fdb69Smrg 561052fd71cdSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561152fd71cdSmrg defined __OS2__ 5612d63fdb69Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613d63fdb69Smrg# define FOPEN_WB "wb" 5614d63fdb69Smrg# ifndef DIR_SEPARATOR_2 5615d63fdb69Smrg# define DIR_SEPARATOR_2 '\\' 5616d63fdb69Smrg# endif 5617d63fdb69Smrg# ifndef PATH_SEPARATOR_2 5618d63fdb69Smrg# define PATH_SEPARATOR_2 ';' 5619d63fdb69Smrg# endif 5620d63fdb69Smrg#endif 5621d63fdb69Smrg 5622d63fdb69Smrg#ifndef DIR_SEPARATOR_2 5623d63fdb69Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624d63fdb69Smrg#else /* DIR_SEPARATOR_2 */ 5625d63fdb69Smrg# define IS_DIR_SEPARATOR(ch) \ 5626d63fdb69Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627d63fdb69Smrg#endif /* DIR_SEPARATOR_2 */ 5628d63fdb69Smrg 5629d63fdb69Smrg#ifndef PATH_SEPARATOR_2 5630d63fdb69Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631d63fdb69Smrg#else /* PATH_SEPARATOR_2 */ 5632d63fdb69Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633d63fdb69Smrg#endif /* PATH_SEPARATOR_2 */ 5634d63fdb69Smrg 5635d63fdb69Smrg#ifndef FOPEN_WB 5636d63fdb69Smrg# define FOPEN_WB "w" 5637d63fdb69Smrg#endif 5638d63fdb69Smrg#ifndef _O_BINARY 5639d63fdb69Smrg# define _O_BINARY 0 5640d63fdb69Smrg#endif 5641d63fdb69Smrg 5642d63fdb69Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643d63fdb69Smrg#define XFREE(stale) do { \ 564452fd71cdSmrg if (stale) { free (stale); stale = 0; } \ 5645d63fdb69Smrg} while (0) 5646d63fdb69Smrg 564752fd71cdSmrg#if defined LT_DEBUGWRAPPER 564855acc8fcSmrgstatic int lt_debug = 1; 5649d63fdb69Smrg#else 565055acc8fcSmrgstatic int lt_debug = 0; 5651d63fdb69Smrg#endif 5652d63fdb69Smrg 565355acc8fcSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654d63fdb69Smrg 5655d63fdb69Smrgvoid *xmalloc (size_t num); 5656d63fdb69Smrgchar *xstrdup (const char *string); 5657d63fdb69Smrgconst char *base_name (const char *name); 5658d63fdb69Smrgchar *find_executable (const char *wrapper); 5659d63fdb69Smrgchar *chase_symlinks (const char *pathspec); 5660d63fdb69Smrgint make_executable (const char *path); 5661d63fdb69Smrgint check_executable (const char *path); 5662d63fdb69Smrgchar *strendzap (char *str, const char *pat); 566355acc8fcSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566455acc8fcSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566555acc8fcSmrgstatic const char *nonnull (const char *s); 566655acc8fcSmrgstatic const char *nonempty (const char *s); 5667d63fdb69Smrgvoid lt_setenv (const char *name, const char *value); 5668d63fdb69Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669d63fdb69Smrgvoid lt_update_exe_path (const char *name, const char *value); 5670d63fdb69Smrgvoid lt_update_lib_path (const char *name, const char *value); 567155acc8fcSmrgchar **prepare_spawn (char **argv); 567255acc8fcSmrgvoid lt_dump_script (FILE *f); 5673d63fdb69SmrgEOF 5674d63fdb69Smrg 5675d63fdb69Smrg cat <<EOF 567652fd71cdSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567752fd71cdSmrg# define externally_visible volatile 567852fd71cdSmrg#else 567952fd71cdSmrg# define externally_visible __attribute__((externally_visible)) volatile 568052fd71cdSmrg#endif 568152fd71cdSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682d63fdb69Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683d63fdb69SmrgEOF 5684d63fdb69Smrg 568552fd71cdSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568648c85eb7Smrg func_to_host_path "$temp_rpath" 5687d63fdb69Smrg cat <<EOF 568848c85eb7Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 56893da084b3SmrgEOF 56903da084b3Smrg else 5691d63fdb69Smrg cat <<"EOF" 5692d63fdb69Smrgconst char * LIB_PATH_VALUE = ""; 5693d63fdb69SmrgEOF 56943da084b3Smrg fi 5695d63fdb69Smrg 5696d63fdb69Smrg if test -n "$dllsearchpath"; then 569748c85eb7Smrg func_to_host_path "$dllsearchpath:" 5698d63fdb69Smrg cat <<EOF 5699d63fdb69Smrgconst char * EXE_PATH_VARNAME = "PATH"; 570048c85eb7Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701d63fdb69SmrgEOF 57023da084b3Smrg else 5703d63fdb69Smrg cat <<"EOF" 5704d63fdb69Smrgconst char * EXE_PATH_VARNAME = ""; 5705d63fdb69Smrgconst char * EXE_PATH_VALUE = ""; 5706d63fdb69SmrgEOF 57073da084b3Smrg fi 5708d63fdb69Smrg 570952fd71cdSmrg if test yes = "$fast_install"; then 5710d63fdb69Smrg cat <<EOF 5711d63fdb69Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712d63fdb69SmrgEOF 57133da084b3Smrg else 5714d63fdb69Smrg cat <<EOF 5715d63fdb69Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716d63fdb69SmrgEOF 57173da084b3Smrg fi 57183da084b3Smrg 57193da084b3Smrg 5720d63fdb69Smrg cat <<"EOF" 57213da084b3Smrg 5722d63fdb69Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 57233da084b3Smrg 5724d63fdb69Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725d63fdb69Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572655acc8fcSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 57273da084b3Smrg 5728d63fdb69Smrgint 5729d63fdb69Smrgmain (int argc, char *argv[]) 5730d63fdb69Smrg{ 5731d63fdb69Smrg char **newargz; 5732d63fdb69Smrg int newargc; 5733d63fdb69Smrg char *tmp_pathspec; 5734d63fdb69Smrg char *actual_cwrapper_path; 5735d63fdb69Smrg char *actual_cwrapper_name; 5736d63fdb69Smrg char *target_name; 5737d63fdb69Smrg char *lt_argv_zero; 573852fd71cdSmrg int rval = 127; 57393da084b3Smrg 5740d63fdb69Smrg int i; 57413da084b3Smrg 5742d63fdb69Smrg program_name = (char *) xstrdup (base_name (argv[0])); 574352fd71cdSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 57443da084b3Smrg 574555acc8fcSmrg /* very simple arg parsing; don't want to rely on getopt 574655acc8fcSmrg * also, copy all non cwrapper options to newargz, except 574755acc8fcSmrg * argz[0], which is handled differently 574855acc8fcSmrg */ 574955acc8fcSmrg newargc=0; 5750d63fdb69Smrg for (i = 1; i < argc; i++) 5751d63fdb69Smrg { 575252fd71cdSmrg if (STREQ (argv[i], dumpscript_opt)) 5753d63fdb69Smrg { 5754d63fdb69SmrgEOF 575552fd71cdSmrg case $host in 5756d63fdb69Smrg *mingw* | *cygwin* ) 5757d63fdb69Smrg # make stdout use "unix" line endings 5758d63fdb69Smrg echo " setmode(1,_O_BINARY);" 5759d63fdb69Smrg ;; 5760d63fdb69Smrg esac 57613da084b3Smrg 5762d63fdb69Smrg cat <<"EOF" 576355acc8fcSmrg lt_dump_script (stdout); 5764d63fdb69Smrg return 0; 5765d63fdb69Smrg } 576652fd71cdSmrg if (STREQ (argv[i], debug_opt)) 576755acc8fcSmrg { 576855acc8fcSmrg lt_debug = 1; 576955acc8fcSmrg continue; 577055acc8fcSmrg } 577152fd71cdSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577255acc8fcSmrg { 577355acc8fcSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577455acc8fcSmrg namespace, but it is not one of the ones we know about and 577555acc8fcSmrg have already dealt with, above (inluding dump-script), then 577655acc8fcSmrg report an error. Otherwise, targets might begin to believe 577755acc8fcSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577855acc8fcSmrg namespace. The first time any user complains about this, we'll 577955acc8fcSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578055acc8fcSmrg or a configure.ac-settable value. 578155acc8fcSmrg */ 578255acc8fcSmrg lt_fatal (__FILE__, __LINE__, 578355acc8fcSmrg "unrecognized %s option: '%s'", 578455acc8fcSmrg ltwrapper_option_prefix, argv[i]); 578555acc8fcSmrg } 578655acc8fcSmrg /* otherwise ... */ 578755acc8fcSmrg newargz[++newargc] = xstrdup (argv[i]); 5788d63fdb69Smrg } 578955acc8fcSmrg newargz[++newargc] = NULL; 579055acc8fcSmrg 579155acc8fcSmrgEOF 579255acc8fcSmrg cat <<EOF 579355acc8fcSmrg /* The GNU banner must be the first non-error debug message */ 579452fd71cdSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579555acc8fcSmrgEOF 579655acc8fcSmrg cat <<"EOF" 579755acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579855acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 57993da084b3Smrg 5800d63fdb69Smrg tmp_pathspec = find_executable (argv[0]); 5801d63fdb69Smrg if (tmp_pathspec == NULL) 580255acc8fcSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580355acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 580455acc8fcSmrg "(main) found exe (before symlink chase) at: %s\n", 580555acc8fcSmrg tmp_pathspec); 5806d63fdb69Smrg 5807d63fdb69Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580855acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 580955acc8fcSmrg "(main) found exe (after symlink chase) at: %s\n", 581055acc8fcSmrg actual_cwrapper_path); 5811d63fdb69Smrg XFREE (tmp_pathspec); 5812d63fdb69Smrg 581355acc8fcSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814d63fdb69Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815d63fdb69Smrg 5816d63fdb69Smrg /* wrapper name transforms */ 5817d63fdb69Smrg strendzap (actual_cwrapper_name, ".exe"); 5818d63fdb69Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819d63fdb69Smrg XFREE (actual_cwrapper_name); 5820d63fdb69Smrg actual_cwrapper_name = tmp_pathspec; 5821d63fdb69Smrg tmp_pathspec = 0; 5822d63fdb69Smrg 5823d63fdb69Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824d63fdb69Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825d63fdb69Smrg strendzap (target_name, ".exe"); 5826d63fdb69Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827d63fdb69Smrg XFREE (target_name); 5828d63fdb69Smrg target_name = tmp_pathspec; 5829d63fdb69Smrg tmp_pathspec = 0; 5830d63fdb69Smrg 583155acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 583255acc8fcSmrg "(main) libtool target name: %s\n", 583355acc8fcSmrg target_name); 5834d63fdb69SmrgEOF 58353da084b3Smrg 5836d63fdb69Smrg cat <<EOF 5837d63fdb69Smrg newargz[0] = 5838d63fdb69Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839d63fdb69Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840d63fdb69Smrg strcpy (newargz[0], actual_cwrapper_path); 5841d63fdb69Smrg strcat (newargz[0], "$objdir"); 5842d63fdb69Smrg strcat (newargz[0], "/"); 5843d63fdb69SmrgEOF 58443da084b3Smrg 5845d63fdb69Smrg cat <<"EOF" 5846d63fdb69Smrg /* stop here, and copy so we don't have to do this twice */ 5847d63fdb69Smrg tmp_pathspec = xstrdup (newargz[0]); 58483da084b3Smrg 5849d63fdb69Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850d63fdb69Smrg strcat (newargz[0], actual_cwrapper_name); 58513da084b3Smrg 5852d63fdb69Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853d63fdb69Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854d63fdb69Smrg XFREE (tmp_pathspec); 5855d63fdb69Smrg tmp_pathspec = NULL; 5856d63fdb69SmrgEOF 58573da084b3Smrg 5858d63fdb69Smrg case $host_os in 5859d63fdb69Smrg mingw*) 5860d63fdb69Smrg cat <<"EOF" 5861d63fdb69Smrg { 5862d63fdb69Smrg char* p; 5863d63fdb69Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864d63fdb69Smrg { 5865d63fdb69Smrg *p = '/'; 5866d63fdb69Smrg } 5867d63fdb69Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868d63fdb69Smrg { 5869d63fdb69Smrg *p = '/'; 5870d63fdb69Smrg } 5871d63fdb69Smrg } 5872d63fdb69SmrgEOF 5873d63fdb69Smrg ;; 5874d63fdb69Smrg esac 58753da084b3Smrg 5876d63fdb69Smrg cat <<"EOF" 5877d63fdb69Smrg XFREE (target_name); 5878d63fdb69Smrg XFREE (actual_cwrapper_path); 5879d63fdb69Smrg XFREE (actual_cwrapper_name); 58803da084b3Smrg 5881d63fdb69Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882d63fdb69Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588348c85eb7Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588448c85eb7Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588548c85eb7Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588648c85eb7Smrg libraries must come first. */ 5887d63fdb69Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588848c85eb7Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 58893da084b3Smrg 589055acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589155acc8fcSmrg nonnull (lt_argv_zero)); 5892d63fdb69Smrg for (i = 0; i < newargc; i++) 5893d63fdb69Smrg { 589455acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589555acc8fcSmrg i, nonnull (newargz[i])); 5896d63fdb69Smrg } 58973da084b3Smrg 5898d63fdb69SmrgEOF 58993da084b3Smrg 5900d63fdb69Smrg case $host_os in 5901d63fdb69Smrg mingw*) 5902d63fdb69Smrg cat <<"EOF" 5903d63fdb69Smrg /* execv doesn't actually work on mingw as expected on unix */ 590455acc8fcSmrg newargz = prepare_spawn (newargz); 590552fd71cdSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906d63fdb69Smrg if (rval == -1) 5907d63fdb69Smrg { 5908d63fdb69Smrg /* failed to start process */ 590955acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 591055acc8fcSmrg "(main) failed to launch target \"%s\": %s\n", 591155acc8fcSmrg lt_argv_zero, nonnull (strerror (errno))); 5912d63fdb69Smrg return 127; 5913d63fdb69Smrg } 5914d63fdb69Smrg return rval; 5915d63fdb69SmrgEOF 5916d63fdb69Smrg ;; 5917d63fdb69Smrg *) 5918d63fdb69Smrg cat <<"EOF" 5919d63fdb69Smrg execv (lt_argv_zero, newargz); 5920d63fdb69Smrg return rval; /* =127, but avoids unused variable warning */ 5921d63fdb69SmrgEOF 5922d63fdb69Smrg ;; 5923d63fdb69Smrg esac 59243da084b3Smrg 5925d63fdb69Smrg cat <<"EOF" 5926d63fdb69Smrg} 59273da084b3Smrg 5928d63fdb69Smrgvoid * 5929d63fdb69Smrgxmalloc (size_t num) 5930d63fdb69Smrg{ 5931d63fdb69Smrg void *p = (void *) malloc (num); 5932d63fdb69Smrg if (!p) 593355acc8fcSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 59343da084b3Smrg 5935d63fdb69Smrg return p; 5936d63fdb69Smrg} 59373da084b3Smrg 5938d63fdb69Smrgchar * 5939d63fdb69Smrgxstrdup (const char *string) 5940d63fdb69Smrg{ 5941d63fdb69Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942d63fdb69Smrg string) : NULL; 5943d63fdb69Smrg} 59443da084b3Smrg 5945d63fdb69Smrgconst char * 5946d63fdb69Smrgbase_name (const char *name) 5947d63fdb69Smrg{ 5948d63fdb69Smrg const char *base; 59493da084b3Smrg 595052fd71cdSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951d63fdb69Smrg /* Skip over the disk name in MSDOS pathnames. */ 5952d63fdb69Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953d63fdb69Smrg name += 2; 5954d63fdb69Smrg#endif 59553da084b3Smrg 5956d63fdb69Smrg for (base = name; *name; name++) 5957d63fdb69Smrg if (IS_DIR_SEPARATOR (*name)) 5958d63fdb69Smrg base = name + 1; 5959d63fdb69Smrg return base; 5960d63fdb69Smrg} 59613da084b3Smrg 5962d63fdb69Smrgint 5963d63fdb69Smrgcheck_executable (const char *path) 5964d63fdb69Smrg{ 5965d63fdb69Smrg struct stat st; 59663da084b3Smrg 596755acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596855acc8fcSmrg nonempty (path)); 5969d63fdb69Smrg if ((!path) || (!*path)) 5970d63fdb69Smrg return 0; 59713da084b3Smrg 5972d63fdb69Smrg if ((stat (path, &st) >= 0) 5973d63fdb69Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974d63fdb69Smrg return 1; 5975d63fdb69Smrg else 5976d63fdb69Smrg return 0; 5977d63fdb69Smrg} 59783da084b3Smrg 5979d63fdb69Smrgint 5980d63fdb69Smrgmake_executable (const char *path) 5981d63fdb69Smrg{ 5982d63fdb69Smrg int rval = 0; 5983d63fdb69Smrg struct stat st; 59843da084b3Smrg 598555acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598655acc8fcSmrg nonempty (path)); 5987d63fdb69Smrg if ((!path) || (!*path)) 5988d63fdb69Smrg return 0; 59893da084b3Smrg 5990d63fdb69Smrg if (stat (path, &st) >= 0) 5991d63fdb69Smrg { 5992d63fdb69Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993d63fdb69Smrg } 5994d63fdb69Smrg return rval; 5995d63fdb69Smrg} 59963da084b3Smrg 5997d63fdb69Smrg/* Searches for the full path of the wrapper. Returns 5998d63fdb69Smrg newly allocated full path name if found, NULL otherwise 5999d63fdb69Smrg Does not chase symlinks, even on platforms that support them. 6000d63fdb69Smrg*/ 6001d63fdb69Smrgchar * 6002d63fdb69Smrgfind_executable (const char *wrapper) 6003d63fdb69Smrg{ 6004d63fdb69Smrg int has_slash = 0; 6005d63fdb69Smrg const char *p; 6006d63fdb69Smrg const char *p_next; 6007d63fdb69Smrg /* static buffer for getcwd */ 6008d63fdb69Smrg char tmp[LT_PATHMAX + 1]; 600952fd71cdSmrg size_t tmp_len; 6010d63fdb69Smrg char *concat_name; 60113da084b3Smrg 601255acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601355acc8fcSmrg nonempty (wrapper)); 60143da084b3Smrg 6015d63fdb69Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016d63fdb69Smrg return NULL; 60173da084b3Smrg 6018d63fdb69Smrg /* Absolute path? */ 601952fd71cdSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020d63fdb69Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021d63fdb69Smrg { 6022d63fdb69Smrg concat_name = xstrdup (wrapper); 6023d63fdb69Smrg if (check_executable (concat_name)) 6024d63fdb69Smrg return concat_name; 6025d63fdb69Smrg XFREE (concat_name); 6026d63fdb69Smrg } 6027d63fdb69Smrg else 6028d63fdb69Smrg { 6029d63fdb69Smrg#endif 6030d63fdb69Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031d63fdb69Smrg { 6032d63fdb69Smrg concat_name = xstrdup (wrapper); 6033d63fdb69Smrg if (check_executable (concat_name)) 6034d63fdb69Smrg return concat_name; 6035d63fdb69Smrg XFREE (concat_name); 6036d63fdb69Smrg } 603752fd71cdSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038d63fdb69Smrg } 6039d63fdb69Smrg#endif 60403da084b3Smrg 6041d63fdb69Smrg for (p = wrapper; *p; p++) 6042d63fdb69Smrg if (*p == '/') 6043d63fdb69Smrg { 6044d63fdb69Smrg has_slash = 1; 6045d63fdb69Smrg break; 6046d63fdb69Smrg } 6047d63fdb69Smrg if (!has_slash) 6048d63fdb69Smrg { 6049d63fdb69Smrg /* no slashes; search PATH */ 6050d63fdb69Smrg const char *path = getenv ("PATH"); 6051d63fdb69Smrg if (path != NULL) 6052d63fdb69Smrg { 6053d63fdb69Smrg for (p = path; *p; p = p_next) 6054d63fdb69Smrg { 6055d63fdb69Smrg const char *q; 6056d63fdb69Smrg size_t p_len; 6057d63fdb69Smrg for (q = p; *q; q++) 6058d63fdb69Smrg if (IS_PATH_SEPARATOR (*q)) 6059d63fdb69Smrg break; 606052fd71cdSmrg p_len = (size_t) (q - p); 6061d63fdb69Smrg p_next = (*q == '\0' ? q : q + 1); 6062d63fdb69Smrg if (p_len == 0) 6063d63fdb69Smrg { 6064d63fdb69Smrg /* empty path: current directory */ 6065d63fdb69Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606655acc8fcSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606755acc8fcSmrg nonnull (strerror (errno))); 6068d63fdb69Smrg tmp_len = strlen (tmp); 6069d63fdb69Smrg concat_name = 6070d63fdb69Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071d63fdb69Smrg memcpy (concat_name, tmp, tmp_len); 6072d63fdb69Smrg concat_name[tmp_len] = '/'; 6073d63fdb69Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6074d63fdb69Smrg } 6075d63fdb69Smrg else 6076d63fdb69Smrg { 6077d63fdb69Smrg concat_name = 6078d63fdb69Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079d63fdb69Smrg memcpy (concat_name, p, p_len); 6080d63fdb69Smrg concat_name[p_len] = '/'; 6081d63fdb69Smrg strcpy (concat_name + p_len + 1, wrapper); 6082d63fdb69Smrg } 6083d63fdb69Smrg if (check_executable (concat_name)) 6084d63fdb69Smrg return concat_name; 6085d63fdb69Smrg XFREE (concat_name); 6086d63fdb69Smrg } 6087d63fdb69Smrg } 6088d63fdb69Smrg /* not found in PATH; assume curdir */ 6089d63fdb69Smrg } 6090d63fdb69Smrg /* Relative path | not found in path: prepend cwd */ 6091d63fdb69Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609255acc8fcSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609355acc8fcSmrg nonnull (strerror (errno))); 6094d63fdb69Smrg tmp_len = strlen (tmp); 6095d63fdb69Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096d63fdb69Smrg memcpy (concat_name, tmp, tmp_len); 6097d63fdb69Smrg concat_name[tmp_len] = '/'; 6098d63fdb69Smrg strcpy (concat_name + tmp_len + 1, wrapper); 60993da084b3Smrg 6100d63fdb69Smrg if (check_executable (concat_name)) 6101d63fdb69Smrg return concat_name; 6102d63fdb69Smrg XFREE (concat_name); 6103d63fdb69Smrg return NULL; 6104d63fdb69Smrg} 61053da084b3Smrg 6106d63fdb69Smrgchar * 6107d63fdb69Smrgchase_symlinks (const char *pathspec) 6108d63fdb69Smrg{ 6109d63fdb69Smrg#ifndef S_ISLNK 6110d63fdb69Smrg return xstrdup (pathspec); 6111d63fdb69Smrg#else 6112d63fdb69Smrg char buf[LT_PATHMAX]; 6113d63fdb69Smrg struct stat s; 6114d63fdb69Smrg char *tmp_pathspec = xstrdup (pathspec); 6115d63fdb69Smrg char *p; 6116d63fdb69Smrg int has_symlinks = 0; 6117d63fdb69Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6118d63fdb69Smrg { 611955acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 612055acc8fcSmrg "checking path component for symlinks: %s\n", 612155acc8fcSmrg tmp_pathspec); 6122d63fdb69Smrg if (lstat (tmp_pathspec, &s) == 0) 6123d63fdb69Smrg { 6124d63fdb69Smrg if (S_ISLNK (s.st_mode) != 0) 6125d63fdb69Smrg { 6126d63fdb69Smrg has_symlinks = 1; 6127d63fdb69Smrg break; 6128d63fdb69Smrg } 61293da084b3Smrg 6130d63fdb69Smrg /* search backwards for last DIR_SEPARATOR */ 6131d63fdb69Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132d63fdb69Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133d63fdb69Smrg p--; 6134d63fdb69Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135d63fdb69Smrg { 6136d63fdb69Smrg /* no more DIR_SEPARATORS left */ 6137d63fdb69Smrg break; 6138d63fdb69Smrg } 6139d63fdb69Smrg *p = '\0'; 6140d63fdb69Smrg } 6141d63fdb69Smrg else 6142d63fdb69Smrg { 614355acc8fcSmrg lt_fatal (__FILE__, __LINE__, 614455acc8fcSmrg "error accessing file \"%s\": %s", 614555acc8fcSmrg tmp_pathspec, nonnull (strerror (errno))); 6146d63fdb69Smrg } 6147d63fdb69Smrg } 6148d63fdb69Smrg XFREE (tmp_pathspec); 61493da084b3Smrg 6150d63fdb69Smrg if (!has_symlinks) 6151d63fdb69Smrg { 6152d63fdb69Smrg return xstrdup (pathspec); 6153d63fdb69Smrg } 61543da084b3Smrg 6155d63fdb69Smrg tmp_pathspec = realpath (pathspec, buf); 6156d63fdb69Smrg if (tmp_pathspec == 0) 6157d63fdb69Smrg { 615855acc8fcSmrg lt_fatal (__FILE__, __LINE__, 615955acc8fcSmrg "could not follow symlinks for %s", pathspec); 6160d63fdb69Smrg } 6161d63fdb69Smrg return xstrdup (tmp_pathspec); 6162d63fdb69Smrg#endif 6163d63fdb69Smrg} 61643da084b3Smrg 6165d63fdb69Smrgchar * 6166d63fdb69Smrgstrendzap (char *str, const char *pat) 6167d63fdb69Smrg{ 6168d63fdb69Smrg size_t len, patlen; 61693da084b3Smrg 6170d63fdb69Smrg assert (str != NULL); 6171d63fdb69Smrg assert (pat != NULL); 61723da084b3Smrg 6173d63fdb69Smrg len = strlen (str); 6174d63fdb69Smrg patlen = strlen (pat); 61753da084b3Smrg 6176d63fdb69Smrg if (patlen <= len) 6177d63fdb69Smrg { 6178d63fdb69Smrg str += len - patlen; 617952fd71cdSmrg if (STREQ (str, pat)) 6180d63fdb69Smrg *str = '\0'; 6181d63fdb69Smrg } 6182d63fdb69Smrg return str; 6183d63fdb69Smrg} 61843da084b3Smrg 618555acc8fcSmrgvoid 618655acc8fcSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618755acc8fcSmrg{ 618855acc8fcSmrg va_list args; 618955acc8fcSmrg if (lt_debug) 619055acc8fcSmrg { 619155acc8fcSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619255acc8fcSmrg va_start (args, fmt); 619355acc8fcSmrg (void) vfprintf (stderr, fmt, args); 619455acc8fcSmrg va_end (args); 619555acc8fcSmrg } 619655acc8fcSmrg} 619755acc8fcSmrg 6198d63fdb69Smrgstatic void 619955acc8fcSmrglt_error_core (int exit_status, const char *file, 620055acc8fcSmrg int line, const char *mode, 6201d63fdb69Smrg const char *message, va_list ap) 6202d63fdb69Smrg{ 620355acc8fcSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204d63fdb69Smrg vfprintf (stderr, message, ap); 6205d63fdb69Smrg fprintf (stderr, ".\n"); 62063da084b3Smrg 6207d63fdb69Smrg if (exit_status >= 0) 6208d63fdb69Smrg exit (exit_status); 6209d63fdb69Smrg} 62103da084b3Smrg 6211d63fdb69Smrgvoid 621255acc8fcSmrglt_fatal (const char *file, int line, const char *message, ...) 6213d63fdb69Smrg{ 6214d63fdb69Smrg va_list ap; 6215d63fdb69Smrg va_start (ap, message); 621655acc8fcSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217d63fdb69Smrg va_end (ap); 6218d63fdb69Smrg} 62193da084b3Smrg 622055acc8fcSmrgstatic const char * 622155acc8fcSmrgnonnull (const char *s) 622255acc8fcSmrg{ 622355acc8fcSmrg return s ? s : "(null)"; 622455acc8fcSmrg} 622555acc8fcSmrg 622655acc8fcSmrgstatic const char * 622755acc8fcSmrgnonempty (const char *s) 622855acc8fcSmrg{ 622955acc8fcSmrg return (s && !*s) ? "(empty)" : nonnull (s); 623055acc8fcSmrg} 623155acc8fcSmrg 6232d63fdb69Smrgvoid 6233d63fdb69Smrglt_setenv (const char *name, const char *value) 6234d63fdb69Smrg{ 623555acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 623655acc8fcSmrg "(lt_setenv) setting '%s' to '%s'\n", 623755acc8fcSmrg nonnull (name), nonnull (value)); 6238d63fdb69Smrg { 6239d63fdb69Smrg#ifdef HAVE_SETENV 6240d63fdb69Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241d63fdb69Smrg char *str = xstrdup (value); 6242d63fdb69Smrg setenv (name, str, 1); 6243d63fdb69Smrg#else 624452fd71cdSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245d63fdb69Smrg char *str = XMALLOC (char, len); 6246d63fdb69Smrg sprintf (str, "%s=%s", name, value); 6247d63fdb69Smrg if (putenv (str) != EXIT_SUCCESS) 6248d63fdb69Smrg { 6249d63fdb69Smrg XFREE (str); 6250d63fdb69Smrg } 6251d63fdb69Smrg#endif 6252d63fdb69Smrg } 6253d63fdb69Smrg} 62543da084b3Smrg 6255d63fdb69Smrgchar * 6256d63fdb69Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257d63fdb69Smrg{ 6258d63fdb69Smrg char *new_value; 6259d63fdb69Smrg if (orig_value && *orig_value) 6260d63fdb69Smrg { 626152fd71cdSmrg size_t orig_value_len = strlen (orig_value); 626252fd71cdSmrg size_t add_len = strlen (add); 6263d63fdb69Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264d63fdb69Smrg if (to_end) 6265d63fdb69Smrg { 6266d63fdb69Smrg strcpy (new_value, orig_value); 6267d63fdb69Smrg strcpy (new_value + orig_value_len, add); 6268d63fdb69Smrg } 6269d63fdb69Smrg else 6270d63fdb69Smrg { 6271d63fdb69Smrg strcpy (new_value, add); 6272d63fdb69Smrg strcpy (new_value + add_len, orig_value); 6273d63fdb69Smrg } 6274d63fdb69Smrg } 6275d63fdb69Smrg else 6276d63fdb69Smrg { 6277d63fdb69Smrg new_value = xstrdup (add); 6278d63fdb69Smrg } 6279d63fdb69Smrg return new_value; 6280d63fdb69Smrg} 62813da084b3Smrg 6282d63fdb69Smrgvoid 6283d63fdb69Smrglt_update_exe_path (const char *name, const char *value) 6284d63fdb69Smrg{ 628555acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 628655acc8fcSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628755acc8fcSmrg nonnull (name), nonnull (value)); 62883da084b3Smrg 6289d63fdb69Smrg if (name && *name && value && *value) 6290d63fdb69Smrg { 6291d63fdb69Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292d63fdb69Smrg /* some systems can't cope with a ':'-terminated path #' */ 629352fd71cdSmrg size_t len = strlen (new_value); 629452fd71cdSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295d63fdb69Smrg { 629652fd71cdSmrg new_value[--len] = '\0'; 6297d63fdb69Smrg } 6298d63fdb69Smrg lt_setenv (name, new_value); 6299d63fdb69Smrg XFREE (new_value); 6300d63fdb69Smrg } 6301d63fdb69Smrg} 63023da084b3Smrg 6303d63fdb69Smrgvoid 6304d63fdb69Smrglt_update_lib_path (const char *name, const char *value) 6305d63fdb69Smrg{ 630655acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 630755acc8fcSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630855acc8fcSmrg nonnull (name), nonnull (value)); 63093da084b3Smrg 6310d63fdb69Smrg if (name && *name && value && *value) 6311d63fdb69Smrg { 6312d63fdb69Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313d63fdb69Smrg lt_setenv (name, new_value); 6314d63fdb69Smrg XFREE (new_value); 6315d63fdb69Smrg } 6316d63fdb69Smrg} 63173da084b3Smrg 631855acc8fcSmrgEOF 631955acc8fcSmrg case $host_os in 632055acc8fcSmrg mingw*) 632155acc8fcSmrg cat <<"EOF" 632255acc8fcSmrg 632355acc8fcSmrg/* Prepares an argument vector before calling spawn(). 632455acc8fcSmrg Note that spawn() does not by itself call the command interpreter 632555acc8fcSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632655acc8fcSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632755acc8fcSmrg GetVersionEx(&v); 632855acc8fcSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632955acc8fcSmrg }) ? "cmd.exe" : "command.com"). 633055acc8fcSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 633155acc8fcSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633255acc8fcSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633355acc8fcSmrg special way: 633455acc8fcSmrg - Space and tab are interpreted as delimiters. They are not treated as 633555acc8fcSmrg delimiters if they are surrounded by double quotes: "...". 633655acc8fcSmrg - Unescaped double quotes are removed from the input. Their only effect is 633755acc8fcSmrg that within double quotes, space and tab are treated like normal 633855acc8fcSmrg characters. 633955acc8fcSmrg - Backslashes not followed by double quotes are not special. 634055acc8fcSmrg - But 2*n+1 backslashes followed by a double quote become 634155acc8fcSmrg n backslashes followed by a double quote (n >= 0): 634255acc8fcSmrg \" -> " 634355acc8fcSmrg \\\" -> \" 634455acc8fcSmrg \\\\\" -> \\" 634555acc8fcSmrg */ 634655acc8fcSmrg#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" 634755acc8fcSmrg#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" 634855acc8fcSmrgchar ** 634955acc8fcSmrgprepare_spawn (char **argv) 635055acc8fcSmrg{ 635155acc8fcSmrg size_t argc; 635255acc8fcSmrg char **new_argv; 635355acc8fcSmrg size_t i; 635455acc8fcSmrg 635555acc8fcSmrg /* Count number of arguments. */ 635655acc8fcSmrg for (argc = 0; argv[argc] != NULL; argc++) 635755acc8fcSmrg ; 635855acc8fcSmrg 635955acc8fcSmrg /* Allocate new argument vector. */ 636055acc8fcSmrg new_argv = XMALLOC (char *, argc + 1); 636155acc8fcSmrg 636255acc8fcSmrg /* Put quoted arguments into the new argument vector. */ 636355acc8fcSmrg for (i = 0; i < argc; i++) 636455acc8fcSmrg { 636555acc8fcSmrg const char *string = argv[i]; 636655acc8fcSmrg 636755acc8fcSmrg if (string[0] == '\0') 636855acc8fcSmrg new_argv[i] = xstrdup ("\"\""); 636955acc8fcSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637055acc8fcSmrg { 637155acc8fcSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637255acc8fcSmrg size_t length; 637355acc8fcSmrg unsigned int backslashes; 637455acc8fcSmrg const char *s; 637555acc8fcSmrg char *quoted_string; 637655acc8fcSmrg char *p; 637755acc8fcSmrg 637855acc8fcSmrg length = 0; 637955acc8fcSmrg backslashes = 0; 638055acc8fcSmrg if (quote_around) 638155acc8fcSmrg length++; 638255acc8fcSmrg for (s = string; *s != '\0'; s++) 638355acc8fcSmrg { 638455acc8fcSmrg char c = *s; 638555acc8fcSmrg if (c == '"') 638655acc8fcSmrg length += backslashes + 1; 638755acc8fcSmrg length++; 638855acc8fcSmrg if (c == '\\') 638955acc8fcSmrg backslashes++; 639055acc8fcSmrg else 639155acc8fcSmrg backslashes = 0; 639255acc8fcSmrg } 639355acc8fcSmrg if (quote_around) 639455acc8fcSmrg length += backslashes + 1; 639555acc8fcSmrg 639655acc8fcSmrg quoted_string = XMALLOC (char, length + 1); 639755acc8fcSmrg 639855acc8fcSmrg p = quoted_string; 639955acc8fcSmrg backslashes = 0; 640055acc8fcSmrg if (quote_around) 640155acc8fcSmrg *p++ = '"'; 640255acc8fcSmrg for (s = string; *s != '\0'; s++) 640355acc8fcSmrg { 640455acc8fcSmrg char c = *s; 640555acc8fcSmrg if (c == '"') 640655acc8fcSmrg { 640755acc8fcSmrg unsigned int j; 640855acc8fcSmrg for (j = backslashes + 1; j > 0; j--) 640955acc8fcSmrg *p++ = '\\'; 641055acc8fcSmrg } 641155acc8fcSmrg *p++ = c; 641255acc8fcSmrg if (c == '\\') 641355acc8fcSmrg backslashes++; 641455acc8fcSmrg else 641555acc8fcSmrg backslashes = 0; 641655acc8fcSmrg } 641755acc8fcSmrg if (quote_around) 641855acc8fcSmrg { 641955acc8fcSmrg unsigned int j; 642055acc8fcSmrg for (j = backslashes; j > 0; j--) 642155acc8fcSmrg *p++ = '\\'; 642255acc8fcSmrg *p++ = '"'; 642355acc8fcSmrg } 642455acc8fcSmrg *p = '\0'; 642555acc8fcSmrg 642655acc8fcSmrg new_argv[i] = quoted_string; 642755acc8fcSmrg } 642855acc8fcSmrg else 642955acc8fcSmrg new_argv[i] = (char *) string; 643055acc8fcSmrg } 643155acc8fcSmrg new_argv[argc] = NULL; 643255acc8fcSmrg 643355acc8fcSmrg return new_argv; 643455acc8fcSmrg} 643555acc8fcSmrgEOF 643655acc8fcSmrg ;; 643755acc8fcSmrg esac 643855acc8fcSmrg 643955acc8fcSmrg cat <<"EOF" 644055acc8fcSmrgvoid lt_dump_script (FILE* f) 644155acc8fcSmrg{ 644255acc8fcSmrgEOF 644355acc8fcSmrg func_emit_wrapper yes | 644448c85eb7Smrg $SED -n -e ' 644548c85eb7Smrgs/^\(.\{79\}\)\(..*\)/\1\ 644648c85eb7Smrg\2/ 644748c85eb7Smrgh 644848c85eb7Smrgs/\([\\"]\)/\\\1/g 644948c85eb7Smrgs/$/\\n/ 645048c85eb7Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 645148c85eb7Smrgg 645248c85eb7SmrgD' 645355acc8fcSmrg cat <<"EOF" 645455acc8fcSmrg} 6455d63fdb69SmrgEOF 6456d63fdb69Smrg} 6457d63fdb69Smrg# end: func_emit_cwrapperexe_src 64583da084b3Smrg 645955acc8fcSmrg# func_win32_import_lib_p ARG 646055acc8fcSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646155acc8fcSmrgfunc_win32_import_lib_p () 646255acc8fcSmrg{ 646352fd71cdSmrg $debug_cmd 646452fd71cdSmrg 646555acc8fcSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646655acc8fcSmrg *import*) : ;; 646755acc8fcSmrg *) false ;; 646855acc8fcSmrg esac 646955acc8fcSmrg} 647055acc8fcSmrg 647152fd71cdSmrg# func_suncc_cstd_abi 647252fd71cdSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647352fd71cdSmrg# Several compiler flags select an ABI that is incompatible with the 647452fd71cdSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647552fd71cdSmrgfunc_suncc_cstd_abi () 647652fd71cdSmrg{ 647752fd71cdSmrg $debug_cmd 647852fd71cdSmrg 647952fd71cdSmrg case " $compile_command " in 648052fd71cdSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648152fd71cdSmrg suncc_use_cstd_abi=no 648252fd71cdSmrg ;; 648352fd71cdSmrg *) 648452fd71cdSmrg suncc_use_cstd_abi=yes 648552fd71cdSmrg ;; 648652fd71cdSmrg esac 648752fd71cdSmrg} 648852fd71cdSmrg 6489d63fdb69Smrg# func_mode_link arg... 6490d63fdb69Smrgfunc_mode_link () 6491d63fdb69Smrg{ 649252fd71cdSmrg $debug_cmd 649352fd71cdSmrg 6494d63fdb69Smrg case $host in 6495d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496d63fdb69Smrg # It is impossible to link a dll without this setting, and 6497d63fdb69Smrg # we shouldn't force the makefile maintainer to figure out 649852fd71cdSmrg # what system we are compiling for in order to pass an extra 6499d63fdb69Smrg # flag for every libtool invocation. 6500d63fdb69Smrg # allow_undefined=no 65013da084b3Smrg 6502d63fdb69Smrg # FIXME: Unfortunately, there are problems with the above when trying 650352fd71cdSmrg # to make a dll that has undefined symbols, in which case not 6504d63fdb69Smrg # even a static library is built. For now, we need to specify 6505d63fdb69Smrg # -no-undefined on the libtool link line when we can be certain 6506d63fdb69Smrg # that all symbols are satisfied, otherwise we get a static library. 6507d63fdb69Smrg allow_undefined=yes 6508d63fdb69Smrg ;; 6509d63fdb69Smrg *) 6510d63fdb69Smrg allow_undefined=yes 6511d63fdb69Smrg ;; 6512d63fdb69Smrg esac 6513d63fdb69Smrg libtool_args=$nonopt 6514d63fdb69Smrg base_compile="$nonopt $@" 6515d63fdb69Smrg compile_command=$nonopt 6516d63fdb69Smrg finalize_command=$nonopt 65173da084b3Smrg 6518d63fdb69Smrg compile_rpath= 6519d63fdb69Smrg finalize_rpath= 6520d63fdb69Smrg compile_shlibpath= 6521d63fdb69Smrg finalize_shlibpath= 6522d63fdb69Smrg convenience= 6523d63fdb69Smrg old_convenience= 6524d63fdb69Smrg deplibs= 6525d63fdb69Smrg old_deplibs= 6526d63fdb69Smrg compiler_flags= 6527d63fdb69Smrg linker_flags= 6528d63fdb69Smrg dllsearchpath= 6529d63fdb69Smrg lib_search_path=`pwd` 6530d63fdb69Smrg inst_prefix_dir= 6531d63fdb69Smrg new_inherited_linker_flags= 65323da084b3Smrg 6533d63fdb69Smrg avoid_version=no 653455acc8fcSmrg bindir= 6535d63fdb69Smrg dlfiles= 6536d63fdb69Smrg dlprefiles= 6537d63fdb69Smrg dlself=no 6538d63fdb69Smrg export_dynamic=no 6539d63fdb69Smrg export_symbols= 6540d63fdb69Smrg export_symbols_regex= 6541d63fdb69Smrg generated= 6542d63fdb69Smrg libobjs= 6543d63fdb69Smrg ltlibs= 6544d63fdb69Smrg module=no 6545d63fdb69Smrg no_install=no 6546d63fdb69Smrg objs= 654752fd71cdSmrg os2dllname= 6548d63fdb69Smrg non_pic_objects= 6549d63fdb69Smrg precious_files_regex= 6550d63fdb69Smrg prefer_static_libs=no 655152fd71cdSmrg preload=false 6552d63fdb69Smrg prev= 6553d63fdb69Smrg prevarg= 6554d63fdb69Smrg release= 6555d63fdb69Smrg rpath= 6556d63fdb69Smrg xrpath= 6557d63fdb69Smrg perm_rpath= 6558d63fdb69Smrg temp_rpath= 6559d63fdb69Smrg thread_safe=no 6560d63fdb69Smrg vinfo= 6561d63fdb69Smrg vinfo_number=no 6562d63fdb69Smrg weak_libs= 656352fd71cdSmrg single_module=$wl-single_module 6564d63fdb69Smrg func_infer_tag $base_compile 65653da084b3Smrg 6566d63fdb69Smrg # We need to know -static, to get the right output filenames. 6567d63fdb69Smrg for arg 6568d63fdb69Smrg do 6569d63fdb69Smrg case $arg in 6570d63fdb69Smrg -shared) 657152fd71cdSmrg test yes != "$build_libtool_libs" \ 657252fd71cdSmrg && func_fatal_configuration "cannot build a shared library" 6573d63fdb69Smrg build_old_libs=no 6574d63fdb69Smrg break 6575d63fdb69Smrg ;; 6576d63fdb69Smrg -all-static | -static | -static-libtool-libs) 6577d63fdb69Smrg case $arg in 6578d63fdb69Smrg -all-static) 657952fd71cdSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580d63fdb69Smrg func_warning "complete static linking is impossible in this configuration" 65813da084b3Smrg fi 6582d63fdb69Smrg if test -n "$link_static_flag"; then 6583d63fdb69Smrg dlopen_self=$dlopen_self_static 65843da084b3Smrg fi 6585d63fdb69Smrg prefer_static_libs=yes 65863da084b3Smrg ;; 6587d63fdb69Smrg -static) 6588d63fdb69Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589d63fdb69Smrg dlopen_self=$dlopen_self_static 6590d63fdb69Smrg fi 6591d63fdb69Smrg prefer_static_libs=built 6592d63fdb69Smrg ;; 6593d63fdb69Smrg -static-libtool-libs) 6594d63fdb69Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595d63fdb69Smrg dlopen_self=$dlopen_self_static 6596d63fdb69Smrg fi 6597d63fdb69Smrg prefer_static_libs=yes 65983da084b3Smrg ;; 65993da084b3Smrg esac 6600d63fdb69Smrg build_libtool_libs=no 6601d63fdb69Smrg build_old_libs=yes 6602d63fdb69Smrg break 6603d63fdb69Smrg ;; 6604d63fdb69Smrg esac 6605d63fdb69Smrg done 66063da084b3Smrg 6607d63fdb69Smrg # See if our shared archives depend on static archives. 6608d63fdb69Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 66093da084b3Smrg 6610d63fdb69Smrg # Go through the arguments, transforming them on the way. 6611d63fdb69Smrg while test "$#" -gt 0; do 661252fd71cdSmrg arg=$1 6613d63fdb69Smrg shift 6614d63fdb69Smrg func_quote_for_eval "$arg" 6615d63fdb69Smrg qarg=$func_quote_for_eval_unquoted_result 6616d63fdb69Smrg func_append libtool_args " $func_quote_for_eval_result" 66173da084b3Smrg 6618d63fdb69Smrg # If the previous option needs an argument, assign it. 6619d63fdb69Smrg if test -n "$prev"; then 6620d63fdb69Smrg case $prev in 6621d63fdb69Smrg output) 6622d63fdb69Smrg func_append compile_command " @OUTPUT@" 6623d63fdb69Smrg func_append finalize_command " @OUTPUT@" 6624d63fdb69Smrg ;; 6625d63fdb69Smrg esac 66263da084b3Smrg 6627d63fdb69Smrg case $prev in 662855acc8fcSmrg bindir) 662952fd71cdSmrg bindir=$arg 663055acc8fcSmrg prev= 663155acc8fcSmrg continue 663255acc8fcSmrg ;; 6633d63fdb69Smrg dlfiles|dlprefiles) 663452fd71cdSmrg $preload || { 6635d63fdb69Smrg # Add the symbol object into the linking commands. 6636d63fdb69Smrg func_append compile_command " @SYMFILE@" 6637d63fdb69Smrg func_append finalize_command " @SYMFILE@" 663852fd71cdSmrg preload=: 663952fd71cdSmrg } 6640d63fdb69Smrg case $arg in 6641d63fdb69Smrg *.la | *.lo) ;; # We handle these cases below. 6642d63fdb69Smrg force) 664352fd71cdSmrg if test no = "$dlself"; then 6644d63fdb69Smrg dlself=needless 6645d63fdb69Smrg export_dynamic=yes 6646d63fdb69Smrg fi 6647d63fdb69Smrg prev= 6648d63fdb69Smrg continue 6649d63fdb69Smrg ;; 6650d63fdb69Smrg self) 665152fd71cdSmrg if test dlprefiles = "$prev"; then 6652d63fdb69Smrg dlself=yes 665352fd71cdSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654d63fdb69Smrg dlself=yes 6655d63fdb69Smrg else 6656d63fdb69Smrg dlself=needless 6657d63fdb69Smrg export_dynamic=yes 6658d63fdb69Smrg fi 6659d63fdb69Smrg prev= 6660d63fdb69Smrg continue 66613da084b3Smrg ;; 66623da084b3Smrg *) 666352fd71cdSmrg if test dlfiles = "$prev"; then 666448c85eb7Smrg func_append dlfiles " $arg" 6665d63fdb69Smrg else 666648c85eb7Smrg func_append dlprefiles " $arg" 6667d63fdb69Smrg fi 6668d63fdb69Smrg prev= 6669d63fdb69Smrg continue 66703da084b3Smrg ;; 66713da084b3Smrg esac 6672d63fdb69Smrg ;; 6673d63fdb69Smrg expsyms) 667452fd71cdSmrg export_symbols=$arg 6675d63fdb69Smrg test -f "$arg" \ 667652fd71cdSmrg || func_fatal_error "symbol file '$arg' does not exist" 6677d63fdb69Smrg prev= 6678d63fdb69Smrg continue 6679d63fdb69Smrg ;; 6680d63fdb69Smrg expsyms_regex) 668152fd71cdSmrg export_symbols_regex=$arg 6682d63fdb69Smrg prev= 6683d63fdb69Smrg continue 6684d63fdb69Smrg ;; 6685d63fdb69Smrg framework) 6686d63fdb69Smrg case $host in 6687d63fdb69Smrg *-*-darwin*) 6688d63fdb69Smrg case "$deplibs " in 6689d63fdb69Smrg *" $qarg.ltframework "*) ;; 669048c85eb7Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691d63fdb69Smrg ;; 6692d63fdb69Smrg esac 6693d63fdb69Smrg ;; 6694d63fdb69Smrg esac 6695d63fdb69Smrg prev= 6696d63fdb69Smrg continue 6697d63fdb69Smrg ;; 6698d63fdb69Smrg inst_prefix) 669952fd71cdSmrg inst_prefix_dir=$arg 670052fd71cdSmrg prev= 670152fd71cdSmrg continue 670252fd71cdSmrg ;; 670352fd71cdSmrg mllvm) 670452fd71cdSmrg # Clang does not use LLVM to link, so we can simply discard any 670552fd71cdSmrg # '-mllvm $arg' options when doing the link step. 6706d63fdb69Smrg prev= 6707d63fdb69Smrg continue 6708d63fdb69Smrg ;; 6709d63fdb69Smrg objectlist) 6710d63fdb69Smrg if test -f "$arg"; then 6711d63fdb69Smrg save_arg=$arg 6712d63fdb69Smrg moreargs= 6713d63fdb69Smrg for fil in `cat "$save_arg"` 6714d63fdb69Smrg do 671548c85eb7Smrg# func_append moreargs " $fil" 6716d63fdb69Smrg arg=$fil 6717d63fdb69Smrg # A libtool-controlled object. 67183da084b3Smrg 6719d63fdb69Smrg # Check to see that this really is a libtool object. 6720d63fdb69Smrg if func_lalib_unsafe_p "$arg"; then 6721d63fdb69Smrg pic_object= 6722d63fdb69Smrg non_pic_object= 67233da084b3Smrg 6724d63fdb69Smrg # Read the .lo file 6725d63fdb69Smrg func_source "$arg" 67263da084b3Smrg 6727d63fdb69Smrg if test -z "$pic_object" || 6728d63fdb69Smrg test -z "$non_pic_object" || 672952fd71cdSmrg test none = "$pic_object" && 673052fd71cdSmrg test none = "$non_pic_object"; then 673152fd71cdSmrg func_fatal_error "cannot find name of object for '$arg'" 6732d63fdb69Smrg fi 67333da084b3Smrg 6734d63fdb69Smrg # Extract subdirectory from the argument. 6735d63fdb69Smrg func_dirname "$arg" "/" "" 673652fd71cdSmrg xdir=$func_dirname_result 67373da084b3Smrg 673852fd71cdSmrg if test none != "$pic_object"; then 6739d63fdb69Smrg # Prepend the subdirectory the object is found in. 674052fd71cdSmrg pic_object=$xdir$pic_object 67413da084b3Smrg 674252fd71cdSmrg if test dlfiles = "$prev"; then 674352fd71cdSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674448c85eb7Smrg func_append dlfiles " $pic_object" 6745d63fdb69Smrg prev= 6746d63fdb69Smrg continue 6747d63fdb69Smrg else 6748d63fdb69Smrg # If libtool objects are unsupported, then we need to preload. 6749d63fdb69Smrg prev=dlprefiles 6750d63fdb69Smrg fi 6751d63fdb69Smrg fi 67523da084b3Smrg 6753d63fdb69Smrg # CHECK ME: I think I busted this. -Ossama 675452fd71cdSmrg if test dlprefiles = "$prev"; then 6755d63fdb69Smrg # Preload the old-style object. 675648c85eb7Smrg func_append dlprefiles " $pic_object" 6757d63fdb69Smrg prev= 6758d63fdb69Smrg fi 67593da084b3Smrg 6760d63fdb69Smrg # A PIC object. 6761d63fdb69Smrg func_append libobjs " $pic_object" 676252fd71cdSmrg arg=$pic_object 6763d63fdb69Smrg fi 67643da084b3Smrg 6765d63fdb69Smrg # Non-PIC object. 676652fd71cdSmrg if test none != "$non_pic_object"; then 6767d63fdb69Smrg # Prepend the subdirectory the object is found in. 676852fd71cdSmrg non_pic_object=$xdir$non_pic_object 67693da084b3Smrg 6770d63fdb69Smrg # A standard non-PIC object 6771d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 677252fd71cdSmrg if test -z "$pic_object" || test none = "$pic_object"; then 677352fd71cdSmrg arg=$non_pic_object 6774d63fdb69Smrg fi 6775d63fdb69Smrg else 6776d63fdb69Smrg # If the PIC object exists, use it instead. 6777d63fdb69Smrg # $xdir was prepended to $pic_object above. 677852fd71cdSmrg non_pic_object=$pic_object 6779d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 6780d63fdb69Smrg fi 6781d63fdb69Smrg else 6782d63fdb69Smrg # Only an error if not doing a dry-run. 6783d63fdb69Smrg if $opt_dry_run; then 6784d63fdb69Smrg # Extract subdirectory from the argument. 6785d63fdb69Smrg func_dirname "$arg" "/" "" 678652fd71cdSmrg xdir=$func_dirname_result 6787d63fdb69Smrg 6788d63fdb69Smrg func_lo2o "$arg" 6789d63fdb69Smrg pic_object=$xdir$objdir/$func_lo2o_result 6790d63fdb69Smrg non_pic_object=$xdir$func_lo2o_result 6791d63fdb69Smrg func_append libobjs " $pic_object" 6792d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 6793d63fdb69Smrg else 679452fd71cdSmrg func_fatal_error "'$arg' is not a valid libtool object" 6795d63fdb69Smrg fi 6796d63fdb69Smrg fi 6797d63fdb69Smrg done 6798d63fdb69Smrg else 679952fd71cdSmrg func_fatal_error "link input file '$arg' does not exist" 6800d63fdb69Smrg fi 6801d63fdb69Smrg arg=$save_arg 6802d63fdb69Smrg prev= 6803d63fdb69Smrg continue 6804d63fdb69Smrg ;; 680552fd71cdSmrg os2dllname) 680652fd71cdSmrg os2dllname=$arg 680752fd71cdSmrg prev= 680852fd71cdSmrg continue 680952fd71cdSmrg ;; 6810d63fdb69Smrg precious_regex) 681152fd71cdSmrg precious_files_regex=$arg 6812d63fdb69Smrg prev= 6813d63fdb69Smrg continue 6814d63fdb69Smrg ;; 6815d63fdb69Smrg release) 681652fd71cdSmrg release=-$arg 6817d63fdb69Smrg prev= 6818d63fdb69Smrg continue 6819d63fdb69Smrg ;; 6820d63fdb69Smrg rpath | xrpath) 6821d63fdb69Smrg # We need an absolute path. 6822d63fdb69Smrg case $arg in 6823d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824d63fdb69Smrg *) 6825d63fdb69Smrg func_fatal_error "only absolute run-paths are allowed" 6826d63fdb69Smrg ;; 6827d63fdb69Smrg esac 682852fd71cdSmrg if test rpath = "$prev"; then 6829d63fdb69Smrg case "$rpath " in 6830d63fdb69Smrg *" $arg "*) ;; 683148c85eb7Smrg *) func_append rpath " $arg" ;; 6832d63fdb69Smrg esac 6833d63fdb69Smrg else 6834d63fdb69Smrg case "$xrpath " in 6835d63fdb69Smrg *" $arg "*) ;; 683648c85eb7Smrg *) func_append xrpath " $arg" ;; 6837d63fdb69Smrg esac 6838d63fdb69Smrg fi 6839d63fdb69Smrg prev= 6840d63fdb69Smrg continue 6841d63fdb69Smrg ;; 6842d63fdb69Smrg shrext) 684352fd71cdSmrg shrext_cmds=$arg 6844d63fdb69Smrg prev= 6845d63fdb69Smrg continue 6846d63fdb69Smrg ;; 6847d63fdb69Smrg weak) 684848c85eb7Smrg func_append weak_libs " $arg" 6849d63fdb69Smrg prev= 6850d63fdb69Smrg continue 6851d63fdb69Smrg ;; 6852d63fdb69Smrg xcclinker) 685348c85eb7Smrg func_append linker_flags " $qarg" 685448c85eb7Smrg func_append compiler_flags " $qarg" 6855d63fdb69Smrg prev= 6856d63fdb69Smrg func_append compile_command " $qarg" 6857d63fdb69Smrg func_append finalize_command " $qarg" 6858d63fdb69Smrg continue 6859d63fdb69Smrg ;; 6860d63fdb69Smrg xcompiler) 686148c85eb7Smrg func_append compiler_flags " $qarg" 6862d63fdb69Smrg prev= 6863d63fdb69Smrg func_append compile_command " $qarg" 6864d63fdb69Smrg func_append finalize_command " $qarg" 6865d63fdb69Smrg continue 6866d63fdb69Smrg ;; 6867d63fdb69Smrg xlinker) 686848c85eb7Smrg func_append linker_flags " $qarg" 686948c85eb7Smrg func_append compiler_flags " $wl$qarg" 6870d63fdb69Smrg prev= 6871d63fdb69Smrg func_append compile_command " $wl$qarg" 6872d63fdb69Smrg func_append finalize_command " $wl$qarg" 6873d63fdb69Smrg continue 6874d63fdb69Smrg ;; 6875d63fdb69Smrg *) 6876d63fdb69Smrg eval "$prev=\"\$arg\"" 6877d63fdb69Smrg prev= 6878d63fdb69Smrg continue 6879d63fdb69Smrg ;; 68803da084b3Smrg esac 6881d63fdb69Smrg fi # test -n "$prev" 68823da084b3Smrg 688352fd71cdSmrg prevarg=$arg 68843da084b3Smrg 6885d63fdb69Smrg case $arg in 6886d63fdb69Smrg -all-static) 6887d63fdb69Smrg if test -n "$link_static_flag"; then 6888d63fdb69Smrg # See comment for -static flag below, for more details. 6889d63fdb69Smrg func_append compile_command " $link_static_flag" 6890d63fdb69Smrg func_append finalize_command " $link_static_flag" 6891d63fdb69Smrg fi 6892d63fdb69Smrg continue 6893d63fdb69Smrg ;; 68943da084b3Smrg 6895d63fdb69Smrg -allow-undefined) 6896d63fdb69Smrg # FIXME: remove this flag sometime in the future. 689752fd71cdSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898d63fdb69Smrg ;; 68993da084b3Smrg 6900d63fdb69Smrg -avoid-version) 6901d63fdb69Smrg avoid_version=yes 6902d63fdb69Smrg continue 6903d63fdb69Smrg ;; 69043da084b3Smrg 690555acc8fcSmrg -bindir) 690655acc8fcSmrg prev=bindir 690755acc8fcSmrg continue 690855acc8fcSmrg ;; 690955acc8fcSmrg 6910d63fdb69Smrg -dlopen) 6911d63fdb69Smrg prev=dlfiles 6912d63fdb69Smrg continue 6913d63fdb69Smrg ;; 69143da084b3Smrg 6915d63fdb69Smrg -dlpreopen) 6916d63fdb69Smrg prev=dlprefiles 6917d63fdb69Smrg continue 6918d63fdb69Smrg ;; 69193da084b3Smrg 6920d63fdb69Smrg -export-dynamic) 6921d63fdb69Smrg export_dynamic=yes 6922d63fdb69Smrg continue 6923d63fdb69Smrg ;; 69243da084b3Smrg 6925d63fdb69Smrg -export-symbols | -export-symbols-regex) 6926d63fdb69Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927d63fdb69Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928d63fdb69Smrg fi 692952fd71cdSmrg if test X-export-symbols = "X$arg"; then 6930d63fdb69Smrg prev=expsyms 6931d63fdb69Smrg else 6932d63fdb69Smrg prev=expsyms_regex 6933d63fdb69Smrg fi 6934d63fdb69Smrg continue 6935d63fdb69Smrg ;; 69363da084b3Smrg 6937d63fdb69Smrg -framework) 6938d63fdb69Smrg prev=framework 6939d63fdb69Smrg continue 6940d63fdb69Smrg ;; 69413da084b3Smrg 6942d63fdb69Smrg -inst-prefix-dir) 6943d63fdb69Smrg prev=inst_prefix 6944d63fdb69Smrg continue 6945d63fdb69Smrg ;; 69463da084b3Smrg 6947d63fdb69Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948d63fdb69Smrg # so, if we see these flags be careful not to treat them like -L 6949d63fdb69Smrg -L[A-Z][A-Z]*:*) 6950d63fdb69Smrg case $with_gcc/$host in 6951d63fdb69Smrg no/*-*-irix* | /*-*-irix*) 6952d63fdb69Smrg func_append compile_command " $arg" 6953d63fdb69Smrg func_append finalize_command " $arg" 6954d63fdb69Smrg ;; 6955d63fdb69Smrg esac 6956d63fdb69Smrg continue 6957d63fdb69Smrg ;; 69583da084b3Smrg 6959d63fdb69Smrg -L*) 696048c85eb7Smrg func_stripname "-L" '' "$arg" 696148c85eb7Smrg if test -z "$func_stripname_result"; then 6962d63fdb69Smrg if test "$#" -gt 0; then 696352fd71cdSmrg func_fatal_error "require no space between '-L' and '$1'" 6964d63fdb69Smrg else 696552fd71cdSmrg func_fatal_error "need path for '-L' option" 6966d63fdb69Smrg fi 6967d63fdb69Smrg fi 696848c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 696948c85eb7Smrg dir=$func_resolve_sysroot_result 6970d63fdb69Smrg # We need an absolute path. 6971d63fdb69Smrg case $dir in 6972d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973d63fdb69Smrg *) 6974d63fdb69Smrg absdir=`cd "$dir" && pwd` 6975d63fdb69Smrg test -z "$absdir" && \ 697652fd71cdSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697752fd71cdSmrg dir=$absdir 6978d63fdb69Smrg ;; 6979d63fdb69Smrg esac 6980d63fdb69Smrg case "$deplibs " in 698148c85eb7Smrg *" -L$dir "* | *" $arg "*) 698248c85eb7Smrg # Will only happen for absolute or sysroot arguments 698348c85eb7Smrg ;; 6984d63fdb69Smrg *) 698548c85eb7Smrg # Preserve sysroot, but never include relative directories 698648c85eb7Smrg case $dir in 698748c85eb7Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698848c85eb7Smrg *) func_append deplibs " -L$dir" ;; 698948c85eb7Smrg esac 699048c85eb7Smrg func_append lib_search_path " $dir" 6991d63fdb69Smrg ;; 6992d63fdb69Smrg esac 6993d63fdb69Smrg case $host in 6994d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699555acc8fcSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996d63fdb69Smrg case :$dllsearchpath: in 6997d63fdb69Smrg *":$dir:"*) ;; 6998d63fdb69Smrg ::) dllsearchpath=$dir;; 699948c85eb7Smrg *) func_append dllsearchpath ":$dir";; 7000d63fdb69Smrg esac 7001d63fdb69Smrg case :$dllsearchpath: in 7002d63fdb69Smrg *":$testbindir:"*) ;; 7003d63fdb69Smrg ::) dllsearchpath=$testbindir;; 700448c85eb7Smrg *) func_append dllsearchpath ":$testbindir";; 7005d63fdb69Smrg esac 7006d63fdb69Smrg ;; 7007d63fdb69Smrg esac 7008d63fdb69Smrg continue 7009d63fdb69Smrg ;; 70103da084b3Smrg 7011d63fdb69Smrg -l*) 701252fd71cdSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013d63fdb69Smrg case $host in 701455acc8fcSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015d63fdb69Smrg # These systems don't actually have a C or math library (as such) 7016d63fdb69Smrg continue 7017d63fdb69Smrg ;; 7018d63fdb69Smrg *-*-os2*) 7019d63fdb69Smrg # These systems don't actually have a C library (as such) 702052fd71cdSmrg test X-lc = "X$arg" && continue 7021d63fdb69Smrg ;; 702252fd71cdSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023d63fdb69Smrg # Do not include libc due to us having libc/libc_r. 702452fd71cdSmrg test X-lc = "X$arg" && continue 7025d63fdb69Smrg ;; 7026d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7027d63fdb69Smrg # Rhapsody C and math libraries are in the System framework 702848c85eb7Smrg func_append deplibs " System.ltframework" 7029d63fdb69Smrg continue 7030d63fdb69Smrg ;; 7031d63fdb69Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7032d63fdb69Smrg # Causes problems with __ctype 703352fd71cdSmrg test X-lc = "X$arg" && continue 7034d63fdb69Smrg ;; 7035d63fdb69Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036d63fdb69Smrg # Compiler inserts libc in the correct place for threads to work 703752fd71cdSmrg test X-lc = "X$arg" && continue 7038d63fdb69Smrg ;; 7039d63fdb69Smrg esac 704052fd71cdSmrg elif test X-lc_r = "X$arg"; then 7041d63fdb69Smrg case $host in 704252fd71cdSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043d63fdb69Smrg # Do not include libc_r directly, use -pthread flag. 7044d63fdb69Smrg continue 7045d63fdb69Smrg ;; 7046d63fdb69Smrg esac 7047d63fdb69Smrg fi 704848c85eb7Smrg func_append deplibs " $arg" 7049d63fdb69Smrg continue 7050d63fdb69Smrg ;; 70513da084b3Smrg 705252fd71cdSmrg -mllvm) 705352fd71cdSmrg prev=mllvm 705452fd71cdSmrg continue 705552fd71cdSmrg ;; 705652fd71cdSmrg 7057d63fdb69Smrg -module) 7058d63fdb69Smrg module=yes 7059d63fdb69Smrg continue 7060d63fdb69Smrg ;; 70613da084b3Smrg 7062d63fdb69Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063d63fdb69Smrg # classes, name mangling, and exception handling. 7064d63fdb69Smrg # Darwin uses the -arch flag to determine output architecture. 706548c85eb7Smrg -model|-arch|-isysroot|--sysroot) 706648c85eb7Smrg func_append compiler_flags " $arg" 7067d63fdb69Smrg func_append compile_command " $arg" 7068d63fdb69Smrg func_append finalize_command " $arg" 7069d63fdb69Smrg prev=xcompiler 7070d63fdb69Smrg continue 7071d63fdb69Smrg ;; 70723da084b3Smrg 707348c85eb7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 707448c85eb7Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707548c85eb7Smrg func_append compiler_flags " $arg" 7076d63fdb69Smrg func_append compile_command " $arg" 7077d63fdb69Smrg func_append finalize_command " $arg" 7078d63fdb69Smrg case "$new_inherited_linker_flags " in 7079d63fdb69Smrg *" $arg "*) ;; 708048c85eb7Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081d63fdb69Smrg esac 7082d63fdb69Smrg continue 7083d63fdb69Smrg ;; 70843da084b3Smrg 7085d63fdb69Smrg -multi_module) 708652fd71cdSmrg single_module=$wl-multi_module 7087d63fdb69Smrg continue 7088d63fdb69Smrg ;; 70893da084b3Smrg 7090d63fdb69Smrg -no-fast-install) 7091d63fdb69Smrg fast_install=no 7092d63fdb69Smrg continue 7093d63fdb69Smrg ;; 70943da084b3Smrg 7095d63fdb69Smrg -no-install) 7096d63fdb69Smrg case $host in 7097d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098d63fdb69Smrg # The PATH hackery in wrapper scripts is required on Windows 7099d63fdb69Smrg # and Darwin in order for the loader to find any dlls it needs. 710052fd71cdSmrg func_warning "'-no-install' is ignored for $host" 710152fd71cdSmrg func_warning "assuming '-no-fast-install' instead" 7102d63fdb69Smrg fast_install=no 7103d63fdb69Smrg ;; 7104d63fdb69Smrg *) no_install=yes ;; 7105d63fdb69Smrg esac 7106d63fdb69Smrg continue 7107d63fdb69Smrg ;; 71083da084b3Smrg 7109d63fdb69Smrg -no-undefined) 7110d63fdb69Smrg allow_undefined=no 7111d63fdb69Smrg continue 7112d63fdb69Smrg ;; 71133da084b3Smrg 7114d63fdb69Smrg -objectlist) 7115d63fdb69Smrg prev=objectlist 7116d63fdb69Smrg continue 7117d63fdb69Smrg ;; 71183da084b3Smrg 711952fd71cdSmrg -os2dllname) 712052fd71cdSmrg prev=os2dllname 712152fd71cdSmrg continue 712252fd71cdSmrg ;; 712352fd71cdSmrg 7124d63fdb69Smrg -o) prev=output ;; 71253da084b3Smrg 7126d63fdb69Smrg -precious-files-regex) 7127d63fdb69Smrg prev=precious_regex 7128d63fdb69Smrg continue 7129d63fdb69Smrg ;; 71303da084b3Smrg 7131d63fdb69Smrg -release) 7132d63fdb69Smrg prev=release 7133d63fdb69Smrg continue 7134d63fdb69Smrg ;; 71353da084b3Smrg 7136d63fdb69Smrg -rpath) 7137d63fdb69Smrg prev=rpath 7138d63fdb69Smrg continue 7139d63fdb69Smrg ;; 71403da084b3Smrg 7141d63fdb69Smrg -R) 7142d63fdb69Smrg prev=xrpath 7143d63fdb69Smrg continue 7144d63fdb69Smrg ;; 71453da084b3Smrg 7146d63fdb69Smrg -R*) 7147d63fdb69Smrg func_stripname '-R' '' "$arg" 7148d63fdb69Smrg dir=$func_stripname_result 7149d63fdb69Smrg # We need an absolute path. 7150d63fdb69Smrg case $dir in 7151d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715248c85eb7Smrg =*) 715348c85eb7Smrg func_stripname '=' '' "$dir" 715448c85eb7Smrg dir=$lt_sysroot$func_stripname_result 715548c85eb7Smrg ;; 7156d63fdb69Smrg *) 7157d63fdb69Smrg func_fatal_error "only absolute run-paths are allowed" 7158d63fdb69Smrg ;; 7159d63fdb69Smrg esac 7160d63fdb69Smrg case "$xrpath " in 7161d63fdb69Smrg *" $dir "*) ;; 716248c85eb7Smrg *) func_append xrpath " $dir" ;; 7163d63fdb69Smrg esac 7164d63fdb69Smrg continue 7165d63fdb69Smrg ;; 71663da084b3Smrg 7167d63fdb69Smrg -shared) 7168d63fdb69Smrg # The effects of -shared are defined in a previous loop. 7169d63fdb69Smrg continue 7170d63fdb69Smrg ;; 71713da084b3Smrg 7172d63fdb69Smrg -shrext) 7173d63fdb69Smrg prev=shrext 7174d63fdb69Smrg continue 7175d63fdb69Smrg ;; 71763da084b3Smrg 7177d63fdb69Smrg -static | -static-libtool-libs) 7178d63fdb69Smrg # The effects of -static are defined in a previous loop. 7179d63fdb69Smrg # We used to do the same as -all-static on platforms that 7180d63fdb69Smrg # didn't have a PIC flag, but the assumption that the effects 7181d63fdb69Smrg # would be equivalent was wrong. It would break on at least 7182d63fdb69Smrg # Digital Unix and AIX. 7183d63fdb69Smrg continue 7184d63fdb69Smrg ;; 71853da084b3Smrg 7186d63fdb69Smrg -thread-safe) 7187d63fdb69Smrg thread_safe=yes 7188d63fdb69Smrg continue 7189d63fdb69Smrg ;; 71903da084b3Smrg 7191d63fdb69Smrg -version-info) 7192d63fdb69Smrg prev=vinfo 7193d63fdb69Smrg continue 7194d63fdb69Smrg ;; 71953da084b3Smrg 7196d63fdb69Smrg -version-number) 7197d63fdb69Smrg prev=vinfo 7198d63fdb69Smrg vinfo_number=yes 7199d63fdb69Smrg continue 7200d63fdb69Smrg ;; 72013da084b3Smrg 7202d63fdb69Smrg -weak) 7203d63fdb69Smrg prev=weak 7204d63fdb69Smrg continue 7205d63fdb69Smrg ;; 72063da084b3Smrg 7207d63fdb69Smrg -Wc,*) 7208d63fdb69Smrg func_stripname '-Wc,' '' "$arg" 7209d63fdb69Smrg args=$func_stripname_result 7210d63fdb69Smrg arg= 721152fd71cdSmrg save_ifs=$IFS; IFS=, 7212d63fdb69Smrg for flag in $args; do 721352fd71cdSmrg IFS=$save_ifs 7214d63fdb69Smrg func_quote_for_eval "$flag" 721548c85eb7Smrg func_append arg " $func_quote_for_eval_result" 721648c85eb7Smrg func_append compiler_flags " $func_quote_for_eval_result" 7217d63fdb69Smrg done 721852fd71cdSmrg IFS=$save_ifs 7219d63fdb69Smrg func_stripname ' ' '' "$arg" 7220d63fdb69Smrg arg=$func_stripname_result 7221d63fdb69Smrg ;; 72223da084b3Smrg 7223d63fdb69Smrg -Wl,*) 7224d63fdb69Smrg func_stripname '-Wl,' '' "$arg" 7225d63fdb69Smrg args=$func_stripname_result 7226d63fdb69Smrg arg= 722752fd71cdSmrg save_ifs=$IFS; IFS=, 7228d63fdb69Smrg for flag in $args; do 722952fd71cdSmrg IFS=$save_ifs 7230d63fdb69Smrg func_quote_for_eval "$flag" 723148c85eb7Smrg func_append arg " $wl$func_quote_for_eval_result" 723248c85eb7Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 723348c85eb7Smrg func_append linker_flags " $func_quote_for_eval_result" 7234d63fdb69Smrg done 723552fd71cdSmrg IFS=$save_ifs 7236d63fdb69Smrg func_stripname ' ' '' "$arg" 7237d63fdb69Smrg arg=$func_stripname_result 7238d63fdb69Smrg ;; 72393da084b3Smrg 7240d63fdb69Smrg -Xcompiler) 7241d63fdb69Smrg prev=xcompiler 7242d63fdb69Smrg continue 7243d63fdb69Smrg ;; 72443da084b3Smrg 7245d63fdb69Smrg -Xlinker) 7246d63fdb69Smrg prev=xlinker 7247d63fdb69Smrg continue 7248d63fdb69Smrg ;; 72493da084b3Smrg 7250d63fdb69Smrg -XCClinker) 7251d63fdb69Smrg prev=xcclinker 7252d63fdb69Smrg continue 7253d63fdb69Smrg ;; 72543da084b3Smrg 7255d63fdb69Smrg # -msg_* for osf cc 7256d63fdb69Smrg -msg_*) 7257d63fdb69Smrg func_quote_for_eval "$arg" 725852fd71cdSmrg arg=$func_quote_for_eval_result 7259d63fdb69Smrg ;; 72603da084b3Smrg 726155acc8fcSmrg # Flags to be passed through unchanged, with rationale: 726255acc8fcSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726355acc8fcSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 726455acc8fcSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726555acc8fcSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726655acc8fcSmrg # -q* compiler args for the IBM compiler 726755acc8fcSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726855acc8fcSmrg # -F/path path to uninstalled frameworks, gcc on darwin 726955acc8fcSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727052fd71cdSmrg # -fstack-protector* stack protector flags for GCC 727155acc8fcSmrg # @file GCC response files 727255acc8fcSmrg # -tp=* Portland pgcc target processor selection 727348c85eb7Smrg # --sysroot=* for sysroot support 727452fd71cdSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 727552fd71cdSmrg # -stdlib=* select c++ std lib with clang 7276d63fdb69Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727748c85eb7Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 727852fd71cdSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279d63fdb69Smrg func_quote_for_eval "$arg" 728052fd71cdSmrg arg=$func_quote_for_eval_result 7281d63fdb69Smrg func_append compile_command " $arg" 7282d63fdb69Smrg func_append finalize_command " $arg" 728348c85eb7Smrg func_append compiler_flags " $arg" 7284d63fdb69Smrg continue 7285d63fdb69Smrg ;; 72863da084b3Smrg 728752fd71cdSmrg -Z*) 728852fd71cdSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 728952fd71cdSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 729052fd71cdSmrg compiler_flags="$compiler_flags $arg" 729152fd71cdSmrg func_append compile_command " $arg" 729252fd71cdSmrg func_append finalize_command " $arg" 729352fd71cdSmrg case $arg in 729452fd71cdSmrg -Zlinker | -Zstack) 729552fd71cdSmrg prev=xcompiler 729652fd71cdSmrg ;; 729752fd71cdSmrg esac 729852fd71cdSmrg continue 729952fd71cdSmrg else 730052fd71cdSmrg # Otherwise treat like 'Some other compiler flag' below 730152fd71cdSmrg func_quote_for_eval "$arg" 730252fd71cdSmrg arg=$func_quote_for_eval_result 730352fd71cdSmrg fi 730452fd71cdSmrg ;; 730552fd71cdSmrg 7306d63fdb69Smrg # Some other compiler flag. 7307d63fdb69Smrg -* | +*) 7308d63fdb69Smrg func_quote_for_eval "$arg" 730952fd71cdSmrg arg=$func_quote_for_eval_result 7310d63fdb69Smrg ;; 73113da084b3Smrg 7312d63fdb69Smrg *.$objext) 7313d63fdb69Smrg # A standard object. 731448c85eb7Smrg func_append objs " $arg" 7315d63fdb69Smrg ;; 73163da084b3Smrg 7317d63fdb69Smrg *.lo) 7318d63fdb69Smrg # A libtool-controlled object. 73193da084b3Smrg 7320d63fdb69Smrg # Check to see that this really is a libtool object. 7321d63fdb69Smrg if func_lalib_unsafe_p "$arg"; then 7322d63fdb69Smrg pic_object= 7323d63fdb69Smrg non_pic_object= 7324d63fdb69Smrg 7325d63fdb69Smrg # Read the .lo file 7326d63fdb69Smrg func_source "$arg" 7327d63fdb69Smrg 7328d63fdb69Smrg if test -z "$pic_object" || 7329d63fdb69Smrg test -z "$non_pic_object" || 733052fd71cdSmrg test none = "$pic_object" && 733152fd71cdSmrg test none = "$non_pic_object"; then 733252fd71cdSmrg func_fatal_error "cannot find name of object for '$arg'" 7333d63fdb69Smrg fi 7334d63fdb69Smrg 7335d63fdb69Smrg # Extract subdirectory from the argument. 7336d63fdb69Smrg func_dirname "$arg" "/" "" 733752fd71cdSmrg xdir=$func_dirname_result 7338d63fdb69Smrg 733952fd71cdSmrg test none = "$pic_object" || { 7340d63fdb69Smrg # Prepend the subdirectory the object is found in. 734152fd71cdSmrg pic_object=$xdir$pic_object 7342d63fdb69Smrg 734352fd71cdSmrg if test dlfiles = "$prev"; then 734452fd71cdSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734548c85eb7Smrg func_append dlfiles " $pic_object" 7346d63fdb69Smrg prev= 7347d63fdb69Smrg continue 7348d63fdb69Smrg else 7349d63fdb69Smrg # If libtool objects are unsupported, then we need to preload. 7350d63fdb69Smrg prev=dlprefiles 7351d63fdb69Smrg fi 7352d63fdb69Smrg fi 7353d63fdb69Smrg 7354d63fdb69Smrg # CHECK ME: I think I busted this. -Ossama 735552fd71cdSmrg if test dlprefiles = "$prev"; then 7356d63fdb69Smrg # Preload the old-style object. 735748c85eb7Smrg func_append dlprefiles " $pic_object" 7358d63fdb69Smrg prev= 7359d63fdb69Smrg fi 7360d63fdb69Smrg 7361d63fdb69Smrg # A PIC object. 7362d63fdb69Smrg func_append libobjs " $pic_object" 736352fd71cdSmrg arg=$pic_object 736452fd71cdSmrg } 7365d63fdb69Smrg 7366d63fdb69Smrg # Non-PIC object. 736752fd71cdSmrg if test none != "$non_pic_object"; then 7368d63fdb69Smrg # Prepend the subdirectory the object is found in. 736952fd71cdSmrg non_pic_object=$xdir$non_pic_object 7370d63fdb69Smrg 7371d63fdb69Smrg # A standard non-PIC object 7372d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 737352fd71cdSmrg if test -z "$pic_object" || test none = "$pic_object"; then 737452fd71cdSmrg arg=$non_pic_object 7375d63fdb69Smrg fi 7376d63fdb69Smrg else 7377d63fdb69Smrg # If the PIC object exists, use it instead. 7378d63fdb69Smrg # $xdir was prepended to $pic_object above. 737952fd71cdSmrg non_pic_object=$pic_object 7380d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 7381d63fdb69Smrg fi 7382d63fdb69Smrg else 7383d63fdb69Smrg # Only an error if not doing a dry-run. 7384d63fdb69Smrg if $opt_dry_run; then 7385d63fdb69Smrg # Extract subdirectory from the argument. 7386d63fdb69Smrg func_dirname "$arg" "/" "" 738752fd71cdSmrg xdir=$func_dirname_result 7388d63fdb69Smrg 7389d63fdb69Smrg func_lo2o "$arg" 7390d63fdb69Smrg pic_object=$xdir$objdir/$func_lo2o_result 7391d63fdb69Smrg non_pic_object=$xdir$func_lo2o_result 7392d63fdb69Smrg func_append libobjs " $pic_object" 7393d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 7394d63fdb69Smrg else 739552fd71cdSmrg func_fatal_error "'$arg' is not a valid libtool object" 7396d63fdb69Smrg fi 7397d63fdb69Smrg fi 7398d63fdb69Smrg ;; 7399d63fdb69Smrg 7400d63fdb69Smrg *.$libext) 7401d63fdb69Smrg # An archive. 740248c85eb7Smrg func_append deplibs " $arg" 740348c85eb7Smrg func_append old_deplibs " $arg" 7404d63fdb69Smrg continue 7405d63fdb69Smrg ;; 7406d63fdb69Smrg 7407d63fdb69Smrg *.la) 7408d63fdb69Smrg # A libtool-controlled library. 7409d63fdb69Smrg 741048c85eb7Smrg func_resolve_sysroot "$arg" 741152fd71cdSmrg if test dlfiles = "$prev"; then 7412d63fdb69Smrg # This library was specified with -dlopen. 741348c85eb7Smrg func_append dlfiles " $func_resolve_sysroot_result" 7414d63fdb69Smrg prev= 741552fd71cdSmrg elif test dlprefiles = "$prev"; then 7416d63fdb69Smrg # The library was specified with -dlpreopen. 741748c85eb7Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7418d63fdb69Smrg prev= 7419d63fdb69Smrg else 742048c85eb7Smrg func_append deplibs " $func_resolve_sysroot_result" 7421d63fdb69Smrg fi 7422d63fdb69Smrg continue 7423d63fdb69Smrg ;; 7424d63fdb69Smrg 7425d63fdb69Smrg # Some other compiler argument. 7426d63fdb69Smrg *) 7427d63fdb69Smrg # Unknown arguments in both finalize_command and compile_command need 7428d63fdb69Smrg # to be aesthetically quoted because they are evaled later. 7429d63fdb69Smrg func_quote_for_eval "$arg" 743052fd71cdSmrg arg=$func_quote_for_eval_result 7431d63fdb69Smrg ;; 7432d63fdb69Smrg esac # arg 7433d63fdb69Smrg 7434d63fdb69Smrg # Now actually substitute the argument into the commands. 7435d63fdb69Smrg if test -n "$arg"; then 7436d63fdb69Smrg func_append compile_command " $arg" 7437d63fdb69Smrg func_append finalize_command " $arg" 7438d63fdb69Smrg fi 7439d63fdb69Smrg done # argument parsing loop 7440d63fdb69Smrg 7441d63fdb69Smrg test -n "$prev" && \ 744252fd71cdSmrg func_fatal_help "the '$prevarg' option requires an argument" 7443d63fdb69Smrg 744452fd71cdSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445d63fdb69Smrg eval arg=\"$export_dynamic_flag_spec\" 7446d63fdb69Smrg func_append compile_command " $arg" 7447d63fdb69Smrg func_append finalize_command " $arg" 7448d63fdb69Smrg fi 7449d63fdb69Smrg 7450d63fdb69Smrg oldlibs= 7451d63fdb69Smrg # calculate the name of the file, without its directory 7452d63fdb69Smrg func_basename "$output" 745352fd71cdSmrg outputname=$func_basename_result 745452fd71cdSmrg libobjs_save=$libobjs 7455d63fdb69Smrg 7456d63fdb69Smrg if test -n "$shlibpath_var"; then 7457d63fdb69Smrg # get the directories listed in $shlibpath_var 745852fd71cdSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 74593da084b3Smrg else 7460d63fdb69Smrg shlib_search_path= 74613da084b3Smrg fi 7462d63fdb69Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463d63fdb69Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 74643da084b3Smrg 746552fd71cdSmrg # Definition is injected by LT_CONFIG during libtool generation. 746652fd71cdSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 746752fd71cdSmrg 7468d63fdb69Smrg func_dirname "$output" "/" "" 746952fd71cdSmrg output_objdir=$func_dirname_result$objdir 747048c85eb7Smrg func_to_tool_file "$output_objdir/" 747148c85eb7Smrg tool_output_objdir=$func_to_tool_file_result 7472d63fdb69Smrg # Create the object directory. 7473d63fdb69Smrg func_mkdir_p "$output_objdir" 74743da084b3Smrg 7475d63fdb69Smrg # Determine the type of output 7476d63fdb69Smrg case $output in 7477d63fdb69Smrg "") 7478d63fdb69Smrg func_fatal_help "you must specify an output file" 7479d63fdb69Smrg ;; 7480d63fdb69Smrg *.$libext) linkmode=oldlib ;; 7481d63fdb69Smrg *.lo | *.$objext) linkmode=obj ;; 7482d63fdb69Smrg *.la) linkmode=lib ;; 7483d63fdb69Smrg *) linkmode=prog ;; # Anything else should be a program. 7484d63fdb69Smrg esac 7485d63fdb69Smrg 7486d63fdb69Smrg specialdeplibs= 7487d63fdb69Smrg 7488d63fdb69Smrg libs= 7489d63fdb69Smrg # Find all interdependent deplibs by searching for libraries 7490d63fdb69Smrg # that are linked more than once (e.g. -la -lb -la) 7491d63fdb69Smrg for deplib in $deplibs; do 749252fd71cdSmrg if $opt_preserve_dup_deps; then 7493d63fdb69Smrg case "$libs " in 749448c85eb7Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495d63fdb69Smrg esac 7496d63fdb69Smrg fi 749748c85eb7Smrg func_append libs " $deplib" 7498d63fdb69Smrg done 7499d63fdb69Smrg 750052fd71cdSmrg if test lib = "$linkmode"; then 7501d63fdb69Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502d63fdb69Smrg 7503d63fdb69Smrg # Compute libraries that are listed more than once in $predeps 7504d63fdb69Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7505d63fdb69Smrg # not to be eliminated). 7506d63fdb69Smrg pre_post_deps= 7507d63fdb69Smrg if $opt_duplicate_compiler_generated_deps; then 7508d63fdb69Smrg for pre_post_dep in $predeps $postdeps; do 7509d63fdb69Smrg case "$pre_post_deps " in 751048c85eb7Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511d63fdb69Smrg esac 751248c85eb7Smrg func_append pre_post_deps " $pre_post_dep" 7513d63fdb69Smrg done 7514d63fdb69Smrg fi 7515d63fdb69Smrg pre_post_deps= 7516d63fdb69Smrg fi 7517d63fdb69Smrg 7518d63fdb69Smrg deplibs= 7519d63fdb69Smrg newdependency_libs= 7520d63fdb69Smrg newlib_search_path= 7521d63fdb69Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7522d63fdb69Smrg notinst_deplibs= # not-installed libtool libraries 7523d63fdb69Smrg notinst_path= # paths that contain not-installed libtool libraries 7524d63fdb69Smrg 7525d63fdb69Smrg case $linkmode in 7526d63fdb69Smrg lib) 7527d63fdb69Smrg passes="conv dlpreopen link" 7528d63fdb69Smrg for file in $dlfiles $dlprefiles; do 7529d63fdb69Smrg case $file in 7530d63fdb69Smrg *.la) ;; 7531d63fdb69Smrg *) 753252fd71cdSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533d63fdb69Smrg ;; 7534d63fdb69Smrg esac 7535d63fdb69Smrg done 7536d63fdb69Smrg ;; 7537d63fdb69Smrg prog) 7538d63fdb69Smrg compile_deplibs= 7539d63fdb69Smrg finalize_deplibs= 754052fd71cdSmrg alldeplibs=false 7541d63fdb69Smrg newdlfiles= 7542d63fdb69Smrg newdlprefiles= 7543d63fdb69Smrg passes="conv scan dlopen dlpreopen link" 7544d63fdb69Smrg ;; 7545d63fdb69Smrg *) passes="conv" 7546d63fdb69Smrg ;; 7547d63fdb69Smrg esac 7548d63fdb69Smrg 7549d63fdb69Smrg for pass in $passes; do 7550d63fdb69Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7551d63fdb69Smrg # so that -L comes before libs that need it for instance... 755252fd71cdSmrg if test lib,link = "$linkmode,$pass"; then 7553d63fdb69Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7554d63fdb69Smrg ## order, and fix it there properly 7555d63fdb69Smrg tmp_deplibs= 7556d63fdb69Smrg for deplib in $deplibs; do 7557d63fdb69Smrg tmp_deplibs="$deplib $tmp_deplibs" 7558d63fdb69Smrg done 755952fd71cdSmrg deplibs=$tmp_deplibs 7560d63fdb69Smrg fi 7561d63fdb69Smrg 756252fd71cdSmrg if test lib,link = "$linkmode,$pass" || 756352fd71cdSmrg test prog,scan = "$linkmode,$pass"; then 756452fd71cdSmrg libs=$deplibs 7565d63fdb69Smrg deplibs= 7566d63fdb69Smrg fi 756752fd71cdSmrg if test prog = "$linkmode"; then 7568d63fdb69Smrg case $pass in 756952fd71cdSmrg dlopen) libs=$dlfiles ;; 757052fd71cdSmrg dlpreopen) libs=$dlprefiles ;; 7571d63fdb69Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572d63fdb69Smrg esac 7573d63fdb69Smrg fi 757452fd71cdSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7575d63fdb69Smrg # Collect and forward deplibs of preopened libtool libs 7576d63fdb69Smrg for lib in $dlprefiles; do 7577d63fdb69Smrg # Ignore non-libtool-libs 7578d63fdb69Smrg dependency_libs= 757948c85eb7Smrg func_resolve_sysroot "$lib" 7580d63fdb69Smrg case $lib in 758148c85eb7Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7582d63fdb69Smrg esac 7583d63fdb69Smrg 7584d63fdb69Smrg # Collect preopened libtool deplibs, except any this library 7585d63fdb69Smrg # has declared as weak libs 7586d63fdb69Smrg for deplib in $dependency_libs; do 758755acc8fcSmrg func_basename "$deplib" 758855acc8fcSmrg deplib_base=$func_basename_result 7589d63fdb69Smrg case " $weak_libs " in 7590d63fdb69Smrg *" $deplib_base "*) ;; 759148c85eb7Smrg *) func_append deplibs " $deplib" ;; 7592d63fdb69Smrg esac 7593d63fdb69Smrg done 7594d63fdb69Smrg done 759552fd71cdSmrg libs=$dlprefiles 7596d63fdb69Smrg fi 759752fd71cdSmrg if test dlopen = "$pass"; then 7598d63fdb69Smrg # Collect dlpreopened libraries 759952fd71cdSmrg save_deplibs=$deplibs 7600d63fdb69Smrg deplibs= 7601d63fdb69Smrg fi 7602d63fdb69Smrg 7603d63fdb69Smrg for deplib in $libs; do 7604d63fdb69Smrg lib= 760552fd71cdSmrg found=false 7606d63fdb69Smrg case $deplib in 760748c85eb7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 760848c85eb7Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 760952fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 7610d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7611d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7612d63fdb69Smrg else 761348c85eb7Smrg func_append compiler_flags " $deplib" 761452fd71cdSmrg if test lib = "$linkmode"; then 7615d63fdb69Smrg case "$new_inherited_linker_flags " in 7616d63fdb69Smrg *" $deplib "*) ;; 761748c85eb7Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7618d63fdb69Smrg esac 7619d63fdb69Smrg fi 7620d63fdb69Smrg fi 7621d63fdb69Smrg continue 7622d63fdb69Smrg ;; 7623d63fdb69Smrg -l*) 762452fd71cdSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 762552fd71cdSmrg func_warning "'-l' is ignored for archives/objects" 7626d63fdb69Smrg continue 7627d63fdb69Smrg fi 7628d63fdb69Smrg func_stripname '-l' '' "$deplib" 7629d63fdb69Smrg name=$func_stripname_result 763052fd71cdSmrg if test lib = "$linkmode"; then 7631d63fdb69Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632d63fdb69Smrg else 7633d63fdb69Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634d63fdb69Smrg fi 7635d63fdb69Smrg for searchdir in $searchdirs; do 7636d63fdb69Smrg for search_ext in .la $std_shrext .so .a; do 7637d63fdb69Smrg # Search the libtool library 763852fd71cdSmrg lib=$searchdir/lib$name$search_ext 7639d63fdb69Smrg if test -f "$lib"; then 764052fd71cdSmrg if test .la = "$search_ext"; then 764152fd71cdSmrg found=: 7642d63fdb69Smrg else 764352fd71cdSmrg found=false 7644d63fdb69Smrg fi 7645d63fdb69Smrg break 2 7646d63fdb69Smrg fi 7647d63fdb69Smrg done 7648d63fdb69Smrg done 764952fd71cdSmrg if $found; then 765052fd71cdSmrg # deplib is a libtool library 7651d63fdb69Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652d63fdb69Smrg # We need to do some special things here, and not later. 765352fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654d63fdb69Smrg case " $predeps $postdeps " in 7655d63fdb69Smrg *" $deplib "*) 7656d63fdb69Smrg if func_lalib_p "$lib"; then 7657d63fdb69Smrg library_names= 7658d63fdb69Smrg old_library= 7659d63fdb69Smrg func_source "$lib" 7660d63fdb69Smrg for l in $old_library $library_names; do 766152fd71cdSmrg ll=$l 7662d63fdb69Smrg done 766352fd71cdSmrg if test "X$ll" = "X$old_library"; then # only static version available 766452fd71cdSmrg found=false 7665d63fdb69Smrg func_dirname "$lib" "" "." 766652fd71cdSmrg ladir=$func_dirname_result 7667d63fdb69Smrg lib=$ladir/$old_library 766852fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 7669d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7670d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7671d63fdb69Smrg else 7672d63fdb69Smrg deplibs="$deplib $deplibs" 767352fd71cdSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674d63fdb69Smrg fi 7675d63fdb69Smrg continue 7676d63fdb69Smrg fi 7677d63fdb69Smrg fi 7678d63fdb69Smrg ;; 7679d63fdb69Smrg *) ;; 7680d63fdb69Smrg esac 7681d63fdb69Smrg fi 768252fd71cdSmrg else 768352fd71cdSmrg # deplib doesn't seem to be a libtool library 768452fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 768552fd71cdSmrg compile_deplibs="$deplib $compile_deplibs" 768652fd71cdSmrg finalize_deplibs="$deplib $finalize_deplibs" 768752fd71cdSmrg else 768852fd71cdSmrg deplibs="$deplib $deplibs" 768952fd71cdSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769052fd71cdSmrg fi 769152fd71cdSmrg continue 7692d63fdb69Smrg fi 7693d63fdb69Smrg ;; # -l 7694d63fdb69Smrg *.ltframework) 769552fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 7696d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7697d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7698d63fdb69Smrg else 7699d63fdb69Smrg deplibs="$deplib $deplibs" 770052fd71cdSmrg if test lib = "$linkmode"; then 7701d63fdb69Smrg case "$new_inherited_linker_flags " in 7702d63fdb69Smrg *" $deplib "*) ;; 770348c85eb7Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7704d63fdb69Smrg esac 7705d63fdb69Smrg fi 7706d63fdb69Smrg fi 7707d63fdb69Smrg continue 7708d63fdb69Smrg ;; 7709d63fdb69Smrg -L*) 7710d63fdb69Smrg case $linkmode in 7711d63fdb69Smrg lib) 7712d63fdb69Smrg deplibs="$deplib $deplibs" 771352fd71cdSmrg test conv = "$pass" && continue 7714d63fdb69Smrg newdependency_libs="$deplib $newdependency_libs" 7715d63fdb69Smrg func_stripname '-L' '' "$deplib" 771648c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 771748c85eb7Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7718d63fdb69Smrg ;; 7719d63fdb69Smrg prog) 772052fd71cdSmrg if test conv = "$pass"; then 7721d63fdb69Smrg deplibs="$deplib $deplibs" 7722d63fdb69Smrg continue 7723d63fdb69Smrg fi 772452fd71cdSmrg if test scan = "$pass"; then 7725d63fdb69Smrg deplibs="$deplib $deplibs" 7726d63fdb69Smrg else 7727d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7728d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7729d63fdb69Smrg fi 7730d63fdb69Smrg func_stripname '-L' '' "$deplib" 773148c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 773248c85eb7Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7733d63fdb69Smrg ;; 7734d63fdb69Smrg *) 773552fd71cdSmrg func_warning "'-L' is ignored for archives/objects" 7736d63fdb69Smrg ;; 7737d63fdb69Smrg esac # linkmode 7738d63fdb69Smrg continue 7739d63fdb69Smrg ;; # -L 7740d63fdb69Smrg -R*) 774152fd71cdSmrg if test link = "$pass"; then 7742d63fdb69Smrg func_stripname '-R' '' "$deplib" 774348c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 774448c85eb7Smrg dir=$func_resolve_sysroot_result 7745d63fdb69Smrg # Make sure the xrpath contains only unique directories. 7746d63fdb69Smrg case "$xrpath " in 7747d63fdb69Smrg *" $dir "*) ;; 774848c85eb7Smrg *) func_append xrpath " $dir" ;; 7749d63fdb69Smrg esac 7750d63fdb69Smrg fi 7751d63fdb69Smrg deplibs="$deplib $deplibs" 7752d63fdb69Smrg continue 7753d63fdb69Smrg ;; 775448c85eb7Smrg *.la) 775548c85eb7Smrg func_resolve_sysroot "$deplib" 775648c85eb7Smrg lib=$func_resolve_sysroot_result 775748c85eb7Smrg ;; 7758d63fdb69Smrg *.$libext) 775952fd71cdSmrg if test conv = "$pass"; then 7760d63fdb69Smrg deplibs="$deplib $deplibs" 7761d63fdb69Smrg continue 7762d63fdb69Smrg fi 7763d63fdb69Smrg case $linkmode in 7764d63fdb69Smrg lib) 7765d63fdb69Smrg # Linking convenience modules into shared libraries is allowed, 7766d63fdb69Smrg # but linking other static libraries is non-portable. 7767d63fdb69Smrg case " $dlpreconveniencelibs " in 7768d63fdb69Smrg *" $deplib "*) ;; 7769d63fdb69Smrg *) 777052fd71cdSmrg valid_a_lib=false 7771d63fdb69Smrg case $deplibs_check_method in 7772d63fdb69Smrg match_pattern*) 7773d63fdb69Smrg set dummy $deplibs_check_method; shift 7774d63fdb69Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777555acc8fcSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776d63fdb69Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 777752fd71cdSmrg valid_a_lib=: 7778d63fdb69Smrg fi 7779d63fdb69Smrg ;; 7780d63fdb69Smrg pass_all) 778152fd71cdSmrg valid_a_lib=: 7782d63fdb69Smrg ;; 7783d63fdb69Smrg esac 778452fd71cdSmrg if $valid_a_lib; then 778552fd71cdSmrg echo 778652fd71cdSmrg $ECHO "*** Warning: Linking the shared library $output against the" 778752fd71cdSmrg $ECHO "*** static library $deplib is not portable!" 778852fd71cdSmrg deplibs="$deplib $deplibs" 778952fd71cdSmrg else 779055acc8fcSmrg echo 7791d63fdb69Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779255acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 779355acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 779455acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 779555acc8fcSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 779655acc8fcSmrg echo "*** that it is just a static archive that I should not use here." 7797d63fdb69Smrg fi 7798d63fdb69Smrg ;; 7799d63fdb69Smrg esac 7800d63fdb69Smrg continue 7801d63fdb69Smrg ;; 7802d63fdb69Smrg prog) 780352fd71cdSmrg if test link != "$pass"; then 7804d63fdb69Smrg deplibs="$deplib $deplibs" 7805d63fdb69Smrg else 7806d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7807d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7808d63fdb69Smrg fi 7809d63fdb69Smrg continue 7810d63fdb69Smrg ;; 7811d63fdb69Smrg esac # linkmode 7812d63fdb69Smrg ;; # *.$libext 7813d63fdb69Smrg *.lo | *.$objext) 781452fd71cdSmrg if test conv = "$pass"; then 7815d63fdb69Smrg deplibs="$deplib $deplibs" 781652fd71cdSmrg elif test prog = "$linkmode"; then 781752fd71cdSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818d63fdb69Smrg # If there is no dlopen support or we're linking statically, 7819d63fdb69Smrg # we need to preload. 782048c85eb7Smrg func_append newdlprefiles " $deplib" 7821d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7822d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7823d63fdb69Smrg else 782448c85eb7Smrg func_append newdlfiles " $deplib" 7825d63fdb69Smrg fi 7826d63fdb69Smrg fi 7827d63fdb69Smrg continue 7828d63fdb69Smrg ;; 7829d63fdb69Smrg %DEPLIBS%) 783052fd71cdSmrg alldeplibs=: 7831d63fdb69Smrg continue 7832d63fdb69Smrg ;; 7833d63fdb69Smrg esac # case $deplib 7834d63fdb69Smrg 783552fd71cdSmrg $found || test -f "$lib" \ 783652fd71cdSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837d63fdb69Smrg 7838d63fdb69Smrg # Check to see that this really is a libtool archive. 7839d63fdb69Smrg func_lalib_unsafe_p "$lib" \ 784052fd71cdSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7841d63fdb69Smrg 7842d63fdb69Smrg func_dirname "$lib" "" "." 784352fd71cdSmrg ladir=$func_dirname_result 7844d63fdb69Smrg 7845d63fdb69Smrg dlname= 7846d63fdb69Smrg dlopen= 7847d63fdb69Smrg dlpreopen= 7848d63fdb69Smrg libdir= 7849d63fdb69Smrg library_names= 7850d63fdb69Smrg old_library= 7851d63fdb69Smrg inherited_linker_flags= 7852d63fdb69Smrg # If the library was installed with an old release of libtool, 7853d63fdb69Smrg # it will not redefine variables installed, or shouldnotlink 7854d63fdb69Smrg installed=yes 7855d63fdb69Smrg shouldnotlink=no 7856d63fdb69Smrg avoidtemprpath= 7857d63fdb69Smrg 7858d63fdb69Smrg 7859d63fdb69Smrg # Read the .la file 7860d63fdb69Smrg func_source "$lib" 7861d63fdb69Smrg 7862d63fdb69Smrg # Convert "-framework foo" to "foo.ltframework" 7863d63fdb69Smrg if test -n "$inherited_linker_flags"; then 786455acc8fcSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865d63fdb69Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866d63fdb69Smrg case " $new_inherited_linker_flags " in 7867d63fdb69Smrg *" $tmp_inherited_linker_flag "*) ;; 786848c85eb7Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869d63fdb69Smrg esac 7870d63fdb69Smrg done 7871d63fdb69Smrg fi 787255acc8fcSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787352fd71cdSmrg if test lib,link = "$linkmode,$pass" || 787452fd71cdSmrg test prog,scan = "$linkmode,$pass" || 787552fd71cdSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 787648c85eb7Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 787748c85eb7Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878d63fdb69Smrg fi 7879d63fdb69Smrg 788052fd71cdSmrg if test conv = "$pass"; then 7881d63fdb69Smrg # Only check for convenience libraries 7882d63fdb69Smrg deplibs="$lib $deplibs" 7883d63fdb69Smrg if test -z "$libdir"; then 7884d63fdb69Smrg if test -z "$old_library"; then 788552fd71cdSmrg func_fatal_error "cannot find name of link library for '$lib'" 7886d63fdb69Smrg fi 7887d63fdb69Smrg # It is a libtool convenience library, so add in its objects. 788848c85eb7Smrg func_append convenience " $ladir/$objdir/$old_library" 788948c85eb7Smrg func_append old_convenience " $ladir/$objdir/$old_library" 789052fd71cdSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 789152fd71cdSmrg func_fatal_error "'$lib' is not a convenience library" 7892d63fdb69Smrg fi 7893d63fdb69Smrg tmp_libs= 7894d63fdb69Smrg for deplib in $dependency_libs; do 7895d63fdb69Smrg deplibs="$deplib $deplibs" 789652fd71cdSmrg if $opt_preserve_dup_deps; then 7897d63fdb69Smrg case "$tmp_libs " in 789848c85eb7Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899d63fdb69Smrg esac 7900d63fdb69Smrg fi 790148c85eb7Smrg func_append tmp_libs " $deplib" 7902d63fdb69Smrg done 7903d63fdb69Smrg continue 7904d63fdb69Smrg fi # $pass = conv 7905d63fdb69Smrg 7906d63fdb69Smrg 7907d63fdb69Smrg # Get the name of the library we link against. 7908d63fdb69Smrg linklib= 790948c85eb7Smrg if test -n "$old_library" && 791052fd71cdSmrg { test yes = "$prefer_static_libs" || 791152fd71cdSmrg test built,no = "$prefer_static_libs,$installed"; }; then 791248c85eb7Smrg linklib=$old_library 791348c85eb7Smrg else 791448c85eb7Smrg for l in $old_library $library_names; do 791552fd71cdSmrg linklib=$l 791648c85eb7Smrg done 791748c85eb7Smrg fi 7918d63fdb69Smrg if test -z "$linklib"; then 791952fd71cdSmrg func_fatal_error "cannot find name of link library for '$lib'" 7920d63fdb69Smrg fi 7921d63fdb69Smrg 7922d63fdb69Smrg # This library was specified with -dlopen. 792352fd71cdSmrg if test dlopen = "$pass"; then 792452fd71cdSmrg test -z "$libdir" \ 792552fd71cdSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926d63fdb69Smrg if test -z "$dlname" || 792752fd71cdSmrg test yes != "$dlopen_support" || 792852fd71cdSmrg test no = "$build_libtool_libs" 792952fd71cdSmrg then 7930d63fdb69Smrg # If there is no dlname, no dlopen support or we're linking 7931d63fdb69Smrg # statically, we need to preload. We also need to preload any 7932d63fdb69Smrg # dependent libraries so libltdl's deplib preloader doesn't 7933d63fdb69Smrg # bomb out in the load deplibs phase. 793448c85eb7Smrg func_append dlprefiles " $lib $dependency_libs" 7935d63fdb69Smrg else 793648c85eb7Smrg func_append newdlfiles " $lib" 7937d63fdb69Smrg fi 7938d63fdb69Smrg continue 7939d63fdb69Smrg fi # $pass = dlopen 7940d63fdb69Smrg 7941d63fdb69Smrg # We need an absolute path. 7942d63fdb69Smrg case $ladir in 794352fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944d63fdb69Smrg *) 7945d63fdb69Smrg abs_ladir=`cd "$ladir" && pwd` 7946d63fdb69Smrg if test -z "$abs_ladir"; then 794752fd71cdSmrg func_warning "cannot determine absolute directory name of '$ladir'" 7948d63fdb69Smrg func_warning "passing it literally to the linker, although it might fail" 794952fd71cdSmrg abs_ladir=$ladir 7950d63fdb69Smrg fi 7951d63fdb69Smrg ;; 7952d63fdb69Smrg esac 7953d63fdb69Smrg func_basename "$lib" 795452fd71cdSmrg laname=$func_basename_result 7955d63fdb69Smrg 7956d63fdb69Smrg # Find the relevant object directory and library name. 795752fd71cdSmrg if test yes = "$installed"; then 795848c85eb7Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 795952fd71cdSmrg func_warning "library '$lib' was moved." 796052fd71cdSmrg dir=$ladir 796152fd71cdSmrg absdir=$abs_ladir 796252fd71cdSmrg libdir=$abs_ladir 7963d63fdb69Smrg else 796452fd71cdSmrg dir=$lt_sysroot$libdir 796552fd71cdSmrg absdir=$lt_sysroot$libdir 7966d63fdb69Smrg fi 796752fd71cdSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968d63fdb69Smrg else 7969d63fdb69Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797052fd71cdSmrg dir=$ladir 797152fd71cdSmrg absdir=$abs_ladir 7972d63fdb69Smrg # Remove this search path later 797348c85eb7Smrg func_append notinst_path " $abs_ladir" 7974d63fdb69Smrg else 797552fd71cdSmrg dir=$ladir/$objdir 797652fd71cdSmrg absdir=$abs_ladir/$objdir 7977d63fdb69Smrg # Remove this search path later 797848c85eb7Smrg func_append notinst_path " $abs_ladir" 7979d63fdb69Smrg fi 7980d63fdb69Smrg fi # $installed = yes 7981d63fdb69Smrg func_stripname 'lib' '.la' "$laname" 7982d63fdb69Smrg name=$func_stripname_result 7983d63fdb69Smrg 7984d63fdb69Smrg # This library was specified with -dlpreopen. 798552fd71cdSmrg if test dlpreopen = "$pass"; then 798652fd71cdSmrg if test -z "$libdir" && test prog = "$linkmode"; then 798752fd71cdSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988d63fdb69Smrg fi 798952fd71cdSmrg case $host in 799048c85eb7Smrg # special handling for platforms with PE-DLLs. 799148c85eb7Smrg *cygwin* | *mingw* | *cegcc* ) 799248c85eb7Smrg # Linker will automatically link against shared library if both 799348c85eb7Smrg # static and shared are present. Therefore, ensure we extract 799448c85eb7Smrg # symbols from the import library if a shared library is present 799548c85eb7Smrg # (otherwise, the dlopen module name will be incorrect). We do 799648c85eb7Smrg # this by putting the import library name into $newdlprefiles. 799748c85eb7Smrg # We recover the dlopen module name by 'saving' the la file 799848c85eb7Smrg # name in a special purpose variable, and (later) extracting the 799948c85eb7Smrg # dlname from the la file. 800048c85eb7Smrg if test -n "$dlname"; then 800148c85eb7Smrg func_tr_sh "$dir/$linklib" 800248c85eb7Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800348c85eb7Smrg func_append newdlprefiles " $dir/$linklib" 800448c85eb7Smrg else 800548c85eb7Smrg func_append newdlprefiles " $dir/$old_library" 800648c85eb7Smrg # Keep a list of preopened convenience libraries to check 800748c85eb7Smrg # that they are being used correctly in the link pass. 800848c85eb7Smrg test -z "$libdir" && \ 800948c85eb7Smrg func_append dlpreconveniencelibs " $dir/$old_library" 801048c85eb7Smrg fi 801148c85eb7Smrg ;; 801248c85eb7Smrg * ) 801348c85eb7Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 801448c85eb7Smrg # are required to link). 801548c85eb7Smrg if test -n "$old_library"; then 801648c85eb7Smrg func_append newdlprefiles " $dir/$old_library" 801748c85eb7Smrg # Keep a list of preopened convenience libraries to check 801848c85eb7Smrg # that they are being used correctly in the link pass. 801948c85eb7Smrg test -z "$libdir" && \ 802048c85eb7Smrg func_append dlpreconveniencelibs " $dir/$old_library" 802148c85eb7Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802248c85eb7Smrg elif test -n "$dlname"; then 802348c85eb7Smrg func_append newdlprefiles " $dir/$dlname" 802448c85eb7Smrg else 802548c85eb7Smrg func_append newdlprefiles " $dir/$linklib" 802648c85eb7Smrg fi 802748c85eb7Smrg ;; 802848c85eb7Smrg esac 8029d63fdb69Smrg fi # $pass = dlpreopen 8030d63fdb69Smrg 8031d63fdb69Smrg if test -z "$libdir"; then 8032d63fdb69Smrg # Link the convenience library 803352fd71cdSmrg if test lib = "$linkmode"; then 8034d63fdb69Smrg deplibs="$dir/$old_library $deplibs" 803552fd71cdSmrg elif test prog,link = "$linkmode,$pass"; then 8036d63fdb69Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8037d63fdb69Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038d63fdb69Smrg else 8039d63fdb69Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8040d63fdb69Smrg fi 8041d63fdb69Smrg continue 8042d63fdb69Smrg fi 8043d63fdb69Smrg 8044d63fdb69Smrg 804552fd71cdSmrg if test prog = "$linkmode" && test link != "$pass"; then 804648c85eb7Smrg func_append newlib_search_path " $ladir" 8047d63fdb69Smrg deplibs="$lib $deplibs" 8048d63fdb69Smrg 804952fd71cdSmrg linkalldeplibs=false 805052fd71cdSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805152fd71cdSmrg test no = "$build_libtool_libs"; then 805252fd71cdSmrg linkalldeplibs=: 8053d63fdb69Smrg fi 8054d63fdb69Smrg 8055d63fdb69Smrg tmp_libs= 8056d63fdb69Smrg for deplib in $dependency_libs; do 8057d63fdb69Smrg case $deplib in 8058d63fdb69Smrg -L*) func_stripname '-L' '' "$deplib" 805948c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 806048c85eb7Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8061d63fdb69Smrg ;; 8062d63fdb69Smrg esac 8063d63fdb69Smrg # Need to link against all dependency_libs? 806452fd71cdSmrg if $linkalldeplibs; then 8065d63fdb69Smrg deplibs="$deplib $deplibs" 8066d63fdb69Smrg else 8067d63fdb69Smrg # Need to hardcode shared library paths 8068d63fdb69Smrg # or/and link against static libraries 8069d63fdb69Smrg newdependency_libs="$deplib $newdependency_libs" 8070d63fdb69Smrg fi 807152fd71cdSmrg if $opt_preserve_dup_deps; then 8072d63fdb69Smrg case "$tmp_libs " in 807348c85eb7Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074d63fdb69Smrg esac 8075d63fdb69Smrg fi 807648c85eb7Smrg func_append tmp_libs " $deplib" 8077d63fdb69Smrg done # for deplib 8078d63fdb69Smrg continue 8079d63fdb69Smrg fi # $linkmode = prog... 8080d63fdb69Smrg 808152fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 8082d63fdb69Smrg if test -n "$library_names" && 808352fd71cdSmrg { { test no = "$prefer_static_libs" || 808452fd71cdSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8085d63fdb69Smrg test -z "$old_library"; }; then 8086d63fdb69Smrg # We need to hardcode the library path 808752fd71cdSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088d63fdb69Smrg # Make sure the rpath contains only unique directories. 808952fd71cdSmrg case $temp_rpath: in 8090d63fdb69Smrg *"$absdir:"*) ;; 809148c85eb7Smrg *) func_append temp_rpath "$absdir:" ;; 8092d63fdb69Smrg esac 8093d63fdb69Smrg fi 8094d63fdb69Smrg 8095d63fdb69Smrg # Hardcode the library path. 8096d63fdb69Smrg # Skip directories that are in the system default run-time 8097d63fdb69Smrg # search path. 8098d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8099d63fdb69Smrg *" $absdir "*) ;; 8100d63fdb69Smrg *) 8101d63fdb69Smrg case "$compile_rpath " in 8102d63fdb69Smrg *" $absdir "*) ;; 810348c85eb7Smrg *) func_append compile_rpath " $absdir" ;; 8104d63fdb69Smrg esac 8105d63fdb69Smrg ;; 8106d63fdb69Smrg esac 8107d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8108d63fdb69Smrg *" $libdir "*) ;; 8109d63fdb69Smrg *) 8110d63fdb69Smrg case "$finalize_rpath " in 8111d63fdb69Smrg *" $libdir "*) ;; 811248c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 8113d63fdb69Smrg esac 8114d63fdb69Smrg ;; 8115d63fdb69Smrg esac 8116d63fdb69Smrg fi # $linkmode,$pass = prog,link... 8117d63fdb69Smrg 811852fd71cdSmrg if $alldeplibs && 811952fd71cdSmrg { test pass_all = "$deplibs_check_method" || 812052fd71cdSmrg { test yes = "$build_libtool_libs" && 8121d63fdb69Smrg test -n "$library_names"; }; }; then 8122d63fdb69Smrg # We only need to search for static libraries 8123d63fdb69Smrg continue 8124d63fdb69Smrg fi 8125d63fdb69Smrg fi 8126d63fdb69Smrg 8127d63fdb69Smrg link_static=no # Whether the deplib will be linked statically 8128d63fdb69Smrg use_static_libs=$prefer_static_libs 812952fd71cdSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8130d63fdb69Smrg use_static_libs=no 8131d63fdb69Smrg fi 8132d63fdb69Smrg if test -n "$library_names" && 813352fd71cdSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134d63fdb69Smrg case $host in 813552fd71cdSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8136d63fdb69Smrg # No point in relinking DLLs because paths are not encoded 813748c85eb7Smrg func_append notinst_deplibs " $lib" 8138d63fdb69Smrg need_relink=no 8139d63fdb69Smrg ;; 8140d63fdb69Smrg *) 814152fd71cdSmrg if test no = "$installed"; then 814248c85eb7Smrg func_append notinst_deplibs " $lib" 8143d63fdb69Smrg need_relink=yes 8144d63fdb69Smrg fi 8145d63fdb69Smrg ;; 8146d63fdb69Smrg esac 8147d63fdb69Smrg # This is a shared library 8148d63fdb69Smrg 8149d63fdb69Smrg # Warn about portability, can't link against -module's on some 8150d63fdb69Smrg # systems (darwin). Don't bleat about dlopened modules though! 815152fd71cdSmrg dlopenmodule= 8152d63fdb69Smrg for dlpremoduletest in $dlprefiles; do 8153d63fdb69Smrg if test "X$dlpremoduletest" = "X$lib"; then 815452fd71cdSmrg dlopenmodule=$dlpremoduletest 8155d63fdb69Smrg break 8156d63fdb69Smrg fi 8157d63fdb69Smrg done 815852fd71cdSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 815955acc8fcSmrg echo 816052fd71cdSmrg if test prog = "$linkmode"; then 8161d63fdb69Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162d63fdb69Smrg else 8163d63fdb69Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164d63fdb69Smrg fi 8165d63fdb69Smrg $ECHO "*** $linklib is not portable!" 8166d63fdb69Smrg fi 816752fd71cdSmrg if test lib = "$linkmode" && 816852fd71cdSmrg test yes = "$hardcode_into_libs"; then 8169d63fdb69Smrg # Hardcode the library path. 8170d63fdb69Smrg # Skip directories that are in the system default run-time 8171d63fdb69Smrg # search path. 8172d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8173d63fdb69Smrg *" $absdir "*) ;; 8174d63fdb69Smrg *) 8175d63fdb69Smrg case "$compile_rpath " in 8176d63fdb69Smrg *" $absdir "*) ;; 817748c85eb7Smrg *) func_append compile_rpath " $absdir" ;; 8178d63fdb69Smrg esac 8179d63fdb69Smrg ;; 8180d63fdb69Smrg esac 8181d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8182d63fdb69Smrg *" $libdir "*) ;; 8183d63fdb69Smrg *) 8184d63fdb69Smrg case "$finalize_rpath " in 8185d63fdb69Smrg *" $libdir "*) ;; 818648c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 8187d63fdb69Smrg esac 8188d63fdb69Smrg ;; 8189d63fdb69Smrg esac 8190d63fdb69Smrg fi 8191d63fdb69Smrg 8192d63fdb69Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8193d63fdb69Smrg # figure out the soname 8194d63fdb69Smrg set dummy $library_names 8195d63fdb69Smrg shift 819652fd71cdSmrg realname=$1 8197d63fdb69Smrg shift 8198d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8199d63fdb69Smrg # use dlname if we got it. it's perfectly good, no? 8200d63fdb69Smrg if test -n "$dlname"; then 820152fd71cdSmrg soname=$dlname 8202d63fdb69Smrg elif test -n "$soname_spec"; then 8203d63fdb69Smrg # bleh windows 8204d63fdb69Smrg case $host in 820552fd71cdSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8206d63fdb69Smrg func_arith $current - $age 8207d63fdb69Smrg major=$func_arith_result 820852fd71cdSmrg versuffix=-$major 8209d63fdb69Smrg ;; 8210d63fdb69Smrg esac 8211d63fdb69Smrg eval soname=\"$soname_spec\" 8212d63fdb69Smrg else 821352fd71cdSmrg soname=$realname 8214d63fdb69Smrg fi 8215d63fdb69Smrg 8216d63fdb69Smrg # Make a new name for the extract_expsyms_cmds to use 821752fd71cdSmrg soroot=$soname 8218d63fdb69Smrg func_basename "$soroot" 821952fd71cdSmrg soname=$func_basename_result 8220d63fdb69Smrg func_stripname 'lib' '.dll' "$soname" 8221d63fdb69Smrg newlib=libimp-$func_stripname_result.a 8222d63fdb69Smrg 8223d63fdb69Smrg # If the library has no export list, then create one now 8224d63fdb69Smrg if test -f "$output_objdir/$soname-def"; then : 8225d63fdb69Smrg else 822652fd71cdSmrg func_verbose "extracting exported symbol list from '$soname'" 8227d63fdb69Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228d63fdb69Smrg fi 8229d63fdb69Smrg 8230d63fdb69Smrg # Create $newlib 8231d63fdb69Smrg if test -f "$output_objdir/$newlib"; then :; else 823252fd71cdSmrg func_verbose "generating import library for '$soname'" 8233d63fdb69Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234d63fdb69Smrg fi 8235d63fdb69Smrg # make sure the library variables are pointing to the new library 8236d63fdb69Smrg dir=$output_objdir 8237d63fdb69Smrg linklib=$newlib 8238d63fdb69Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8239d63fdb69Smrg 824052fd71cdSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241d63fdb69Smrg add_shlibpath= 8242d63fdb69Smrg add_dir= 8243d63fdb69Smrg add= 8244d63fdb69Smrg lib_linked=yes 8245d63fdb69Smrg case $hardcode_action in 8246d63fdb69Smrg immediate | unsupported) 824752fd71cdSmrg if test no = "$hardcode_direct"; then 824852fd71cdSmrg add=$dir/$linklib 8249d63fdb69Smrg case $host in 825052fd71cdSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825152fd71cdSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252d63fdb69Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825352fd71cdSmrg *-*-unixware7*) add_dir=-L$dir ;; 8254d63fdb69Smrg *-*-darwin* ) 825552fd71cdSmrg # if the lib is a (non-dlopened) module then we cannot 8256d63fdb69Smrg # link against it, someone is ignoring the earlier warnings 8257d63fdb69Smrg if /usr/bin/file -L $add 2> /dev/null | 825852fd71cdSmrg $GREP ": [^:]* bundle" >/dev/null; then 8259d63fdb69Smrg if test "X$dlopenmodule" != "X$lib"; then 8260d63fdb69Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826152fd71cdSmrg if test -z "$old_library"; then 826255acc8fcSmrg echo 826355acc8fcSmrg echo "*** And there doesn't seem to be a static archive available" 826455acc8fcSmrg echo "*** The link will probably fail, sorry" 8265d63fdb69Smrg else 826652fd71cdSmrg add=$dir/$old_library 8267d63fdb69Smrg fi 8268d63fdb69Smrg elif test -n "$old_library"; then 826952fd71cdSmrg add=$dir/$old_library 8270d63fdb69Smrg fi 8271d63fdb69Smrg fi 8272d63fdb69Smrg esac 827352fd71cdSmrg elif test no = "$hardcode_minus_L"; then 8274d63fdb69Smrg case $host in 827552fd71cdSmrg *-*-sunos*) add_shlibpath=$dir ;; 8276d63fdb69Smrg esac 827752fd71cdSmrg add_dir=-L$dir 827852fd71cdSmrg add=-l$name 827952fd71cdSmrg elif test no = "$hardcode_shlibpath_var"; then 828052fd71cdSmrg add_shlibpath=$dir 828152fd71cdSmrg add=-l$name 8282d63fdb69Smrg else 8283d63fdb69Smrg lib_linked=no 8284d63fdb69Smrg fi 8285d63fdb69Smrg ;; 8286d63fdb69Smrg relink) 828752fd71cdSmrg if test yes = "$hardcode_direct" && 828852fd71cdSmrg test no = "$hardcode_direct_absolute"; then 828952fd71cdSmrg add=$dir/$linklib 829052fd71cdSmrg elif test yes = "$hardcode_minus_L"; then 829152fd71cdSmrg add_dir=-L$absdir 8292d63fdb69Smrg # Try looking first in the location we're being installed to. 8293d63fdb69Smrg if test -n "$inst_prefix_dir"; then 8294d63fdb69Smrg case $libdir in 8295d63fdb69Smrg [\\/]*) 829648c85eb7Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8297d63fdb69Smrg ;; 8298d63fdb69Smrg esac 8299d63fdb69Smrg fi 830052fd71cdSmrg add=-l$name 830152fd71cdSmrg elif test yes = "$hardcode_shlibpath_var"; then 830252fd71cdSmrg add_shlibpath=$dir 830352fd71cdSmrg add=-l$name 8304d63fdb69Smrg else 8305d63fdb69Smrg lib_linked=no 8306d63fdb69Smrg fi 8307d63fdb69Smrg ;; 8308d63fdb69Smrg *) lib_linked=no ;; 8309d63fdb69Smrg esac 8310d63fdb69Smrg 831152fd71cdSmrg if test yes != "$lib_linked"; then 8312d63fdb69Smrg func_fatal_configuration "unsupported hardcode properties" 8313d63fdb69Smrg fi 8314d63fdb69Smrg 8315d63fdb69Smrg if test -n "$add_shlibpath"; then 8316d63fdb69Smrg case :$compile_shlibpath: in 8317d63fdb69Smrg *":$add_shlibpath:"*) ;; 831848c85eb7Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319d63fdb69Smrg esac 8320d63fdb69Smrg fi 832152fd71cdSmrg if test prog = "$linkmode"; then 8322d63fdb69Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323d63fdb69Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324d63fdb69Smrg else 8325d63fdb69Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326d63fdb69Smrg test -n "$add" && deplibs="$add $deplibs" 832752fd71cdSmrg if test yes != "$hardcode_direct" && 832852fd71cdSmrg test yes != "$hardcode_minus_L" && 832952fd71cdSmrg test yes = "$hardcode_shlibpath_var"; then 8330d63fdb69Smrg case :$finalize_shlibpath: in 8331d63fdb69Smrg *":$libdir:"*) ;; 833248c85eb7Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8333d63fdb69Smrg esac 8334d63fdb69Smrg fi 8335d63fdb69Smrg fi 8336d63fdb69Smrg fi 8337d63fdb69Smrg 833852fd71cdSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339d63fdb69Smrg add_shlibpath= 8340d63fdb69Smrg add_dir= 8341d63fdb69Smrg add= 8342d63fdb69Smrg # Finalize command for both is simple: just hardcode it. 834352fd71cdSmrg if test yes = "$hardcode_direct" && 834452fd71cdSmrg test no = "$hardcode_direct_absolute"; then 834552fd71cdSmrg add=$libdir/$linklib 834652fd71cdSmrg elif test yes = "$hardcode_minus_L"; then 834752fd71cdSmrg add_dir=-L$libdir 834852fd71cdSmrg add=-l$name 834952fd71cdSmrg elif test yes = "$hardcode_shlibpath_var"; then 8350d63fdb69Smrg case :$finalize_shlibpath: in 8351d63fdb69Smrg *":$libdir:"*) ;; 835248c85eb7Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8353d63fdb69Smrg esac 835452fd71cdSmrg add=-l$name 835552fd71cdSmrg elif test yes = "$hardcode_automatic"; then 8356d63fdb69Smrg if test -n "$inst_prefix_dir" && 835752fd71cdSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 835852fd71cdSmrg add=$inst_prefix_dir$libdir/$linklib 8359d63fdb69Smrg else 836052fd71cdSmrg add=$libdir/$linklib 8361d63fdb69Smrg fi 8362d63fdb69Smrg else 8363d63fdb69Smrg # We cannot seem to hardcode it, guess we'll fake it. 836452fd71cdSmrg add_dir=-L$libdir 8365d63fdb69Smrg # Try looking first in the location we're being installed to. 8366d63fdb69Smrg if test -n "$inst_prefix_dir"; then 8367d63fdb69Smrg case $libdir in 8368d63fdb69Smrg [\\/]*) 836948c85eb7Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8370d63fdb69Smrg ;; 8371d63fdb69Smrg esac 8372d63fdb69Smrg fi 837352fd71cdSmrg add=-l$name 8374d63fdb69Smrg fi 8375d63fdb69Smrg 837652fd71cdSmrg if test prog = "$linkmode"; then 8377d63fdb69Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378d63fdb69Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379d63fdb69Smrg else 8380d63fdb69Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381d63fdb69Smrg test -n "$add" && deplibs="$add $deplibs" 8382d63fdb69Smrg fi 8383d63fdb69Smrg fi 838452fd71cdSmrg elif test prog = "$linkmode"; then 8385d63fdb69Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8386d63fdb69Smrg # is not unsupported. This is valid on all known static and 8387d63fdb69Smrg # shared platforms. 838852fd71cdSmrg if test unsupported != "$hardcode_direct"; then 838952fd71cdSmrg test -n "$old_library" && linklib=$old_library 8390d63fdb69Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8391d63fdb69Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392d63fdb69Smrg else 8393d63fdb69Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8394d63fdb69Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395d63fdb69Smrg fi 839652fd71cdSmrg elif test yes = "$build_libtool_libs"; then 8397d63fdb69Smrg # Not a shared library 839852fd71cdSmrg if test pass_all != "$deplibs_check_method"; then 8399d63fdb69Smrg # We're trying link a shared library against a static one 8400d63fdb69Smrg # but the system doesn't support it. 8401d63fdb69Smrg 8402d63fdb69Smrg # Just print a warning and add the library to dependency_libs so 8403d63fdb69Smrg # that the program can be linked against the static library. 840455acc8fcSmrg echo 840552fd71cdSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 840655acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 840755acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 840855acc8fcSmrg echo "*** shared version of the library, which you do not appear to have." 840952fd71cdSmrg if test yes = "$module"; then 841055acc8fcSmrg echo "*** But as you try to build a module library, libtool will still create " 841155acc8fcSmrg echo "*** a static module, that should work as long as the dlopening application" 841255acc8fcSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413d63fdb69Smrg if test -z "$global_symbol_pipe"; then 841455acc8fcSmrg echo 841555acc8fcSmrg echo "*** However, this would only work if libtool was able to extract symbol" 841652fd71cdSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 841755acc8fcSmrg echo "*** not find such a program. So, this module is probably useless." 841852fd71cdSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419d63fdb69Smrg fi 842052fd71cdSmrg if test no = "$build_old_libs"; then 8421d63fdb69Smrg build_libtool_libs=module 8422d63fdb69Smrg build_old_libs=yes 8423d63fdb69Smrg else 8424d63fdb69Smrg build_libtool_libs=no 8425d63fdb69Smrg fi 8426d63fdb69Smrg fi 8427d63fdb69Smrg else 8428d63fdb69Smrg deplibs="$dir/$old_library $deplibs" 8429d63fdb69Smrg link_static=yes 8430d63fdb69Smrg fi 8431d63fdb69Smrg fi # link shared/static library? 8432d63fdb69Smrg 843352fd71cdSmrg if test lib = "$linkmode"; then 8434d63fdb69Smrg if test -n "$dependency_libs" && 843552fd71cdSmrg { test yes != "$hardcode_into_libs" || 843652fd71cdSmrg test yes = "$build_old_libs" || 843752fd71cdSmrg test yes = "$link_static"; }; then 8438d63fdb69Smrg # Extract -R from dependency_libs 8439d63fdb69Smrg temp_deplibs= 8440d63fdb69Smrg for libdir in $dependency_libs; do 8441d63fdb69Smrg case $libdir in 8442d63fdb69Smrg -R*) func_stripname '-R' '' "$libdir" 8443d63fdb69Smrg temp_xrpath=$func_stripname_result 8444d63fdb69Smrg case " $xrpath " in 8445d63fdb69Smrg *" $temp_xrpath "*) ;; 844648c85eb7Smrg *) func_append xrpath " $temp_xrpath";; 8447d63fdb69Smrg esac;; 844848c85eb7Smrg *) func_append temp_deplibs " $libdir";; 8449d63fdb69Smrg esac 8450d63fdb69Smrg done 845152fd71cdSmrg dependency_libs=$temp_deplibs 8452d63fdb69Smrg fi 8453d63fdb69Smrg 845448c85eb7Smrg func_append newlib_search_path " $absdir" 8455d63fdb69Smrg # Link against this library 845652fd71cdSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457d63fdb69Smrg # ... and its dependency_libs 8458d63fdb69Smrg tmp_libs= 8459d63fdb69Smrg for deplib in $dependency_libs; do 8460d63fdb69Smrg newdependency_libs="$deplib $newdependency_libs" 846148c85eb7Smrg case $deplib in 846248c85eb7Smrg -L*) func_stripname '-L' '' "$deplib" 846348c85eb7Smrg func_resolve_sysroot "$func_stripname_result";; 846448c85eb7Smrg *) func_resolve_sysroot "$deplib" ;; 846548c85eb7Smrg esac 846652fd71cdSmrg if $opt_preserve_dup_deps; then 8467d63fdb69Smrg case "$tmp_libs " in 846848c85eb7Smrg *" $func_resolve_sysroot_result "*) 846948c85eb7Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470d63fdb69Smrg esac 8471d63fdb69Smrg fi 847248c85eb7Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8473d63fdb69Smrg done 8474d63fdb69Smrg 847552fd71cdSmrg if test no != "$link_all_deplibs"; then 8476d63fdb69Smrg # Add the search paths of all dependency libraries 8477d63fdb69Smrg for deplib in $dependency_libs; do 847855acc8fcSmrg path= 8479d63fdb69Smrg case $deplib in 848052fd71cdSmrg -L*) path=$deplib ;; 8481d63fdb69Smrg *.la) 848248c85eb7Smrg func_resolve_sysroot "$deplib" 848348c85eb7Smrg deplib=$func_resolve_sysroot_result 8484d63fdb69Smrg func_dirname "$deplib" "" "." 848548c85eb7Smrg dir=$func_dirname_result 8486d63fdb69Smrg # We need an absolute path. 8487d63fdb69Smrg case $dir in 848852fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489d63fdb69Smrg *) 8490d63fdb69Smrg absdir=`cd "$dir" && pwd` 8491d63fdb69Smrg if test -z "$absdir"; then 849252fd71cdSmrg func_warning "cannot determine absolute directory name of '$dir'" 849352fd71cdSmrg absdir=$dir 8494d63fdb69Smrg fi 8495d63fdb69Smrg ;; 8496d63fdb69Smrg esac 8497d63fdb69Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8498d63fdb69Smrg case $host in 8499d63fdb69Smrg *-*-darwin*) 8500d63fdb69Smrg depdepl= 850152fd71cdSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850252fd71cdSmrg if test -n "$deplibrary_names"; then 850352fd71cdSmrg for tmp in $deplibrary_names; do 8504d63fdb69Smrg depdepl=$tmp 8505d63fdb69Smrg done 850652fd71cdSmrg if test -f "$absdir/$objdir/$depdepl"; then 850752fd71cdSmrg depdepl=$absdir/$objdir/$depdepl 850852fd71cdSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509d63fdb69Smrg if test -z "$darwin_install_name"; then 851052fd71cdSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511d63fdb69Smrg fi 851252fd71cdSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851352fd71cdSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514d63fdb69Smrg path= 8515d63fdb69Smrg fi 8516d63fdb69Smrg fi 8517d63fdb69Smrg ;; 8518d63fdb69Smrg *) 851952fd71cdSmrg path=-L$absdir/$objdir 8520d63fdb69Smrg ;; 8521d63fdb69Smrg esac 8522d63fdb69Smrg else 852352fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524d63fdb69Smrg test -z "$libdir" && \ 852552fd71cdSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8526d63fdb69Smrg test "$absdir" != "$libdir" && \ 852752fd71cdSmrg func_warning "'$deplib' seems to be moved" 8528d63fdb69Smrg 852952fd71cdSmrg path=-L$absdir 8530d63fdb69Smrg fi 8531d63fdb69Smrg ;; 8532d63fdb69Smrg esac 8533d63fdb69Smrg case " $deplibs " in 8534d63fdb69Smrg *" $path "*) ;; 8535d63fdb69Smrg *) deplibs="$path $deplibs" ;; 8536d63fdb69Smrg esac 8537d63fdb69Smrg done 8538d63fdb69Smrg fi # link_all_deplibs != no 8539d63fdb69Smrg fi # linkmode = lib 8540d63fdb69Smrg done # for deplib in $libs 854152fd71cdSmrg if test link = "$pass"; then 854252fd71cdSmrg if test prog = "$linkmode"; then 8543d63fdb69Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544d63fdb69Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545d63fdb69Smrg else 854655acc8fcSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547d63fdb69Smrg fi 8548d63fdb69Smrg fi 854952fd71cdSmrg dependency_libs=$newdependency_libs 855052fd71cdSmrg if test dlpreopen = "$pass"; then 8551d63fdb69Smrg # Link the dlpreopened libraries before other libraries 8552d63fdb69Smrg for deplib in $save_deplibs; do 8553d63fdb69Smrg deplibs="$deplib $deplibs" 8554d63fdb69Smrg done 8555d63fdb69Smrg fi 855652fd71cdSmrg if test dlopen != "$pass"; then 855752fd71cdSmrg test conv = "$pass" || { 8558d63fdb69Smrg # Make sure lib_search_path contains only unique directories. 8559d63fdb69Smrg lib_search_path= 8560d63fdb69Smrg for dir in $newlib_search_path; do 8561d63fdb69Smrg case "$lib_search_path " in 8562d63fdb69Smrg *" $dir "*) ;; 856348c85eb7Smrg *) func_append lib_search_path " $dir" ;; 8564d63fdb69Smrg esac 8565d63fdb69Smrg done 8566d63fdb69Smrg newlib_search_path= 856752fd71cdSmrg } 8568d63fdb69Smrg 856952fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 8570d63fdb69Smrg vars="compile_deplibs finalize_deplibs" 857152fd71cdSmrg else 857252fd71cdSmrg vars=deplibs 8573d63fdb69Smrg fi 8574d63fdb69Smrg for var in $vars dependency_libs; do 8575d63fdb69Smrg # Add libraries to $var in reverse order 8576d63fdb69Smrg eval tmp_libs=\"\$$var\" 8577d63fdb69Smrg new_libs= 8578d63fdb69Smrg for deplib in $tmp_libs; do 8579d63fdb69Smrg # FIXME: Pedantically, this is the right thing to do, so 8580d63fdb69Smrg # that some nasty dependency loop isn't accidentally 8581d63fdb69Smrg # broken: 8582d63fdb69Smrg #new_libs="$deplib $new_libs" 8583d63fdb69Smrg # Pragmatically, this seems to cause very few problems in 8584d63fdb69Smrg # practice: 8585d63fdb69Smrg case $deplib in 8586d63fdb69Smrg -L*) new_libs="$deplib $new_libs" ;; 8587d63fdb69Smrg -R*) ;; 8588d63fdb69Smrg *) 8589d63fdb69Smrg # And here is the reason: when a library appears more 8590d63fdb69Smrg # than once as an explicit dependence of a library, or 8591d63fdb69Smrg # is implicitly linked in more than once by the 8592d63fdb69Smrg # compiler, it is considered special, and multiple 8593d63fdb69Smrg # occurrences thereof are not removed. Compare this 8594d63fdb69Smrg # with having the same library being listed as a 8595d63fdb69Smrg # dependency of multiple other libraries: in this case, 8596d63fdb69Smrg # we know (pedantically, we assume) the library does not 8597d63fdb69Smrg # need to be listed more than once, so we keep only the 8598d63fdb69Smrg # last copy. This is not always right, but it is rare 8599d63fdb69Smrg # enough that we require users that really mean to play 8600d63fdb69Smrg # such unportable linking tricks to link the library 8601d63fdb69Smrg # using -Wl,-lname, so that libtool does not consider it 8602d63fdb69Smrg # for duplicate removal. 8603d63fdb69Smrg case " $specialdeplibs " in 8604d63fdb69Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605d63fdb69Smrg *) 8606d63fdb69Smrg case " $new_libs " in 8607d63fdb69Smrg *" $deplib "*) ;; 8608d63fdb69Smrg *) new_libs="$deplib $new_libs" ;; 8609d63fdb69Smrg esac 8610d63fdb69Smrg ;; 8611d63fdb69Smrg esac 8612d63fdb69Smrg ;; 8613d63fdb69Smrg esac 8614d63fdb69Smrg done 8615d63fdb69Smrg tmp_libs= 8616d63fdb69Smrg for deplib in $new_libs; do 8617d63fdb69Smrg case $deplib in 8618d63fdb69Smrg -L*) 8619d63fdb69Smrg case " $tmp_libs " in 8620d63fdb69Smrg *" $deplib "*) ;; 862148c85eb7Smrg *) func_append tmp_libs " $deplib" ;; 8622d63fdb69Smrg esac 8623d63fdb69Smrg ;; 862448c85eb7Smrg *) func_append tmp_libs " $deplib" ;; 8625d63fdb69Smrg esac 8626d63fdb69Smrg done 8627d63fdb69Smrg eval $var=\"$tmp_libs\" 8628d63fdb69Smrg done # for var 8629d63fdb69Smrg fi 863052fd71cdSmrg 863152fd71cdSmrg # Add Sun CC postdeps if required: 863252fd71cdSmrg test CXX = "$tagname" && { 863352fd71cdSmrg case $host_os in 863452fd71cdSmrg linux*) 863552fd71cdSmrg case `$CC -V 2>&1 | sed 5q` in 863652fd71cdSmrg *Sun\ C*) # Sun C++ 5.9 863752fd71cdSmrg func_suncc_cstd_abi 863852fd71cdSmrg 863952fd71cdSmrg if test no != "$suncc_use_cstd_abi"; then 864052fd71cdSmrg func_append postdeps ' -library=Cstd -library=Crun' 864152fd71cdSmrg fi 864252fd71cdSmrg ;; 864352fd71cdSmrg esac 864452fd71cdSmrg ;; 864552fd71cdSmrg 864652fd71cdSmrg solaris*) 864752fd71cdSmrg func_cc_basename "$CC" 864852fd71cdSmrg case $func_cc_basename_result in 864952fd71cdSmrg CC* | sunCC*) 865052fd71cdSmrg func_suncc_cstd_abi 865152fd71cdSmrg 865252fd71cdSmrg if test no != "$suncc_use_cstd_abi"; then 865352fd71cdSmrg func_append postdeps ' -library=Cstd -library=Crun' 865452fd71cdSmrg fi 865552fd71cdSmrg ;; 865652fd71cdSmrg esac 865752fd71cdSmrg ;; 865852fd71cdSmrg esac 865952fd71cdSmrg } 866052fd71cdSmrg 8661d63fdb69Smrg # Last step: remove runtime libs from dependency_libs 8662d63fdb69Smrg # (they stay in deplibs) 8663d63fdb69Smrg tmp_libs= 866452fd71cdSmrg for i in $dependency_libs; do 8665d63fdb69Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8666d63fdb69Smrg *" $i "*) 866752fd71cdSmrg i= 8668d63fdb69Smrg ;; 8669d63fdb69Smrg esac 867052fd71cdSmrg if test -n "$i"; then 867148c85eb7Smrg func_append tmp_libs " $i" 8672d63fdb69Smrg fi 8673d63fdb69Smrg done 8674d63fdb69Smrg dependency_libs=$tmp_libs 8675d63fdb69Smrg done # for pass 867652fd71cdSmrg if test prog = "$linkmode"; then 867752fd71cdSmrg dlfiles=$newdlfiles 8678d63fdb69Smrg fi 867952fd71cdSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868052fd71cdSmrg dlprefiles=$newdlprefiles 8681d63fdb69Smrg fi 8682d63fdb69Smrg 8683d63fdb69Smrg case $linkmode in 8684d63fdb69Smrg oldlib) 868552fd71cdSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 868652fd71cdSmrg func_warning "'-dlopen' is ignored for archives" 8687d63fdb69Smrg fi 8688d63fdb69Smrg 8689d63fdb69Smrg case " $deplibs" in 8690d63fdb69Smrg *\ -l* | *\ -L*) 869152fd71cdSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8692d63fdb69Smrg esac 8693d63fdb69Smrg 8694d63fdb69Smrg test -n "$rpath" && \ 869552fd71cdSmrg func_warning "'-rpath' is ignored for archives" 8696d63fdb69Smrg 8697d63fdb69Smrg test -n "$xrpath" && \ 869852fd71cdSmrg func_warning "'-R' is ignored for archives" 8699d63fdb69Smrg 8700d63fdb69Smrg test -n "$vinfo" && \ 870152fd71cdSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8702d63fdb69Smrg 8703d63fdb69Smrg test -n "$release" && \ 870452fd71cdSmrg func_warning "'-release' is ignored for archives" 8705d63fdb69Smrg 8706d63fdb69Smrg test -n "$export_symbols$export_symbols_regex" && \ 870752fd71cdSmrg func_warning "'-export-symbols' is ignored for archives" 8708d63fdb69Smrg 8709d63fdb69Smrg # Now set the variables for building old libraries. 8710d63fdb69Smrg build_libtool_libs=no 871152fd71cdSmrg oldlibs=$output 871248c85eb7Smrg func_append objs "$old_deplibs" 8713d63fdb69Smrg ;; 8714d63fdb69Smrg 8715d63fdb69Smrg lib) 871652fd71cdSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8717d63fdb69Smrg case $outputname in 8718d63fdb69Smrg lib*) 8719d63fdb69Smrg func_stripname 'lib' '.la' "$outputname" 8720d63fdb69Smrg name=$func_stripname_result 8721d63fdb69Smrg eval shared_ext=\"$shrext_cmds\" 8722d63fdb69Smrg eval libname=\"$libname_spec\" 8723d63fdb69Smrg ;; 8724d63fdb69Smrg *) 872552fd71cdSmrg test no = "$module" \ 872652fd71cdSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727d63fdb69Smrg 872852fd71cdSmrg if test no != "$need_lib_prefix"; then 8729d63fdb69Smrg # Add the "lib" prefix for modules if required 8730d63fdb69Smrg func_stripname '' '.la' "$outputname" 8731d63fdb69Smrg name=$func_stripname_result 8732d63fdb69Smrg eval shared_ext=\"$shrext_cmds\" 8733d63fdb69Smrg eval libname=\"$libname_spec\" 8734d63fdb69Smrg else 8735d63fdb69Smrg func_stripname '' '.la' "$outputname" 8736d63fdb69Smrg libname=$func_stripname_result 8737d63fdb69Smrg fi 8738d63fdb69Smrg ;; 8739d63fdb69Smrg esac 8740d63fdb69Smrg 8741d63fdb69Smrg if test -n "$objs"; then 874252fd71cdSmrg if test pass_all != "$deplibs_check_method"; then 874352fd71cdSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744d63fdb69Smrg else 874555acc8fcSmrg echo 8746d63fdb69Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747d63fdb69Smrg $ECHO "*** objects $objs is not portable!" 874848c85eb7Smrg func_append libobjs " $objs" 8749d63fdb69Smrg fi 8750d63fdb69Smrg fi 8751d63fdb69Smrg 875252fd71cdSmrg test no = "$dlself" \ 875352fd71cdSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8754d63fdb69Smrg 8755d63fdb69Smrg set dummy $rpath 8756d63fdb69Smrg shift 875752fd71cdSmrg test 1 -lt "$#" \ 875852fd71cdSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8759d63fdb69Smrg 876052fd71cdSmrg install_libdir=$1 8761d63fdb69Smrg 8762d63fdb69Smrg oldlibs= 8763d63fdb69Smrg if test -z "$rpath"; then 876452fd71cdSmrg if test yes = "$build_libtool_libs"; then 8765d63fdb69Smrg # Building a libtool convenience library. 876652fd71cdSmrg # Some compilers have problems with a '.al' extension so 8767d63fdb69Smrg # convenience libraries should have the same extension an 8768d63fdb69Smrg # archive normally would. 8769d63fdb69Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770d63fdb69Smrg build_libtool_libs=convenience 8771d63fdb69Smrg build_old_libs=yes 8772d63fdb69Smrg fi 8773d63fdb69Smrg 8774d63fdb69Smrg test -n "$vinfo" && \ 877552fd71cdSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776d63fdb69Smrg 8777d63fdb69Smrg test -n "$release" && \ 877852fd71cdSmrg func_warning "'-release' is ignored for convenience libraries" 8779d63fdb69Smrg else 8780d63fdb69Smrg 8781d63fdb69Smrg # Parse the version information argument. 878252fd71cdSmrg save_ifs=$IFS; IFS=: 8783d63fdb69Smrg set dummy $vinfo 0 0 0 8784d63fdb69Smrg shift 878552fd71cdSmrg IFS=$save_ifs 8786d63fdb69Smrg 8787d63fdb69Smrg test -n "$7" && \ 878852fd71cdSmrg func_fatal_help "too many parameters to '-version-info'" 8789d63fdb69Smrg 8790d63fdb69Smrg # convert absolute version numbers to libtool ages 8791d63fdb69Smrg # this retains compatibility with .la files and attempts 8792d63fdb69Smrg # to make the code below a bit more comprehensible 8793d63fdb69Smrg 8794d63fdb69Smrg case $vinfo_number in 8795d63fdb69Smrg yes) 879652fd71cdSmrg number_major=$1 879752fd71cdSmrg number_minor=$2 879852fd71cdSmrg number_revision=$3 8799d63fdb69Smrg # 8800d63fdb69Smrg # There are really only two kinds -- those that 8801d63fdb69Smrg # use the current revision as the major version 8802d63fdb69Smrg # and those that subtract age and use age as 8803d63fdb69Smrg # a minor version. But, then there is irix 880452fd71cdSmrg # that has an extra 1 added just for fun 8805d63fdb69Smrg # 8806d63fdb69Smrg case $version_type in 880748c85eb7Smrg # correct linux to gnu/linux during the next big refactor 880852fd71cdSmrg darwin|freebsd-elf|linux|osf|windows|none) 8809d63fdb69Smrg func_arith $number_major + $number_minor 8810d63fdb69Smrg current=$func_arith_result 881152fd71cdSmrg age=$number_minor 881252fd71cdSmrg revision=$number_revision 8813d63fdb69Smrg ;; 881452fd71cdSmrg freebsd-aout|qnx|sunos) 881552fd71cdSmrg current=$number_major 881652fd71cdSmrg revision=$number_minor 881752fd71cdSmrg age=0 8818d63fdb69Smrg ;; 8819d63fdb69Smrg irix|nonstopux) 8820d63fdb69Smrg func_arith $number_major + $number_minor 8821d63fdb69Smrg current=$func_arith_result 882252fd71cdSmrg age=$number_minor 882352fd71cdSmrg revision=$number_minor 8824d63fdb69Smrg lt_irix_increment=no 8825d63fdb69Smrg ;; 8826d63fdb69Smrg esac 8827d63fdb69Smrg ;; 8828d63fdb69Smrg no) 882952fd71cdSmrg current=$1 883052fd71cdSmrg revision=$2 883152fd71cdSmrg age=$3 8832d63fdb69Smrg ;; 8833d63fdb69Smrg esac 8834d63fdb69Smrg 8835d63fdb69Smrg # Check that each of the things are valid numbers. 8836d63fdb69Smrg case $current in 8837d63fdb69Smrg 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]) ;; 8838d63fdb69Smrg *) 883952fd71cdSmrg func_error "CURRENT '$current' must be a nonnegative integer" 884052fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 8841d63fdb69Smrg ;; 8842d63fdb69Smrg esac 8843d63fdb69Smrg 8844d63fdb69Smrg case $revision in 8845d63fdb69Smrg 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]) ;; 8846d63fdb69Smrg *) 884752fd71cdSmrg func_error "REVISION '$revision' must be a nonnegative integer" 884852fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 8849d63fdb69Smrg ;; 8850d63fdb69Smrg esac 8851d63fdb69Smrg 8852d63fdb69Smrg case $age in 8853d63fdb69Smrg 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]) ;; 8854d63fdb69Smrg *) 885552fd71cdSmrg func_error "AGE '$age' must be a nonnegative integer" 885652fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 8857d63fdb69Smrg ;; 8858d63fdb69Smrg esac 8859d63fdb69Smrg 8860d63fdb69Smrg if test "$age" -gt "$current"; then 886152fd71cdSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 886252fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 8863d63fdb69Smrg fi 8864d63fdb69Smrg 8865d63fdb69Smrg # Calculate the version variables. 8866d63fdb69Smrg major= 8867d63fdb69Smrg versuffix= 8868d63fdb69Smrg verstring= 8869d63fdb69Smrg case $version_type in 8870d63fdb69Smrg none) ;; 8871d63fdb69Smrg 8872d63fdb69Smrg darwin) 8873d63fdb69Smrg # Like Linux, but with the current version available in 8874d63fdb69Smrg # verstring for coding it into the library header 8875d63fdb69Smrg func_arith $current - $age 8876d63fdb69Smrg major=.$func_arith_result 887752fd71cdSmrg versuffix=$major.$age.$revision 8878d63fdb69Smrg # Darwin ld doesn't like 0 for these options... 8879d63fdb69Smrg func_arith $current + 1 8880d63fdb69Smrg minor_current=$func_arith_result 888152fd71cdSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882d63fdb69Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 888352fd71cdSmrg # On Darwin other compilers 888452fd71cdSmrg case $CC in 888552fd71cdSmrg nagfor*) 888652fd71cdSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888752fd71cdSmrg ;; 888852fd71cdSmrg *) 888952fd71cdSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889052fd71cdSmrg ;; 889152fd71cdSmrg esac 8892d63fdb69Smrg ;; 8893d63fdb69Smrg 8894d63fdb69Smrg freebsd-aout) 889552fd71cdSmrg major=.$current 889652fd71cdSmrg versuffix=.$current.$revision 8897d63fdb69Smrg ;; 8898d63fdb69Smrg 8899d63fdb69Smrg freebsd-elf) 890052fd71cdSmrg func_arith $current - $age 890152fd71cdSmrg major=.$func_arith_result 890252fd71cdSmrg versuffix=$major.$age.$revision 8903d63fdb69Smrg ;; 8904d63fdb69Smrg 8905d63fdb69Smrg irix | nonstopux) 890652fd71cdSmrg if test no = "$lt_irix_increment"; then 8907d63fdb69Smrg func_arith $current - $age 8908d63fdb69Smrg else 8909d63fdb69Smrg func_arith $current - $age + 1 8910d63fdb69Smrg fi 8911d63fdb69Smrg major=$func_arith_result 8912d63fdb69Smrg 8913d63fdb69Smrg case $version_type in 8914d63fdb69Smrg nonstopux) verstring_prefix=nonstopux ;; 8915d63fdb69Smrg *) verstring_prefix=sgi ;; 8916d63fdb69Smrg esac 891752fd71cdSmrg verstring=$verstring_prefix$major.$revision 8918d63fdb69Smrg 8919d63fdb69Smrg # Add in all the interfaces that we are compatible with. 8920d63fdb69Smrg loop=$revision 892152fd71cdSmrg while test 0 -ne "$loop"; do 8922d63fdb69Smrg func_arith $revision - $loop 8923d63fdb69Smrg iface=$func_arith_result 8924d63fdb69Smrg func_arith $loop - 1 8925d63fdb69Smrg loop=$func_arith_result 892652fd71cdSmrg verstring=$verstring_prefix$major.$iface:$verstring 8927d63fdb69Smrg done 8928d63fdb69Smrg 892952fd71cdSmrg # Before this point, $major must not contain '.'. 8930d63fdb69Smrg major=.$major 893152fd71cdSmrg versuffix=$major.$revision 8932d63fdb69Smrg ;; 8933d63fdb69Smrg 893448c85eb7Smrg linux) # correct to gnu/linux during the next big refactor 8935d63fdb69Smrg func_arith $current - $age 8936d63fdb69Smrg major=.$func_arith_result 893752fd71cdSmrg versuffix=$major.$age.$revision 8938d63fdb69Smrg ;; 8939d63fdb69Smrg 8940d63fdb69Smrg osf) 8941d63fdb69Smrg func_arith $current - $age 8942d63fdb69Smrg major=.$func_arith_result 894352fd71cdSmrg versuffix=.$current.$age.$revision 894452fd71cdSmrg verstring=$current.$age.$revision 8945d63fdb69Smrg 8946d63fdb69Smrg # Add in all the interfaces that we are compatible with. 8947d63fdb69Smrg loop=$age 894852fd71cdSmrg while test 0 -ne "$loop"; do 8949d63fdb69Smrg func_arith $current - $loop 8950d63fdb69Smrg iface=$func_arith_result 8951d63fdb69Smrg func_arith $loop - 1 8952d63fdb69Smrg loop=$func_arith_result 895352fd71cdSmrg verstring=$verstring:$iface.0 8954d63fdb69Smrg done 8955d63fdb69Smrg 8956d63fdb69Smrg # Make executables depend on our current version. 895752fd71cdSmrg func_append verstring ":$current.0" 8958d63fdb69Smrg ;; 8959d63fdb69Smrg 8960d63fdb69Smrg qnx) 896152fd71cdSmrg major=.$current 896252fd71cdSmrg versuffix=.$current 896352fd71cdSmrg ;; 896452fd71cdSmrg 896552fd71cdSmrg sco) 896652fd71cdSmrg major=.$current 896752fd71cdSmrg versuffix=.$current 8968d63fdb69Smrg ;; 8969d63fdb69Smrg 8970d63fdb69Smrg sunos) 897152fd71cdSmrg major=.$current 897252fd71cdSmrg versuffix=.$current.$revision 8973d63fdb69Smrg ;; 8974d63fdb69Smrg 8975d63fdb69Smrg windows) 8976d63fdb69Smrg # Use '-' rather than '.', since we only want one 897752fd71cdSmrg # extension on DOS 8.3 file systems. 8978d63fdb69Smrg func_arith $current - $age 8979d63fdb69Smrg major=$func_arith_result 898052fd71cdSmrg versuffix=-$major 8981d63fdb69Smrg ;; 8982d63fdb69Smrg 8983d63fdb69Smrg *) 898452fd71cdSmrg func_fatal_configuration "unknown library version type '$version_type'" 8985d63fdb69Smrg ;; 8986d63fdb69Smrg esac 8987d63fdb69Smrg 8988d63fdb69Smrg # Clear the version info if we defaulted, and they specified a release. 8989d63fdb69Smrg if test -z "$vinfo" && test -n "$release"; then 8990d63fdb69Smrg major= 8991d63fdb69Smrg case $version_type in 8992d63fdb69Smrg darwin) 8993d63fdb69Smrg # we can't check for "0.0" in archive_cmds due to quoting 8994d63fdb69Smrg # problems, so we reset it completely 8995d63fdb69Smrg verstring= 8996d63fdb69Smrg ;; 8997d63fdb69Smrg *) 899852fd71cdSmrg verstring=0.0 8999d63fdb69Smrg ;; 9000d63fdb69Smrg esac 900152fd71cdSmrg if test no = "$need_version"; then 9002d63fdb69Smrg versuffix= 9003d63fdb69Smrg else 900452fd71cdSmrg versuffix=.0.0 9005d63fdb69Smrg fi 9006d63fdb69Smrg fi 9007d63fdb69Smrg 9008d63fdb69Smrg # Remove version info from name if versioning should be avoided 900952fd71cdSmrg if test yes,no = "$avoid_version,$need_version"; then 9010d63fdb69Smrg major= 9011d63fdb69Smrg versuffix= 901252fd71cdSmrg verstring= 9013d63fdb69Smrg fi 9014d63fdb69Smrg 9015d63fdb69Smrg # Check to see if the archive will have undefined symbols. 901652fd71cdSmrg if test yes = "$allow_undefined"; then 901752fd71cdSmrg if test unsupported = "$allow_undefined_flag"; then 901852fd71cdSmrg if test yes = "$build_old_libs"; then 901952fd71cdSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902052fd71cdSmrg build_libtool_libs=no 902152fd71cdSmrg else 902252fd71cdSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 902352fd71cdSmrg fi 9024d63fdb69Smrg fi 9025d63fdb69Smrg else 9026d63fdb69Smrg # Don't allow undefined symbols. 902752fd71cdSmrg allow_undefined_flag=$no_undefined_flag 9028d63fdb69Smrg fi 9029d63fdb69Smrg 9030d63fdb69Smrg fi 9031d63fdb69Smrg 903252fd71cdSmrg func_generate_dlsyms "$libname" "$libname" : 903348c85eb7Smrg func_append libobjs " $symfileobj" 903452fd71cdSmrg test " " = "$libobjs" && libobjs= 9035d63fdb69Smrg 903652fd71cdSmrg if test relink != "$opt_mode"; then 9037d63fdb69Smrg # Remove our outputs, but don't remove object files since they 9038d63fdb69Smrg # may have been created when compiling PIC objects. 9039d63fdb69Smrg removelist= 9040d63fdb69Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9041d63fdb69Smrg for p in $tempremovelist; do 9042d63fdb69Smrg case $p in 9043d63fdb69Smrg *.$objext | *.gcno) 9044d63fdb69Smrg ;; 904552fd71cdSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 904652fd71cdSmrg if test -n "$precious_files_regex"; then 9047d63fdb69Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048d63fdb69Smrg then 9049d63fdb69Smrg continue 9050d63fdb69Smrg fi 9051d63fdb69Smrg fi 905248c85eb7Smrg func_append removelist " $p" 9053d63fdb69Smrg ;; 9054d63fdb69Smrg *) ;; 9055d63fdb69Smrg esac 9056d63fdb69Smrg done 9057d63fdb69Smrg test -n "$removelist" && \ 9058d63fdb69Smrg func_show_eval "${RM}r \$removelist" 9059d63fdb69Smrg fi 9060d63fdb69Smrg 9061d63fdb69Smrg # Now set the variables for building old libraries. 906252fd71cdSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 906348c85eb7Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9064d63fdb69Smrg 9065d63fdb69Smrg # Transform .lo files to .o files. 906652fd71cdSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067d63fdb69Smrg fi 9068d63fdb69Smrg 9069d63fdb69Smrg # Eliminate all temporary directories. 9070d63fdb69Smrg #for path in $notinst_path; do 907155acc8fcSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 907255acc8fcSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 907355acc8fcSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074d63fdb69Smrg #done 9075d63fdb69Smrg 9076d63fdb69Smrg if test -n "$xrpath"; then 9077d63fdb69Smrg # If the user specified any rpath flags, then add them. 9078d63fdb69Smrg temp_xrpath= 9079d63fdb69Smrg for libdir in $xrpath; do 908048c85eb7Smrg func_replace_sysroot "$libdir" 908148c85eb7Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9082d63fdb69Smrg case "$finalize_rpath " in 9083d63fdb69Smrg *" $libdir "*) ;; 908448c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 9085d63fdb69Smrg esac 9086d63fdb69Smrg done 908752fd71cdSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088d63fdb69Smrg dependency_libs="$temp_xrpath $dependency_libs" 9089d63fdb69Smrg fi 9090d63fdb69Smrg fi 9091d63fdb69Smrg 9092d63fdb69Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 909352fd71cdSmrg old_dlfiles=$dlfiles 9094d63fdb69Smrg dlfiles= 9095d63fdb69Smrg for lib in $old_dlfiles; do 9096d63fdb69Smrg case " $dlprefiles $dlfiles " in 9097d63fdb69Smrg *" $lib "*) ;; 909848c85eb7Smrg *) func_append dlfiles " $lib" ;; 9099d63fdb69Smrg esac 9100d63fdb69Smrg done 9101d63fdb69Smrg 9102d63fdb69Smrg # Make sure dlprefiles contains only unique files 910352fd71cdSmrg old_dlprefiles=$dlprefiles 9104d63fdb69Smrg dlprefiles= 9105d63fdb69Smrg for lib in $old_dlprefiles; do 9106d63fdb69Smrg case "$dlprefiles " in 9107d63fdb69Smrg *" $lib "*) ;; 910848c85eb7Smrg *) func_append dlprefiles " $lib" ;; 9109d63fdb69Smrg esac 9110d63fdb69Smrg done 9111d63fdb69Smrg 911252fd71cdSmrg if test yes = "$build_libtool_libs"; then 9113d63fdb69Smrg if test -n "$rpath"; then 9114d63fdb69Smrg case $host in 911555acc8fcSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116d63fdb69Smrg # these systems don't actually have a c library (as such)! 9117d63fdb69Smrg ;; 9118d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9119d63fdb69Smrg # Rhapsody C library is in the System framework 912048c85eb7Smrg func_append deplibs " System.ltframework" 9121d63fdb69Smrg ;; 9122d63fdb69Smrg *-*-netbsd*) 9123d63fdb69Smrg # Don't link with libc until the a.out ld.so is fixed. 9124d63fdb69Smrg ;; 9125d63fdb69Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126d63fdb69Smrg # Do not include libc due to us having libc/libc_r. 9127d63fdb69Smrg ;; 9128d63fdb69Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9129d63fdb69Smrg # Causes problems with __ctype 9130d63fdb69Smrg ;; 9131d63fdb69Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132d63fdb69Smrg # Compiler inserts libc in the correct place for threads to work 9133d63fdb69Smrg ;; 9134d63fdb69Smrg *) 9135d63fdb69Smrg # Add libc to deplibs on all other systems if necessary. 913652fd71cdSmrg if test yes = "$build_libtool_need_lc"; then 913748c85eb7Smrg func_append deplibs " -lc" 9138d63fdb69Smrg fi 9139d63fdb69Smrg ;; 9140d63fdb69Smrg esac 9141d63fdb69Smrg fi 9142d63fdb69Smrg 9143d63fdb69Smrg # Transform deplibs into only deplibs that can be linked in shared. 9144d63fdb69Smrg name_save=$name 9145d63fdb69Smrg libname_save=$libname 9146d63fdb69Smrg release_save=$release 9147d63fdb69Smrg versuffix_save=$versuffix 9148d63fdb69Smrg major_save=$major 9149d63fdb69Smrg # I'm not sure if I'm treating the release correctly. I think 9150d63fdb69Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9151d63fdb69Smrg # add it in twice. Is that correct? 915252fd71cdSmrg release= 915352fd71cdSmrg versuffix= 915452fd71cdSmrg major= 9155d63fdb69Smrg newdeplibs= 9156d63fdb69Smrg droppeddeps=no 9157d63fdb69Smrg case $deplibs_check_method in 9158d63fdb69Smrg pass_all) 9159d63fdb69Smrg # Don't check for shared/static. Everything works. 9160d63fdb69Smrg # This might be a little naive. We might want to check 9161d63fdb69Smrg # whether the library exists or not. But this is on 9162d63fdb69Smrg # osf3 & osf4 and I'm not really sure... Just 9163d63fdb69Smrg # implementing what was already the behavior. 9164d63fdb69Smrg newdeplibs=$deplibs 9165d63fdb69Smrg ;; 9166d63fdb69Smrg test_compile) 9167d63fdb69Smrg # This code stresses the "libraries are programs" paradigm to its 9168d63fdb69Smrg # limits. Maybe even breaks it. We compile a program, linking it 9169d63fdb69Smrg # against the deplibs as a proxy for the library. Then we can check 9170d63fdb69Smrg # whether they linked in statically or dynamically with ldd. 9171d63fdb69Smrg $opt_dry_run || $RM conftest.c 9172d63fdb69Smrg cat > conftest.c <<EOF 9173d63fdb69Smrg int main() { return 0; } 9174d63fdb69SmrgEOF 9175d63fdb69Smrg $opt_dry_run || $RM conftest 9176d63fdb69Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177d63fdb69Smrg ldd_output=`ldd conftest` 9178d63fdb69Smrg for i in $deplibs; do 9179d63fdb69Smrg case $i in 9180d63fdb69Smrg -l*) 9181d63fdb69Smrg func_stripname -l '' "$i" 9182d63fdb69Smrg name=$func_stripname_result 918352fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184d63fdb69Smrg case " $predeps $postdeps " in 9185d63fdb69Smrg *" $i "*) 918648c85eb7Smrg func_append newdeplibs " $i" 918752fd71cdSmrg i= 9188d63fdb69Smrg ;; 9189d63fdb69Smrg esac 9190d63fdb69Smrg fi 919152fd71cdSmrg if test -n "$i"; then 9192d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9193d63fdb69Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194d63fdb69Smrg set dummy $deplib_matches; shift 9195d63fdb69Smrg deplib_match=$1 919652fd71cdSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 919748c85eb7Smrg func_append newdeplibs " $i" 9198d63fdb69Smrg else 9199d63fdb69Smrg droppeddeps=yes 920055acc8fcSmrg echo 9201d63fdb69Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 920255acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 920355acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 920455acc8fcSmrg echo "*** shared version of the library, which I believe you do not have" 920555acc8fcSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 920655acc8fcSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207d63fdb69Smrg fi 9208d63fdb69Smrg fi 9209d63fdb69Smrg ;; 9210d63fdb69Smrg *) 921148c85eb7Smrg func_append newdeplibs " $i" 9212d63fdb69Smrg ;; 9213d63fdb69Smrg esac 9214d63fdb69Smrg done 9215d63fdb69Smrg else 9216d63fdb69Smrg # Error occurred in the first compile. Let's try to salvage 9217d63fdb69Smrg # the situation: Compile a separate program for each library. 9218d63fdb69Smrg for i in $deplibs; do 9219d63fdb69Smrg case $i in 9220d63fdb69Smrg -l*) 9221d63fdb69Smrg func_stripname -l '' "$i" 9222d63fdb69Smrg name=$func_stripname_result 9223d63fdb69Smrg $opt_dry_run || $RM conftest 9224d63fdb69Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225d63fdb69Smrg ldd_output=`ldd conftest` 922652fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227d63fdb69Smrg case " $predeps $postdeps " in 9228d63fdb69Smrg *" $i "*) 922948c85eb7Smrg func_append newdeplibs " $i" 923052fd71cdSmrg i= 9231d63fdb69Smrg ;; 9232d63fdb69Smrg esac 9233d63fdb69Smrg fi 923452fd71cdSmrg if test -n "$i"; then 9235d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9236d63fdb69Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237d63fdb69Smrg set dummy $deplib_matches; shift 9238d63fdb69Smrg deplib_match=$1 923952fd71cdSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924048c85eb7Smrg func_append newdeplibs " $i" 9241d63fdb69Smrg else 9242d63fdb69Smrg droppeddeps=yes 924355acc8fcSmrg echo 9244d63fdb69Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 924555acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 924655acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 924755acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 924855acc8fcSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 924955acc8fcSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250d63fdb69Smrg fi 9251d63fdb69Smrg fi 9252d63fdb69Smrg else 9253d63fdb69Smrg droppeddeps=yes 925455acc8fcSmrg echo 9255d63fdb69Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 925655acc8fcSmrg echo "*** make it link in! You will probably need to install it or some" 925755acc8fcSmrg echo "*** library that it depends on before this library will be fully" 925855acc8fcSmrg echo "*** functional. Installing it before continuing would be even better." 9259d63fdb69Smrg fi 9260d63fdb69Smrg ;; 9261d63fdb69Smrg *) 926248c85eb7Smrg func_append newdeplibs " $i" 9263d63fdb69Smrg ;; 9264d63fdb69Smrg esac 9265d63fdb69Smrg done 9266d63fdb69Smrg fi 9267d63fdb69Smrg ;; 9268d63fdb69Smrg file_magic*) 9269d63fdb69Smrg set dummy $deplibs_check_method; shift 9270d63fdb69Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271d63fdb69Smrg for a_deplib in $deplibs; do 9272d63fdb69Smrg case $a_deplib in 9273d63fdb69Smrg -l*) 9274d63fdb69Smrg func_stripname -l '' "$a_deplib" 9275d63fdb69Smrg name=$func_stripname_result 927652fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277d63fdb69Smrg case " $predeps $postdeps " in 9278d63fdb69Smrg *" $a_deplib "*) 927948c85eb7Smrg func_append newdeplibs " $a_deplib" 928052fd71cdSmrg a_deplib= 9281d63fdb69Smrg ;; 9282d63fdb69Smrg esac 9283d63fdb69Smrg fi 928452fd71cdSmrg if test -n "$a_deplib"; then 9285d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 928648c85eb7Smrg if test -n "$file_magic_glob"; then 928748c85eb7Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 928848c85eb7Smrg else 928948c85eb7Smrg libnameglob=$libname 929048c85eb7Smrg fi 929152fd71cdSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292d63fdb69Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 929352fd71cdSmrg if test yes = "$want_nocaseglob"; then 929448c85eb7Smrg shopt -s nocaseglob 929548c85eb7Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929648c85eb7Smrg $nocaseglob 929748c85eb7Smrg else 929848c85eb7Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929948c85eb7Smrg fi 9300d63fdb69Smrg for potent_lib in $potential_libs; do 9301d63fdb69Smrg # Follow soft links. 9302d63fdb69Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9303d63fdb69Smrg $GREP " -> " >/dev/null; then 9304d63fdb69Smrg continue 9305d63fdb69Smrg fi 9306d63fdb69Smrg # The statement above tries to avoid entering an 9307d63fdb69Smrg # endless loop below, in case of cyclic links. 9308d63fdb69Smrg # We might still enter an endless loop, since a link 9309d63fdb69Smrg # loop can be closed while we follow links, 9310d63fdb69Smrg # but so what? 931152fd71cdSmrg potlib=$potent_lib 9312d63fdb69Smrg while test -h "$potlib" 2>/dev/null; do 931352fd71cdSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314d63fdb69Smrg case $potliblink in 931552fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 931652fd71cdSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317d63fdb69Smrg esac 9318d63fdb69Smrg done 9319d63fdb69Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320d63fdb69Smrg $SED -e 10q | 9321d63fdb69Smrg $EGREP "$file_magic_regex" > /dev/null; then 932248c85eb7Smrg func_append newdeplibs " $a_deplib" 932352fd71cdSmrg a_deplib= 9324d63fdb69Smrg break 2 9325d63fdb69Smrg fi 9326d63fdb69Smrg done 9327d63fdb69Smrg done 9328d63fdb69Smrg fi 932952fd71cdSmrg if test -n "$a_deplib"; then 9330d63fdb69Smrg droppeddeps=yes 933155acc8fcSmrg echo 9332d63fdb69Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 933355acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 933455acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 933555acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 933655acc8fcSmrg echo "*** because I did check the linker path looking for a file starting" 933752fd71cdSmrg if test -z "$potlib"; then 9338d63fdb69Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339d63fdb69Smrg else 9340d63fdb69Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9341d63fdb69Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9342d63fdb69Smrg fi 9343d63fdb69Smrg fi 9344d63fdb69Smrg ;; 9345d63fdb69Smrg *) 9346d63fdb69Smrg # Add a -L argument. 934748c85eb7Smrg func_append newdeplibs " $a_deplib" 9348d63fdb69Smrg ;; 9349d63fdb69Smrg esac 9350d63fdb69Smrg done # Gone through all deplibs. 9351d63fdb69Smrg ;; 9352d63fdb69Smrg match_pattern*) 9353d63fdb69Smrg set dummy $deplibs_check_method; shift 9354d63fdb69Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355d63fdb69Smrg for a_deplib in $deplibs; do 9356d63fdb69Smrg case $a_deplib in 9357d63fdb69Smrg -l*) 9358d63fdb69Smrg func_stripname -l '' "$a_deplib" 9359d63fdb69Smrg name=$func_stripname_result 936052fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361d63fdb69Smrg case " $predeps $postdeps " in 9362d63fdb69Smrg *" $a_deplib "*) 936348c85eb7Smrg func_append newdeplibs " $a_deplib" 936452fd71cdSmrg a_deplib= 9365d63fdb69Smrg ;; 9366d63fdb69Smrg esac 9367d63fdb69Smrg fi 936852fd71cdSmrg if test -n "$a_deplib"; then 9369d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9370d63fdb69Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371d63fdb69Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372d63fdb69Smrg for potent_lib in $potential_libs; do 937352fd71cdSmrg potlib=$potent_lib # see symlink-check above in file_magic test 937455acc8fcSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375d63fdb69Smrg $EGREP "$match_pattern_regex" > /dev/null; then 937648c85eb7Smrg func_append newdeplibs " $a_deplib" 937752fd71cdSmrg a_deplib= 9378d63fdb69Smrg break 2 9379d63fdb69Smrg fi 9380d63fdb69Smrg done 9381d63fdb69Smrg done 9382d63fdb69Smrg fi 938352fd71cdSmrg if test -n "$a_deplib"; then 9384d63fdb69Smrg droppeddeps=yes 938555acc8fcSmrg echo 9386d63fdb69Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 938755acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 938855acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 938955acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 939055acc8fcSmrg echo "*** because I did check the linker path looking for a file starting" 939152fd71cdSmrg if test -z "$potlib"; then 9392d63fdb69Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393d63fdb69Smrg else 9394d63fdb69Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9395d63fdb69Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396d63fdb69Smrg fi 9397d63fdb69Smrg fi 9398d63fdb69Smrg ;; 9399d63fdb69Smrg *) 9400d63fdb69Smrg # Add a -L argument. 940148c85eb7Smrg func_append newdeplibs " $a_deplib" 9402d63fdb69Smrg ;; 9403d63fdb69Smrg esac 9404d63fdb69Smrg done # Gone through all deplibs. 9405d63fdb69Smrg ;; 9406d63fdb69Smrg none | unknown | *) 940752fd71cdSmrg newdeplibs= 940855acc8fcSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 940952fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941052fd71cdSmrg for i in $predeps $postdeps; do 9411d63fdb69Smrg # can't use Xsed below, because $i might contain '/' 941252fd71cdSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413d63fdb69Smrg done 9414d63fdb69Smrg fi 941555acc8fcSmrg case $tmp_deplibs in 941655acc8fcSmrg *[!\ \ ]*) 941755acc8fcSmrg echo 941852fd71cdSmrg if test none = "$deplibs_check_method"; then 941955acc8fcSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9420d63fdb69Smrg else 942155acc8fcSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 9422d63fdb69Smrg fi 942355acc8fcSmrg echo "*** All declared inter-library dependencies are being dropped." 9424d63fdb69Smrg droppeddeps=yes 942555acc8fcSmrg ;; 942655acc8fcSmrg esac 9427d63fdb69Smrg ;; 9428d63fdb69Smrg esac 9429d63fdb69Smrg versuffix=$versuffix_save 9430d63fdb69Smrg major=$major_save 9431d63fdb69Smrg release=$release_save 9432d63fdb69Smrg libname=$libname_save 9433d63fdb69Smrg name=$name_save 9434d63fdb69Smrg 9435d63fdb69Smrg case $host in 9436d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9437d63fdb69Smrg # On Rhapsody replace the C library with the System framework 943855acc8fcSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439d63fdb69Smrg ;; 9440d63fdb69Smrg esac 9441d63fdb69Smrg 944252fd71cdSmrg if test yes = "$droppeddeps"; then 944352fd71cdSmrg if test yes = "$module"; then 944455acc8fcSmrg echo 944555acc8fcSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9446d63fdb69Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 944755acc8fcSmrg echo "*** a static module, that should work as long as the dlopening" 944855acc8fcSmrg echo "*** application is linked with the -dlopen flag." 9449d63fdb69Smrg if test -z "$global_symbol_pipe"; then 945055acc8fcSmrg echo 945155acc8fcSmrg echo "*** However, this would only work if libtool was able to extract symbol" 945252fd71cdSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 945355acc8fcSmrg echo "*** not find such a program. So, this module is probably useless." 945452fd71cdSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455d63fdb69Smrg fi 945652fd71cdSmrg if test no = "$build_old_libs"; then 945752fd71cdSmrg oldlibs=$output_objdir/$libname.$libext 9458d63fdb69Smrg build_libtool_libs=module 9459d63fdb69Smrg build_old_libs=yes 9460d63fdb69Smrg else 9461d63fdb69Smrg build_libtool_libs=no 9462d63fdb69Smrg fi 9463d63fdb69Smrg else 946455acc8fcSmrg echo "*** The inter-library dependencies that have been dropped here will be" 946555acc8fcSmrg echo "*** automatically added whenever a program is linked with this library" 946655acc8fcSmrg echo "*** or is declared to -dlopen it." 9467d63fdb69Smrg 946852fd71cdSmrg if test no = "$allow_undefined"; then 946955acc8fcSmrg echo 947055acc8fcSmrg echo "*** Since this library must not contain undefined symbols," 947155acc8fcSmrg echo "*** because either the platform does not support them or" 947255acc8fcSmrg echo "*** it was explicitly requested with -no-undefined," 947355acc8fcSmrg echo "*** libtool will only create a static version of it." 947452fd71cdSmrg if test no = "$build_old_libs"; then 947552fd71cdSmrg oldlibs=$output_objdir/$libname.$libext 9476d63fdb69Smrg build_libtool_libs=module 9477d63fdb69Smrg build_old_libs=yes 9478d63fdb69Smrg else 9479d63fdb69Smrg build_libtool_libs=no 9480d63fdb69Smrg fi 9481d63fdb69Smrg fi 9482d63fdb69Smrg fi 9483d63fdb69Smrg fi 9484d63fdb69Smrg # Done checking deplibs! 9485d63fdb69Smrg deplibs=$newdeplibs 9486d63fdb69Smrg fi 9487d63fdb69Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488d63fdb69Smrg case $host in 9489d63fdb69Smrg *-*-darwin*) 949055acc8fcSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949155acc8fcSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949255acc8fcSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493d63fdb69Smrg ;; 9494d63fdb69Smrg esac 9495d63fdb69Smrg 9496d63fdb69Smrg # move library search paths that coincide with paths to not yet 9497d63fdb69Smrg # installed libraries to the beginning of the library search list 9498d63fdb69Smrg new_libs= 9499d63fdb69Smrg for path in $notinst_path; do 9500d63fdb69Smrg case " $new_libs " in 9501d63fdb69Smrg *" -L$path/$objdir "*) ;; 9502d63fdb69Smrg *) 9503d63fdb69Smrg case " $deplibs " in 9504d63fdb69Smrg *" -L$path/$objdir "*) 950548c85eb7Smrg func_append new_libs " -L$path/$objdir" ;; 9506d63fdb69Smrg esac 9507d63fdb69Smrg ;; 9508d63fdb69Smrg esac 9509d63fdb69Smrg done 9510d63fdb69Smrg for deplib in $deplibs; do 9511d63fdb69Smrg case $deplib in 9512d63fdb69Smrg -L*) 9513d63fdb69Smrg case " $new_libs " in 9514d63fdb69Smrg *" $deplib "*) ;; 951548c85eb7Smrg *) func_append new_libs " $deplib" ;; 9516d63fdb69Smrg esac 9517d63fdb69Smrg ;; 951848c85eb7Smrg *) func_append new_libs " $deplib" ;; 9519d63fdb69Smrg esac 9520d63fdb69Smrg done 952152fd71cdSmrg deplibs=$new_libs 9522d63fdb69Smrg 9523d63fdb69Smrg # All the library-specific variables (install_libdir is set above). 9524d63fdb69Smrg library_names= 9525d63fdb69Smrg old_library= 9526d63fdb69Smrg dlname= 9527d63fdb69Smrg 9528d63fdb69Smrg # Test again, we may have decided not to build it any more 952952fd71cdSmrg if test yes = "$build_libtool_libs"; then 953052fd71cdSmrg # Remove $wl instances when linking with ld. 953148c85eb7Smrg # FIXME: should test the right _cmds variable. 953248c85eb7Smrg case $archive_cmds in 953348c85eb7Smrg *\$LD\ *) wl= ;; 953448c85eb7Smrg esac 953552fd71cdSmrg if test yes = "$hardcode_into_libs"; then 9536d63fdb69Smrg # Hardcode the library paths 9537d63fdb69Smrg hardcode_libdirs= 9538d63fdb69Smrg dep_rpath= 953952fd71cdSmrg rpath=$finalize_rpath 954052fd71cdSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541d63fdb69Smrg for libdir in $rpath; do 9542d63fdb69Smrg if test -n "$hardcode_libdir_flag_spec"; then 9543d63fdb69Smrg if test -n "$hardcode_libdir_separator"; then 954448c85eb7Smrg func_replace_sysroot "$libdir" 954548c85eb7Smrg libdir=$func_replace_sysroot_result 9546d63fdb69Smrg if test -z "$hardcode_libdirs"; then 954752fd71cdSmrg hardcode_libdirs=$libdir 9548d63fdb69Smrg else 9549d63fdb69Smrg # Just accumulate the unique libdirs. 9550d63fdb69Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551d63fdb69Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552d63fdb69Smrg ;; 9553d63fdb69Smrg *) 955448c85eb7Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555d63fdb69Smrg ;; 9556d63fdb69Smrg esac 9557d63fdb69Smrg fi 9558d63fdb69Smrg else 9559d63fdb69Smrg eval flag=\"$hardcode_libdir_flag_spec\" 956048c85eb7Smrg func_append dep_rpath " $flag" 9561d63fdb69Smrg fi 9562d63fdb69Smrg elif test -n "$runpath_var"; then 9563d63fdb69Smrg case "$perm_rpath " in 9564d63fdb69Smrg *" $libdir "*) ;; 956548c85eb7Smrg *) func_append perm_rpath " $libdir" ;; 9566d63fdb69Smrg esac 9567d63fdb69Smrg fi 9568d63fdb69Smrg done 9569d63fdb69Smrg # Substitute the hardcoded libdirs into the rpath. 9570d63fdb69Smrg if test -n "$hardcode_libdir_separator" && 9571d63fdb69Smrg test -n "$hardcode_libdirs"; then 957252fd71cdSmrg libdir=$hardcode_libdirs 957348c85eb7Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574d63fdb69Smrg fi 9575d63fdb69Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576d63fdb69Smrg # We should set the runpath_var. 9577d63fdb69Smrg rpath= 9578d63fdb69Smrg for dir in $perm_rpath; do 957948c85eb7Smrg func_append rpath "$dir:" 9580d63fdb69Smrg done 9581d63fdb69Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582d63fdb69Smrg fi 9583d63fdb69Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584d63fdb69Smrg fi 95853da084b3Smrg 958652fd71cdSmrg shlibpath=$finalize_shlibpath 958752fd71cdSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588d63fdb69Smrg if test -n "$shlibpath"; then 9589d63fdb69Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590d63fdb69Smrg fi 95913da084b3Smrg 9592d63fdb69Smrg # Get the real and link names of the library. 9593d63fdb69Smrg eval shared_ext=\"$shrext_cmds\" 9594d63fdb69Smrg eval library_names=\"$library_names_spec\" 9595d63fdb69Smrg set dummy $library_names 9596d63fdb69Smrg shift 959752fd71cdSmrg realname=$1 9598d63fdb69Smrg shift 95993da084b3Smrg 9600d63fdb69Smrg if test -n "$soname_spec"; then 9601d63fdb69Smrg eval soname=\"$soname_spec\" 9602d63fdb69Smrg else 960352fd71cdSmrg soname=$realname 9604d63fdb69Smrg fi 9605d63fdb69Smrg if test -z "$dlname"; then 9606d63fdb69Smrg dlname=$soname 9607d63fdb69Smrg fi 96083da084b3Smrg 960952fd71cdSmrg lib=$output_objdir/$realname 9610d63fdb69Smrg linknames= 9611d63fdb69Smrg for link 9612d63fdb69Smrg do 961348c85eb7Smrg func_append linknames " $link" 9614d63fdb69Smrg done 96153da084b3Smrg 9616d63fdb69Smrg # Use standard objects if they are pic 961755acc8fcSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 96193da084b3Smrg 9620d63fdb69Smrg delfiles= 9621d63fdb69Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622d63fdb69Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 962352fd71cdSmrg export_symbols=$output_objdir/$libname.uexp 962448c85eb7Smrg func_append delfiles " $export_symbols" 9625d63fdb69Smrg fi 96263da084b3Smrg 9627d63fdb69Smrg orig_export_symbols= 9628d63fdb69Smrg case $host_os in 9629d63fdb69Smrg cygwin* | mingw* | cegcc*) 9630d63fdb69Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631d63fdb69Smrg # exporting using user supplied symfile 963252fd71cdSmrg func_dll_def_p "$export_symbols" || { 9633d63fdb69Smrg # and it's NOT already a .def file. Must figure out 9634d63fdb69Smrg # which of the given symbols are data symbols and tag 9635d63fdb69Smrg # them as such. So, trigger use of export_symbols_cmds. 9636d63fdb69Smrg # export_symbols gets reassigned inside the "prepare 9637d63fdb69Smrg # the list of exported symbols" if statement, so the 9638d63fdb69Smrg # include_expsyms logic still works. 963952fd71cdSmrg orig_export_symbols=$export_symbols 9640d63fdb69Smrg export_symbols= 9641d63fdb69Smrg always_export_symbols=yes 964252fd71cdSmrg } 9643d63fdb69Smrg fi 9644d63fdb69Smrg ;; 9645d63fdb69Smrg esac 96463da084b3Smrg 9647d63fdb69Smrg # Prepare the list of exported symbols 9648d63fdb69Smrg if test -z "$export_symbols"; then 964952fd71cdSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965052fd71cdSmrg func_verbose "generating symbol list for '$libname.la'" 965152fd71cdSmrg export_symbols=$output_objdir/$libname.exp 9652d63fdb69Smrg $opt_dry_run || $RM $export_symbols 9653d63fdb69Smrg cmds=$export_symbols_cmds 965452fd71cdSmrg save_ifs=$IFS; IFS='~' 965548c85eb7Smrg for cmd1 in $cmds; do 965652fd71cdSmrg IFS=$save_ifs 965748c85eb7Smrg # Take the normal branch if the nm_file_list_spec branch 965848c85eb7Smrg # doesn't work or if tool conversion is not needed. 965948c85eb7Smrg case $nm_file_list_spec~$to_tool_file_cmd in 966048c85eb7Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 966148c85eb7Smrg try_normal_branch=yes 966248c85eb7Smrg eval cmd=\"$cmd1\" 966348c85eb7Smrg func_len " $cmd" 966448c85eb7Smrg len=$func_len_result 966548c85eb7Smrg ;; 966648c85eb7Smrg *) 966748c85eb7Smrg try_normal_branch=no 966848c85eb7Smrg ;; 966948c85eb7Smrg esac 967052fd71cdSmrg if test yes = "$try_normal_branch" \ 967148c85eb7Smrg && { test "$len" -lt "$max_cmd_len" \ 967248c85eb7Smrg || test "$max_cmd_len" -le -1; } 967348c85eb7Smrg then 967448c85eb7Smrg func_show_eval "$cmd" 'exit $?' 967548c85eb7Smrg skipped_export=false 967648c85eb7Smrg elif test -n "$nm_file_list_spec"; then 967748c85eb7Smrg func_basename "$output" 967848c85eb7Smrg output_la=$func_basename_result 967948c85eb7Smrg save_libobjs=$libobjs 968048c85eb7Smrg save_output=$output 968152fd71cdSmrg output=$output_objdir/$output_la.nm 968248c85eb7Smrg func_to_tool_file "$output" 968348c85eb7Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 968448c85eb7Smrg func_append delfiles " $output" 968548c85eb7Smrg func_verbose "creating $NM input file list: $output" 968648c85eb7Smrg for obj in $save_libobjs; do 968748c85eb7Smrg func_to_tool_file "$obj" 968848c85eb7Smrg $ECHO "$func_to_tool_file_result" 968948c85eb7Smrg done > "$output" 969048c85eb7Smrg eval cmd=\"$cmd1\" 9691d63fdb69Smrg func_show_eval "$cmd" 'exit $?' 969248c85eb7Smrg output=$save_output 969348c85eb7Smrg libobjs=$save_libobjs 9694d63fdb69Smrg skipped_export=false 9695d63fdb69Smrg else 9696d63fdb69Smrg # The command line is too long to execute in one step. 9697d63fdb69Smrg func_verbose "using reloadable object file for export list..." 9698d63fdb69Smrg skipped_export=: 9699d63fdb69Smrg # Break out early, otherwise skipped_export may be 9700d63fdb69Smrg # set to false by a later but shorter cmd. 9701d63fdb69Smrg break 9702d63fdb69Smrg fi 9703d63fdb69Smrg done 970452fd71cdSmrg IFS=$save_ifs 970552fd71cdSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706d63fdb69Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707d63fdb69Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708d63fdb69Smrg fi 9709d63fdb69Smrg fi 9710d63fdb69Smrg fi 97113da084b3Smrg 9712d63fdb69Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 971352fd71cdSmrg tmp_export_symbols=$export_symbols 971452fd71cdSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 971555acc8fcSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716d63fdb69Smrg fi 97173da084b3Smrg 971852fd71cdSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719d63fdb69Smrg # The given exports_symbols file has to be filtered, so filter it. 972052fd71cdSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721d63fdb69Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 972252fd71cdSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9723d63fdb69Smrg # though. Also, the filter scales superlinearly with the number of 9724d63fdb69Smrg # global variables. join(1) would be nice here, but unfortunately 9725d63fdb69Smrg # isn't a blessed tool. 9726d63fdb69Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 972748c85eb7Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728d63fdb69Smrg export_symbols=$output_objdir/$libname.def 9729d63fdb69Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97303da084b3Smrg fi 97313da084b3Smrg 9732d63fdb69Smrg tmp_deplibs= 9733d63fdb69Smrg for test_deplib in $deplibs; do 9734d63fdb69Smrg case " $convenience " in 9735d63fdb69Smrg *" $test_deplib "*) ;; 9736d63fdb69Smrg *) 973748c85eb7Smrg func_append tmp_deplibs " $test_deplib" 9738d63fdb69Smrg ;; 9739d63fdb69Smrg esac 9740d63fdb69Smrg done 974152fd71cdSmrg deplibs=$tmp_deplibs 97423da084b3Smrg 9743d63fdb69Smrg if test -n "$convenience"; then 9744d63fdb69Smrg if test -n "$whole_archive_flag_spec" && 974552fd71cdSmrg test yes = "$compiler_needs_object" && 9746d63fdb69Smrg test -z "$libobjs"; then 9747d63fdb69Smrg # extract the archives, so we have objects to list. 9748d63fdb69Smrg # TODO: could optimize this to just extract one archive. 9749d63fdb69Smrg whole_archive_flag_spec= 9750d63fdb69Smrg fi 9751d63fdb69Smrg if test -n "$whole_archive_flag_spec"; then 9752d63fdb69Smrg save_libobjs=$libobjs 9753d63fdb69Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 9755d63fdb69Smrg else 975652fd71cdSmrg gentop=$output_objdir/${outputname}x 975748c85eb7Smrg func_append generated " $gentop" 97583da084b3Smrg 9759d63fdb69Smrg func_extract_archives $gentop $convenience 976048c85eb7Smrg func_append libobjs " $func_extract_archives_result" 9761d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 9762d63fdb69Smrg fi 9763d63fdb69Smrg fi 97643da084b3Smrg 976552fd71cdSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766d63fdb69Smrg eval flag=\"$thread_safe_flag_spec\" 976748c85eb7Smrg func_append linker_flags " $flag" 9768d63fdb69Smrg fi 97693da084b3Smrg 9770d63fdb69Smrg # Make a backup of the uninstalled library when relinking 977152fd71cdSmrg if test relink = "$opt_mode"; then 9772d63fdb69Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 97733da084b3Smrg fi 97743da084b3Smrg 9775d63fdb69Smrg # Do each of the archive commands. 977652fd71cdSmrg if test yes = "$module" && test -n "$module_cmds"; then 9777d63fdb69Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778d63fdb69Smrg eval test_cmds=\"$module_expsym_cmds\" 9779d63fdb69Smrg cmds=$module_expsym_cmds 9780d63fdb69Smrg else 9781d63fdb69Smrg eval test_cmds=\"$module_cmds\" 9782d63fdb69Smrg cmds=$module_cmds 9783d63fdb69Smrg fi 9784d63fdb69Smrg else 9785d63fdb69Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786d63fdb69Smrg eval test_cmds=\"$archive_expsym_cmds\" 9787d63fdb69Smrg cmds=$archive_expsym_cmds 9788d63fdb69Smrg else 9789d63fdb69Smrg eval test_cmds=\"$archive_cmds\" 9790d63fdb69Smrg cmds=$archive_cmds 9791d63fdb69Smrg fi 97923da084b3Smrg fi 97933da084b3Smrg 979452fd71cdSmrg if test : != "$skipped_export" && 9795d63fdb69Smrg func_len " $test_cmds" && 9796d63fdb69Smrg len=$func_len_result && 9797d63fdb69Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798d63fdb69Smrg : 9799d63fdb69Smrg else 9800d63fdb69Smrg # The command line is too long to link in one step, link piecewise 9801d63fdb69Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9802d63fdb69Smrg # script. 98033da084b3Smrg 9804d63fdb69Smrg # Save the value of $output and $libobjs because we want to 9805d63fdb69Smrg # use them later. If we have whole_archive_flag_spec, we 9806d63fdb69Smrg # want to use save_libobjs as it was before 9807d63fdb69Smrg # whole_archive_flag_spec was expanded, because we can't 9808d63fdb69Smrg # assume the linker understands whole_archive_flag_spec. 9809d63fdb69Smrg # This may have to be revisited, in case too many 9810d63fdb69Smrg # convenience libraries get linked in and end up exceeding 9811d63fdb69Smrg # the spec. 9812d63fdb69Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813d63fdb69Smrg save_libobjs=$libobjs 9814d63fdb69Smrg fi 9815d63fdb69Smrg save_output=$output 981655acc8fcSmrg func_basename "$output" 981755acc8fcSmrg output_la=$func_basename_result 98183da084b3Smrg 9819d63fdb69Smrg # Clear the reloadable object creation command queue and 9820d63fdb69Smrg # initialize k to one. 9821d63fdb69Smrg test_cmds= 9822d63fdb69Smrg concat_cmds= 9823d63fdb69Smrg objlist= 9824d63fdb69Smrg last_robj= 9825d63fdb69Smrg k=1 98263da084b3Smrg 982752fd71cdSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 982852fd71cdSmrg output=$output_objdir/$output_la.lnkscript 9829d63fdb69Smrg func_verbose "creating GNU ld script: $output" 983055acc8fcSmrg echo 'INPUT (' > $output 9831d63fdb69Smrg for obj in $save_libobjs 9832d63fdb69Smrg do 983348c85eb7Smrg func_to_tool_file "$obj" 983448c85eb7Smrg $ECHO "$func_to_tool_file_result" >> $output 9835d63fdb69Smrg done 983655acc8fcSmrg echo ')' >> $output 983748c85eb7Smrg func_append delfiles " $output" 983848c85eb7Smrg func_to_tool_file "$output" 983948c85eb7Smrg output=$func_to_tool_file_result 984052fd71cdSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 984152fd71cdSmrg output=$output_objdir/$output_la.lnk 9842d63fdb69Smrg func_verbose "creating linker input file list: $output" 9843d63fdb69Smrg : > $output 9844d63fdb69Smrg set x $save_libobjs 9845d63fdb69Smrg shift 9846d63fdb69Smrg firstobj= 984752fd71cdSmrg if test yes = "$compiler_needs_object"; then 9848d63fdb69Smrg firstobj="$1 " 9849d63fdb69Smrg shift 9850d63fdb69Smrg fi 9851d63fdb69Smrg for obj 9852d63fdb69Smrg do 985348c85eb7Smrg func_to_tool_file "$obj" 985448c85eb7Smrg $ECHO "$func_to_tool_file_result" >> $output 9855d63fdb69Smrg done 985648c85eb7Smrg func_append delfiles " $output" 985748c85eb7Smrg func_to_tool_file "$output" 985848c85eb7Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859d63fdb69Smrg else 9860d63fdb69Smrg if test -n "$save_libobjs"; then 9861d63fdb69Smrg func_verbose "creating reloadable object files..." 986252fd71cdSmrg output=$output_objdir/$output_la-$k.$objext 9863d63fdb69Smrg eval test_cmds=\"$reload_cmds\" 9864d63fdb69Smrg func_len " $test_cmds" 9865d63fdb69Smrg len0=$func_len_result 9866d63fdb69Smrg len=$len0 9867d63fdb69Smrg 9868d63fdb69Smrg # Loop over the list of objects to be linked. 9869d63fdb69Smrg for obj in $save_libobjs 9870d63fdb69Smrg do 9871d63fdb69Smrg func_len " $obj" 9872d63fdb69Smrg func_arith $len + $func_len_result 9873d63fdb69Smrg len=$func_arith_result 987452fd71cdSmrg if test -z "$objlist" || 9875d63fdb69Smrg test "$len" -lt "$max_cmd_len"; then 9876d63fdb69Smrg func_append objlist " $obj" 9877d63fdb69Smrg else 9878d63fdb69Smrg # The command $test_cmds is almost too long, add a 9879d63fdb69Smrg # command to the queue. 988052fd71cdSmrg if test 1 -eq "$k"; then 9881d63fdb69Smrg # The first file doesn't have a previous command to add. 988255acc8fcSmrg reload_objs=$objlist 988355acc8fcSmrg eval concat_cmds=\"$reload_cmds\" 9884d63fdb69Smrg else 9885d63fdb69Smrg # All subsequent reloadable object files will link in 9886d63fdb69Smrg # the last one created. 988755acc8fcSmrg reload_objs="$objlist $last_robj" 988855acc8fcSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889d63fdb69Smrg fi 989052fd71cdSmrg last_robj=$output_objdir/$output_la-$k.$objext 9891d63fdb69Smrg func_arith $k + 1 9892d63fdb69Smrg k=$func_arith_result 989352fd71cdSmrg output=$output_objdir/$output_la-$k.$objext 989455acc8fcSmrg objlist=" $obj" 9895d63fdb69Smrg func_len " $last_robj" 9896d63fdb69Smrg func_arith $len0 + $func_len_result 9897d63fdb69Smrg len=$func_arith_result 9898d63fdb69Smrg fi 9899d63fdb69Smrg done 9900d63fdb69Smrg # Handle the remaining objects by creating one last 9901d63fdb69Smrg # reloadable object file. All subsequent reloadable object 9902d63fdb69Smrg # files will link in the last one created. 9903d63fdb69Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 990455acc8fcSmrg reload_objs="$objlist $last_robj" 990552fd71cdSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906d63fdb69Smrg if test -n "$last_robj"; then 990752fd71cdSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908d63fdb69Smrg fi 990948c85eb7Smrg func_append delfiles " $output" 99103da084b3Smrg 9911d63fdb69Smrg else 9912d63fdb69Smrg output= 9913d63fdb69Smrg fi 99143da084b3Smrg 991552fd71cdSmrg ${skipped_export-false} && { 991652fd71cdSmrg func_verbose "generating symbol list for '$libname.la'" 991752fd71cdSmrg export_symbols=$output_objdir/$libname.exp 9918d63fdb69Smrg $opt_dry_run || $RM $export_symbols 9919d63fdb69Smrg libobjs=$output 9920d63fdb69Smrg # Append the command to create the export file. 9921d63fdb69Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922d63fdb69Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923d63fdb69Smrg if test -n "$last_robj"; then 9924d63fdb69Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925d63fdb69Smrg fi 992652fd71cdSmrg } 99273da084b3Smrg 9928d63fdb69Smrg test -n "$save_libobjs" && 9929d63fdb69Smrg func_verbose "creating a temporary reloadable object file: $output" 99303da084b3Smrg 9931d63fdb69Smrg # Loop through the commands generated above and execute them. 993252fd71cdSmrg save_ifs=$IFS; IFS='~' 9933d63fdb69Smrg for cmd in $concat_cmds; do 993452fd71cdSmrg IFS=$save_ifs 993552fd71cdSmrg $opt_quiet || { 9936d63fdb69Smrg func_quote_for_expand "$cmd" 9937d63fdb69Smrg eval "func_echo $func_quote_for_expand_result" 9938d63fdb69Smrg } 9939d63fdb69Smrg $opt_dry_run || eval "$cmd" || { 9940d63fdb69Smrg lt_exit=$? 9941d63fdb69Smrg 9942d63fdb69Smrg # Restore the uninstalled library and exit 994352fd71cdSmrg if test relink = "$opt_mode"; then 9944d63fdb69Smrg ( cd "$output_objdir" && \ 9945d63fdb69Smrg $RM "${realname}T" && \ 9946d63fdb69Smrg $MV "${realname}U" "$realname" ) 9947d63fdb69Smrg fi 99483da084b3Smrg 9949d63fdb69Smrg exit $lt_exit 9950d63fdb69Smrg } 9951d63fdb69Smrg done 995252fd71cdSmrg IFS=$save_ifs 9953d63fdb69Smrg 9954d63fdb69Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955d63fdb69Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956d63fdb69Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99573da084b3Smrg fi 99583da084b3Smrg fi 99593da084b3Smrg 996052fd71cdSmrg ${skipped_export-false} && { 9961d63fdb69Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 996252fd71cdSmrg tmp_export_symbols=$export_symbols 996352fd71cdSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 996455acc8fcSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965d63fdb69Smrg fi 99663da084b3Smrg 9967d63fdb69Smrg if test -n "$orig_export_symbols"; then 9968d63fdb69Smrg # The given exports_symbols file has to be filtered, so filter it. 996952fd71cdSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970d63fdb69Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 997152fd71cdSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9972d63fdb69Smrg # though. Also, the filter scales superlinearly with the number of 9973d63fdb69Smrg # global variables. join(1) would be nice here, but unfortunately 9974d63fdb69Smrg # isn't a blessed tool. 9975d63fdb69Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 997648c85eb7Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977d63fdb69Smrg export_symbols=$output_objdir/$libname.def 9978d63fdb69Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979d63fdb69Smrg fi 998052fd71cdSmrg } 99813da084b3Smrg 9982d63fdb69Smrg libobjs=$output 9983d63fdb69Smrg # Restore the value of output. 9984d63fdb69Smrg output=$save_output 99853da084b3Smrg 9986d63fdb69Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987d63fdb69Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 9989d63fdb69Smrg fi 9990d63fdb69Smrg # Expand the library linking commands again to reset the 9991d63fdb69Smrg # value of $libobjs for piecewise linking. 9992d63fdb69Smrg 9993d63fdb69Smrg # Do each of the archive commands. 999452fd71cdSmrg if test yes = "$module" && test -n "$module_cmds"; then 9995d63fdb69Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996d63fdb69Smrg cmds=$module_expsym_cmds 99973da084b3Smrg else 9998d63fdb69Smrg cmds=$module_cmds 99993da084b3Smrg fi 100003da084b3Smrg else 10001d63fdb69Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002d63fdb69Smrg cmds=$archive_expsym_cmds 10003d63fdb69Smrg else 10004d63fdb69Smrg cmds=$archive_cmds 10005d63fdb69Smrg fi 100063da084b3Smrg fi 100073da084b3Smrg fi 100083da084b3Smrg 10009d63fdb69Smrg if test -n "$delfiles"; then 10010d63fdb69Smrg # Append the command to remove temporary files to $cmds. 10011d63fdb69Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10012d63fdb69Smrg fi 100133da084b3Smrg 10014d63fdb69Smrg # Add any objects from preloaded convenience libraries 10015d63fdb69Smrg if test -n "$dlprefiles"; then 1001652fd71cdSmrg gentop=$output_objdir/${outputname}x 1001748c85eb7Smrg func_append generated " $gentop" 100183da084b3Smrg 10019d63fdb69Smrg func_extract_archives $gentop $dlprefiles 1002048c85eb7Smrg func_append libobjs " $func_extract_archives_result" 10021d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 100223da084b3Smrg fi 100233da084b3Smrg 1002452fd71cdSmrg save_ifs=$IFS; IFS='~' 10025d63fdb69Smrg for cmd in $cmds; do 1002652fd71cdSmrg IFS=$sp$nl 10027d63fdb69Smrg eval cmd=\"$cmd\" 1002852fd71cdSmrg IFS=$save_ifs 1002952fd71cdSmrg $opt_quiet || { 10030d63fdb69Smrg func_quote_for_expand "$cmd" 10031d63fdb69Smrg eval "func_echo $func_quote_for_expand_result" 10032d63fdb69Smrg } 10033d63fdb69Smrg $opt_dry_run || eval "$cmd" || { 10034d63fdb69Smrg lt_exit=$? 100353da084b3Smrg 10036d63fdb69Smrg # Restore the uninstalled library and exit 1003752fd71cdSmrg if test relink = "$opt_mode"; then 10038d63fdb69Smrg ( cd "$output_objdir" && \ 10039d63fdb69Smrg $RM "${realname}T" && \ 10040d63fdb69Smrg $MV "${realname}U" "$realname" ) 10041d63fdb69Smrg fi 10042d63fdb69Smrg 10043d63fdb69Smrg exit $lt_exit 10044d63fdb69Smrg } 10045d63fdb69Smrg done 1004652fd71cdSmrg IFS=$save_ifs 10047d63fdb69Smrg 10048d63fdb69Smrg # Restore the uninstalled library and exit 1004952fd71cdSmrg if test relink = "$opt_mode"; then 10050d63fdb69Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051d63fdb69Smrg 10052d63fdb69Smrg if test -n "$convenience"; then 10053d63fdb69Smrg if test -z "$whole_archive_flag_spec"; then 10054d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 100553da084b3Smrg fi 100563da084b3Smrg fi 100573da084b3Smrg 10058d63fdb69Smrg exit $EXIT_SUCCESS 10059d63fdb69Smrg fi 100603da084b3Smrg 10061d63fdb69Smrg # Create links to the real library. 10062d63fdb69Smrg for linkname in $linknames; do 10063d63fdb69Smrg if test "$realname" != "$linkname"; then 10064d63fdb69Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065d63fdb69Smrg fi 10066d63fdb69Smrg done 10067d63fdb69Smrg 10068d63fdb69Smrg # If -module or -export-dynamic was specified, set the dlname. 1006952fd71cdSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10070d63fdb69Smrg # On all known operating systems, these are identical. 1007152fd71cdSmrg dlname=$soname 10072d63fdb69Smrg fi 10073d63fdb69Smrg fi 10074d63fdb69Smrg ;; 10075d63fdb69Smrg 10076d63fdb69Smrg obj) 1007752fd71cdSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1007852fd71cdSmrg func_warning "'-dlopen' is ignored for objects" 10079d63fdb69Smrg fi 10080d63fdb69Smrg 10081d63fdb69Smrg case " $deplibs" in 10082d63fdb69Smrg *\ -l* | *\ -L*) 1008352fd71cdSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084d63fdb69Smrg esac 10085d63fdb69Smrg 10086d63fdb69Smrg test -n "$rpath" && \ 1008752fd71cdSmrg func_warning "'-rpath' is ignored for objects" 10088d63fdb69Smrg 10089d63fdb69Smrg test -n "$xrpath" && \ 1009052fd71cdSmrg func_warning "'-R' is ignored for objects" 10091d63fdb69Smrg 10092d63fdb69Smrg test -n "$vinfo" && \ 1009352fd71cdSmrg func_warning "'-version-info' is ignored for objects" 10094d63fdb69Smrg 10095d63fdb69Smrg test -n "$release" && \ 1009652fd71cdSmrg func_warning "'-release' is ignored for objects" 10097d63fdb69Smrg 10098d63fdb69Smrg case $output in 10099d63fdb69Smrg *.lo) 10100d63fdb69Smrg test -n "$objs$old_deplibs" && \ 1010152fd71cdSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102d63fdb69Smrg 10103d63fdb69Smrg libobj=$output 10104d63fdb69Smrg func_lo2o "$libobj" 10105d63fdb69Smrg obj=$func_lo2o_result 10106d63fdb69Smrg ;; 10107d63fdb69Smrg *) 10108d63fdb69Smrg libobj= 1010952fd71cdSmrg obj=$output 10110d63fdb69Smrg ;; 10111d63fdb69Smrg esac 10112d63fdb69Smrg 10113d63fdb69Smrg # Delete the old objects. 10114d63fdb69Smrg $opt_dry_run || $RM $obj $libobj 10115d63fdb69Smrg 10116d63fdb69Smrg # Objects from convenience libraries. This assumes 10117d63fdb69Smrg # single-version convenience libraries. Whenever we create 10118d63fdb69Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10119d63fdb69Smrg # the extraction. 10120d63fdb69Smrg reload_conv_objs= 10121d63fdb69Smrg gentop= 1012252fd71cdSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1012352fd71cdSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1012452fd71cdSmrg # into space. 1012552fd71cdSmrg case $reload_cmds in 1012652fd71cdSmrg *\$LD[\ \$]*) wl= ;; 1012752fd71cdSmrg esac 10128d63fdb69Smrg if test -n "$convenience"; then 10129d63fdb69Smrg if test -n "$whole_archive_flag_spec"; then 10130d63fdb69Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1013152fd71cdSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1013252fd71cdSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133d63fdb69Smrg else 1013452fd71cdSmrg gentop=$output_objdir/${obj}x 1013548c85eb7Smrg func_append generated " $gentop" 10136d63fdb69Smrg 10137d63fdb69Smrg func_extract_archives $gentop $convenience 10138d63fdb69Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139d63fdb69Smrg fi 10140d63fdb69Smrg fi 101413da084b3Smrg 1014248c85eb7Smrg # If we're not building shared, we need to use non_pic_objs 1014352fd71cdSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1014448c85eb7Smrg 10145d63fdb69Smrg # Create the old-style object. 1014652fd71cdSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 101473da084b3Smrg 1014852fd71cdSmrg output=$obj 10149d63fdb69Smrg func_execute_cmds "$reload_cmds" 'exit $?' 101503da084b3Smrg 10151d63fdb69Smrg # Exit if we aren't doing a library object file. 10152d63fdb69Smrg if test -z "$libobj"; then 10153d63fdb69Smrg if test -n "$gentop"; then 10154d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 10155d63fdb69Smrg fi 101563da084b3Smrg 10157d63fdb69Smrg exit $EXIT_SUCCESS 10158d63fdb69Smrg fi 101593da084b3Smrg 1016052fd71cdSmrg test yes = "$build_libtool_libs" || { 10161d63fdb69Smrg if test -n "$gentop"; then 10162d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 10163d63fdb69Smrg fi 101643da084b3Smrg 10165d63fdb69Smrg # Create an invalid libtool object if no PIC, so that we don't 10166d63fdb69Smrg # accidentally link it into a program. 10167d63fdb69Smrg # $show "echo timestamp > $libobj" 10168d63fdb69Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169d63fdb69Smrg exit $EXIT_SUCCESS 1017052fd71cdSmrg } 101713da084b3Smrg 1017252fd71cdSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10173d63fdb69Smrg # Only do commands if we really have different PIC objects. 10174d63fdb69Smrg reload_objs="$libobjs $reload_conv_objs" 1017552fd71cdSmrg output=$libobj 10176d63fdb69Smrg func_execute_cmds "$reload_cmds" 'exit $?' 101773da084b3Smrg fi 101783da084b3Smrg 10179d63fdb69Smrg if test -n "$gentop"; then 10180d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 10181d63fdb69Smrg fi 101823da084b3Smrg 10183d63fdb69Smrg exit $EXIT_SUCCESS 10184d63fdb69Smrg ;; 101853da084b3Smrg 10186d63fdb69Smrg prog) 10187d63fdb69Smrg case $host in 10188d63fdb69Smrg *cygwin*) func_stripname '' '.exe' "$output" 10189d63fdb69Smrg output=$func_stripname_result.exe;; 101903da084b3Smrg esac 10191d63fdb69Smrg test -n "$vinfo" && \ 1019252fd71cdSmrg func_warning "'-version-info' is ignored for programs" 101933da084b3Smrg 10194d63fdb69Smrg test -n "$release" && \ 1019552fd71cdSmrg func_warning "'-release' is ignored for programs" 101963da084b3Smrg 1019752fd71cdSmrg $preload \ 1019852fd71cdSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1019952fd71cdSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102003da084b3Smrg 10201d63fdb69Smrg case $host in 10202d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10203d63fdb69Smrg # On Rhapsody replace the C library is the System framework 1020455acc8fcSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020555acc8fcSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 102063da084b3Smrg ;; 102073da084b3Smrg esac 102083da084b3Smrg 10209d63fdb69Smrg case $host in 10210d63fdb69Smrg *-*-darwin*) 10211d63fdb69Smrg # Don't allow lazy linking, it breaks C++ global constructors 10212d63fdb69Smrg # But is supposedly fixed on 10.4 or later (yay!). 1021352fd71cdSmrg if test CXX = "$tagname"; then 10214d63fdb69Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215d63fdb69Smrg 10.[0123]) 1021652fd71cdSmrg func_append compile_command " $wl-bind_at_load" 1021752fd71cdSmrg func_append finalize_command " $wl-bind_at_load" 10218d63fdb69Smrg ;; 10219d63fdb69Smrg esac 10220d63fdb69Smrg fi 10221d63fdb69Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1022255acc8fcSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022355acc8fcSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102243da084b3Smrg ;; 102253da084b3Smrg esac 102263da084b3Smrg 102273da084b3Smrg 10228d63fdb69Smrg # move library search paths that coincide with paths to not yet 10229d63fdb69Smrg # installed libraries to the beginning of the library search list 10230d63fdb69Smrg new_libs= 10231d63fdb69Smrg for path in $notinst_path; do 10232d63fdb69Smrg case " $new_libs " in 10233d63fdb69Smrg *" -L$path/$objdir "*) ;; 102343da084b3Smrg *) 10235d63fdb69Smrg case " $compile_deplibs " in 10236d63fdb69Smrg *" -L$path/$objdir "*) 1023748c85eb7Smrg func_append new_libs " -L$path/$objdir" ;; 10238d63fdb69Smrg esac 102393da084b3Smrg ;; 102403da084b3Smrg esac 102413da084b3Smrg done 10242d63fdb69Smrg for deplib in $compile_deplibs; do 10243d63fdb69Smrg case $deplib in 10244d63fdb69Smrg -L*) 10245d63fdb69Smrg case " $new_libs " in 10246d63fdb69Smrg *" $deplib "*) ;; 1024748c85eb7Smrg *) func_append new_libs " $deplib" ;; 10248d63fdb69Smrg esac 10249d63fdb69Smrg ;; 1025048c85eb7Smrg *) func_append new_libs " $deplib" ;; 10251d63fdb69Smrg esac 10252d63fdb69Smrg done 1025352fd71cdSmrg compile_deplibs=$new_libs 102543da084b3Smrg 102553da084b3Smrg 1025648c85eb7Smrg func_append compile_command " $compile_deplibs" 1025748c85eb7Smrg func_append finalize_command " $finalize_deplibs" 102583da084b3Smrg 10259d63fdb69Smrg if test -n "$rpath$xrpath"; then 10260d63fdb69Smrg # If the user specified any rpath flags, then add them. 10261d63fdb69Smrg for libdir in $rpath $xrpath; do 10262d63fdb69Smrg # This is the magic to use -rpath. 10263d63fdb69Smrg case "$finalize_rpath " in 10264d63fdb69Smrg *" $libdir "*) ;; 1026548c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 10266d63fdb69Smrg esac 10267d63fdb69Smrg done 10268d63fdb69Smrg fi 102693da084b3Smrg 10270d63fdb69Smrg # Now hardcode the library paths 10271d63fdb69Smrg rpath= 10272d63fdb69Smrg hardcode_libdirs= 10273d63fdb69Smrg for libdir in $compile_rpath $finalize_rpath; do 10274d63fdb69Smrg if test -n "$hardcode_libdir_flag_spec"; then 10275d63fdb69Smrg if test -n "$hardcode_libdir_separator"; then 10276d63fdb69Smrg if test -z "$hardcode_libdirs"; then 1027752fd71cdSmrg hardcode_libdirs=$libdir 10278d63fdb69Smrg else 10279d63fdb69Smrg # Just accumulate the unique libdirs. 10280d63fdb69Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281d63fdb69Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282d63fdb69Smrg ;; 10283d63fdb69Smrg *) 1028448c85eb7Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285d63fdb69Smrg ;; 10286d63fdb69Smrg esac 10287d63fdb69Smrg fi 10288d63fdb69Smrg else 10289d63fdb69Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1029048c85eb7Smrg func_append rpath " $flag" 10291d63fdb69Smrg fi 10292d63fdb69Smrg elif test -n "$runpath_var"; then 10293d63fdb69Smrg case "$perm_rpath " in 102943da084b3Smrg *" $libdir "*) ;; 1029548c85eb7Smrg *) func_append perm_rpath " $libdir" ;; 102963da084b3Smrg esac 10297d63fdb69Smrg fi 10298d63fdb69Smrg case $host in 10299d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030052fd71cdSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301d63fdb69Smrg case :$dllsearchpath: in 10302d63fdb69Smrg *":$libdir:"*) ;; 10303d63fdb69Smrg ::) dllsearchpath=$libdir;; 1030448c85eb7Smrg *) func_append dllsearchpath ":$libdir";; 10305d63fdb69Smrg esac 10306d63fdb69Smrg case :$dllsearchpath: in 10307d63fdb69Smrg *":$testbindir:"*) ;; 10308d63fdb69Smrg ::) dllsearchpath=$testbindir;; 1030948c85eb7Smrg *) func_append dllsearchpath ":$testbindir";; 10310d63fdb69Smrg esac 10311d63fdb69Smrg ;; 10312d63fdb69Smrg esac 10313d63fdb69Smrg done 10314d63fdb69Smrg # Substitute the hardcoded libdirs into the rpath. 10315d63fdb69Smrg if test -n "$hardcode_libdir_separator" && 10316d63fdb69Smrg test -n "$hardcode_libdirs"; then 1031752fd71cdSmrg libdir=$hardcode_libdirs 10318d63fdb69Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10319d63fdb69Smrg fi 1032052fd71cdSmrg compile_rpath=$rpath 10321d63fdb69Smrg 10322d63fdb69Smrg rpath= 10323d63fdb69Smrg hardcode_libdirs= 10324d63fdb69Smrg for libdir in $finalize_rpath; do 10325d63fdb69Smrg if test -n "$hardcode_libdir_flag_spec"; then 10326d63fdb69Smrg if test -n "$hardcode_libdir_separator"; then 10327d63fdb69Smrg if test -z "$hardcode_libdirs"; then 1032852fd71cdSmrg hardcode_libdirs=$libdir 10329d63fdb69Smrg else 10330d63fdb69Smrg # Just accumulate the unique libdirs. 10331d63fdb69Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332d63fdb69Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333d63fdb69Smrg ;; 10334d63fdb69Smrg *) 1033548c85eb7Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336d63fdb69Smrg ;; 10337d63fdb69Smrg esac 10338d63fdb69Smrg fi 10339d63fdb69Smrg else 10340d63fdb69Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1034148c85eb7Smrg func_append rpath " $flag" 10342d63fdb69Smrg fi 10343d63fdb69Smrg elif test -n "$runpath_var"; then 10344d63fdb69Smrg case "$finalize_perm_rpath " in 103453da084b3Smrg *" $libdir "*) ;; 1034648c85eb7Smrg *) func_append finalize_perm_rpath " $libdir" ;; 103473da084b3Smrg esac 103483da084b3Smrg fi 10349d63fdb69Smrg done 10350d63fdb69Smrg # Substitute the hardcoded libdirs into the rpath. 10351d63fdb69Smrg if test -n "$hardcode_libdir_separator" && 10352d63fdb69Smrg test -n "$hardcode_libdirs"; then 1035352fd71cdSmrg libdir=$hardcode_libdirs 10354d63fdb69Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10355d63fdb69Smrg fi 1035652fd71cdSmrg finalize_rpath=$rpath 103573da084b3Smrg 1035852fd71cdSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359d63fdb69Smrg # Transform all the library objects into standard objects. 1036055acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036155acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362d63fdb69Smrg fi 103633da084b3Smrg 1036452fd71cdSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 103653da084b3Smrg 10366d63fdb69Smrg # template prelinking step 10367d63fdb69Smrg if test -n "$prelink_cmds"; then 10368d63fdb69Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10369d63fdb69Smrg fi 103703da084b3Smrg 1037152fd71cdSmrg wrappers_required=: 10372d63fdb69Smrg case $host in 1037355acc8fcSmrg *cegcc* | *mingw32ce*) 1037455acc8fcSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1037552fd71cdSmrg wrappers_required=false 1037655acc8fcSmrg ;; 10377d63fdb69Smrg *cygwin* | *mingw* ) 1037852fd71cdSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10379d63fdb69Smrg ;; 10380d63fdb69Smrg *) 1038152fd71cdSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1038252fd71cdSmrg wrappers_required=false 10383d63fdb69Smrg fi 10384d63fdb69Smrg ;; 10385d63fdb69Smrg esac 1038652fd71cdSmrg $wrappers_required || { 10387d63fdb69Smrg # Replace the output file specification. 1038855acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1038952fd71cdSmrg link_command=$compile_command$compile_rpath 103903da084b3Smrg 10391d63fdb69Smrg # We have no uninstalled library dependencies, so finalize right now. 10392d63fdb69Smrg exit_status=0 10393d63fdb69Smrg func_show_eval "$link_command" 'exit_status=$?' 103943da084b3Smrg 1039548c85eb7Smrg if test -n "$postlink_cmds"; then 1039648c85eb7Smrg func_to_tool_file "$output" 1039748c85eb7Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1039848c85eb7Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1039948c85eb7Smrg fi 1040048c85eb7Smrg 10401d63fdb69Smrg # Delete the generated files. 1040252fd71cdSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1040352fd71cdSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404d63fdb69Smrg fi 104053da084b3Smrg 10406d63fdb69Smrg exit $exit_status 1040752fd71cdSmrg } 104083da084b3Smrg 10409d63fdb69Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410d63fdb69Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411d63fdb69Smrg fi 10412d63fdb69Smrg if test -n "$finalize_shlibpath"; then 10413d63fdb69Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414d63fdb69Smrg fi 104153da084b3Smrg 10416d63fdb69Smrg compile_var= 10417d63fdb69Smrg finalize_var= 10418d63fdb69Smrg if test -n "$runpath_var"; then 10419d63fdb69Smrg if test -n "$perm_rpath"; then 10420d63fdb69Smrg # We should set the runpath_var. 10421d63fdb69Smrg rpath= 10422d63fdb69Smrg for dir in $perm_rpath; do 1042348c85eb7Smrg func_append rpath "$dir:" 104243da084b3Smrg done 10425d63fdb69Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 104263da084b3Smrg fi 10427d63fdb69Smrg if test -n "$finalize_perm_rpath"; then 10428d63fdb69Smrg # We should set the runpath_var. 10429d63fdb69Smrg rpath= 10430d63fdb69Smrg for dir in $finalize_perm_rpath; do 1043148c85eb7Smrg func_append rpath "$dir:" 10432d63fdb69Smrg done 10433d63fdb69Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434d63fdb69Smrg fi 10435d63fdb69Smrg fi 104363da084b3Smrg 1043752fd71cdSmrg if test yes = "$no_install"; then 10438d63fdb69Smrg # We don't need to create a wrapper script. 1043952fd71cdSmrg link_command=$compile_var$compile_command$compile_rpath 10440d63fdb69Smrg # Replace the output file specification. 1044155acc8fcSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442d63fdb69Smrg # Delete the old output file. 10443d63fdb69Smrg $opt_dry_run || $RM $output 10444d63fdb69Smrg # Link the executable and exit 10445d63fdb69Smrg func_show_eval "$link_command" 'exit $?' 1044648c85eb7Smrg 1044748c85eb7Smrg if test -n "$postlink_cmds"; then 1044848c85eb7Smrg func_to_tool_file "$output" 1044948c85eb7Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045048c85eb7Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1045148c85eb7Smrg fi 1045248c85eb7Smrg 10453d63fdb69Smrg exit $EXIT_SUCCESS 10454d63fdb69Smrg fi 104553da084b3Smrg 1045652fd71cdSmrg case $hardcode_action,$fast_install in 1045752fd71cdSmrg relink,*) 1045852fd71cdSmrg # Fast installation is not supported 1045952fd71cdSmrg link_command=$compile_var$compile_command$compile_rpath 1046052fd71cdSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 104613da084b3Smrg 1046252fd71cdSmrg func_warning "this platform does not like uninstalled shared libraries" 1046352fd71cdSmrg func_warning "'$output' will be relinked during installation" 1046452fd71cdSmrg ;; 1046552fd71cdSmrg *,yes) 1046652fd71cdSmrg link_command=$finalize_var$compile_command$finalize_rpath 1046752fd71cdSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1046852fd71cdSmrg ;; 1046952fd71cdSmrg *,no) 1047052fd71cdSmrg link_command=$compile_var$compile_command$compile_rpath 1047152fd71cdSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1047252fd71cdSmrg ;; 1047352fd71cdSmrg *,needless) 1047452fd71cdSmrg link_command=$finalize_var$compile_command$finalize_rpath 1047552fd71cdSmrg relink_command= 1047652fd71cdSmrg ;; 1047752fd71cdSmrg esac 104783da084b3Smrg 10479d63fdb69Smrg # Replace the output file specification. 1048055acc8fcSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 104813da084b3Smrg 10482d63fdb69Smrg # Delete the old output files. 10483d63fdb69Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 104843da084b3Smrg 10485d63fdb69Smrg func_show_eval "$link_command" 'exit $?' 104863da084b3Smrg 1048748c85eb7Smrg if test -n "$postlink_cmds"; then 1048848c85eb7Smrg func_to_tool_file "$output_objdir/$outputname" 1048948c85eb7Smrg 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'` 1049048c85eb7Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1049148c85eb7Smrg fi 1049248c85eb7Smrg 10493d63fdb69Smrg # Now create the wrapper script. 10494d63fdb69Smrg func_verbose "creating $output" 104953da084b3Smrg 10496d63fdb69Smrg # Quote the relink command for shipping. 10497d63fdb69Smrg if test -n "$relink_command"; then 10498d63fdb69Smrg # Preserve any variables that may affect compiler behavior 10499d63fdb69Smrg for var in $variables_saved_for_relink; do 10500d63fdb69Smrg if eval test -z \"\${$var+set}\"; then 10501d63fdb69Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502d63fdb69Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10503d63fdb69Smrg relink_command="$var=; export $var; $relink_command" 10504d63fdb69Smrg else 10505d63fdb69Smrg func_quote_for_eval "$var_value" 10506d63fdb69Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507d63fdb69Smrg fi 10508d63fdb69Smrg done 10509d63fdb69Smrg relink_command="(cd `pwd`; $relink_command)" 1051055acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511d63fdb69Smrg fi 105123da084b3Smrg 10513d63fdb69Smrg # Only actually do things if not in dry run mode. 10514d63fdb69Smrg $opt_dry_run || { 10515d63fdb69Smrg # win32 will think the script is a binary if it has 10516d63fdb69Smrg # a .exe suffix, so we strip it off here. 10517d63fdb69Smrg case $output in 10518d63fdb69Smrg *.exe) func_stripname '' '.exe' "$output" 10519d63fdb69Smrg output=$func_stripname_result ;; 10520d63fdb69Smrg esac 10521d63fdb69Smrg # test for cygwin because mv fails w/o .exe extensions 105223da084b3Smrg case $host in 10523d63fdb69Smrg *cygwin*) 10524d63fdb69Smrg exeext=.exe 10525d63fdb69Smrg func_stripname '' '.exe' "$outputname" 10526d63fdb69Smrg outputname=$func_stripname_result ;; 10527d63fdb69Smrg *) exeext= ;; 105283da084b3Smrg esac 10529d63fdb69Smrg case $host in 10530d63fdb69Smrg *cygwin* | *mingw* ) 10531d63fdb69Smrg func_dirname_and_basename "$output" "" "." 10532d63fdb69Smrg output_name=$func_basename_result 10533d63fdb69Smrg output_path=$func_dirname_result 1053452fd71cdSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1053552fd71cdSmrg cwrapper=$output_path/$output_name.exe 10536d63fdb69Smrg $RM $cwrappersource $cwrapper 10537d63fdb69Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538d63fdb69Smrg 10539d63fdb69Smrg func_emit_cwrapperexe_src > $cwrappersource 10540d63fdb69Smrg 10541d63fdb69Smrg # The wrapper executable is built using the $host compiler, 10542d63fdb69Smrg # because it contains $host paths and files. If cross- 10543d63fdb69Smrg # compiling, it, like the target executable, must be 10544d63fdb69Smrg # executed on the $host or under an emulation environment. 10545d63fdb69Smrg $opt_dry_run || { 10546d63fdb69Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547d63fdb69Smrg $STRIP $cwrapper 10548d63fdb69Smrg } 105493da084b3Smrg 10550d63fdb69Smrg # Now, create the wrapper script for func_source use: 10551d63fdb69Smrg func_ltwrapper_scriptname $cwrapper 10552d63fdb69Smrg $RM $func_ltwrapper_scriptname_result 10553d63fdb69Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554d63fdb69Smrg $opt_dry_run || { 10555d63fdb69Smrg # note: this script will not be executed, so do not chmod. 1055652fd71cdSmrg if test "x$build" = "x$host"; then 10557d63fdb69Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105583da084b3Smrg else 10559d63fdb69Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105603da084b3Smrg fi 10561d63fdb69Smrg } 10562d63fdb69Smrg ;; 10563d63fdb69Smrg * ) 10564d63fdb69Smrg $RM $output 10565d63fdb69Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 105663da084b3Smrg 10567d63fdb69Smrg func_emit_wrapper no > $output 10568d63fdb69Smrg chmod +x $output 105693da084b3Smrg ;; 105703da084b3Smrg esac 10571d63fdb69Smrg } 10572d63fdb69Smrg exit $EXIT_SUCCESS 10573d63fdb69Smrg ;; 10574d63fdb69Smrg esac 105753da084b3Smrg 10576d63fdb69Smrg # See if we need to build an old-fashioned archive. 10577d63fdb69Smrg for oldlib in $oldlibs; do 105783da084b3Smrg 1057952fd71cdSmrg case $build_libtool_libs in 1058052fd71cdSmrg convenience) 1058152fd71cdSmrg oldobjs="$libobjs_save $symfileobj" 1058252fd71cdSmrg addlibs=$convenience 10583d63fdb69Smrg build_libtool_libs=no 1058452fd71cdSmrg ;; 1058552fd71cdSmrg module) 1058652fd71cdSmrg oldobjs=$libobjs_save 1058752fd71cdSmrg addlibs=$old_convenience 1058852fd71cdSmrg build_libtool_libs=no 1058952fd71cdSmrg ;; 1059052fd71cdSmrg *) 10591d63fdb69Smrg oldobjs="$old_deplibs $non_pic_objects" 1059252fd71cdSmrg $preload && test -f "$symfileobj" \ 1059352fd71cdSmrg && func_append oldobjs " $symfileobj" 1059452fd71cdSmrg addlibs=$old_convenience 1059552fd71cdSmrg ;; 1059652fd71cdSmrg esac 105973da084b3Smrg 10598d63fdb69Smrg if test -n "$addlibs"; then 1059952fd71cdSmrg gentop=$output_objdir/${outputname}x 1060048c85eb7Smrg func_append generated " $gentop" 106013da084b3Smrg 10602d63fdb69Smrg func_extract_archives $gentop $addlibs 1060348c85eb7Smrg func_append oldobjs " $func_extract_archives_result" 10604d63fdb69Smrg fi 106053da084b3Smrg 10606d63fdb69Smrg # Do each command in the archive commands. 1060752fd71cdSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608d63fdb69Smrg cmds=$old_archive_from_new_cmds 10609d63fdb69Smrg else 106103da084b3Smrg 10611d63fdb69Smrg # Add any objects from preloaded convenience libraries 10612d63fdb69Smrg if test -n "$dlprefiles"; then 1061352fd71cdSmrg gentop=$output_objdir/${outputname}x 1061448c85eb7Smrg func_append generated " $gentop" 106153da084b3Smrg 10616d63fdb69Smrg func_extract_archives $gentop $dlprefiles 1061748c85eb7Smrg func_append oldobjs " $func_extract_archives_result" 10618d63fdb69Smrg fi 106193da084b3Smrg 10620d63fdb69Smrg # POSIX demands no paths to be encoded in archives. We have 10621d63fdb69Smrg # to avoid creating archives with duplicate basenames if we 10622d63fdb69Smrg # might have to extract them afterwards, e.g., when creating a 10623d63fdb69Smrg # static archive out of a convenience library, or when linking 10624d63fdb69Smrg # the entirety of a libtool archive into another (currently 10625d63fdb69Smrg # not supported by libtool). 10626d63fdb69Smrg if (for obj in $oldobjs 10627d63fdb69Smrg do 10628d63fdb69Smrg func_basename "$obj" 10629d63fdb69Smrg $ECHO "$func_basename_result" 10630d63fdb69Smrg done | sort | sort -uc >/dev/null 2>&1); then 10631d63fdb69Smrg : 10632d63fdb69Smrg else 1063355acc8fcSmrg echo "copying selected object files to avoid basename conflicts..." 1063452fd71cdSmrg gentop=$output_objdir/${outputname}x 1063548c85eb7Smrg func_append generated " $gentop" 10636d63fdb69Smrg func_mkdir_p "$gentop" 10637d63fdb69Smrg save_oldobjs=$oldobjs 10638d63fdb69Smrg oldobjs= 10639d63fdb69Smrg counter=1 10640d63fdb69Smrg for obj in $save_oldobjs 10641d63fdb69Smrg do 10642d63fdb69Smrg func_basename "$obj" 1064352fd71cdSmrg objbase=$func_basename_result 10644d63fdb69Smrg case " $oldobjs " in 10645d63fdb69Smrg " ") oldobjs=$obj ;; 10646d63fdb69Smrg *[\ /]"$objbase "*) 10647d63fdb69Smrg while :; do 10648d63fdb69Smrg # Make sure we don't pick an alternate name that also 10649d63fdb69Smrg # overlaps. 10650d63fdb69Smrg newobj=lt$counter-$objbase 10651d63fdb69Smrg func_arith $counter + 1 10652d63fdb69Smrg counter=$func_arith_result 10653d63fdb69Smrg case " $oldobjs " in 10654d63fdb69Smrg *[\ /]"$newobj "*) ;; 10655d63fdb69Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656d63fdb69Smrg esac 10657d63fdb69Smrg done 10658d63fdb69Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1065948c85eb7Smrg func_append oldobjs " $gentop/$newobj" 10660d63fdb69Smrg ;; 1066148c85eb7Smrg *) func_append oldobjs " $obj" ;; 10662d63fdb69Smrg esac 106633da084b3Smrg done 106643da084b3Smrg fi 1066548c85eb7Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1066648c85eb7Smrg tool_oldlib=$func_to_tool_file_result 10667d63fdb69Smrg eval cmds=\"$old_archive_cmds\" 106683da084b3Smrg 10669d63fdb69Smrg func_len " $cmds" 10670d63fdb69Smrg len=$func_len_result 10671d63fdb69Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672d63fdb69Smrg cmds=$old_archive_cmds 1067348c85eb7Smrg elif test -n "$archiver_list_spec"; then 1067448c85eb7Smrg func_verbose "using command file archive linking..." 1067548c85eb7Smrg for obj in $oldobjs 1067648c85eb7Smrg do 1067748c85eb7Smrg func_to_tool_file "$obj" 1067848c85eb7Smrg $ECHO "$func_to_tool_file_result" 1067948c85eb7Smrg done > $output_objdir/$libname.libcmd 1068048c85eb7Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1068148c85eb7Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1068248c85eb7Smrg cmds=$old_archive_cmds 10683d63fdb69Smrg else 10684d63fdb69Smrg # the command line is too long to link in one step, link in parts 10685d63fdb69Smrg func_verbose "using piecewise archive linking..." 10686d63fdb69Smrg save_RANLIB=$RANLIB 10687d63fdb69Smrg RANLIB=: 10688d63fdb69Smrg objlist= 10689d63fdb69Smrg concat_cmds= 10690d63fdb69Smrg save_oldobjs=$oldobjs 10691d63fdb69Smrg oldobjs= 10692d63fdb69Smrg # Is there a better way of finding the last object in the list? 10693d63fdb69Smrg for obj in $save_oldobjs 10694d63fdb69Smrg do 10695d63fdb69Smrg last_oldobj=$obj 10696d63fdb69Smrg done 10697d63fdb69Smrg eval test_cmds=\"$old_archive_cmds\" 10698d63fdb69Smrg func_len " $test_cmds" 10699d63fdb69Smrg len0=$func_len_result 10700d63fdb69Smrg len=$len0 10701d63fdb69Smrg for obj in $save_oldobjs 10702d63fdb69Smrg do 10703d63fdb69Smrg func_len " $obj" 10704d63fdb69Smrg func_arith $len + $func_len_result 10705d63fdb69Smrg len=$func_arith_result 10706d63fdb69Smrg func_append objlist " $obj" 10707d63fdb69Smrg if test "$len" -lt "$max_cmd_len"; then 10708d63fdb69Smrg : 10709d63fdb69Smrg else 10710d63fdb69Smrg # the above command should be used before it gets too long 10711d63fdb69Smrg oldobjs=$objlist 1071252fd71cdSmrg if test "$obj" = "$last_oldobj"; then 10713d63fdb69Smrg RANLIB=$save_RANLIB 10714d63fdb69Smrg fi 10715d63fdb69Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1071652fd71cdSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717d63fdb69Smrg objlist= 10718d63fdb69Smrg len=$len0 10719d63fdb69Smrg fi 10720d63fdb69Smrg done 10721d63fdb69Smrg RANLIB=$save_RANLIB 10722d63fdb69Smrg oldobjs=$objlist 1072352fd71cdSmrg if test -z "$oldobjs"; then 10724d63fdb69Smrg eval cmds=\"\$concat_cmds\" 10725d63fdb69Smrg else 10726d63fdb69Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727d63fdb69Smrg fi 10728d63fdb69Smrg fi 10729d63fdb69Smrg fi 10730d63fdb69Smrg func_execute_cmds "$cmds" 'exit $?' 107313da084b3Smrg done 107323da084b3Smrg 10733d63fdb69Smrg test -n "$generated" && \ 10734d63fdb69Smrg func_show_eval "${RM}r$generated" 107353da084b3Smrg 10736d63fdb69Smrg # Now create the libtool archive. 10737d63fdb69Smrg case $output in 10738d63fdb69Smrg *.la) 10739d63fdb69Smrg old_library= 1074052fd71cdSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10741d63fdb69Smrg func_verbose "creating $output" 107423da084b3Smrg 10743d63fdb69Smrg # Preserve any variables that may affect compiler behavior 10744d63fdb69Smrg for var in $variables_saved_for_relink; do 10745d63fdb69Smrg if eval test -z \"\${$var+set}\"; then 10746d63fdb69Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747d63fdb69Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10748d63fdb69Smrg relink_command="$var=; export $var; $relink_command" 107493da084b3Smrg else 10750d63fdb69Smrg func_quote_for_eval "$var_value" 10751d63fdb69Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 107523da084b3Smrg fi 10753d63fdb69Smrg done 10754d63fdb69Smrg # Quote the link command for shipping. 1075552fd71cdSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1075655acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1075752fd71cdSmrg if test yes = "$hardcode_automatic"; then 10758d63fdb69Smrg relink_command= 10759d63fdb69Smrg fi 107603da084b3Smrg 10761d63fdb69Smrg # Only create the output if not a dry run. 10762d63fdb69Smrg $opt_dry_run || { 10763d63fdb69Smrg for installed in no yes; do 1076452fd71cdSmrg if test yes = "$installed"; then 10765d63fdb69Smrg if test -z "$install_libdir"; then 10766d63fdb69Smrg break 10767d63fdb69Smrg fi 1076852fd71cdSmrg output=$output_objdir/${outputname}i 10769d63fdb69Smrg # Replace all uninstalled libtool libraries with the installed ones 10770d63fdb69Smrg newdependency_libs= 10771d63fdb69Smrg for deplib in $dependency_libs; do 10772d63fdb69Smrg case $deplib in 10773d63fdb69Smrg *.la) 10774d63fdb69Smrg func_basename "$deplib" 1077552fd71cdSmrg name=$func_basename_result 1077648c85eb7Smrg func_resolve_sysroot "$deplib" 1077752fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778d63fdb69Smrg test -z "$libdir" && \ 1077952fd71cdSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078048c85eb7Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1078148c85eb7Smrg ;; 1078248c85eb7Smrg -L*) 1078348c85eb7Smrg func_stripname -L '' "$deplib" 1078448c85eb7Smrg func_replace_sysroot "$func_stripname_result" 1078548c85eb7Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1078648c85eb7Smrg ;; 1078748c85eb7Smrg -R*) 1078848c85eb7Smrg func_stripname -R '' "$deplib" 1078948c85eb7Smrg func_replace_sysroot "$func_stripname_result" 1079048c85eb7Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791d63fdb69Smrg ;; 1079248c85eb7Smrg *) func_append newdependency_libs " $deplib" ;; 10793d63fdb69Smrg esac 10794d63fdb69Smrg done 1079552fd71cdSmrg dependency_libs=$newdependency_libs 10796d63fdb69Smrg newdlfiles= 10797d63fdb69Smrg 10798d63fdb69Smrg for lib in $dlfiles; do 10799d63fdb69Smrg case $lib in 10800d63fdb69Smrg *.la) 10801d63fdb69Smrg func_basename "$lib" 1080252fd71cdSmrg name=$func_basename_result 1080352fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804d63fdb69Smrg test -z "$libdir" && \ 1080552fd71cdSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1080648c85eb7Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807d63fdb69Smrg ;; 1080848c85eb7Smrg *) func_append newdlfiles " $lib" ;; 10809d63fdb69Smrg esac 10810d63fdb69Smrg done 1081152fd71cdSmrg dlfiles=$newdlfiles 10812d63fdb69Smrg newdlprefiles= 10813d63fdb69Smrg for lib in $dlprefiles; do 10814d63fdb69Smrg case $lib in 10815d63fdb69Smrg *.la) 10816d63fdb69Smrg # Only pass preopened files to the pseudo-archive (for 10817d63fdb69Smrg # eventual linking with the app. that links it) if we 10818d63fdb69Smrg # didn't already link the preopened objects directly into 10819d63fdb69Smrg # the library: 10820d63fdb69Smrg func_basename "$lib" 1082152fd71cdSmrg name=$func_basename_result 1082252fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823d63fdb69Smrg test -z "$libdir" && \ 1082452fd71cdSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1082548c85eb7Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826d63fdb69Smrg ;; 10827d63fdb69Smrg esac 10828d63fdb69Smrg done 1082952fd71cdSmrg dlprefiles=$newdlprefiles 10830d63fdb69Smrg else 10831d63fdb69Smrg newdlfiles= 10832d63fdb69Smrg for lib in $dlfiles; do 10833d63fdb69Smrg case $lib in 1083452fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835d63fdb69Smrg *) abs=`pwd`"/$lib" ;; 10836d63fdb69Smrg esac 1083748c85eb7Smrg func_append newdlfiles " $abs" 10838d63fdb69Smrg done 1083952fd71cdSmrg dlfiles=$newdlfiles 10840d63fdb69Smrg newdlprefiles= 10841d63fdb69Smrg for lib in $dlprefiles; do 10842d63fdb69Smrg case $lib in 1084352fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844d63fdb69Smrg *) abs=`pwd`"/$lib" ;; 10845d63fdb69Smrg esac 1084648c85eb7Smrg func_append newdlprefiles " $abs" 10847d63fdb69Smrg done 1084852fd71cdSmrg dlprefiles=$newdlprefiles 10849d63fdb69Smrg fi 10850d63fdb69Smrg $RM $output 10851d63fdb69Smrg # place dlname in correct position for cygwin 1085255acc8fcSmrg # In fact, it would be nice if we could use this code for all target 1085355acc8fcSmrg # systems that can't hard-code library paths into their executables 1085455acc8fcSmrg # and that have no shared library path variable independent of PATH, 1085555acc8fcSmrg # but it turns out we can't easily determine that from inspecting 1085655acc8fcSmrg # libtool variables, so we have to hard-code the OSs to which it 1085755acc8fcSmrg # applies here; at the moment, that means platforms that use the PE 1085855acc8fcSmrg # object format with DLL files. See the long comment at the top of 1085955acc8fcSmrg # tests/bindir.at for full details. 10860d63fdb69Smrg tdlname=$dlname 10861d63fdb69Smrg case $host,$output,$installed,$module,$dlname in 1086255acc8fcSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1086355acc8fcSmrg # If a -bindir argument was supplied, place the dll there. 1086452fd71cdSmrg if test -n "$bindir"; then 1086555acc8fcSmrg func_relative_path "$install_libdir" "$bindir" 1086652fd71cdSmrg tdlname=$func_relative_path_result/$dlname 1086755acc8fcSmrg else 1086855acc8fcSmrg # Otherwise fall back on heuristic. 1086955acc8fcSmrg tdlname=../bin/$dlname 1087055acc8fcSmrg fi 1087155acc8fcSmrg ;; 10872d63fdb69Smrg esac 10873d63fdb69Smrg $ECHO > $output "\ 10874d63fdb69Smrg# $outputname - a libtool library file 1087552fd71cdSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876d63fdb69Smrg# 10877d63fdb69Smrg# Please DO NOT delete this file! 10878d63fdb69Smrg# It is necessary for linking the library. 108793da084b3Smrg 10880d63fdb69Smrg# The name that we can dlopen(3). 10881d63fdb69Smrgdlname='$tdlname' 108823da084b3Smrg 10883d63fdb69Smrg# Names of this library. 10884d63fdb69Smrglibrary_names='$library_names' 108853da084b3Smrg 10886d63fdb69Smrg# The name of the static archive. 10887d63fdb69Smrgold_library='$old_library' 108883da084b3Smrg 1088952fd71cdSmrg# Linker flags that cannot go in dependency_libs. 10890d63fdb69Smrginherited_linker_flags='$new_inherited_linker_flags' 108913da084b3Smrg 10892d63fdb69Smrg# Libraries that this one depends upon. 10893d63fdb69Smrgdependency_libs='$dependency_libs' 108943da084b3Smrg 10895d63fdb69Smrg# Names of additional weak libraries provided by this library 10896d63fdb69Smrgweak_library_names='$weak_libs' 108973da084b3Smrg 10898d63fdb69Smrg# Version information for $libname. 10899d63fdb69Smrgcurrent=$current 10900d63fdb69Smrgage=$age 10901d63fdb69Smrgrevision=$revision 109023da084b3Smrg 10903d63fdb69Smrg# Is this an already installed library? 10904d63fdb69Smrginstalled=$installed 109053da084b3Smrg 10906d63fdb69Smrg# Should we warn about portability when linking against -modules? 10907d63fdb69Smrgshouldnotlink=$module 109083da084b3Smrg 10909d63fdb69Smrg# Files to dlopen/dlpreopen 10910d63fdb69Smrgdlopen='$dlfiles' 10911d63fdb69Smrgdlpreopen='$dlprefiles' 109123da084b3Smrg 10913d63fdb69Smrg# Directory that this library needs to be installed in: 10914d63fdb69Smrglibdir='$install_libdir'" 1091552fd71cdSmrg if test no,yes = "$installed,$need_relink"; then 10916d63fdb69Smrg $ECHO >> $output "\ 10917d63fdb69Smrgrelink_command=\"$relink_command\"" 10918d63fdb69Smrg fi 10919d63fdb69Smrg done 10920d63fdb69Smrg } 109213da084b3Smrg 10922d63fdb69Smrg # Do a symbolic link so that the libtool archive can be found in 10923d63fdb69Smrg # LD_LIBRARY_PATH before the program is installed. 10924d63fdb69Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925d63fdb69Smrg ;; 10926d63fdb69Smrg esac 10927d63fdb69Smrg exit $EXIT_SUCCESS 10928d63fdb69Smrg} 109293da084b3Smrg 1093052fd71cdSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1093152fd71cdSmrg func_mode_link ${1+"$@"} 1093252fd71cdSmrgfi 109333da084b3Smrg 109343da084b3Smrg 10935d63fdb69Smrg# func_mode_uninstall arg... 10936d63fdb69Smrgfunc_mode_uninstall () 10937d63fdb69Smrg{ 1093852fd71cdSmrg $debug_cmd 1093952fd71cdSmrg 1094052fd71cdSmrg RM=$nonopt 109413da084b3Smrg files= 1094252fd71cdSmrg rmforce=false 109433da084b3Smrg exit_status=0 109443da084b3Smrg 109453da084b3Smrg # This variable tells wrapper scripts just to set variables rather 109463da084b3Smrg # than running their programs. 1094752fd71cdSmrg libtool_install_magic=$magic 109483da084b3Smrg 109493da084b3Smrg for arg 109503da084b3Smrg do 109513da084b3Smrg case $arg in 1095252fd71cdSmrg -f) func_append RM " $arg"; rmforce=: ;; 1095348c85eb7Smrg -*) func_append RM " $arg" ;; 1095448c85eb7Smrg *) func_append files " $arg" ;; 109553da084b3Smrg esac 109563da084b3Smrg done 109573da084b3Smrg 10958d63fdb69Smrg test -z "$RM" && \ 10959d63fdb69Smrg func_fatal_help "you must specify an RM program" 109603da084b3Smrg 109613da084b3Smrg rmdirs= 109623da084b3Smrg 109633da084b3Smrg for file in $files; do 10964d63fdb69Smrg func_dirname "$file" "" "." 1096552fd71cdSmrg dir=$func_dirname_result 1096652fd71cdSmrg if test . = "$dir"; then 1096752fd71cdSmrg odir=$objdir 109683da084b3Smrg else 1096952fd71cdSmrg odir=$dir/$objdir 109703da084b3Smrg fi 10971d63fdb69Smrg func_basename "$file" 1097252fd71cdSmrg name=$func_basename_result 1097352fd71cdSmrg test uninstall = "$opt_mode" && odir=$dir 109743da084b3Smrg 1097548c85eb7Smrg # Remember odir for removal later, being careful to avoid duplicates 1097652fd71cdSmrg if test clean = "$opt_mode"; then 109773da084b3Smrg case " $rmdirs " in 1097848c85eb7Smrg *" $odir "*) ;; 1097948c85eb7Smrg *) func_append rmdirs " $odir" ;; 109803da084b3Smrg esac 109813da084b3Smrg fi 109823da084b3Smrg 109833da084b3Smrg # Don't error if the file doesn't exist and rm -f was used. 10984d63fdb69Smrg if { test -L "$file"; } >/dev/null 2>&1 || 10985d63fdb69Smrg { test -h "$file"; } >/dev/null 2>&1 || 10986d63fdb69Smrg test -f "$file"; then 109873da084b3Smrg : 109883da084b3Smrg elif test -d "$file"; then 109893da084b3Smrg exit_status=1 109903da084b3Smrg continue 1099152fd71cdSmrg elif $rmforce; then 109923da084b3Smrg continue 109933da084b3Smrg fi 109943da084b3Smrg 1099552fd71cdSmrg rmfiles=$file 109963da084b3Smrg 109973da084b3Smrg case $name in 109983da084b3Smrg *.la) 109993da084b3Smrg # Possibly a libtool archive, so verify it. 11000d63fdb69Smrg if func_lalib_p "$file"; then 11001d63fdb69Smrg func_source $dir/$name 110023da084b3Smrg 110033da084b3Smrg # Delete the libtool libraries and symlinks. 110043da084b3Smrg for n in $library_names; do 1100548c85eb7Smrg func_append rmfiles " $odir/$n" 110063da084b3Smrg done 1100748c85eb7Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 110083da084b3Smrg 1100952fd71cdSmrg case $opt_mode in 110103da084b3Smrg clean) 1101148c85eb7Smrg case " $library_names " in 110123da084b3Smrg *" $dlname "*) ;; 1101348c85eb7Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 110143da084b3Smrg esac 1101548c85eb7Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 110163da084b3Smrg ;; 110173da084b3Smrg uninstall) 110183da084b3Smrg if test -n "$library_names"; then 110193da084b3Smrg # Do each command in the postuninstall commands. 1102052fd71cdSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 110213da084b3Smrg fi 110223da084b3Smrg 110233da084b3Smrg if test -n "$old_library"; then 110243da084b3Smrg # Do each command in the old_postuninstall commands. 1102552fd71cdSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 110263da084b3Smrg fi 110273da084b3Smrg # FIXME: should reinstall the best remaining shared library. 110283da084b3Smrg ;; 110293da084b3Smrg esac 110303da084b3Smrg fi 110313da084b3Smrg ;; 110323da084b3Smrg 110333da084b3Smrg *.lo) 110343da084b3Smrg # Possibly a libtool object, so verify it. 11035d63fdb69Smrg if func_lalib_p "$file"; then 110363da084b3Smrg 110373da084b3Smrg # Read the .lo file 11038d63fdb69Smrg func_source $dir/$name 110393da084b3Smrg 110403da084b3Smrg # Add PIC object to the list of files to remove. 1104152fd71cdSmrg if test -n "$pic_object" && test none != "$pic_object"; then 1104248c85eb7Smrg func_append rmfiles " $dir/$pic_object" 110433da084b3Smrg fi 110443da084b3Smrg 110453da084b3Smrg # Add non-PIC object to the list of files to remove. 1104652fd71cdSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1104748c85eb7Smrg func_append rmfiles " $dir/$non_pic_object" 110483da084b3Smrg fi 110493da084b3Smrg fi 110503da084b3Smrg ;; 110513da084b3Smrg 110523da084b3Smrg *) 1105352fd71cdSmrg if test clean = "$opt_mode"; then 110543da084b3Smrg noexename=$name 110553da084b3Smrg case $file in 110563da084b3Smrg *.exe) 11057d63fdb69Smrg func_stripname '' '.exe' "$file" 11058d63fdb69Smrg file=$func_stripname_result 11059d63fdb69Smrg func_stripname '' '.exe' "$name" 11060d63fdb69Smrg noexename=$func_stripname_result 110613da084b3Smrg # $file with .exe has already been added to rmfiles, 110623da084b3Smrg # add $file without .exe 1106348c85eb7Smrg func_append rmfiles " $file" 110643da084b3Smrg ;; 110653da084b3Smrg esac 110663da084b3Smrg # Do a test to see if this is a libtool program. 11067d63fdb69Smrg if func_ltwrapper_p "$file"; then 11068d63fdb69Smrg if func_ltwrapper_executable_p "$file"; then 11069d63fdb69Smrg func_ltwrapper_scriptname "$file" 11070d63fdb69Smrg relink_command= 11071d63fdb69Smrg func_source $func_ltwrapper_scriptname_result 1107248c85eb7Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11073d63fdb69Smrg else 11074d63fdb69Smrg relink_command= 11075d63fdb69Smrg func_source $dir/$noexename 11076d63fdb69Smrg fi 110773da084b3Smrg 110783da084b3Smrg # note $name still contains .exe if it was in $file originally 110793da084b3Smrg # as does the version of $file that was added into $rmfiles 1108052fd71cdSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1108152fd71cdSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 1108248c85eb7Smrg func_append rmfiles " $odir/lt-$name" 110833da084b3Smrg fi 1108452fd71cdSmrg if test "X$noexename" != "X$name"; then 1108552fd71cdSmrg func_append rmfiles " $odir/lt-$noexename.c" 110863da084b3Smrg fi 110873da084b3Smrg fi 110883da084b3Smrg fi 110893da084b3Smrg ;; 110903da084b3Smrg esac 11091d63fdb69Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 110923da084b3Smrg done 110933da084b3Smrg 1109452fd71cdSmrg # Try to remove the $objdir's in the directories where we deleted files 110953da084b3Smrg for dir in $rmdirs; do 110963da084b3Smrg if test -d "$dir"; then 11097d63fdb69Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 110983da084b3Smrg fi 110993da084b3Smrg done 111003da084b3Smrg 111013da084b3Smrg exit $exit_status 11102d63fdb69Smrg} 111033da084b3Smrg 1110452fd71cdSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1110552fd71cdSmrg func_mode_uninstall ${1+"$@"} 1110652fd71cdSmrgfi 111073da084b3Smrg 1110848c85eb7Smrgtest -z "$opt_mode" && { 1110952fd71cdSmrg help=$generic_help 11110d63fdb69Smrg func_fatal_help "you must specify a MODE" 11111d63fdb69Smrg} 11112d63fdb69Smrg 11113d63fdb69Smrgtest -z "$exec_cmd" && \ 1111452fd71cdSmrg func_fatal_help "invalid operation mode '$opt_mode'" 111153da084b3Smrg 111163da084b3Smrgif test -n "$exec_cmd"; then 11117d63fdb69Smrg eval exec "$exec_cmd" 111183da084b3Smrg exit $EXIT_FAILURE 111193da084b3Smrgfi 111203da084b3Smrg 11121d63fdb69Smrgexit $exit_status 111223da084b3Smrg 111233da084b3Smrg 111243da084b3Smrg# The TAGs below are defined such that we never get into a situation 1112552fd71cdSmrg# where we disable both kinds of libraries. Given conflicting 111263da084b3Smrg# choices, we go for a static library, that is the most portable, 111273da084b3Smrg# since we can't tell whether shared libraries were disabled because 111283da084b3Smrg# the user asked for that or because the platform doesn't support 111293da084b3Smrg# them. This is particularly important on AIX, because we don't 111303da084b3Smrg# support having both static and shared libraries enabled at the same 111313da084b3Smrg# time on that platform, so we default to a shared-only configuration. 111323da084b3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 111333da084b3Smrg# configuration. But we'll never go from static-only to shared-only. 111343da084b3Smrg 111353da084b3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136d63fdb69Smrgbuild_libtool_libs=no 11137d63fdb69Smrgbuild_old_libs=yes 111383da084b3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 111393da084b3Smrg 111403da084b3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141d63fdb69Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 111423da084b3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 111433da084b3Smrg 111443da084b3Smrg# Local Variables: 111453da084b3Smrg# mode:shell-script 111463da084b3Smrg# sh-indentation:2 111473da084b3Smrg# End: 11148