ltmain.sh revision 1b5d61b8
135c4bbdfSmrg#! /bin/sh 235c4bbdfSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 335c4bbdfSmrg## by inline-source v2014-01-03.01 44642e01fSmrg 535c4bbdfSmrg# libtool (GNU libtool) 2.4.6 635c4bbdfSmrg# Provide generalized library-building support services. 74642e01fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 84642e01fSmrg 935c4bbdfSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 104642e01fSmrg# This is free software; see the source for copying conditions. There is NO 114642e01fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 124642e01fSmrg 134642e01fSmrg# GNU Libtool is free software; you can redistribute it and/or modify 1405b261ecSmrg# it under the terms of the GNU General Public License as published by 1505b261ecSmrg# the Free Software Foundation; either version 2 of the License, or 1605b261ecSmrg# (at your option) any later version. 1705b261ecSmrg# 184642e01fSmrg# As a special exception to the GNU General Public License, 194642e01fSmrg# if you distribute this file as part of a program or library that 204642e01fSmrg# is built using GNU Libtool, you may include this file under the 214642e01fSmrg# same distribution terms that you use for the rest of that program. 224642e01fSmrg# 234642e01fSmrg# GNU Libtool is distributed in the hope that it will be useful, but 2405b261ecSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2505b261ecSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2605b261ecSmrg# General Public License for more details. 2705b261ecSmrg# 2805b261ecSmrg# You should have received a copy of the GNU General Public License 2935c4bbdfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3005b261ecSmrg 3105b261ecSmrg 326747b715SmrgPROGRAM=libtool 3305b261ecSmrgPACKAGE=libtool 3435c4bbdfSmrgVERSION=2.4.6 3535c4bbdfSmrgpackage_revision=2.4.6 3605b261ecSmrg 3735c4bbdfSmrg 3835c4bbdfSmrg## ------ ## 3935c4bbdfSmrg## Usage. ## 4035c4bbdfSmrg## ------ ## 4135c4bbdfSmrg 4235c4bbdfSmrg# Run './libtool --help' for help with using this script from the 4335c4bbdfSmrg# command line. 4435c4bbdfSmrg 4535c4bbdfSmrg 4635c4bbdfSmrg## ------------------------------- ## 4735c4bbdfSmrg## User overridable command paths. ## 4835c4bbdfSmrg## ------------------------------- ## 4935c4bbdfSmrg 5035c4bbdfSmrg# After configure completes, it has a better idea of some of the 5135c4bbdfSmrg# shell tools we need than the defaults used by the functions shared 5235c4bbdfSmrg# with bootstrap, so set those here where they can still be over- 5335c4bbdfSmrg# ridden by the user, but otherwise take precedence. 5435c4bbdfSmrg 5535c4bbdfSmrg: ${AUTOCONF="autoconf"} 5635c4bbdfSmrg: ${AUTOMAKE="automake"} 5735c4bbdfSmrg 5835c4bbdfSmrg 5935c4bbdfSmrg## -------------------------- ## 6035c4bbdfSmrg## Source external libraries. ## 6135c4bbdfSmrg## -------------------------- ## 6235c4bbdfSmrg 6335c4bbdfSmrg# Much of our low-level functionality needs to be sourced from external 6435c4bbdfSmrg# libraries, which are installed to $pkgauxdir. 6535c4bbdfSmrg 6635c4bbdfSmrg# Set a version string for this script. 6735c4bbdfSmrgscriptversion=2015-01-20.17; # UTC 6835c4bbdfSmrg 6935c4bbdfSmrg# General shell script boiler plate, and helper functions. 7035c4bbdfSmrg# Written by Gary V. Vaughan, 2004 7135c4bbdfSmrg 7235c4bbdfSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7335c4bbdfSmrg# This is free software; see the source for copying conditions. There is NO 7435c4bbdfSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7535c4bbdfSmrg 7635c4bbdfSmrg# This program is free software; you can redistribute it and/or modify 7735c4bbdfSmrg# it under the terms of the GNU General Public License as published by 7835c4bbdfSmrg# the Free Software Foundation; either version 3 of the License, or 7935c4bbdfSmrg# (at your option) any later version. 8035c4bbdfSmrg 8135c4bbdfSmrg# As a special exception to the GNU General Public License, if you distribute 8235c4bbdfSmrg# this file as part of a program or library that is built using GNU Libtool, 8335c4bbdfSmrg# you may include this file under the same distribution terms that you use 8435c4bbdfSmrg# for the rest of that program. 8535c4bbdfSmrg 8635c4bbdfSmrg# This program is distributed in the hope that it will be useful, 8735c4bbdfSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8835c4bbdfSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8935c4bbdfSmrg# General Public License for more details. 9035c4bbdfSmrg 9135c4bbdfSmrg# You should have received a copy of the GNU General Public License 9235c4bbdfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9335c4bbdfSmrg 9435c4bbdfSmrg# Please report bugs or propose patches to gary@gnu.org. 9535c4bbdfSmrg 9635c4bbdfSmrg 9735c4bbdfSmrg## ------ ## 9835c4bbdfSmrg## Usage. ## 9935c4bbdfSmrg## ------ ## 10035c4bbdfSmrg 10135c4bbdfSmrg# Evaluate this file near the top of your script to gain access to 10235c4bbdfSmrg# the functions and variables defined here: 10335c4bbdfSmrg# 10435c4bbdfSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10535c4bbdfSmrg# 10635c4bbdfSmrg# If you need to override any of the default environment variable 10735c4bbdfSmrg# settings, do that before evaluating this file. 10835c4bbdfSmrg 10935c4bbdfSmrg 11035c4bbdfSmrg## -------------------- ## 11135c4bbdfSmrg## Shell normalisation. ## 11235c4bbdfSmrg## -------------------- ## 11335c4bbdfSmrg 11435c4bbdfSmrg# Some shells need a little help to be as Bourne compatible as possible. 11535c4bbdfSmrg# Before doing anything else, make sure all that help has been provided! 11635c4bbdfSmrg 11735c4bbdfSmrgDUALCASE=1; export DUALCASE # for MKS sh 11835c4bbdfSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11905b261ecSmrg emulate sh 12005b261ecSmrg NULLCMD=: 12135c4bbdfSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 12205b261ecSmrg # is contrary to our usage. Disable this feature. 12305b261ecSmrg alias -g '${1+"$@"}'='"$@"' 12405b261ecSmrg setopt NO_GLOB_SUBST 12505b261ecSmrgelse 12635c4bbdfSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12705b261ecSmrgfi 1286747b715Smrg 12935c4bbdfSmrg# NLS nuisances: We save the old values in case they are required later. 13035c4bbdfSmrg_G_user_locale= 13135c4bbdfSmrg_G_safe_locale= 13235c4bbdfSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 13305b261ecSmrgdo 13435c4bbdfSmrg eval "if test set = \"\${$_G_var+set}\"; then 13535c4bbdfSmrg save_$_G_var=\$$_G_var 13635c4bbdfSmrg $_G_var=C 13735c4bbdfSmrg export $_G_var 13835c4bbdfSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13935c4bbdfSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 14005b261ecSmrg fi" 14105b261ecSmrgdone 14205b261ecSmrg 14335c4bbdfSmrg# CDPATH. 14435c4bbdfSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 1454642e01fSmrg 14635c4bbdfSmrg# Make sure IFS has a sensible default 14735c4bbdfSmrgsp=' ' 14835c4bbdfSmrgnl=' 14935c4bbdfSmrg' 15035c4bbdfSmrgIFS="$sp $nl" 15135c4bbdfSmrg 15235c4bbdfSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 15335c4bbdfSmrgif test "${PATH_SEPARATOR+set}" != set; then 15435c4bbdfSmrg PATH_SEPARATOR=: 15535c4bbdfSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15635c4bbdfSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15735c4bbdfSmrg PATH_SEPARATOR=';' 15835c4bbdfSmrg } 15935c4bbdfSmrgfi 1604642e01fSmrg 1614642e01fSmrg 1624642e01fSmrg 16335c4bbdfSmrg## ------------------------- ## 16435c4bbdfSmrg## Locate command utilities. ## 16535c4bbdfSmrg## ------------------------- ## 16635c4bbdfSmrg 16735c4bbdfSmrg 16835c4bbdfSmrg# func_executable_p FILE 16935c4bbdfSmrg# ---------------------- 17035c4bbdfSmrg# Check that FILE is an executable regular file. 17135c4bbdfSmrgfunc_executable_p () 17235c4bbdfSmrg{ 17335c4bbdfSmrg test -f "$1" && test -x "$1" 17435c4bbdfSmrg} 17535c4bbdfSmrg 17635c4bbdfSmrg 17735c4bbdfSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17835c4bbdfSmrg# -------------------------------------------- 17935c4bbdfSmrg# Search for either a program that responds to --version with output 18035c4bbdfSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18135c4bbdfSmrg# trying all the directories in PATH with each of the elements of 18235c4bbdfSmrg# PROGS_LIST. 18335c4bbdfSmrg# 18435c4bbdfSmrg# CHECK_FUNC should accept the path to a candidate program, and 18535c4bbdfSmrg# set $func_check_prog_result if it truncates its output less than 18635c4bbdfSmrg# $_G_path_prog_max characters. 18735c4bbdfSmrgfunc_path_progs () 18835c4bbdfSmrg{ 18935c4bbdfSmrg _G_progs_list=$1 19035c4bbdfSmrg _G_check_func=$2 19135c4bbdfSmrg _G_PATH=${3-"$PATH"} 19235c4bbdfSmrg 19335c4bbdfSmrg _G_path_prog_max=0 19435c4bbdfSmrg _G_path_prog_found=false 19535c4bbdfSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19635c4bbdfSmrg for _G_dir in $_G_PATH; do 19735c4bbdfSmrg IFS=$_G_save_IFS 19835c4bbdfSmrg test -z "$_G_dir" && _G_dir=. 19935c4bbdfSmrg for _G_prog_name in $_G_progs_list; do 20035c4bbdfSmrg for _exeext in '' .EXE; do 20135c4bbdfSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20235c4bbdfSmrg func_executable_p "$_G_path_prog" || continue 20335c4bbdfSmrg case `"$_G_path_prog" --version 2>&1` in 20435c4bbdfSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20535c4bbdfSmrg *) $_G_check_func $_G_path_prog 20635c4bbdfSmrg func_path_progs_result=$func_check_prog_result 20735c4bbdfSmrg ;; 20835c4bbdfSmrg esac 20935c4bbdfSmrg $_G_path_prog_found && break 3 21035c4bbdfSmrg done 21135c4bbdfSmrg done 21235c4bbdfSmrg done 21335c4bbdfSmrg IFS=$_G_save_IFS 21435c4bbdfSmrg test -z "$func_path_progs_result" && { 21535c4bbdfSmrg echo "no acceptable sed could be found in \$PATH" >&2 21635c4bbdfSmrg exit 1 21735c4bbdfSmrg } 21835c4bbdfSmrg} 21935c4bbdfSmrg 22035c4bbdfSmrg 22135c4bbdfSmrg# We want to be able to use the functions in this file before configure 22235c4bbdfSmrg# has figured out where the best binaries are kept, which means we have 22335c4bbdfSmrg# to search for them ourselves - except when the results are already set 22435c4bbdfSmrg# where we skip the searches. 22535c4bbdfSmrg 22635c4bbdfSmrg# Unless the user overrides by setting SED, search the path for either GNU 22735c4bbdfSmrg# sed, or the sed that truncates its output the least. 22835c4bbdfSmrgtest -z "$SED" && { 22935c4bbdfSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23035c4bbdfSmrg for _G_i in 1 2 3 4 5 6 7; do 23135c4bbdfSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23235c4bbdfSmrg done 23335c4bbdfSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23435c4bbdfSmrg _G_sed_script= 23535c4bbdfSmrg 23635c4bbdfSmrg func_check_prog_sed () 23735c4bbdfSmrg { 23835c4bbdfSmrg _G_path_prog=$1 23935c4bbdfSmrg 24035c4bbdfSmrg _G_count=0 24135c4bbdfSmrg printf 0123456789 >conftest.in 24235c4bbdfSmrg while : 24335c4bbdfSmrg do 24435c4bbdfSmrg cat conftest.in conftest.in >conftest.tmp 24535c4bbdfSmrg mv conftest.tmp conftest.in 24635c4bbdfSmrg cp conftest.in conftest.nl 24735c4bbdfSmrg echo '' >> conftest.nl 24835c4bbdfSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24935c4bbdfSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25035c4bbdfSmrg _G_count=`expr $_G_count + 1` 25135c4bbdfSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25235c4bbdfSmrg # Best one so far, save it but keep looking for a better one 25335c4bbdfSmrg func_check_prog_result=$_G_path_prog 25435c4bbdfSmrg _G_path_prog_max=$_G_count 25535c4bbdfSmrg fi 25635c4bbdfSmrg # 10*(2^10) chars as input seems more than enough 25735c4bbdfSmrg test 10 -lt "$_G_count" && break 25835c4bbdfSmrg done 25935c4bbdfSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26035c4bbdfSmrg } 26135c4bbdfSmrg 26235c4bbdfSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26335c4bbdfSmrg rm -f conftest.sed 26435c4bbdfSmrg SED=$func_path_progs_result 26535c4bbdfSmrg} 26635c4bbdfSmrg 26735c4bbdfSmrg 26835c4bbdfSmrg# Unless the user overrides by setting GREP, search the path for either GNU 26935c4bbdfSmrg# grep, or the grep that truncates its output the least. 27035c4bbdfSmrgtest -z "$GREP" && { 27135c4bbdfSmrg func_check_prog_grep () 27235c4bbdfSmrg { 27335c4bbdfSmrg _G_path_prog=$1 27435c4bbdfSmrg 27535c4bbdfSmrg _G_count=0 27635c4bbdfSmrg _G_path_prog_max=0 27735c4bbdfSmrg printf 0123456789 >conftest.in 27835c4bbdfSmrg while : 27935c4bbdfSmrg do 28035c4bbdfSmrg cat conftest.in conftest.in >conftest.tmp 28135c4bbdfSmrg mv conftest.tmp conftest.in 28235c4bbdfSmrg cp conftest.in conftest.nl 28335c4bbdfSmrg echo 'GREP' >> conftest.nl 28435c4bbdfSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28535c4bbdfSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28635c4bbdfSmrg _G_count=`expr $_G_count + 1` 28735c4bbdfSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28835c4bbdfSmrg # Best one so far, save it but keep looking for a better one 28935c4bbdfSmrg func_check_prog_result=$_G_path_prog 29035c4bbdfSmrg _G_path_prog_max=$_G_count 29135c4bbdfSmrg fi 29235c4bbdfSmrg # 10*(2^10) chars as input seems more than enough 29335c4bbdfSmrg test 10 -lt "$_G_count" && break 29435c4bbdfSmrg done 29535c4bbdfSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29635c4bbdfSmrg } 29735c4bbdfSmrg 29835c4bbdfSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29935c4bbdfSmrg GREP=$func_path_progs_result 30035c4bbdfSmrg} 30135c4bbdfSmrg 30235c4bbdfSmrg 30335c4bbdfSmrg## ------------------------------- ## 30435c4bbdfSmrg## User overridable command paths. ## 30535c4bbdfSmrg## ------------------------------- ## 30635c4bbdfSmrg 30735c4bbdfSmrg# All uppercase variable names are used for environment variables. These 30835c4bbdfSmrg# variables can be overridden by the user before calling a script that 30935c4bbdfSmrg# uses them if a suitable command of that name is not already available 31035c4bbdfSmrg# in the command search PATH. 3114642e01fSmrg 3124642e01fSmrg: ${CP="cp -f"} 31335c4bbdfSmrg: ${ECHO="printf %s\n"} 31435c4bbdfSmrg: ${EGREP="$GREP -E"} 31535c4bbdfSmrg: ${FGREP="$GREP -F"} 3164642e01fSmrg: ${LN_S="ln -s"} 3174642e01fSmrg: ${MAKE="make"} 3184642e01fSmrg: ${MKDIR="mkdir"} 3194642e01fSmrg: ${MV="mv -f"} 3204642e01fSmrg: ${RM="rm -f"} 3214642e01fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3224642e01fSmrg 3234642e01fSmrg 32435c4bbdfSmrg## -------------------- ## 32535c4bbdfSmrg## Useful sed snippets. ## 32635c4bbdfSmrg## -------------------- ## 32705b261ecSmrg 32835c4bbdfSmrgsed_dirname='s|/[^/]*$||' 32935c4bbdfSmrgsed_basename='s|^.*/||' 33005b261ecSmrg 33135c4bbdfSmrg# Sed substitution that helps us do robust quoting. It backslashifies 33235c4bbdfSmrg# metacharacters that are still active within double-quoted strings. 33335c4bbdfSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3344642e01fSmrg 33535c4bbdfSmrg# Same as above, but do not quote variable references. 33635c4bbdfSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33735c4bbdfSmrg 33835c4bbdfSmrg# Sed substitution that turns a string into a regex matching for the 33935c4bbdfSmrg# string literally. 34035c4bbdfSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34135c4bbdfSmrg 34235c4bbdfSmrg# Sed substitution that converts a w32 file name or path 34335c4bbdfSmrg# that contains forward slashes, into one that contains 34435c4bbdfSmrg# (escaped) backslashes. A very naive implementation. 34535c4bbdfSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34635c4bbdfSmrg 34735c4bbdfSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34835c4bbdfSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34935c4bbdfSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35035c4bbdfSmrg# expansion. Since each input '\' is now two '\'s, look for any number 35135c4bbdfSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35235c4bbdfSmrg_G_bs='\\' 35335c4bbdfSmrg_G_bs2='\\\\' 35435c4bbdfSmrg_G_bs4='\\\\\\\\' 35535c4bbdfSmrg_G_dollar='\$' 35635c4bbdfSmrgsed_double_backslash="\ 35735c4bbdfSmrg s/$_G_bs4/&\\ 35835c4bbdfSmrg/g 35935c4bbdfSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36035c4bbdfSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36135c4bbdfSmrg s/\n//g" 3626747b715Smrg 3636747b715Smrg 36435c4bbdfSmrg## ----------------- ## 36535c4bbdfSmrg## Global variables. ## 36635c4bbdfSmrg## ----------------- ## 3676747b715Smrg 36835c4bbdfSmrg# Except for the global variables explicitly listed below, the following 36935c4bbdfSmrg# functions in the '^func_' namespace, and the '^require_' namespace 37035c4bbdfSmrg# variables initialised in the 'Resource management' section, sourcing 37135c4bbdfSmrg# this file will not pollute your global namespace with anything 37235c4bbdfSmrg# else. There's no portable way to scope variables in Bourne shell 37335c4bbdfSmrg# though, so actually running these functions will sometimes place 37435c4bbdfSmrg# results into a variable named after the function, and often use 37535c4bbdfSmrg# temporary variables in the '^_G_' namespace. If you are careful to 37635c4bbdfSmrg# avoid using those namespaces casually in your sourcing script, things 37735c4bbdfSmrg# should continue to work as you expect. And, of course, you can freely 37835c4bbdfSmrg# overwrite any of the functions or variables defined here before 37935c4bbdfSmrg# calling anything to customize them. 38005b261ecSmrg 38135c4bbdfSmrgEXIT_SUCCESS=0 38235c4bbdfSmrgEXIT_FAILURE=1 38335c4bbdfSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38435c4bbdfSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 3854642e01fSmrg 38635c4bbdfSmrg# Allow overriding, eg assuming that you follow the convention of 38735c4bbdfSmrg# putting '$debug_cmd' at the start of all your functions, you can get 38835c4bbdfSmrg# bash to show function call trace with: 38935c4bbdfSmrg# 39035c4bbdfSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39135c4bbdfSmrgdebug_cmd=${debug_cmd-":"} 39235c4bbdfSmrgexit_cmd=: 3936747b715Smrg 39435c4bbdfSmrg# By convention, finish your script with: 39535c4bbdfSmrg# 39635c4bbdfSmrg# exit $exit_status 39735c4bbdfSmrg# 39835c4bbdfSmrg# so that you can set exit_status to non-zero if you want to indicate 39935c4bbdfSmrg# something went wrong during execution without actually bailing out at 40035c4bbdfSmrg# the point of failure. 40135c4bbdfSmrgexit_status=$EXIT_SUCCESS 40235c4bbdfSmrg 40335c4bbdfSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40435c4bbdfSmrg# is ksh but when the shell is invoked as "sh" and the current value of 40535c4bbdfSmrg# the _XPG environment variable is not equal to 1 (one), the special 40635c4bbdfSmrg# positional parameter $0, within a function call, is the name of the 40735c4bbdfSmrg# function. 40835c4bbdfSmrgprogpath=$0 4094642e01fSmrg 41035c4bbdfSmrg# The name of this program. 41135c4bbdfSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4124642e01fSmrg 41335c4bbdfSmrg# Make sure we have an absolute progpath for reexecution: 4144642e01fSmrgcase $progpath in 4154642e01fSmrg [\\/]*|[A-Za-z]:\\*) ;; 4164642e01fSmrg *[\\/]*) 41735c4bbdfSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4184642e01fSmrg progdir=`cd "$progdir" && pwd` 41935c4bbdfSmrg progpath=$progdir/$progname 4204642e01fSmrg ;; 4214642e01fSmrg *) 42235c4bbdfSmrg _G_IFS=$IFS 42335c4bbdfSmrg IFS=${PATH_SEPARATOR-:} 4244642e01fSmrg for progdir in $PATH; do 42535c4bbdfSmrg IFS=$_G_IFS 4264642e01fSmrg test -x "$progdir/$progname" && break 4274642e01fSmrg done 42835c4bbdfSmrg IFS=$_G_IFS 4294642e01fSmrg test -n "$progdir" || progdir=`pwd` 43035c4bbdfSmrg progpath=$progdir/$progname 4314642e01fSmrg ;; 4324642e01fSmrgesac 4334642e01fSmrg 4344642e01fSmrg 43535c4bbdfSmrg## ----------------- ## 43635c4bbdfSmrg## Standard options. ## 43735c4bbdfSmrg## ----------------- ## 43835c4bbdfSmrg 43935c4bbdfSmrg# The following options affect the operation of the functions defined 44035c4bbdfSmrg# below, and should be set appropriately depending on run-time para- 44135c4bbdfSmrg# meters passed on the command line. 4424642e01fSmrg 4434642e01fSmrgopt_dry_run=false 4444642e01fSmrgopt_quiet=false 4454642e01fSmrgopt_verbose=false 4464642e01fSmrg 44735c4bbdfSmrg# Categories 'all' and 'none' are always available. Append any others 44835c4bbdfSmrg# you will pass as the first argument to func_warning from your own 44935c4bbdfSmrg# code. 45035c4bbdfSmrgwarning_categories= 4514642e01fSmrg 45235c4bbdfSmrg# By default, display warnings according to 'opt_warning_types'. Set 45335c4bbdfSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45435c4bbdfSmrg# treat the next displayed warning as a fatal error. 45535c4bbdfSmrgwarning_func=func_warn_and_continue 4564642e01fSmrg 45735c4bbdfSmrg# Set to 'all' to display all warnings, 'none' to suppress all 45835c4bbdfSmrg# warnings, or a space delimited list of some subset of 45935c4bbdfSmrg# 'warning_categories' to display only the listed warnings. 46035c4bbdfSmrgopt_warning_types=all 4614642e01fSmrg 4626747b715Smrg 46335c4bbdfSmrg## -------------------- ## 46435c4bbdfSmrg## Resource management. ## 46535c4bbdfSmrg## -------------------- ## 4664642e01fSmrg 46735c4bbdfSmrg# This section contains definitions for functions that each ensure a 46835c4bbdfSmrg# particular resource (a file, or a non-empty configuration variable for 46935c4bbdfSmrg# example) is available, and if appropriate to extract default values 47035c4bbdfSmrg# from pertinent package files. Call them using their associated 47135c4bbdfSmrg# 'require_*' variable to ensure that they are executed, at most, once. 47235c4bbdfSmrg# 47335c4bbdfSmrg# It's entirely deliberate that calling these functions can set 47435c4bbdfSmrg# variables that don't obey the namespace limitations obeyed by the rest 47535c4bbdfSmrg# of this file, in order that that they be as useful as possible to 47635c4bbdfSmrg# callers. 4774642e01fSmrg 4784642e01fSmrg 47935c4bbdfSmrg# require_term_colors 48035c4bbdfSmrg# ------------------- 48135c4bbdfSmrg# Allow display of bold text on terminals that support it. 48235c4bbdfSmrgrequire_term_colors=func_require_term_colors 48335c4bbdfSmrgfunc_require_term_colors () 4844642e01fSmrg{ 48535c4bbdfSmrg $debug_cmd 48635c4bbdfSmrg 48735c4bbdfSmrg test -t 1 && { 48835c4bbdfSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 48935c4bbdfSmrg # precedence, because most terminfo databases neglect to describe 49035c4bbdfSmrg # whether color sequences are supported. 49135c4bbdfSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49235c4bbdfSmrg 49335c4bbdfSmrg if test 1 = "$USE_ANSI_COLORS"; then 49435c4bbdfSmrg # Standard ANSI escape sequences 49535c4bbdfSmrg tc_reset='[0m' 49635c4bbdfSmrg tc_bold='[1m'; tc_standout='[7m' 49735c4bbdfSmrg tc_red='[31m'; tc_green='[32m' 49835c4bbdfSmrg tc_blue='[34m'; tc_cyan='[36m' 49935c4bbdfSmrg else 50035c4bbdfSmrg # Otherwise trust the terminfo database after all. 50135c4bbdfSmrg test -n "`tput sgr0 2>/dev/null`" && { 50235c4bbdfSmrg tc_reset=`tput sgr0` 50335c4bbdfSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50435c4bbdfSmrg tc_standout=$tc_bold 50535c4bbdfSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50635c4bbdfSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50735c4bbdfSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50835c4bbdfSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50935c4bbdfSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51035c4bbdfSmrg } 51135c4bbdfSmrg fi 51235c4bbdfSmrg } 5134642e01fSmrg 51435c4bbdfSmrg require_term_colors=: 5154642e01fSmrg} 5164642e01fSmrg 5174642e01fSmrg 51835c4bbdfSmrg## ----------------- ## 51935c4bbdfSmrg## Function library. ## 52035c4bbdfSmrg## ----------------- ## 5214642e01fSmrg 52235c4bbdfSmrg# This section contains a variety of useful functions to call in your 52335c4bbdfSmrg# scripts. Take note of the portable wrappers for features provided by 52435c4bbdfSmrg# some modern shells, which will fall back to slower equivalents on 52535c4bbdfSmrg# less featureful shells. 5264642e01fSmrg 5274642e01fSmrg 52835c4bbdfSmrg# func_append VAR VALUE 52935c4bbdfSmrg# --------------------- 53035c4bbdfSmrg# Append VALUE onto the existing contents of VAR. 5314642e01fSmrg 53235c4bbdfSmrg # We should try to minimise forks, especially on Windows where they are 53335c4bbdfSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 53435c4bbdfSmrg # being used: 53535c4bbdfSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53635c4bbdfSmrg : ${_G_HAVE_ARITH_OP="yes"} 53735c4bbdfSmrg : ${_G_HAVE_XSI_OPS="yes"} 53835c4bbdfSmrg # The += operator was introduced in bash 3.1 53935c4bbdfSmrg case $BASH_VERSION in 54035c4bbdfSmrg [12].* | 3.0 | 3.0*) ;; 54135c4bbdfSmrg *) 54235c4bbdfSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54335c4bbdfSmrg ;; 54435c4bbdfSmrg esac 54535c4bbdfSmrg fi 5464642e01fSmrg 54735c4bbdfSmrg # _G_HAVE_PLUSEQ_OP 54835c4bbdfSmrg # Can be empty, in which case the shell is probed, "yes" if += is 54935c4bbdfSmrg # useable or anything else if it does not work. 55035c4bbdfSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55135c4bbdfSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55235c4bbdfSmrg && _G_HAVE_PLUSEQ_OP=yes 55335c4bbdfSmrg 55435c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55535c4bbdfSmrgthen 55635c4bbdfSmrg # This is an XSI compatible shell, allowing a faster implementation... 55735c4bbdfSmrg eval 'func_append () 55835c4bbdfSmrg { 55935c4bbdfSmrg $debug_cmd 5604642e01fSmrg 56135c4bbdfSmrg eval "$1+=\$2" 56235c4bbdfSmrg }' 56335c4bbdfSmrgelse 56435c4bbdfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 56535c4bbdfSmrg func_append () 56635c4bbdfSmrg { 56735c4bbdfSmrg $debug_cmd 5684642e01fSmrg 56935c4bbdfSmrg eval "$1=\$$1\$2" 57035c4bbdfSmrg } 57135c4bbdfSmrgfi 57235c4bbdfSmrg 57335c4bbdfSmrg 57435c4bbdfSmrg# func_append_quoted VAR VALUE 57535c4bbdfSmrg# ---------------------------- 57635c4bbdfSmrg# Quote VALUE and append to the end of shell variable VAR, separated 57735c4bbdfSmrg# by a space. 57835c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57935c4bbdfSmrg eval 'func_append_quoted () 58035c4bbdfSmrg { 58135c4bbdfSmrg $debug_cmd 58235c4bbdfSmrg 58335c4bbdfSmrg func_quote_for_eval "$2" 58435c4bbdfSmrg eval "$1+=\\ \$func_quote_for_eval_result" 58535c4bbdfSmrg }' 58635c4bbdfSmrgelse 58735c4bbdfSmrg func_append_quoted () 58835c4bbdfSmrg { 58935c4bbdfSmrg $debug_cmd 59035c4bbdfSmrg 59135c4bbdfSmrg func_quote_for_eval "$2" 59235c4bbdfSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59335c4bbdfSmrg } 59435c4bbdfSmrgfi 59535c4bbdfSmrg 59635c4bbdfSmrg 59735c4bbdfSmrg# func_append_uniq VAR VALUE 59835c4bbdfSmrg# -------------------------- 59935c4bbdfSmrg# Append unique VALUE onto the existing contents of VAR, assuming 60035c4bbdfSmrg# entries are delimited by the first character of VALUE. For example: 60135c4bbdfSmrg# 60235c4bbdfSmrg# func_append_uniq options " --another-option option-argument" 60335c4bbdfSmrg# 60435c4bbdfSmrg# will only append to $options if " --another-option option-argument " 60535c4bbdfSmrg# is not already present somewhere in $options already (note spaces at 60635c4bbdfSmrg# each end implied by leading space in second argument). 60735c4bbdfSmrgfunc_append_uniq () 60835c4bbdfSmrg{ 60935c4bbdfSmrg $debug_cmd 61035c4bbdfSmrg 61135c4bbdfSmrg eval _G_current_value='`$ECHO $'$1'`' 61235c4bbdfSmrg _G_delim=`expr "$2" : '\(.\)'` 61335c4bbdfSmrg 61435c4bbdfSmrg case $_G_delim$_G_current_value$_G_delim in 61535c4bbdfSmrg *"$2$_G_delim"*) ;; 61635c4bbdfSmrg *) func_append "$@" ;; 61735c4bbdfSmrg esac 61835c4bbdfSmrg} 61935c4bbdfSmrg 62035c4bbdfSmrg 62135c4bbdfSmrg# func_arith TERM... 62235c4bbdfSmrg# ------------------ 62335c4bbdfSmrg# Set func_arith_result to the result of evaluating TERMs. 62435c4bbdfSmrg test -z "$_G_HAVE_ARITH_OP" \ 62535c4bbdfSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62635c4bbdfSmrg && _G_HAVE_ARITH_OP=yes 62735c4bbdfSmrg 62835c4bbdfSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 62935c4bbdfSmrg eval 'func_arith () 63035c4bbdfSmrg { 63135c4bbdfSmrg $debug_cmd 63235c4bbdfSmrg 63335c4bbdfSmrg func_arith_result=$(( $* )) 63435c4bbdfSmrg }' 63535c4bbdfSmrgelse 63635c4bbdfSmrg func_arith () 63735c4bbdfSmrg { 63835c4bbdfSmrg $debug_cmd 63935c4bbdfSmrg 64035c4bbdfSmrg func_arith_result=`expr "$@"` 64135c4bbdfSmrg } 64235c4bbdfSmrgfi 64335c4bbdfSmrg 64435c4bbdfSmrg 64535c4bbdfSmrg# func_basename FILE 64635c4bbdfSmrg# ------------------ 64735c4bbdfSmrg# Set func_basename_result to FILE with everything up to and including 64835c4bbdfSmrg# the last / stripped. 64935c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 65035c4bbdfSmrg # If this shell supports suffix pattern removal, then use it to avoid 65135c4bbdfSmrg # forking. Hide the definitions single quotes in case the shell chokes 65235c4bbdfSmrg # on unsupported syntax... 65335c4bbdfSmrg _b='func_basename_result=${1##*/}' 65435c4bbdfSmrg _d='case $1 in 65535c4bbdfSmrg */*) func_dirname_result=${1%/*}$2 ;; 65635c4bbdfSmrg * ) func_dirname_result=$3 ;; 65735c4bbdfSmrg esac' 65835c4bbdfSmrg 65935c4bbdfSmrgelse 66035c4bbdfSmrg # ...otherwise fall back to using sed. 66135c4bbdfSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66235c4bbdfSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66335c4bbdfSmrg if test "X$func_dirname_result" = "X$1"; then 66435c4bbdfSmrg func_dirname_result=$3 66535c4bbdfSmrg else 66635c4bbdfSmrg func_append func_dirname_result "$2" 66735c4bbdfSmrg fi' 66835c4bbdfSmrgfi 66935c4bbdfSmrg 67035c4bbdfSmrgeval 'func_basename () 67135c4bbdfSmrg{ 67235c4bbdfSmrg $debug_cmd 67335c4bbdfSmrg 67435c4bbdfSmrg '"$_b"' 67535c4bbdfSmrg}' 67635c4bbdfSmrg 67735c4bbdfSmrg 67835c4bbdfSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67935c4bbdfSmrg# ------------------------------------------- 68035c4bbdfSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68135c4bbdfSmrg# otherwise set result to NONDIR_REPLACEMENT. 68235c4bbdfSmrgeval 'func_dirname () 68335c4bbdfSmrg{ 68435c4bbdfSmrg $debug_cmd 68535c4bbdfSmrg 68635c4bbdfSmrg '"$_d"' 68735c4bbdfSmrg}' 68835c4bbdfSmrg 68935c4bbdfSmrg 69035c4bbdfSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69135c4bbdfSmrg# -------------------------------------------------------- 69235c4bbdfSmrg# Perform func_basename and func_dirname in a single function 69335c4bbdfSmrg# call: 69435c4bbdfSmrg# dirname: Compute the dirname of FILE. If nonempty, 69535c4bbdfSmrg# add APPEND to the result, otherwise set result 69635c4bbdfSmrg# to NONDIR_REPLACEMENT. 69735c4bbdfSmrg# value returned in "$func_dirname_result" 69835c4bbdfSmrg# basename: Compute filename of FILE. 69935c4bbdfSmrg# value retuned in "$func_basename_result" 70035c4bbdfSmrg# For efficiency, we do not delegate to the functions above but instead 70135c4bbdfSmrg# duplicate the functionality here. 70235c4bbdfSmrgeval 'func_dirname_and_basename () 70335c4bbdfSmrg{ 70435c4bbdfSmrg $debug_cmd 70535c4bbdfSmrg 70635c4bbdfSmrg '"$_b"' 70735c4bbdfSmrg '"$_d"' 70835c4bbdfSmrg}' 70935c4bbdfSmrg 71035c4bbdfSmrg 71135c4bbdfSmrg# func_echo ARG... 71235c4bbdfSmrg# ---------------- 71335c4bbdfSmrg# Echo program name prefixed message. 71435c4bbdfSmrgfunc_echo () 71535c4bbdfSmrg{ 71635c4bbdfSmrg $debug_cmd 71735c4bbdfSmrg 71835c4bbdfSmrg _G_message=$* 71935c4bbdfSmrg 72035c4bbdfSmrg func_echo_IFS=$IFS 72135c4bbdfSmrg IFS=$nl 72235c4bbdfSmrg for _G_line in $_G_message; do 72335c4bbdfSmrg IFS=$func_echo_IFS 72435c4bbdfSmrg $ECHO "$progname: $_G_line" 72535c4bbdfSmrg done 72635c4bbdfSmrg IFS=$func_echo_IFS 72735c4bbdfSmrg} 72835c4bbdfSmrg 72935c4bbdfSmrg 73035c4bbdfSmrg# func_echo_all ARG... 73135c4bbdfSmrg# -------------------- 73235c4bbdfSmrg# Invoke $ECHO with all args, space-separated. 73335c4bbdfSmrgfunc_echo_all () 73435c4bbdfSmrg{ 73535c4bbdfSmrg $ECHO "$*" 73635c4bbdfSmrg} 73735c4bbdfSmrg 73835c4bbdfSmrg 73935c4bbdfSmrg# func_echo_infix_1 INFIX ARG... 74035c4bbdfSmrg# ------------------------------ 74135c4bbdfSmrg# Echo program name, followed by INFIX on the first line, with any 74235c4bbdfSmrg# additional lines not showing INFIX. 74335c4bbdfSmrgfunc_echo_infix_1 () 74435c4bbdfSmrg{ 74535c4bbdfSmrg $debug_cmd 74635c4bbdfSmrg 74735c4bbdfSmrg $require_term_colors 74835c4bbdfSmrg 74935c4bbdfSmrg _G_infix=$1; shift 75035c4bbdfSmrg _G_indent=$_G_infix 75135c4bbdfSmrg _G_prefix="$progname: $_G_infix: " 75235c4bbdfSmrg _G_message=$* 75335c4bbdfSmrg 75435c4bbdfSmrg # Strip color escape sequences before counting printable length 75535c4bbdfSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75635c4bbdfSmrg do 75735c4bbdfSmrg test -n "$_G_tc" && { 75835c4bbdfSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75935c4bbdfSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76035c4bbdfSmrg } 76135c4bbdfSmrg done 76235c4bbdfSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76335c4bbdfSmrg 76435c4bbdfSmrg func_echo_infix_1_IFS=$IFS 76535c4bbdfSmrg IFS=$nl 76635c4bbdfSmrg for _G_line in $_G_message; do 76735c4bbdfSmrg IFS=$func_echo_infix_1_IFS 76835c4bbdfSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76935c4bbdfSmrg _G_prefix=$_G_indent 77035c4bbdfSmrg done 77135c4bbdfSmrg IFS=$func_echo_infix_1_IFS 77235c4bbdfSmrg} 77335c4bbdfSmrg 77435c4bbdfSmrg 77535c4bbdfSmrg# func_error ARG... 77635c4bbdfSmrg# ----------------- 77735c4bbdfSmrg# Echo program name prefixed message to standard error. 77835c4bbdfSmrgfunc_error () 77935c4bbdfSmrg{ 78035c4bbdfSmrg $debug_cmd 78135c4bbdfSmrg 78235c4bbdfSmrg $require_term_colors 78335c4bbdfSmrg 78435c4bbdfSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78535c4bbdfSmrg} 78635c4bbdfSmrg 78735c4bbdfSmrg 78835c4bbdfSmrg# func_fatal_error ARG... 78935c4bbdfSmrg# ----------------------- 79035c4bbdfSmrg# Echo program name prefixed message to standard error, and exit. 79135c4bbdfSmrgfunc_fatal_error () 79235c4bbdfSmrg{ 79335c4bbdfSmrg $debug_cmd 79435c4bbdfSmrg 79535c4bbdfSmrg func_error "$*" 79635c4bbdfSmrg exit $EXIT_FAILURE 79735c4bbdfSmrg} 79835c4bbdfSmrg 79935c4bbdfSmrg 80035c4bbdfSmrg# func_grep EXPRESSION FILENAME 80135c4bbdfSmrg# ----------------------------- 80235c4bbdfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 80335c4bbdfSmrgfunc_grep () 80435c4bbdfSmrg{ 80535c4bbdfSmrg $debug_cmd 80635c4bbdfSmrg 80735c4bbdfSmrg $GREP "$1" "$2" >/dev/null 2>&1 80835c4bbdfSmrg} 80935c4bbdfSmrg 81035c4bbdfSmrg 81135c4bbdfSmrg# func_len STRING 81235c4bbdfSmrg# --------------- 81335c4bbdfSmrg# Set func_len_result to the length of STRING. STRING may not 81435c4bbdfSmrg# start with a hyphen. 81535c4bbdfSmrg test -z "$_G_HAVE_XSI_OPS" \ 81635c4bbdfSmrg && (eval 'x=a/b/c; 81735c4bbdfSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81835c4bbdfSmrg && _G_HAVE_XSI_OPS=yes 81935c4bbdfSmrg 82035c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 82135c4bbdfSmrg eval 'func_len () 82235c4bbdfSmrg { 82335c4bbdfSmrg $debug_cmd 82435c4bbdfSmrg 82535c4bbdfSmrg func_len_result=${#1} 82635c4bbdfSmrg }' 82735c4bbdfSmrgelse 82835c4bbdfSmrg func_len () 82935c4bbdfSmrg { 83035c4bbdfSmrg $debug_cmd 83135c4bbdfSmrg 83235c4bbdfSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83335c4bbdfSmrg } 83435c4bbdfSmrgfi 83535c4bbdfSmrg 83635c4bbdfSmrg 83735c4bbdfSmrg# func_mkdir_p DIRECTORY-PATH 83835c4bbdfSmrg# --------------------------- 83935c4bbdfSmrg# Make sure the entire path to DIRECTORY-PATH is available. 84035c4bbdfSmrgfunc_mkdir_p () 84135c4bbdfSmrg{ 84235c4bbdfSmrg $debug_cmd 84335c4bbdfSmrg 84435c4bbdfSmrg _G_directory_path=$1 84535c4bbdfSmrg _G_dir_list= 84635c4bbdfSmrg 84735c4bbdfSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84835c4bbdfSmrg 84935c4bbdfSmrg # Protect directory names starting with '-' 85035c4bbdfSmrg case $_G_directory_path in 85135c4bbdfSmrg -*) _G_directory_path=./$_G_directory_path ;; 85235c4bbdfSmrg esac 85335c4bbdfSmrg 85435c4bbdfSmrg # While some portion of DIR does not yet exist... 85535c4bbdfSmrg while test ! -d "$_G_directory_path"; do 85635c4bbdfSmrg # ...make a list in topmost first order. Use a colon delimited 85735c4bbdfSmrg # list incase some portion of path contains whitespace. 85835c4bbdfSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 85935c4bbdfSmrg 86035c4bbdfSmrg # If the last portion added has no slash in it, the list is done 86135c4bbdfSmrg case $_G_directory_path in */*) ;; *) break ;; esac 86235c4bbdfSmrg 86335c4bbdfSmrg # ...otherwise throw away the child directory and loop 86435c4bbdfSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 86535c4bbdfSmrg done 86635c4bbdfSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 8674642e01fSmrg 86835c4bbdfSmrg func_mkdir_p_IFS=$IFS; IFS=: 86935c4bbdfSmrg for _G_dir in $_G_dir_list; do 87035c4bbdfSmrg IFS=$func_mkdir_p_IFS 87135c4bbdfSmrg # mkdir can fail with a 'File exist' error if two processes 8724642e01fSmrg # try to create one of the directories concurrently. Don't 8734642e01fSmrg # stop in that case! 87435c4bbdfSmrg $MKDIR "$_G_dir" 2>/dev/null || : 8754642e01fSmrg done 87635c4bbdfSmrg IFS=$func_mkdir_p_IFS 8774642e01fSmrg 8784642e01fSmrg # Bail out if we (or some other process) failed to create a directory. 87935c4bbdfSmrg test -d "$_G_directory_path" || \ 88035c4bbdfSmrg func_fatal_error "Failed to create '$1'" 8814642e01fSmrg fi 8824642e01fSmrg} 88305b261ecSmrg 88405b261ecSmrg 88535c4bbdfSmrg# func_mktempdir [BASENAME] 88635c4bbdfSmrg# ------------------------- 88705b261ecSmrg# Make a temporary directory that won't clash with other running 88805b261ecSmrg# libtool processes, and avoids race conditions if possible. If 88935c4bbdfSmrg# given, BASENAME is the basename for that directory. 89005b261ecSmrgfunc_mktempdir () 89105b261ecSmrg{ 89235c4bbdfSmrg $debug_cmd 89305b261ecSmrg 89435c4bbdfSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 89535c4bbdfSmrg 89635c4bbdfSmrg if test : = "$opt_dry_run"; then 89705b261ecSmrg # Return a directory name, but don't create it in dry-run mode 89835c4bbdfSmrg _G_tmpdir=$_G_template-$$ 89905b261ecSmrg else 90005b261ecSmrg 90105b261ecSmrg # If mktemp works, use that first and foremost 90235c4bbdfSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 90305b261ecSmrg 90435c4bbdfSmrg if test ! -d "$_G_tmpdir"; then 9054642e01fSmrg # Failing that, at least try and use $RANDOM to avoid a race 90635c4bbdfSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 90705b261ecSmrg 90835c4bbdfSmrg func_mktempdir_umask=`umask` 9094642e01fSmrg umask 0077 91035c4bbdfSmrg $MKDIR "$_G_tmpdir" 91135c4bbdfSmrg umask $func_mktempdir_umask 91205b261ecSmrg fi 91305b261ecSmrg 91405b261ecSmrg # If we're not in dry-run mode, bomb out on failure 91535c4bbdfSmrg test -d "$_G_tmpdir" || \ 91635c4bbdfSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91705b261ecSmrg fi 91805b261ecSmrg 91935c4bbdfSmrg $ECHO "$_G_tmpdir" 92005b261ecSmrg} 92105b261ecSmrg 92205b261ecSmrg 92335c4bbdfSmrg# func_normal_abspath PATH 92435c4bbdfSmrg# ------------------------ 92535c4bbdfSmrg# Remove doubled-up and trailing slashes, "." path components, 92635c4bbdfSmrg# and cancel out any ".." path components in PATH after making 92735c4bbdfSmrg# it an absolute path. 92835c4bbdfSmrgfunc_normal_abspath () 92905b261ecSmrg{ 93035c4bbdfSmrg $debug_cmd 9314642e01fSmrg 93235c4bbdfSmrg # These SED scripts presuppose an absolute path with a trailing slash. 93335c4bbdfSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93435c4bbdfSmrg _G_pathcdr='s|^/[^/]*||' 93535c4bbdfSmrg _G_removedotparts=':dotsl 93635c4bbdfSmrg s|/\./|/|g 93735c4bbdfSmrg t dotsl 93835c4bbdfSmrg s|/\.$|/|' 93935c4bbdfSmrg _G_collapseslashes='s|/\{1,\}|/|g' 94035c4bbdfSmrg _G_finalslash='s|/*$|/|' 94135c4bbdfSmrg 94235c4bbdfSmrg # Start from root dir and reassemble the path. 94335c4bbdfSmrg func_normal_abspath_result= 94435c4bbdfSmrg func_normal_abspath_tpath=$1 94535c4bbdfSmrg func_normal_abspath_altnamespace= 94635c4bbdfSmrg case $func_normal_abspath_tpath in 94735c4bbdfSmrg "") 94835c4bbdfSmrg # Empty path, that just means $cwd. 94935c4bbdfSmrg func_stripname '' '/' "`pwd`" 95035c4bbdfSmrg func_normal_abspath_result=$func_stripname_result 95135c4bbdfSmrg return 95235c4bbdfSmrg ;; 95335c4bbdfSmrg # The next three entries are used to spot a run of precisely 95435c4bbdfSmrg # two leading slashes without using negated character classes; 95535c4bbdfSmrg # we take advantage of case's first-match behaviour. 95635c4bbdfSmrg ///*) 95735c4bbdfSmrg # Unusual form of absolute path, do nothing. 95835c4bbdfSmrg ;; 95935c4bbdfSmrg //*) 96035c4bbdfSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96135c4bbdfSmrg # and for example Cygwin uses it to access remote file shares 96235c4bbdfSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 96335c4bbdfSmrg func_normal_abspath_altnamespace=/ 96435c4bbdfSmrg ;; 96535c4bbdfSmrg /*) 96635c4bbdfSmrg # Absolute path, do nothing. 9674642e01fSmrg ;; 9684642e01fSmrg *) 96935c4bbdfSmrg # Relative path, prepend $cwd. 97035c4bbdfSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97135c4bbdfSmrg ;; 97205b261ecSmrg esac 97335c4bbdfSmrg 97435c4bbdfSmrg # Cancel out all the simple stuff to save iterations. We also want 97535c4bbdfSmrg # the path to end with a slash for ease of parsing, so make sure 97635c4bbdfSmrg # there is one (and only one) here. 97735c4bbdfSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97835c4bbdfSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97935c4bbdfSmrg while :; do 98035c4bbdfSmrg # Processed it all yet? 98135c4bbdfSmrg if test / = "$func_normal_abspath_tpath"; then 98235c4bbdfSmrg # If we ascended to the root using ".." the result may be empty now. 98335c4bbdfSmrg if test -z "$func_normal_abspath_result"; then 98435c4bbdfSmrg func_normal_abspath_result=/ 98535c4bbdfSmrg fi 98635c4bbdfSmrg break 98735c4bbdfSmrg fi 98835c4bbdfSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98935c4bbdfSmrg -e "$_G_pathcar"` 99035c4bbdfSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99135c4bbdfSmrg -e "$_G_pathcdr"` 99235c4bbdfSmrg # Figure out what to do with it 99335c4bbdfSmrg case $func_normal_abspath_tcomponent in 99435c4bbdfSmrg "") 99535c4bbdfSmrg # Trailing empty path component, ignore it. 99635c4bbdfSmrg ;; 99735c4bbdfSmrg ..) 99835c4bbdfSmrg # Parent dir; strip last assembled component from result. 99935c4bbdfSmrg func_dirname "$func_normal_abspath_result" 100035c4bbdfSmrg func_normal_abspath_result=$func_dirname_result 100135c4bbdfSmrg ;; 100235c4bbdfSmrg *) 100335c4bbdfSmrg # Actual path component, append it. 100435c4bbdfSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100535c4bbdfSmrg ;; 100635c4bbdfSmrg esac 100735c4bbdfSmrg done 100835c4bbdfSmrg # Restore leading double-slash if one was found on entry. 100935c4bbdfSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101035c4bbdfSmrg} 101135c4bbdfSmrg 101235c4bbdfSmrg 101335c4bbdfSmrg# func_notquiet ARG... 101435c4bbdfSmrg# -------------------- 101535c4bbdfSmrg# Echo program name prefixed message only when not in quiet mode. 101635c4bbdfSmrgfunc_notquiet () 101735c4bbdfSmrg{ 101835c4bbdfSmrg $debug_cmd 101935c4bbdfSmrg 102035c4bbdfSmrg $opt_quiet || func_echo ${1+"$@"} 102135c4bbdfSmrg 102235c4bbdfSmrg # A bug in bash halts the script if the last line of a function 102335c4bbdfSmrg # fails when set -e is in force, so we need another command to 102435c4bbdfSmrg # work around that: 102535c4bbdfSmrg : 102635c4bbdfSmrg} 102735c4bbdfSmrg 102835c4bbdfSmrg 102935c4bbdfSmrg# func_relative_path SRCDIR DSTDIR 103035c4bbdfSmrg# -------------------------------- 103135c4bbdfSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103235c4bbdfSmrgfunc_relative_path () 103335c4bbdfSmrg{ 103435c4bbdfSmrg $debug_cmd 103535c4bbdfSmrg 103635c4bbdfSmrg func_relative_path_result= 103735c4bbdfSmrg func_normal_abspath "$1" 103835c4bbdfSmrg func_relative_path_tlibdir=$func_normal_abspath_result 103935c4bbdfSmrg func_normal_abspath "$2" 104035c4bbdfSmrg func_relative_path_tbindir=$func_normal_abspath_result 104135c4bbdfSmrg 104235c4bbdfSmrg # Ascend the tree starting from libdir 104335c4bbdfSmrg while :; do 104435c4bbdfSmrg # check if we have found a prefix of bindir 104535c4bbdfSmrg case $func_relative_path_tbindir in 104635c4bbdfSmrg $func_relative_path_tlibdir) 104735c4bbdfSmrg # found an exact match 104835c4bbdfSmrg func_relative_path_tcancelled= 104935c4bbdfSmrg break 105035c4bbdfSmrg ;; 105135c4bbdfSmrg $func_relative_path_tlibdir*) 105235c4bbdfSmrg # found a matching prefix 105335c4bbdfSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105435c4bbdfSmrg func_relative_path_tcancelled=$func_stripname_result 105535c4bbdfSmrg if test -z "$func_relative_path_result"; then 105635c4bbdfSmrg func_relative_path_result=. 105735c4bbdfSmrg fi 105835c4bbdfSmrg break 105935c4bbdfSmrg ;; 106035c4bbdfSmrg *) 106135c4bbdfSmrg func_dirname $func_relative_path_tlibdir 106235c4bbdfSmrg func_relative_path_tlibdir=$func_dirname_result 106335c4bbdfSmrg if test -z "$func_relative_path_tlibdir"; then 106435c4bbdfSmrg # Have to descend all the way to the root! 106535c4bbdfSmrg func_relative_path_result=../$func_relative_path_result 106635c4bbdfSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 106735c4bbdfSmrg break 106835c4bbdfSmrg fi 106935c4bbdfSmrg func_relative_path_result=../$func_relative_path_result 107035c4bbdfSmrg ;; 107135c4bbdfSmrg esac 107235c4bbdfSmrg done 107335c4bbdfSmrg 107435c4bbdfSmrg # Now calculate path; take care to avoid doubling-up slashes. 107535c4bbdfSmrg func_stripname '' '/' "$func_relative_path_result" 107635c4bbdfSmrg func_relative_path_result=$func_stripname_result 107735c4bbdfSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107835c4bbdfSmrg if test -n "$func_stripname_result"; then 107935c4bbdfSmrg func_append func_relative_path_result "/$func_stripname_result" 108035c4bbdfSmrg fi 108135c4bbdfSmrg 108235c4bbdfSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 108335c4bbdfSmrg if test -n "$func_relative_path_result"; then 108435c4bbdfSmrg func_stripname './' '' "$func_relative_path_result" 108535c4bbdfSmrg func_relative_path_result=$func_stripname_result 108635c4bbdfSmrg fi 108735c4bbdfSmrg 108835c4bbdfSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 108935c4bbdfSmrg 109035c4bbdfSmrg : 109135c4bbdfSmrg} 109235c4bbdfSmrg 109335c4bbdfSmrg 109435c4bbdfSmrg# func_quote_for_eval ARG... 109535c4bbdfSmrg# -------------------------- 109635c4bbdfSmrg# Aesthetically quote ARGs to be evaled later. 109735c4bbdfSmrg# This function returns two values: 109835c4bbdfSmrg# i) func_quote_for_eval_result 109935c4bbdfSmrg# double-quoted, suitable for a subsequent eval 110035c4bbdfSmrg# ii) func_quote_for_eval_unquoted_result 110135c4bbdfSmrg# has all characters that are still active within double 110235c4bbdfSmrg# quotes backslashified. 110335c4bbdfSmrgfunc_quote_for_eval () 110435c4bbdfSmrg{ 110535c4bbdfSmrg $debug_cmd 110635c4bbdfSmrg 110735c4bbdfSmrg func_quote_for_eval_unquoted_result= 110835c4bbdfSmrg func_quote_for_eval_result= 110935c4bbdfSmrg while test 0 -lt $#; do 111035c4bbdfSmrg case $1 in 111135c4bbdfSmrg *[\\\`\"\$]*) 111235c4bbdfSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111335c4bbdfSmrg *) 111435c4bbdfSmrg _G_unquoted_arg=$1 ;; 111535c4bbdfSmrg esac 111635c4bbdfSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 111735c4bbdfSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111835c4bbdfSmrg else 111935c4bbdfSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112035c4bbdfSmrg fi 112135c4bbdfSmrg 112235c4bbdfSmrg case $_G_unquoted_arg in 112335c4bbdfSmrg # Double-quote args containing shell metacharacters to delay 112435c4bbdfSmrg # word splitting, command substitution and variable expansion 112535c4bbdfSmrg # for a subsequent eval. 112635c4bbdfSmrg # Many Bourne shells cannot handle close brackets correctly 112735c4bbdfSmrg # in scan sets, so we specify it separately. 112835c4bbdfSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112935c4bbdfSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 113035c4bbdfSmrg ;; 113135c4bbdfSmrg *) 113235c4bbdfSmrg _G_quoted_arg=$_G_unquoted_arg 113335c4bbdfSmrg ;; 113435c4bbdfSmrg esac 113535c4bbdfSmrg 113635c4bbdfSmrg if test -n "$func_quote_for_eval_result"; then 113735c4bbdfSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113835c4bbdfSmrg else 113935c4bbdfSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114035c4bbdfSmrg fi 114135c4bbdfSmrg shift 114235c4bbdfSmrg done 114305b261ecSmrg} 114405b261ecSmrg 114505b261ecSmrg 114635c4bbdfSmrg# func_quote_for_expand ARG 114735c4bbdfSmrg# ------------------------- 11484642e01fSmrg# Aesthetically quote ARG to be evaled later; same as above, 11494642e01fSmrg# but do not quote variable references. 11504642e01fSmrgfunc_quote_for_expand () 115105b261ecSmrg{ 115235c4bbdfSmrg $debug_cmd 115335c4bbdfSmrg 11544642e01fSmrg case $1 in 11554642e01fSmrg *[\\\`\"]*) 115635c4bbdfSmrg _G_arg=`$ECHO "$1" | $SED \ 115735c4bbdfSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115805b261ecSmrg *) 115935c4bbdfSmrg _G_arg=$1 ;; 11604642e01fSmrg esac 11614642e01fSmrg 116235c4bbdfSmrg case $_G_arg in 11634642e01fSmrg # Double-quote args containing shell metacharacters to delay 11644642e01fSmrg # word splitting and command substitution for a subsequent eval. 11654642e01fSmrg # Many Bourne shells cannot handle close brackets correctly 11664642e01fSmrg # in scan sets, so we specify it separately. 11674642e01fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116835c4bbdfSmrg _G_arg=\"$_G_arg\" 11694642e01fSmrg ;; 11704642e01fSmrg esac 11714642e01fSmrg 117235c4bbdfSmrg func_quote_for_expand_result=$_G_arg 117305b261ecSmrg} 117405b261ecSmrg 117505b261ecSmrg 117635c4bbdfSmrg# func_stripname PREFIX SUFFIX NAME 117735c4bbdfSmrg# --------------------------------- 117835c4bbdfSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117935c4bbdfSmrg# PREFIX and SUFFIX must not contain globbing or regex special 118035c4bbdfSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118135c4bbdfSmrg# dot (in which case that matches only a dot). 118235c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 118335c4bbdfSmrg eval 'func_stripname () 118435c4bbdfSmrg { 118535c4bbdfSmrg $debug_cmd 118635c4bbdfSmrg 118735c4bbdfSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118835c4bbdfSmrg # positional parameters, so assign one to ordinary variable first. 118935c4bbdfSmrg func_stripname_result=$3 119035c4bbdfSmrg func_stripname_result=${func_stripname_result#"$1"} 119135c4bbdfSmrg func_stripname_result=${func_stripname_result%"$2"} 119235c4bbdfSmrg }' 119335c4bbdfSmrgelse 119435c4bbdfSmrg func_stripname () 119535c4bbdfSmrg { 119635c4bbdfSmrg $debug_cmd 119735c4bbdfSmrg 119835c4bbdfSmrg case $2 in 119935c4bbdfSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120035c4bbdfSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120135c4bbdfSmrg esac 120235c4bbdfSmrg } 120335c4bbdfSmrgfi 120435c4bbdfSmrg 120535c4bbdfSmrg 120635c4bbdfSmrg# func_show_eval CMD [FAIL_EXP] 120735c4bbdfSmrg# ----------------------------- 120835c4bbdfSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 12094642e01fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 12104642e01fSmrg# is given, then evaluate it. 12114642e01fSmrgfunc_show_eval () 121205b261ecSmrg{ 121335c4bbdfSmrg $debug_cmd 121405b261ecSmrg 121535c4bbdfSmrg _G_cmd=$1 121635c4bbdfSmrg _G_fail_exp=${2-':'} 12174642e01fSmrg 121835c4bbdfSmrg func_quote_for_expand "$_G_cmd" 121935c4bbdfSmrg eval "func_notquiet $func_quote_for_expand_result" 122035c4bbdfSmrg 122135c4bbdfSmrg $opt_dry_run || { 122235c4bbdfSmrg eval "$_G_cmd" 122335c4bbdfSmrg _G_status=$? 122435c4bbdfSmrg if test 0 -ne "$_G_status"; then 122535c4bbdfSmrg eval "(exit $_G_status); $_G_fail_exp" 12264642e01fSmrg fi 122735c4bbdfSmrg } 122805b261ecSmrg} 122905b261ecSmrg 12304642e01fSmrg 123135c4bbdfSmrg# func_show_eval_locale CMD [FAIL_EXP] 123235c4bbdfSmrg# ------------------------------------ 123335c4bbdfSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 12344642e01fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 12354642e01fSmrg# is given, then evaluate it. Use the saved locale for evaluation. 12364642e01fSmrgfunc_show_eval_locale () 123705b261ecSmrg{ 123835c4bbdfSmrg $debug_cmd 12394642e01fSmrg 124035c4bbdfSmrg _G_cmd=$1 124135c4bbdfSmrg _G_fail_exp=${2-':'} 124235c4bbdfSmrg 124335c4bbdfSmrg $opt_quiet || { 124435c4bbdfSmrg func_quote_for_expand "$_G_cmd" 12454642e01fSmrg eval "func_echo $func_quote_for_expand_result" 12464642e01fSmrg } 12474642e01fSmrg 124835c4bbdfSmrg $opt_dry_run || { 124935c4bbdfSmrg eval "$_G_user_locale 125035c4bbdfSmrg $_G_cmd" 125135c4bbdfSmrg _G_status=$? 125235c4bbdfSmrg eval "$_G_safe_locale" 125335c4bbdfSmrg if test 0 -ne "$_G_status"; then 125435c4bbdfSmrg eval "(exit $_G_status); $_G_fail_exp" 12554642e01fSmrg fi 125635c4bbdfSmrg } 12574642e01fSmrg} 125805b261ecSmrg 12594642e01fSmrg 126035c4bbdfSmrg# func_tr_sh 126135c4bbdfSmrg# ---------- 126235c4bbdfSmrg# Turn $1 into a string suitable for a shell variable name. 126335c4bbdfSmrg# Result is stored in $func_tr_sh_result. All characters 126435c4bbdfSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126535c4bbdfSmrg# if $1 begins with a digit, a '_' is prepended as well. 126635c4bbdfSmrgfunc_tr_sh () 12674642e01fSmrg{ 126835c4bbdfSmrg $debug_cmd 12694642e01fSmrg 127035c4bbdfSmrg case $1 in 127135c4bbdfSmrg [0-9]* | *[!a-zA-Z0-9_]*) 127235c4bbdfSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127335c4bbdfSmrg ;; 127435c4bbdfSmrg * ) 127535c4bbdfSmrg func_tr_sh_result=$1 127635c4bbdfSmrg ;; 127735c4bbdfSmrg esac 12784642e01fSmrg} 12794642e01fSmrg 12804642e01fSmrg 128135c4bbdfSmrg# func_verbose ARG... 128235c4bbdfSmrg# ------------------- 128335c4bbdfSmrg# Echo program name prefixed message in verbose mode only. 128435c4bbdfSmrgfunc_verbose () 12854642e01fSmrg{ 128635c4bbdfSmrg $debug_cmd 128705b261ecSmrg 128835c4bbdfSmrg $opt_verbose && func_echo "$*" 12896747b715Smrg 129035c4bbdfSmrg : 129135c4bbdfSmrg} 12924642e01fSmrg 12934642e01fSmrg 129435c4bbdfSmrg# func_warn_and_continue ARG... 129535c4bbdfSmrg# ----------------------------- 129635c4bbdfSmrg# Echo program name prefixed warning message to standard error. 129735c4bbdfSmrgfunc_warn_and_continue () 129835c4bbdfSmrg{ 129935c4bbdfSmrg $debug_cmd 130005b261ecSmrg 130135c4bbdfSmrg $require_term_colors 130205b261ecSmrg 130335c4bbdfSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130435c4bbdfSmrg} 1305475c125cSmrg 130635c4bbdfSmrg 130735c4bbdfSmrg# func_warning CATEGORY ARG... 130835c4bbdfSmrg# ---------------------------- 130935c4bbdfSmrg# Echo program name prefixed warning message to standard error. Warning 131035c4bbdfSmrg# messages can be filtered according to CATEGORY, where this function 131135c4bbdfSmrg# elides messages where CATEGORY is not listed in the global variable 131235c4bbdfSmrg# 'opt_warning_types'. 131335c4bbdfSmrgfunc_warning () 131435c4bbdfSmrg{ 131535c4bbdfSmrg $debug_cmd 131635c4bbdfSmrg 131735c4bbdfSmrg # CATEGORY must be in the warning_categories list! 131835c4bbdfSmrg case " $warning_categories " in 131935c4bbdfSmrg *" $1 "*) ;; 132035c4bbdfSmrg *) func_internal_error "invalid warning category '$1'" ;; 132135c4bbdfSmrg esac 132235c4bbdfSmrg 132335c4bbdfSmrg _G_category=$1 132435c4bbdfSmrg shift 132535c4bbdfSmrg 132635c4bbdfSmrg case " $opt_warning_types " in 132735c4bbdfSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132835c4bbdfSmrg esac 132935c4bbdfSmrg} 133035c4bbdfSmrg 133135c4bbdfSmrg 133235c4bbdfSmrg# func_sort_ver VER1 VER2 133335c4bbdfSmrg# ----------------------- 133435c4bbdfSmrg# 'sort -V' is not generally available. 133535c4bbdfSmrg# Note this deviates from the version comparison in automake 133635c4bbdfSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133735c4bbdfSmrg# but this should suffice as we won't be specifying old 133835c4bbdfSmrg# version formats or redundant trailing .0 in bootstrap.conf. 133935c4bbdfSmrg# If we did want full compatibility then we should probably 134035c4bbdfSmrg# use m4_version_compare from autoconf. 134135c4bbdfSmrgfunc_sort_ver () 134235c4bbdfSmrg{ 134335c4bbdfSmrg $debug_cmd 134435c4bbdfSmrg 134535c4bbdfSmrg printf '%s\n%s\n' "$1" "$2" \ 134635c4bbdfSmrg | 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 134735c4bbdfSmrg} 134835c4bbdfSmrg 134935c4bbdfSmrg# func_lt_ver PREV CURR 135035c4bbdfSmrg# --------------------- 135135c4bbdfSmrg# Return true if PREV and CURR are in the correct order according to 135235c4bbdfSmrg# func_sort_ver, otherwise false. Use it like this: 135335c4bbdfSmrg# 135435c4bbdfSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135535c4bbdfSmrgfunc_lt_ver () 135635c4bbdfSmrg{ 135735c4bbdfSmrg $debug_cmd 135835c4bbdfSmrg 135935c4bbdfSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136035c4bbdfSmrg} 136135c4bbdfSmrg 136235c4bbdfSmrg 136335c4bbdfSmrg# Local variables: 136435c4bbdfSmrg# mode: shell-script 136535c4bbdfSmrg# sh-indentation: 2 136635c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 136735c4bbdfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136835c4bbdfSmrg# time-stamp-time-zone: "UTC" 136935c4bbdfSmrg# End: 137035c4bbdfSmrg#! /bin/sh 137135c4bbdfSmrg 137235c4bbdfSmrg# Set a version string for this script. 137335c4bbdfSmrgscriptversion=2014-01-07.03; # UTC 137435c4bbdfSmrg 137535c4bbdfSmrg# A portable, pluggable option parser for Bourne shell. 137635c4bbdfSmrg# Written by Gary V. Vaughan, 2010 137735c4bbdfSmrg 137835c4bbdfSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137935c4bbdfSmrg# This is free software; see the source for copying conditions. There is NO 138035c4bbdfSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138135c4bbdfSmrg 138235c4bbdfSmrg# This program is free software: you can redistribute it and/or modify 138335c4bbdfSmrg# it under the terms of the GNU General Public License as published by 138435c4bbdfSmrg# the Free Software Foundation, either version 3 of the License, or 138535c4bbdfSmrg# (at your option) any later version. 138635c4bbdfSmrg 138735c4bbdfSmrg# This program is distributed in the hope that it will be useful, 138835c4bbdfSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138935c4bbdfSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139035c4bbdfSmrg# GNU General Public License for more details. 139135c4bbdfSmrg 139235c4bbdfSmrg# You should have received a copy of the GNU General Public License 139335c4bbdfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139435c4bbdfSmrg 139535c4bbdfSmrg# Please report bugs or propose patches to gary@gnu.org. 139635c4bbdfSmrg 139735c4bbdfSmrg 139835c4bbdfSmrg## ------ ## 139935c4bbdfSmrg## Usage. ## 140035c4bbdfSmrg## ------ ## 140135c4bbdfSmrg 140235c4bbdfSmrg# This file is a library for parsing options in your shell scripts along 140335c4bbdfSmrg# with assorted other useful supporting features that you can make use 140435c4bbdfSmrg# of too. 140535c4bbdfSmrg# 140635c4bbdfSmrg# For the simplest scripts you might need only: 140735c4bbdfSmrg# 140835c4bbdfSmrg# #!/bin/sh 140935c4bbdfSmrg# . relative/path/to/funclib.sh 141035c4bbdfSmrg# . relative/path/to/options-parser 141135c4bbdfSmrg# scriptversion=1.0 141235c4bbdfSmrg# func_options ${1+"$@"} 141335c4bbdfSmrg# eval set dummy "$func_options_result"; shift 141435c4bbdfSmrg# ...rest of your script... 141535c4bbdfSmrg# 141635c4bbdfSmrg# In order for the '--version' option to work, you will need to have a 141735c4bbdfSmrg# suitably formatted comment like the one at the top of this file 141835c4bbdfSmrg# starting with '# Written by ' and ending with '# warranty; '. 141935c4bbdfSmrg# 142035c4bbdfSmrg# For '-h' and '--help' to work, you will also need a one line 142135c4bbdfSmrg# description of your script's purpose in a comment directly above the 142235c4bbdfSmrg# '# Written by ' line, like the one at the top of this file. 142335c4bbdfSmrg# 142435c4bbdfSmrg# The default options also support '--debug', which will turn on shell 142535c4bbdfSmrg# execution tracing (see the comment above debug_cmd below for another 142635c4bbdfSmrg# use), and '--verbose' and the func_verbose function to allow your script 142735c4bbdfSmrg# to display verbose messages only when your user has specified 142835c4bbdfSmrg# '--verbose'. 142935c4bbdfSmrg# 143035c4bbdfSmrg# After sourcing this file, you can plug processing for additional 143135c4bbdfSmrg# options by amending the variables from the 'Configuration' section 143235c4bbdfSmrg# below, and following the instructions in the 'Option parsing' 143335c4bbdfSmrg# section further down. 143435c4bbdfSmrg 143535c4bbdfSmrg## -------------- ## 143635c4bbdfSmrg## Configuration. ## 143735c4bbdfSmrg## -------------- ## 143835c4bbdfSmrg 143935c4bbdfSmrg# You should override these variables in your script after sourcing this 144035c4bbdfSmrg# file so that they reflect the customisations you have added to the 144135c4bbdfSmrg# option parser. 144235c4bbdfSmrg 144335c4bbdfSmrg# The usage line for option parsing errors and the start of '-h' and 144435c4bbdfSmrg# '--help' output messages. You can embed shell variables for delayed 144535c4bbdfSmrg# expansion at the time the message is displayed, but you will need to 144635c4bbdfSmrg# quote other shell meta-characters carefully to prevent them being 144735c4bbdfSmrg# expanded when the contents are evaled. 144835c4bbdfSmrgusage='$progpath [OPTION]...' 144935c4bbdfSmrg 145035c4bbdfSmrg# Short help message in response to '-h' and '--help'. Add to this or 145135c4bbdfSmrg# override it after sourcing this library to reflect the full set of 145235c4bbdfSmrg# options your script accepts. 145335c4bbdfSmrgusage_message="\ 145435c4bbdfSmrg --debug enable verbose shell tracing 145535c4bbdfSmrg -W, --warnings=CATEGORY 145635c4bbdfSmrg report the warnings falling in CATEGORY [all] 145735c4bbdfSmrg -v, --verbose verbosely report processing 145835c4bbdfSmrg --version print version information and exit 145935c4bbdfSmrg -h, --help print short or long help message and exit 146035c4bbdfSmrg" 146135c4bbdfSmrg 146235c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'. 146335c4bbdfSmrglong_help_message=" 146435c4bbdfSmrgWarning categories include: 146535c4bbdfSmrg 'all' show all warnings 146635c4bbdfSmrg 'none' turn off all the warnings 146735c4bbdfSmrg 'error' warnings are treated as fatal errors" 146835c4bbdfSmrg 146935c4bbdfSmrg# Help message printed before fatal option parsing errors. 147035c4bbdfSmrgfatal_help="Try '\$progname --help' for more information." 147135c4bbdfSmrg 147235c4bbdfSmrg 147335c4bbdfSmrg 147435c4bbdfSmrg## ------------------------- ## 147535c4bbdfSmrg## Hook function management. ## 147635c4bbdfSmrg## ------------------------- ## 147735c4bbdfSmrg 147835c4bbdfSmrg# This section contains functions for adding, removing, and running hooks 147935c4bbdfSmrg# to the main code. A hook is just a named list of of function, that can 148035c4bbdfSmrg# be run in order later on. 148135c4bbdfSmrg 148235c4bbdfSmrg# func_hookable FUNC_NAME 148335c4bbdfSmrg# ----------------------- 148435c4bbdfSmrg# Declare that FUNC_NAME will run hooks added with 148535c4bbdfSmrg# 'func_add_hook FUNC_NAME ...'. 148635c4bbdfSmrgfunc_hookable () 148735c4bbdfSmrg{ 148835c4bbdfSmrg $debug_cmd 148935c4bbdfSmrg 149035c4bbdfSmrg func_append hookable_fns " $1" 149135c4bbdfSmrg} 149235c4bbdfSmrg 149335c4bbdfSmrg 149435c4bbdfSmrg# func_add_hook FUNC_NAME HOOK_FUNC 149535c4bbdfSmrg# --------------------------------- 149635c4bbdfSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149735c4bbdfSmrg# first have been declared "hookable" by a call to 'func_hookable'. 149835c4bbdfSmrgfunc_add_hook () 149935c4bbdfSmrg{ 150035c4bbdfSmrg $debug_cmd 150135c4bbdfSmrg 150235c4bbdfSmrg case " $hookable_fns " in 150335c4bbdfSmrg *" $1 "*) ;; 150435c4bbdfSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150535c4bbdfSmrg esac 150635c4bbdfSmrg 150735c4bbdfSmrg eval func_append ${1}_hooks '" $2"' 150835c4bbdfSmrg} 150935c4bbdfSmrg 151035c4bbdfSmrg 151135c4bbdfSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 151235c4bbdfSmrg# ------------------------------------ 151335c4bbdfSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151435c4bbdfSmrgfunc_remove_hook () 151535c4bbdfSmrg{ 151635c4bbdfSmrg $debug_cmd 151735c4bbdfSmrg 151835c4bbdfSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151935c4bbdfSmrg} 152035c4bbdfSmrg 152135c4bbdfSmrg 152235c4bbdfSmrg# func_run_hooks FUNC_NAME [ARG]... 152335c4bbdfSmrg# --------------------------------- 152435c4bbdfSmrg# Run all hook functions registered to FUNC_NAME. 152535c4bbdfSmrg# It is assumed that the list of hook functions contains nothing more 152635c4bbdfSmrg# than a whitespace-delimited list of legal shell function names, and 152735c4bbdfSmrg# no effort is wasted trying to catch shell meta-characters or preserve 152835c4bbdfSmrg# whitespace. 152935c4bbdfSmrgfunc_run_hooks () 153035c4bbdfSmrg{ 153135c4bbdfSmrg $debug_cmd 153235c4bbdfSmrg 153335c4bbdfSmrg case " $hookable_fns " in 153435c4bbdfSmrg *" $1 "*) ;; 153535c4bbdfSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153635c4bbdfSmrg esac 153735c4bbdfSmrg 153835c4bbdfSmrg eval _G_hook_fns=\$$1_hooks; shift 153935c4bbdfSmrg 154035c4bbdfSmrg for _G_hook in $_G_hook_fns; do 154135c4bbdfSmrg eval $_G_hook '"$@"' 154235c4bbdfSmrg 154335c4bbdfSmrg # store returned options list back into positional 154435c4bbdfSmrg # parameters for next 'cmd' execution. 154535c4bbdfSmrg eval _G_hook_result=\$${_G_hook}_result 154635c4bbdfSmrg eval set dummy "$_G_hook_result"; shift 154735c4bbdfSmrg done 154835c4bbdfSmrg 154935c4bbdfSmrg func_quote_for_eval ${1+"$@"} 155035c4bbdfSmrg func_run_hooks_result=$func_quote_for_eval_result 155135c4bbdfSmrg} 155235c4bbdfSmrg 155335c4bbdfSmrg 155435c4bbdfSmrg 155535c4bbdfSmrg## --------------- ## 155635c4bbdfSmrg## Option parsing. ## 155735c4bbdfSmrg## --------------- ## 155835c4bbdfSmrg 155935c4bbdfSmrg# In order to add your own option parsing hooks, you must accept the 156035c4bbdfSmrg# full positional parameter list in your hook function, remove any 156135c4bbdfSmrg# options that you action, and then pass back the remaining unprocessed 156235c4bbdfSmrg# options in '<hooked_function_name>_result', escaped suitably for 156335c4bbdfSmrg# 'eval'. Like this: 156435c4bbdfSmrg# 156535c4bbdfSmrg# my_options_prep () 156635c4bbdfSmrg# { 156735c4bbdfSmrg# $debug_cmd 156835c4bbdfSmrg# 156935c4bbdfSmrg# # Extend the existing usage message. 157035c4bbdfSmrg# usage_message=$usage_message' 157135c4bbdfSmrg# -s, --silent don'\''t print informational messages 157235c4bbdfSmrg# ' 157335c4bbdfSmrg# 157435c4bbdfSmrg# func_quote_for_eval ${1+"$@"} 157535c4bbdfSmrg# my_options_prep_result=$func_quote_for_eval_result 157635c4bbdfSmrg# } 157735c4bbdfSmrg# func_add_hook func_options_prep my_options_prep 157835c4bbdfSmrg# 157935c4bbdfSmrg# 158035c4bbdfSmrg# my_silent_option () 158135c4bbdfSmrg# { 158235c4bbdfSmrg# $debug_cmd 158335c4bbdfSmrg# 158435c4bbdfSmrg# # Note that for efficiency, we parse as many options as we can 158535c4bbdfSmrg# # recognise in a loop before passing the remainder back to the 158635c4bbdfSmrg# # caller on the first unrecognised argument we encounter. 158735c4bbdfSmrg# while test $# -gt 0; do 158835c4bbdfSmrg# opt=$1; shift 158935c4bbdfSmrg# case $opt in 159035c4bbdfSmrg# --silent|-s) opt_silent=: ;; 159135c4bbdfSmrg# # Separate non-argument short options: 159235c4bbdfSmrg# -s*) func_split_short_opt "$_G_opt" 159335c4bbdfSmrg# set dummy "$func_split_short_opt_name" \ 159435c4bbdfSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 159535c4bbdfSmrg# shift 159635c4bbdfSmrg# ;; 159735c4bbdfSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159835c4bbdfSmrg# esac 159935c4bbdfSmrg# done 160035c4bbdfSmrg# 160135c4bbdfSmrg# func_quote_for_eval ${1+"$@"} 160235c4bbdfSmrg# my_silent_option_result=$func_quote_for_eval_result 160335c4bbdfSmrg# } 160435c4bbdfSmrg# func_add_hook func_parse_options my_silent_option 160535c4bbdfSmrg# 160635c4bbdfSmrg# 160735c4bbdfSmrg# my_option_validation () 160835c4bbdfSmrg# { 160935c4bbdfSmrg# $debug_cmd 161035c4bbdfSmrg# 161135c4bbdfSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161235c4bbdfSmrg# '--silent' and '--verbose' options are mutually exclusive." 161335c4bbdfSmrg# 161435c4bbdfSmrg# func_quote_for_eval ${1+"$@"} 161535c4bbdfSmrg# my_option_validation_result=$func_quote_for_eval_result 161635c4bbdfSmrg# } 161735c4bbdfSmrg# func_add_hook func_validate_options my_option_validation 161835c4bbdfSmrg# 161935c4bbdfSmrg# You'll alse need to manually amend $usage_message to reflect the extra 162035c4bbdfSmrg# options you parse. It's preferable to append if you can, so that 162135c4bbdfSmrg# multiple option parsing hooks can be added safely. 162235c4bbdfSmrg 162335c4bbdfSmrg 162435c4bbdfSmrg# func_options [ARG]... 162535c4bbdfSmrg# --------------------- 162635c4bbdfSmrg# All the functions called inside func_options are hookable. See the 162735c4bbdfSmrg# individual implementations for details. 162835c4bbdfSmrgfunc_hookable func_options 162935c4bbdfSmrgfunc_options () 163035c4bbdfSmrg{ 163135c4bbdfSmrg $debug_cmd 163235c4bbdfSmrg 163335c4bbdfSmrg func_options_prep ${1+"$@"} 163435c4bbdfSmrg eval func_parse_options \ 163535c4bbdfSmrg ${func_options_prep_result+"$func_options_prep_result"} 163635c4bbdfSmrg eval func_validate_options \ 163735c4bbdfSmrg ${func_parse_options_result+"$func_parse_options_result"} 163835c4bbdfSmrg 163935c4bbdfSmrg eval func_run_hooks func_options \ 164035c4bbdfSmrg ${func_validate_options_result+"$func_validate_options_result"} 164135c4bbdfSmrg 164235c4bbdfSmrg # save modified positional parameters for caller 164335c4bbdfSmrg func_options_result=$func_run_hooks_result 164435c4bbdfSmrg} 164535c4bbdfSmrg 164635c4bbdfSmrg 164735c4bbdfSmrg# func_options_prep [ARG]... 164835c4bbdfSmrg# -------------------------- 164935c4bbdfSmrg# All initialisations required before starting the option parse loop. 165035c4bbdfSmrg# Note that when calling hook functions, we pass through the list of 165135c4bbdfSmrg# positional parameters. If a hook function modifies that list, and 165235c4bbdfSmrg# needs to propogate that back to rest of this script, then the complete 165335c4bbdfSmrg# modified list must be put in 'func_run_hooks_result' before 165435c4bbdfSmrg# returning. 165535c4bbdfSmrgfunc_hookable func_options_prep 165635c4bbdfSmrgfunc_options_prep () 165735c4bbdfSmrg{ 165835c4bbdfSmrg $debug_cmd 165935c4bbdfSmrg 166035c4bbdfSmrg # Option defaults: 166135c4bbdfSmrg opt_verbose=false 166235c4bbdfSmrg opt_warning_types= 166335c4bbdfSmrg 166435c4bbdfSmrg func_run_hooks func_options_prep ${1+"$@"} 166535c4bbdfSmrg 166635c4bbdfSmrg # save modified positional parameters for caller 166735c4bbdfSmrg func_options_prep_result=$func_run_hooks_result 166835c4bbdfSmrg} 166935c4bbdfSmrg 167035c4bbdfSmrg 167135c4bbdfSmrg# func_parse_options [ARG]... 167235c4bbdfSmrg# --------------------------- 167335c4bbdfSmrg# The main option parsing loop. 167435c4bbdfSmrgfunc_hookable func_parse_options 167535c4bbdfSmrgfunc_parse_options () 167635c4bbdfSmrg{ 167735c4bbdfSmrg $debug_cmd 167835c4bbdfSmrg 167935c4bbdfSmrg func_parse_options_result= 168035c4bbdfSmrg 168135c4bbdfSmrg # this just eases exit handling 168235c4bbdfSmrg while test $# -gt 0; do 168335c4bbdfSmrg # Defer to hook functions for initial option parsing, so they 168435c4bbdfSmrg # get priority in the event of reusing an option name. 168535c4bbdfSmrg func_run_hooks func_parse_options ${1+"$@"} 168635c4bbdfSmrg 168735c4bbdfSmrg # Adjust func_parse_options positional parameters to match 168835c4bbdfSmrg eval set dummy "$func_run_hooks_result"; shift 168935c4bbdfSmrg 169035c4bbdfSmrg # Break out of the loop if we already parsed every option. 169135c4bbdfSmrg test $# -gt 0 || break 169235c4bbdfSmrg 169335c4bbdfSmrg _G_opt=$1 169435c4bbdfSmrg shift 169535c4bbdfSmrg case $_G_opt in 169635c4bbdfSmrg --debug|-x) debug_cmd='set -x' 169735c4bbdfSmrg func_echo "enabling shell trace mode" 169835c4bbdfSmrg $debug_cmd 169935c4bbdfSmrg ;; 170035c4bbdfSmrg 170135c4bbdfSmrg --no-warnings|--no-warning|--no-warn) 170235c4bbdfSmrg set dummy --warnings none ${1+"$@"} 170335c4bbdfSmrg shift 170435c4bbdfSmrg ;; 170535c4bbdfSmrg 170635c4bbdfSmrg --warnings|--warning|-W) 170735c4bbdfSmrg test $# = 0 && func_missing_arg $_G_opt && break 170835c4bbdfSmrg case " $warning_categories $1" in 170935c4bbdfSmrg *" $1 "*) 171035c4bbdfSmrg # trailing space prevents matching last $1 above 171135c4bbdfSmrg func_append_uniq opt_warning_types " $1" 171235c4bbdfSmrg ;; 171335c4bbdfSmrg *all) 171435c4bbdfSmrg opt_warning_types=$warning_categories 171535c4bbdfSmrg ;; 171635c4bbdfSmrg *none) 171735c4bbdfSmrg opt_warning_types=none 171835c4bbdfSmrg warning_func=: 171935c4bbdfSmrg ;; 172035c4bbdfSmrg *error) 172135c4bbdfSmrg opt_warning_types=$warning_categories 172235c4bbdfSmrg warning_func=func_fatal_error 172335c4bbdfSmrg ;; 172435c4bbdfSmrg *) 172535c4bbdfSmrg func_fatal_error \ 172635c4bbdfSmrg "unsupported warning category: '$1'" 172735c4bbdfSmrg ;; 172835c4bbdfSmrg esac 172935c4bbdfSmrg shift 173035c4bbdfSmrg ;; 173135c4bbdfSmrg 173235c4bbdfSmrg --verbose|-v) opt_verbose=: ;; 173335c4bbdfSmrg --version) func_version ;; 173435c4bbdfSmrg -\?|-h) func_usage ;; 173535c4bbdfSmrg --help) func_help ;; 173635c4bbdfSmrg 173735c4bbdfSmrg # Separate optargs to long options (plugins may need this): 173835c4bbdfSmrg --*=*) func_split_equals "$_G_opt" 173935c4bbdfSmrg set dummy "$func_split_equals_lhs" \ 174035c4bbdfSmrg "$func_split_equals_rhs" ${1+"$@"} 174135c4bbdfSmrg shift 174235c4bbdfSmrg ;; 174335c4bbdfSmrg 174435c4bbdfSmrg # Separate optargs to short options: 174535c4bbdfSmrg -W*) 174635c4bbdfSmrg func_split_short_opt "$_G_opt" 174735c4bbdfSmrg set dummy "$func_split_short_opt_name" \ 174835c4bbdfSmrg "$func_split_short_opt_arg" ${1+"$@"} 174935c4bbdfSmrg shift 175035c4bbdfSmrg ;; 175135c4bbdfSmrg 175235c4bbdfSmrg # Separate non-argument short options: 175335c4bbdfSmrg -\?*|-h*|-v*|-x*) 175435c4bbdfSmrg func_split_short_opt "$_G_opt" 175535c4bbdfSmrg set dummy "$func_split_short_opt_name" \ 175635c4bbdfSmrg "-$func_split_short_opt_arg" ${1+"$@"} 175735c4bbdfSmrg shift 175835c4bbdfSmrg ;; 175935c4bbdfSmrg 176035c4bbdfSmrg --) break ;; 176135c4bbdfSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176235c4bbdfSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176335c4bbdfSmrg esac 176435c4bbdfSmrg done 176535c4bbdfSmrg 176635c4bbdfSmrg # save modified positional parameters for caller 176735c4bbdfSmrg func_quote_for_eval ${1+"$@"} 176835c4bbdfSmrg func_parse_options_result=$func_quote_for_eval_result 176935c4bbdfSmrg} 177035c4bbdfSmrg 177135c4bbdfSmrg 177235c4bbdfSmrg# func_validate_options [ARG]... 177335c4bbdfSmrg# ------------------------------ 177435c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed 177535c4bbdfSmrg# arguments. 177635c4bbdfSmrgfunc_hookable func_validate_options 177735c4bbdfSmrgfunc_validate_options () 177835c4bbdfSmrg{ 177935c4bbdfSmrg $debug_cmd 178035c4bbdfSmrg 178135c4bbdfSmrg # Display all warnings if -W was not given. 178235c4bbdfSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 178335c4bbdfSmrg 178435c4bbdfSmrg func_run_hooks func_validate_options ${1+"$@"} 178535c4bbdfSmrg 178635c4bbdfSmrg # Bail if the options were screwed! 178735c4bbdfSmrg $exit_cmd $EXIT_FAILURE 178835c4bbdfSmrg 178935c4bbdfSmrg # save modified positional parameters for caller 179035c4bbdfSmrg func_validate_options_result=$func_run_hooks_result 179135c4bbdfSmrg} 179235c4bbdfSmrg 179335c4bbdfSmrg 179435c4bbdfSmrg 179535c4bbdfSmrg## ----------------- ## 179635c4bbdfSmrg## Helper functions. ## 179735c4bbdfSmrg## ----------------- ## 179835c4bbdfSmrg 179935c4bbdfSmrg# This section contains the helper functions used by the rest of the 180035c4bbdfSmrg# hookable option parser framework in ascii-betical order. 180135c4bbdfSmrg 180235c4bbdfSmrg 180335c4bbdfSmrg# func_fatal_help ARG... 180435c4bbdfSmrg# ---------------------- 180535c4bbdfSmrg# Echo program name prefixed message to standard error, followed by 180635c4bbdfSmrg# a help hint, and exit. 180735c4bbdfSmrgfunc_fatal_help () 180835c4bbdfSmrg{ 180935c4bbdfSmrg $debug_cmd 181035c4bbdfSmrg 181135c4bbdfSmrg eval \$ECHO \""Usage: $usage"\" 181235c4bbdfSmrg eval \$ECHO \""$fatal_help"\" 181335c4bbdfSmrg func_error ${1+"$@"} 181435c4bbdfSmrg exit $EXIT_FAILURE 181535c4bbdfSmrg} 181635c4bbdfSmrg 181735c4bbdfSmrg 181835c4bbdfSmrg# func_help 181935c4bbdfSmrg# --------- 182035c4bbdfSmrg# Echo long help message to standard output and exit. 182135c4bbdfSmrgfunc_help () 182235c4bbdfSmrg{ 182335c4bbdfSmrg $debug_cmd 182435c4bbdfSmrg 182535c4bbdfSmrg func_usage_message 182635c4bbdfSmrg $ECHO "$long_help_message" 182735c4bbdfSmrg exit 0 182835c4bbdfSmrg} 182935c4bbdfSmrg 183035c4bbdfSmrg 183135c4bbdfSmrg# func_missing_arg ARGNAME 183235c4bbdfSmrg# ------------------------ 183335c4bbdfSmrg# Echo program name prefixed message to standard error and set global 183435c4bbdfSmrg# exit_cmd. 183535c4bbdfSmrgfunc_missing_arg () 183635c4bbdfSmrg{ 183735c4bbdfSmrg $debug_cmd 183835c4bbdfSmrg 183935c4bbdfSmrg func_error "Missing argument for '$1'." 184035c4bbdfSmrg exit_cmd=exit 184135c4bbdfSmrg} 184235c4bbdfSmrg 184335c4bbdfSmrg 184435c4bbdfSmrg# func_split_equals STRING 184535c4bbdfSmrg# ------------------------ 184635c4bbdfSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184735c4bbdfSmrg# splitting STRING at the '=' sign. 184835c4bbdfSmrgtest -z "$_G_HAVE_XSI_OPS" \ 184935c4bbdfSmrg && (eval 'x=a/b/c; 185035c4bbdfSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185135c4bbdfSmrg && _G_HAVE_XSI_OPS=yes 185235c4bbdfSmrg 185335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS" 185435c4bbdfSmrgthen 185535c4bbdfSmrg # This is an XSI compatible shell, allowing a faster implementation... 185635c4bbdfSmrg eval 'func_split_equals () 185735c4bbdfSmrg { 185835c4bbdfSmrg $debug_cmd 185935c4bbdfSmrg 186035c4bbdfSmrg func_split_equals_lhs=${1%%=*} 186135c4bbdfSmrg func_split_equals_rhs=${1#*=} 186235c4bbdfSmrg test "x$func_split_equals_lhs" = "x$1" \ 186335c4bbdfSmrg && func_split_equals_rhs= 186435c4bbdfSmrg }' 186535c4bbdfSmrgelse 186635c4bbdfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 186735c4bbdfSmrg func_split_equals () 186835c4bbdfSmrg { 186935c4bbdfSmrg $debug_cmd 187035c4bbdfSmrg 187135c4bbdfSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187235c4bbdfSmrg func_split_equals_rhs= 187335c4bbdfSmrg test "x$func_split_equals_lhs" = "x$1" \ 187435c4bbdfSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187535c4bbdfSmrg } 187635c4bbdfSmrgfi #func_split_equals 187735c4bbdfSmrg 187835c4bbdfSmrg 187935c4bbdfSmrg# func_split_short_opt SHORTOPT 188035c4bbdfSmrg# ----------------------------- 188135c4bbdfSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188235c4bbdfSmrg# variables after splitting SHORTOPT after the 2nd character. 188335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS" 188435c4bbdfSmrgthen 188535c4bbdfSmrg # This is an XSI compatible shell, allowing a faster implementation... 188635c4bbdfSmrg eval 'func_split_short_opt () 188735c4bbdfSmrg { 188835c4bbdfSmrg $debug_cmd 188935c4bbdfSmrg 189035c4bbdfSmrg func_split_short_opt_arg=${1#??} 189135c4bbdfSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189235c4bbdfSmrg }' 189335c4bbdfSmrgelse 189435c4bbdfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 189535c4bbdfSmrg func_split_short_opt () 189635c4bbdfSmrg { 189735c4bbdfSmrg $debug_cmd 189835c4bbdfSmrg 189935c4bbdfSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190035c4bbdfSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190135c4bbdfSmrg } 190235c4bbdfSmrgfi #func_split_short_opt 190335c4bbdfSmrg 190435c4bbdfSmrg 190535c4bbdfSmrg# func_usage 190635c4bbdfSmrg# ---------- 190735c4bbdfSmrg# Echo short help message to standard output and exit. 190835c4bbdfSmrgfunc_usage () 190935c4bbdfSmrg{ 191035c4bbdfSmrg $debug_cmd 191135c4bbdfSmrg 191235c4bbdfSmrg func_usage_message 191335c4bbdfSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191435c4bbdfSmrg exit 0 191535c4bbdfSmrg} 191635c4bbdfSmrg 191735c4bbdfSmrg 191835c4bbdfSmrg# func_usage_message 191935c4bbdfSmrg# ------------------ 192035c4bbdfSmrg# Echo short help message to standard output. 192135c4bbdfSmrgfunc_usage_message () 192235c4bbdfSmrg{ 192335c4bbdfSmrg $debug_cmd 192435c4bbdfSmrg 192535c4bbdfSmrg eval \$ECHO \""Usage: $usage"\" 192635c4bbdfSmrg echo 192735c4bbdfSmrg $SED -n 's|^# || 192835c4bbdfSmrg /^Written by/{ 192935c4bbdfSmrg x;p;x 193035c4bbdfSmrg } 193135c4bbdfSmrg h 193235c4bbdfSmrg /^Written by/q' < "$progpath" 193335c4bbdfSmrg echo 193435c4bbdfSmrg eval \$ECHO \""$usage_message"\" 193535c4bbdfSmrg} 193635c4bbdfSmrg 193735c4bbdfSmrg 193835c4bbdfSmrg# func_version 193935c4bbdfSmrg# ------------ 194035c4bbdfSmrg# Echo version message to standard output and exit. 194135c4bbdfSmrgfunc_version () 194235c4bbdfSmrg{ 194335c4bbdfSmrg $debug_cmd 194435c4bbdfSmrg 194535c4bbdfSmrg printf '%s\n' "$progname $scriptversion" 194635c4bbdfSmrg $SED -n ' 194735c4bbdfSmrg /(C)/!b go 194835c4bbdfSmrg :more 194935c4bbdfSmrg /\./!{ 195035c4bbdfSmrg N 195135c4bbdfSmrg s|\n# | | 195235c4bbdfSmrg b more 195335c4bbdfSmrg } 195435c4bbdfSmrg :go 195535c4bbdfSmrg /^# Written by /,/# warranty; / { 195635c4bbdfSmrg s|^# || 195735c4bbdfSmrg s|^# *$|| 195835c4bbdfSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195935c4bbdfSmrg p 196035c4bbdfSmrg } 196135c4bbdfSmrg /^# Written by / { 196235c4bbdfSmrg s|^# || 196335c4bbdfSmrg p 196435c4bbdfSmrg } 196535c4bbdfSmrg /^warranty; /q' < "$progpath" 196635c4bbdfSmrg 196735c4bbdfSmrg exit $? 196835c4bbdfSmrg} 196935c4bbdfSmrg 197035c4bbdfSmrg 197135c4bbdfSmrg# Local variables: 197235c4bbdfSmrg# mode: shell-script 197335c4bbdfSmrg# sh-indentation: 2 197435c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 197535c4bbdfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197635c4bbdfSmrg# time-stamp-time-zone: "UTC" 197735c4bbdfSmrg# End: 197835c4bbdfSmrg 197935c4bbdfSmrg# Set a version string. 198035c4bbdfSmrgscriptversion='(GNU libtool) 2.4.6' 198135c4bbdfSmrg 198235c4bbdfSmrg 198335c4bbdfSmrg# func_echo ARG... 198435c4bbdfSmrg# ---------------- 198535c4bbdfSmrg# Libtool also displays the current mode in messages, so override 198635c4bbdfSmrg# funclib.sh func_echo with this custom definition. 198735c4bbdfSmrgfunc_echo () 198835c4bbdfSmrg{ 198935c4bbdfSmrg $debug_cmd 199035c4bbdfSmrg 199135c4bbdfSmrg _G_message=$* 199235c4bbdfSmrg 199335c4bbdfSmrg func_echo_IFS=$IFS 199435c4bbdfSmrg IFS=$nl 199535c4bbdfSmrg for _G_line in $_G_message; do 199635c4bbdfSmrg IFS=$func_echo_IFS 199735c4bbdfSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199835c4bbdfSmrg done 199935c4bbdfSmrg IFS=$func_echo_IFS 200035c4bbdfSmrg} 200135c4bbdfSmrg 200235c4bbdfSmrg 200335c4bbdfSmrg# func_warning ARG... 200435c4bbdfSmrg# ------------------- 200535c4bbdfSmrg# Libtool warnings are not categorized, so override funclib.sh 200635c4bbdfSmrg# func_warning with this simpler definition. 200735c4bbdfSmrgfunc_warning () 200835c4bbdfSmrg{ 200935c4bbdfSmrg $debug_cmd 201035c4bbdfSmrg 201135c4bbdfSmrg $warning_func ${1+"$@"} 201235c4bbdfSmrg} 201335c4bbdfSmrg 201435c4bbdfSmrg 201535c4bbdfSmrg## ---------------- ## 201635c4bbdfSmrg## Options parsing. ## 201735c4bbdfSmrg## ---------------- ## 201835c4bbdfSmrg 201935c4bbdfSmrg# Hook in the functions to make sure our own options are parsed during 202035c4bbdfSmrg# the option parsing loop. 202135c4bbdfSmrg 202235c4bbdfSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 202335c4bbdfSmrg 202435c4bbdfSmrg# Short help message in response to '-h'. 202535c4bbdfSmrgusage_message="Options: 202635c4bbdfSmrg --config show all configuration variables 202735c4bbdfSmrg --debug enable verbose shell tracing 202835c4bbdfSmrg -n, --dry-run display commands without modifying any files 202935c4bbdfSmrg --features display basic configuration information and exit 203035c4bbdfSmrg --mode=MODE use operation mode MODE 203135c4bbdfSmrg --no-warnings equivalent to '-Wnone' 203235c4bbdfSmrg --preserve-dup-deps don't remove duplicate dependency libraries 203335c4bbdfSmrg --quiet, --silent don't print informational messages 203435c4bbdfSmrg --tag=TAG use configuration variables from tag TAG 203535c4bbdfSmrg -v, --verbose print more informational messages than default 203635c4bbdfSmrg --version print version information 203735c4bbdfSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203835c4bbdfSmrg -h, --help, --help-all print short, long, or detailed help message 203935c4bbdfSmrg" 204035c4bbdfSmrg 204135c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'. 204235c4bbdfSmrgfunc_help () 204335c4bbdfSmrg{ 204435c4bbdfSmrg $debug_cmd 204535c4bbdfSmrg 204635c4bbdfSmrg func_usage_message 204735c4bbdfSmrg $ECHO "$long_help_message 204835c4bbdfSmrg 204935c4bbdfSmrgMODE must be one of the following: 205035c4bbdfSmrg 205135c4bbdfSmrg clean remove files from the build directory 205235c4bbdfSmrg compile compile a source file into a libtool object 205335c4bbdfSmrg execute automatically set library path, then run a program 205435c4bbdfSmrg finish complete the installation of libtool libraries 205535c4bbdfSmrg install install libraries or executables 205635c4bbdfSmrg link create a library or an executable 205735c4bbdfSmrg uninstall remove libraries from an installed directory 205835c4bbdfSmrg 205935c4bbdfSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206035c4bbdfSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206135c4bbdfSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206235c4bbdfSmrg 206335c4bbdfSmrgWhen reporting a bug, please describe a test case to reproduce it and 206435c4bbdfSmrginclude the following information: 206535c4bbdfSmrg 206635c4bbdfSmrg host-triplet: $host 206735c4bbdfSmrg shell: $SHELL 206835c4bbdfSmrg compiler: $LTCC 206935c4bbdfSmrg compiler flags: $LTCFLAGS 207035c4bbdfSmrg linker: $LD (gnu? $with_gnu_ld) 207135c4bbdfSmrg version: $progname (GNU libtool) 2.4.6 207235c4bbdfSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207335c4bbdfSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207435c4bbdfSmrg 207535c4bbdfSmrgReport bugs to <bug-libtool@gnu.org>. 207635c4bbdfSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 207735c4bbdfSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207835c4bbdfSmrg exit 0 207935c4bbdfSmrg} 208035c4bbdfSmrg 208135c4bbdfSmrg 208235c4bbdfSmrg# func_lo2o OBJECT-NAME 208335c4bbdfSmrg# --------------------- 208435c4bbdfSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208535c4bbdfSmrg# object suffix. 208635c4bbdfSmrg 208735c4bbdfSmrglo2o=s/\\.lo\$/.$objext/ 208835c4bbdfSmrgo2lo=s/\\.$objext\$/.lo/ 208935c4bbdfSmrg 209035c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 209135c4bbdfSmrg eval 'func_lo2o () 209235c4bbdfSmrg { 209335c4bbdfSmrg case $1 in 209435c4bbdfSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209535c4bbdfSmrg * ) func_lo2o_result=$1 ;; 209635c4bbdfSmrg esac 209735c4bbdfSmrg }' 209835c4bbdfSmrg 209935c4bbdfSmrg # func_xform LIBOBJ-OR-SOURCE 210035c4bbdfSmrg # --------------------------- 210135c4bbdfSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210235c4bbdfSmrg # suffix to a '.lo' libtool-object suffix. 210335c4bbdfSmrg eval 'func_xform () 210435c4bbdfSmrg { 210535c4bbdfSmrg func_xform_result=${1%.*}.lo 210635c4bbdfSmrg }' 210735c4bbdfSmrgelse 210835c4bbdfSmrg # ...otherwise fall back to using sed. 210935c4bbdfSmrg func_lo2o () 211035c4bbdfSmrg { 211135c4bbdfSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211235c4bbdfSmrg } 211335c4bbdfSmrg 211435c4bbdfSmrg func_xform () 211535c4bbdfSmrg { 211635c4bbdfSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211735c4bbdfSmrg } 211835c4bbdfSmrgfi 211935c4bbdfSmrg 212035c4bbdfSmrg 212135c4bbdfSmrg# func_fatal_configuration ARG... 212235c4bbdfSmrg# ------------------------------- 212335c4bbdfSmrg# Echo program name prefixed message to standard error, followed by 212435c4bbdfSmrg# a configuration failure hint, and exit. 212535c4bbdfSmrgfunc_fatal_configuration () 212635c4bbdfSmrg{ 212735c4bbdfSmrg func__fatal_error ${1+"$@"} \ 212835c4bbdfSmrg "See the $PACKAGE documentation for more information." \ 212935c4bbdfSmrg "Fatal configuration error." 213035c4bbdfSmrg} 213135c4bbdfSmrg 213235c4bbdfSmrg 213335c4bbdfSmrg# func_config 213435c4bbdfSmrg# ----------- 213535c4bbdfSmrg# Display the configuration for all the tags in this script. 213635c4bbdfSmrgfunc_config () 213735c4bbdfSmrg{ 213835c4bbdfSmrg re_begincf='^# ### BEGIN LIBTOOL' 213935c4bbdfSmrg re_endcf='^# ### END LIBTOOL' 214035c4bbdfSmrg 214135c4bbdfSmrg # Default configuration. 214235c4bbdfSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 214335c4bbdfSmrg 214435c4bbdfSmrg # Now print the configurations for the tags. 214535c4bbdfSmrg for tagname in $taglist; do 214635c4bbdfSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 214735c4bbdfSmrg done 214835c4bbdfSmrg 214935c4bbdfSmrg exit $? 215035c4bbdfSmrg} 215135c4bbdfSmrg 215235c4bbdfSmrg 215335c4bbdfSmrg# func_features 215435c4bbdfSmrg# ------------- 215535c4bbdfSmrg# Display the features supported by this script. 215635c4bbdfSmrgfunc_features () 215735c4bbdfSmrg{ 215835c4bbdfSmrg echo "host: $host" 215935c4bbdfSmrg if test yes = "$build_libtool_libs"; then 216035c4bbdfSmrg echo "enable shared libraries" 216135c4bbdfSmrg else 216235c4bbdfSmrg echo "disable shared libraries" 216335c4bbdfSmrg fi 216435c4bbdfSmrg if test yes = "$build_old_libs"; then 216535c4bbdfSmrg echo "enable static libraries" 216635c4bbdfSmrg else 216735c4bbdfSmrg echo "disable static libraries" 216835c4bbdfSmrg fi 216935c4bbdfSmrg 217035c4bbdfSmrg exit $? 217135c4bbdfSmrg} 217235c4bbdfSmrg 217335c4bbdfSmrg 217435c4bbdfSmrg# func_enable_tag TAGNAME 217535c4bbdfSmrg# ----------------------- 217635c4bbdfSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 217735c4bbdfSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 217835c4bbdfSmrg# variable here. 217935c4bbdfSmrgfunc_enable_tag () 218035c4bbdfSmrg{ 218135c4bbdfSmrg # Global variable: 218235c4bbdfSmrg tagname=$1 218335c4bbdfSmrg 218435c4bbdfSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218535c4bbdfSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218635c4bbdfSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 218735c4bbdfSmrg 218835c4bbdfSmrg # Validate tagname. 218935c4bbdfSmrg case $tagname in 219035c4bbdfSmrg *[!-_A-Za-z0-9,/]*) 219135c4bbdfSmrg func_fatal_error "invalid tag name: $tagname" 219235c4bbdfSmrg ;; 219335c4bbdfSmrg esac 219435c4bbdfSmrg 219535c4bbdfSmrg # Don't test for the "default" C tag, as we know it's 219635c4bbdfSmrg # there but not specially marked. 219735c4bbdfSmrg case $tagname in 219835c4bbdfSmrg CC) ;; 219935c4bbdfSmrg *) 220035c4bbdfSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220135c4bbdfSmrg taglist="$taglist $tagname" 220235c4bbdfSmrg 220335c4bbdfSmrg # Evaluate the configuration. Be careful to quote the path 220435c4bbdfSmrg # and the sed script, to avoid splitting on whitespace, but 220535c4bbdfSmrg # also don't use non-portable quotes within backquotes within 220635c4bbdfSmrg # quotes we have to do it in 2 steps: 220735c4bbdfSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220835c4bbdfSmrg eval "$extractedcf" 220935c4bbdfSmrg else 221035c4bbdfSmrg func_error "ignoring unknown tag $tagname" 221135c4bbdfSmrg fi 221235c4bbdfSmrg ;; 221335c4bbdfSmrg esac 221435c4bbdfSmrg} 221535c4bbdfSmrg 221635c4bbdfSmrg 221735c4bbdfSmrg# func_check_version_match 221835c4bbdfSmrg# ------------------------ 221935c4bbdfSmrg# Ensure that we are using m4 macros, and libtool script from the same 222035c4bbdfSmrg# release of libtool. 222135c4bbdfSmrgfunc_check_version_match () 222235c4bbdfSmrg{ 222335c4bbdfSmrg if test "$package_revision" != "$macro_revision"; then 222435c4bbdfSmrg if test "$VERSION" != "$macro_version"; then 222535c4bbdfSmrg if test -z "$macro_version"; then 222635c4bbdfSmrg cat >&2 <<_LT_EOF 222735c4bbdfSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222835c4bbdfSmrg$progname: definition of this LT_INIT comes from an older release. 222935c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223035c4bbdfSmrg$progname: and run autoconf again. 223135c4bbdfSmrg_LT_EOF 223235c4bbdfSmrg else 223335c4bbdfSmrg cat >&2 <<_LT_EOF 223435c4bbdfSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223535c4bbdfSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223635c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223735c4bbdfSmrg$progname: and run autoconf again. 223835c4bbdfSmrg_LT_EOF 223935c4bbdfSmrg fi 224035c4bbdfSmrg else 224135c4bbdfSmrg cat >&2 <<_LT_EOF 224235c4bbdfSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224335c4bbdfSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224435c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224535c4bbdfSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 224635c4bbdfSmrg_LT_EOF 224735c4bbdfSmrg fi 224835c4bbdfSmrg 224935c4bbdfSmrg exit $EXIT_MISMATCH 225035c4bbdfSmrg fi 225135c4bbdfSmrg} 225235c4bbdfSmrg 225335c4bbdfSmrg 225435c4bbdfSmrg# libtool_options_prep [ARG]... 225535c4bbdfSmrg# ----------------------------- 225635c4bbdfSmrg# Preparation for options parsed by libtool. 225735c4bbdfSmrglibtool_options_prep () 225835c4bbdfSmrg{ 225935c4bbdfSmrg $debug_mode 226035c4bbdfSmrg 226135c4bbdfSmrg # Option defaults: 226235c4bbdfSmrg opt_config=false 226335c4bbdfSmrg opt_dlopen= 226435c4bbdfSmrg opt_dry_run=false 226535c4bbdfSmrg opt_help=false 226635c4bbdfSmrg opt_mode= 226735c4bbdfSmrg opt_preserve_dup_deps=false 226835c4bbdfSmrg opt_quiet=false 226935c4bbdfSmrg 227035c4bbdfSmrg nonopt= 227135c4bbdfSmrg preserve_args= 227235c4bbdfSmrg 227335c4bbdfSmrg # Shorthand for --mode=foo, only valid as the first argument 227435c4bbdfSmrg case $1 in 227535c4bbdfSmrg clean|clea|cle|cl) 227635c4bbdfSmrg shift; set dummy --mode clean ${1+"$@"}; shift 227735c4bbdfSmrg ;; 227835c4bbdfSmrg compile|compil|compi|comp|com|co|c) 227935c4bbdfSmrg shift; set dummy --mode compile ${1+"$@"}; shift 228035c4bbdfSmrg ;; 228135c4bbdfSmrg execute|execut|execu|exec|exe|ex|e) 228235c4bbdfSmrg shift; set dummy --mode execute ${1+"$@"}; shift 228335c4bbdfSmrg ;; 228435c4bbdfSmrg finish|finis|fini|fin|fi|f) 228535c4bbdfSmrg shift; set dummy --mode finish ${1+"$@"}; shift 228635c4bbdfSmrg ;; 228735c4bbdfSmrg install|instal|insta|inst|ins|in|i) 228835c4bbdfSmrg shift; set dummy --mode install ${1+"$@"}; shift 228935c4bbdfSmrg ;; 229035c4bbdfSmrg link|lin|li|l) 229135c4bbdfSmrg shift; set dummy --mode link ${1+"$@"}; shift 229235c4bbdfSmrg ;; 229335c4bbdfSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229435c4bbdfSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229535c4bbdfSmrg ;; 229635c4bbdfSmrg esac 229735c4bbdfSmrg 229835c4bbdfSmrg # Pass back the list of options. 229935c4bbdfSmrg func_quote_for_eval ${1+"$@"} 230035c4bbdfSmrg libtool_options_prep_result=$func_quote_for_eval_result 230135c4bbdfSmrg} 230235c4bbdfSmrgfunc_add_hook func_options_prep libtool_options_prep 230335c4bbdfSmrg 230435c4bbdfSmrg 230535c4bbdfSmrg# libtool_parse_options [ARG]... 230635c4bbdfSmrg# --------------------------------- 230735c4bbdfSmrg# Provide handling for libtool specific options. 230835c4bbdfSmrglibtool_parse_options () 230935c4bbdfSmrg{ 231035c4bbdfSmrg $debug_cmd 231135c4bbdfSmrg 231235c4bbdfSmrg # Perform our own loop to consume as many options as possible in 231335c4bbdfSmrg # each iteration. 231435c4bbdfSmrg while test $# -gt 0; do 231535c4bbdfSmrg _G_opt=$1 231635c4bbdfSmrg shift 231735c4bbdfSmrg case $_G_opt in 231835c4bbdfSmrg --dry-run|--dryrun|-n) 231935c4bbdfSmrg opt_dry_run=: 232035c4bbdfSmrg ;; 232135c4bbdfSmrg 232235c4bbdfSmrg --config) func_config ;; 232335c4bbdfSmrg 232435c4bbdfSmrg --dlopen|-dlopen) 232535c4bbdfSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 232635c4bbdfSmrg}$1" 232735c4bbdfSmrg shift 232835c4bbdfSmrg ;; 232935c4bbdfSmrg 233035c4bbdfSmrg --preserve-dup-deps) 233135c4bbdfSmrg opt_preserve_dup_deps=: ;; 233235c4bbdfSmrg 233335c4bbdfSmrg --features) func_features ;; 233435c4bbdfSmrg 233535c4bbdfSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233635c4bbdfSmrg 233735c4bbdfSmrg --help) opt_help=: ;; 233835c4bbdfSmrg 233935c4bbdfSmrg --help-all) opt_help=': help-all' ;; 234035c4bbdfSmrg 234135c4bbdfSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234235c4bbdfSmrg opt_mode=$1 234335c4bbdfSmrg case $1 in 234435c4bbdfSmrg # Valid mode arguments: 234535c4bbdfSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234635c4bbdfSmrg 234735c4bbdfSmrg # Catch anything else as an error 234835c4bbdfSmrg *) func_error "invalid argument for $_G_opt" 234935c4bbdfSmrg exit_cmd=exit 235035c4bbdfSmrg break 235135c4bbdfSmrg ;; 235235c4bbdfSmrg esac 235335c4bbdfSmrg shift 235435c4bbdfSmrg ;; 235535c4bbdfSmrg 235635c4bbdfSmrg --no-silent|--no-quiet) 235735c4bbdfSmrg opt_quiet=false 235835c4bbdfSmrg func_append preserve_args " $_G_opt" 235935c4bbdfSmrg ;; 236035c4bbdfSmrg 236135c4bbdfSmrg --no-warnings|--no-warning|--no-warn) 236235c4bbdfSmrg opt_warning=false 236335c4bbdfSmrg func_append preserve_args " $_G_opt" 236435c4bbdfSmrg ;; 236535c4bbdfSmrg 236635c4bbdfSmrg --no-verbose) 236735c4bbdfSmrg opt_verbose=false 236835c4bbdfSmrg func_append preserve_args " $_G_opt" 236935c4bbdfSmrg ;; 237035c4bbdfSmrg 237135c4bbdfSmrg --silent|--quiet) 237235c4bbdfSmrg opt_quiet=: 237335c4bbdfSmrg opt_verbose=false 237435c4bbdfSmrg func_append preserve_args " $_G_opt" 237535c4bbdfSmrg ;; 237635c4bbdfSmrg 237735c4bbdfSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237835c4bbdfSmrg opt_tag=$1 237935c4bbdfSmrg func_append preserve_args " $_G_opt $1" 238035c4bbdfSmrg func_enable_tag "$1" 238135c4bbdfSmrg shift 238235c4bbdfSmrg ;; 238335c4bbdfSmrg 238435c4bbdfSmrg --verbose|-v) opt_quiet=false 238535c4bbdfSmrg opt_verbose=: 238635c4bbdfSmrg func_append preserve_args " $_G_opt" 238735c4bbdfSmrg ;; 238835c4bbdfSmrg 238935c4bbdfSmrg # An option not handled by this hook function: 239035c4bbdfSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239135c4bbdfSmrg esac 239235c4bbdfSmrg done 239335c4bbdfSmrg 239435c4bbdfSmrg 239535c4bbdfSmrg # save modified positional parameters for caller 239635c4bbdfSmrg func_quote_for_eval ${1+"$@"} 239735c4bbdfSmrg libtool_parse_options_result=$func_quote_for_eval_result 239835c4bbdfSmrg} 239935c4bbdfSmrgfunc_add_hook func_parse_options libtool_parse_options 240035c4bbdfSmrg 240135c4bbdfSmrg 240235c4bbdfSmrg 240335c4bbdfSmrg# libtool_validate_options [ARG]... 240435c4bbdfSmrg# --------------------------------- 240535c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed 240635c4bbdfSmrg# arguments. 240735c4bbdfSmrglibtool_validate_options () 240835c4bbdfSmrg{ 240935c4bbdfSmrg # save first non-option argument 241035c4bbdfSmrg if test 0 -lt $#; then 241135c4bbdfSmrg nonopt=$1 241235c4bbdfSmrg shift 241335c4bbdfSmrg fi 241435c4bbdfSmrg 241535c4bbdfSmrg # preserve --debug 241635c4bbdfSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 241735c4bbdfSmrg 241835c4bbdfSmrg case $host in 241935c4bbdfSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242035c4bbdfSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242135c4bbdfSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242235c4bbdfSmrg # don't eliminate duplications in $postdeps and $predeps 242335c4bbdfSmrg opt_duplicate_compiler_generated_deps=: 242435c4bbdfSmrg ;; 242535c4bbdfSmrg *) 242635c4bbdfSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242735c4bbdfSmrg ;; 242835c4bbdfSmrg esac 242935c4bbdfSmrg 243035c4bbdfSmrg $opt_help || { 243135c4bbdfSmrg # Sanity checks first: 243235c4bbdfSmrg func_check_version_match 243335c4bbdfSmrg 243435c4bbdfSmrg test yes != "$build_libtool_libs" \ 243535c4bbdfSmrg && test yes != "$build_old_libs" \ 243635c4bbdfSmrg && func_fatal_configuration "not configured to build any kind of library" 243735c4bbdfSmrg 243835c4bbdfSmrg # Darwin sucks 243935c4bbdfSmrg eval std_shrext=\"$shrext_cmds\" 244035c4bbdfSmrg 244135c4bbdfSmrg # Only execute mode is allowed to have -dlopen flags. 244235c4bbdfSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244335c4bbdfSmrg func_error "unrecognized option '-dlopen'" 244435c4bbdfSmrg $ECHO "$help" 1>&2 244535c4bbdfSmrg exit $EXIT_FAILURE 244635c4bbdfSmrg fi 244735c4bbdfSmrg 244835c4bbdfSmrg # Change the help message to a mode-specific one. 244935c4bbdfSmrg generic_help=$help 245035c4bbdfSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 245135c4bbdfSmrg } 245235c4bbdfSmrg 245335c4bbdfSmrg # Pass back the unparsed argument list 245435c4bbdfSmrg func_quote_for_eval ${1+"$@"} 245535c4bbdfSmrg libtool_validate_options_result=$func_quote_for_eval_result 245635c4bbdfSmrg} 245735c4bbdfSmrgfunc_add_hook func_validate_options libtool_validate_options 245835c4bbdfSmrg 245935c4bbdfSmrg 246035c4bbdfSmrg# Process options as early as possible so that --help and --version 246135c4bbdfSmrg# can return quickly. 246235c4bbdfSmrgfunc_options ${1+"$@"} 246335c4bbdfSmrgeval set dummy "$func_options_result"; shift 246435c4bbdfSmrg 246535c4bbdfSmrg 246635c4bbdfSmrg 246735c4bbdfSmrg## ----------- ## 246835c4bbdfSmrg## Main. ## 246935c4bbdfSmrg## ----------- ## 247035c4bbdfSmrg 247135c4bbdfSmrgmagic='%%%MAGIC variable%%%' 247235c4bbdfSmrgmagic_exe='%%%MAGIC EXE variable%%%' 247305b261ecSmrg 24744642e01fSmrg# Global variables. 24754642e01fSmrgextracted_archives= 24764642e01fSmrgextracted_serial=0 247705b261ecSmrg 247835c4bbdfSmrg# If this variable is set in any of the actions, the command in it 247935c4bbdfSmrg# will be execed at the end. This prevents here-documents from being 248035c4bbdfSmrg# left over by shells. 248135c4bbdfSmrgexec_cmd= 248235c4bbdfSmrg 248335c4bbdfSmrg 248435c4bbdfSmrg# A function that is used when there is no print builtin or printf. 248535c4bbdfSmrgfunc_fallback_echo () 248635c4bbdfSmrg{ 248735c4bbdfSmrg eval 'cat <<_LTECHO_EOF 248835c4bbdfSmrg$1 248935c4bbdfSmrg_LTECHO_EOF' 249035c4bbdfSmrg} 249135c4bbdfSmrg 249235c4bbdfSmrg# func_generated_by_libtool 249335c4bbdfSmrg# True iff stdin has been generated by Libtool. This function is only 249435c4bbdfSmrg# a basic sanity check; it will hardly flush out determined imposters. 249535c4bbdfSmrgfunc_generated_by_libtool_p () 249635c4bbdfSmrg{ 249735c4bbdfSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249835c4bbdfSmrg} 249935c4bbdfSmrg 250035c4bbdfSmrg# func_lalib_p file 250135c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 250235c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 250335c4bbdfSmrg# determined imposters. 250435c4bbdfSmrgfunc_lalib_p () 250535c4bbdfSmrg{ 250635c4bbdfSmrg test -f "$1" && 250735c4bbdfSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 250835c4bbdfSmrg} 250935c4bbdfSmrg 251035c4bbdfSmrg# func_lalib_unsafe_p file 251135c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 251235c4bbdfSmrg# This function implements the same check as func_lalib_p without 251335c4bbdfSmrg# resorting to external programs. To this end, it redirects stdin and 251435c4bbdfSmrg# closes it afterwards, without saving the original file descriptor. 251535c4bbdfSmrg# As a safety measure, use it only where a negative result would be 251635c4bbdfSmrg# fatal anyway. Works if 'file' does not exist. 251735c4bbdfSmrgfunc_lalib_unsafe_p () 251835c4bbdfSmrg{ 251935c4bbdfSmrg lalib_p=no 252035c4bbdfSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 252135c4bbdfSmrg for lalib_p_l in 1 2 3 4 252235c4bbdfSmrg do 252335c4bbdfSmrg read lalib_p_line 252435c4bbdfSmrg case $lalib_p_line in 252535c4bbdfSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 252635c4bbdfSmrg esac 252735c4bbdfSmrg done 252835c4bbdfSmrg exec 0<&5 5<&- 252935c4bbdfSmrg fi 253035c4bbdfSmrg test yes = "$lalib_p" 253135c4bbdfSmrg} 253235c4bbdfSmrg 253335c4bbdfSmrg# func_ltwrapper_script_p file 253435c4bbdfSmrg# True iff FILE is a libtool wrapper script 253535c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 253635c4bbdfSmrg# determined imposters. 253735c4bbdfSmrgfunc_ltwrapper_script_p () 253835c4bbdfSmrg{ 253935c4bbdfSmrg test -f "$1" && 254035c4bbdfSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 254135c4bbdfSmrg} 254235c4bbdfSmrg 254335c4bbdfSmrg# func_ltwrapper_executable_p file 254435c4bbdfSmrg# True iff FILE is a libtool wrapper executable 254535c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 254635c4bbdfSmrg# determined imposters. 254735c4bbdfSmrgfunc_ltwrapper_executable_p () 254835c4bbdfSmrg{ 254935c4bbdfSmrg func_ltwrapper_exec_suffix= 255035c4bbdfSmrg case $1 in 255135c4bbdfSmrg *.exe) ;; 255235c4bbdfSmrg *) func_ltwrapper_exec_suffix=.exe ;; 255335c4bbdfSmrg esac 255435c4bbdfSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 255535c4bbdfSmrg} 255635c4bbdfSmrg 255735c4bbdfSmrg# func_ltwrapper_scriptname file 255835c4bbdfSmrg# Assumes file is an ltwrapper_executable 255935c4bbdfSmrg# uses $file to determine the appropriate filename for a 256035c4bbdfSmrg# temporary ltwrapper_script. 256135c4bbdfSmrgfunc_ltwrapper_scriptname () 256235c4bbdfSmrg{ 256335c4bbdfSmrg func_dirname_and_basename "$1" "" "." 256435c4bbdfSmrg func_stripname '' '.exe' "$func_basename_result" 256535c4bbdfSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 256635c4bbdfSmrg} 256735c4bbdfSmrg 256835c4bbdfSmrg# func_ltwrapper_p file 256935c4bbdfSmrg# True iff FILE is a libtool wrapper script or wrapper executable 257035c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 257135c4bbdfSmrg# determined imposters. 257235c4bbdfSmrgfunc_ltwrapper_p () 257335c4bbdfSmrg{ 257435c4bbdfSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 257535c4bbdfSmrg} 257635c4bbdfSmrg 257735c4bbdfSmrg 257835c4bbdfSmrg# func_execute_cmds commands fail_cmd 257935c4bbdfSmrg# Execute tilde-delimited COMMANDS. 258035c4bbdfSmrg# If FAIL_CMD is given, eval that upon failure. 258135c4bbdfSmrg# FAIL_CMD may read-access the current command in variable CMD! 258235c4bbdfSmrgfunc_execute_cmds () 258335c4bbdfSmrg{ 258435c4bbdfSmrg $debug_cmd 258535c4bbdfSmrg 258635c4bbdfSmrg save_ifs=$IFS; IFS='~' 258735c4bbdfSmrg for cmd in $1; do 258835c4bbdfSmrg IFS=$sp$nl 258935c4bbdfSmrg eval cmd=\"$cmd\" 259035c4bbdfSmrg IFS=$save_ifs 259135c4bbdfSmrg func_show_eval "$cmd" "${2-:}" 259235c4bbdfSmrg done 259335c4bbdfSmrg IFS=$save_ifs 259435c4bbdfSmrg} 259535c4bbdfSmrg 259635c4bbdfSmrg 259735c4bbdfSmrg# func_source file 259835c4bbdfSmrg# Source FILE, adding directory component if necessary. 259935c4bbdfSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 260035c4bbdfSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 260135c4bbdfSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260235c4bbdfSmrg# 'FILE.' does not work on cygwin managed mounts. 260335c4bbdfSmrgfunc_source () 260435c4bbdfSmrg{ 260535c4bbdfSmrg $debug_cmd 260635c4bbdfSmrg 260735c4bbdfSmrg case $1 in 260835c4bbdfSmrg */* | *\\*) . "$1" ;; 260935c4bbdfSmrg *) . "./$1" ;; 261035c4bbdfSmrg esac 261135c4bbdfSmrg} 261235c4bbdfSmrg 261335c4bbdfSmrg 261435c4bbdfSmrg# func_resolve_sysroot PATH 261535c4bbdfSmrg# Replace a leading = in PATH with a sysroot. Store the result into 261635c4bbdfSmrg# func_resolve_sysroot_result 261735c4bbdfSmrgfunc_resolve_sysroot () 261835c4bbdfSmrg{ 261935c4bbdfSmrg func_resolve_sysroot_result=$1 262035c4bbdfSmrg case $func_resolve_sysroot_result in 262135c4bbdfSmrg =*) 262235c4bbdfSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 262335c4bbdfSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262435c4bbdfSmrg ;; 262535c4bbdfSmrg esac 262635c4bbdfSmrg} 262735c4bbdfSmrg 262835c4bbdfSmrg# func_replace_sysroot PATH 262935c4bbdfSmrg# If PATH begins with the sysroot, replace it with = and 263035c4bbdfSmrg# store the result into func_replace_sysroot_result. 263135c4bbdfSmrgfunc_replace_sysroot () 263235c4bbdfSmrg{ 263335c4bbdfSmrg case $lt_sysroot:$1 in 263435c4bbdfSmrg ?*:"$lt_sysroot"*) 263535c4bbdfSmrg func_stripname "$lt_sysroot" '' "$1" 263635c4bbdfSmrg func_replace_sysroot_result='='$func_stripname_result 263735c4bbdfSmrg ;; 263835c4bbdfSmrg *) 263935c4bbdfSmrg # Including no sysroot. 264035c4bbdfSmrg func_replace_sysroot_result=$1 264135c4bbdfSmrg ;; 264235c4bbdfSmrg esac 264335c4bbdfSmrg} 264435c4bbdfSmrg 264535c4bbdfSmrg# func_infer_tag arg 264635c4bbdfSmrg# Infer tagged configuration to use if any are available and 264735c4bbdfSmrg# if one wasn't chosen via the "--tag" command line option. 264835c4bbdfSmrg# Only attempt this if the compiler in the base compile 264935c4bbdfSmrg# command doesn't match the default compiler. 265035c4bbdfSmrg# arg is usually of the form 'gcc ...' 265135c4bbdfSmrgfunc_infer_tag () 265235c4bbdfSmrg{ 265335c4bbdfSmrg $debug_cmd 265435c4bbdfSmrg 265535c4bbdfSmrg if test -n "$available_tags" && test -z "$tagname"; then 265635c4bbdfSmrg CC_quoted= 265735c4bbdfSmrg for arg in $CC; do 265835c4bbdfSmrg func_append_quoted CC_quoted "$arg" 265935c4bbdfSmrg done 266035c4bbdfSmrg CC_expanded=`func_echo_all $CC` 266135c4bbdfSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 266235c4bbdfSmrg case $@ in 266335c4bbdfSmrg # Blanks in the command may have been stripped by the calling shell, 266435c4bbdfSmrg # but not from the CC environment variable when configure was run. 266535c4bbdfSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266635c4bbdfSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 266735c4bbdfSmrg # Blanks at the start of $base_compile will cause this to fail 266835c4bbdfSmrg # if we don't check for them as well. 266935c4bbdfSmrg *) 267035c4bbdfSmrg for z in $available_tags; do 267135c4bbdfSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 267235c4bbdfSmrg # Evaluate the configuration. 267335c4bbdfSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 267435c4bbdfSmrg CC_quoted= 267535c4bbdfSmrg for arg in $CC; do 267635c4bbdfSmrg # Double-quote args containing other shell metacharacters. 267735c4bbdfSmrg func_append_quoted CC_quoted "$arg" 267835c4bbdfSmrg done 267935c4bbdfSmrg CC_expanded=`func_echo_all $CC` 268035c4bbdfSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 268135c4bbdfSmrg case "$@ " in 268235c4bbdfSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268335c4bbdfSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 268435c4bbdfSmrg # The compiler in the base compile command matches 268535c4bbdfSmrg # the one in the tagged configuration. 268635c4bbdfSmrg # Assume this is the tagged configuration we want. 268735c4bbdfSmrg tagname=$z 268835c4bbdfSmrg break 268935c4bbdfSmrg ;; 269035c4bbdfSmrg esac 269135c4bbdfSmrg fi 269235c4bbdfSmrg done 269335c4bbdfSmrg # If $tagname still isn't set, then no tagged configuration 269435c4bbdfSmrg # was found and let the user know that the "--tag" command 269535c4bbdfSmrg # line option must be used. 269635c4bbdfSmrg if test -z "$tagname"; then 269735c4bbdfSmrg func_echo "unable to infer tagged configuration" 269835c4bbdfSmrg func_fatal_error "specify a tag with '--tag'" 269935c4bbdfSmrg# else 270035c4bbdfSmrg# func_verbose "using $tagname tagged configuration" 270135c4bbdfSmrg fi 270235c4bbdfSmrg ;; 270335c4bbdfSmrg esac 270435c4bbdfSmrg fi 270535c4bbdfSmrg} 270635c4bbdfSmrg 2707475c125cSmrg 27084642e01fSmrg 270935c4bbdfSmrg# func_write_libtool_object output_name pic_name nonpic_name 271035c4bbdfSmrg# Create a libtool object file (analogous to a ".la" file), 271135c4bbdfSmrg# but don't create it if we're doing a dry run. 271235c4bbdfSmrgfunc_write_libtool_object () 27134642e01fSmrg{ 271435c4bbdfSmrg write_libobj=$1 271535c4bbdfSmrg if test yes = "$build_libtool_libs"; then 271635c4bbdfSmrg write_lobj=\'$2\' 271735c4bbdfSmrg else 271835c4bbdfSmrg write_lobj=none 271935c4bbdfSmrg fi 272005b261ecSmrg 272135c4bbdfSmrg if test yes = "$build_old_libs"; then 272235c4bbdfSmrg write_oldobj=\'$3\' 272335c4bbdfSmrg else 272435c4bbdfSmrg write_oldobj=none 272535c4bbdfSmrg fi 272605b261ecSmrg 272735c4bbdfSmrg $opt_dry_run || { 272835c4bbdfSmrg cat >${write_libobj}T <<EOF 272935c4bbdfSmrg# $write_libobj - a libtool object file 273035c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 273135c4bbdfSmrg# 273235c4bbdfSmrg# Please DO NOT delete this file! 273335c4bbdfSmrg# It is necessary for linking the library. 27344642e01fSmrg 273535c4bbdfSmrg# Name of the PIC object. 273635c4bbdfSmrgpic_object=$write_lobj 273705b261ecSmrg 273835c4bbdfSmrg# Name of the non-PIC object 273935c4bbdfSmrgnon_pic_object=$write_oldobj 274005b261ecSmrg 274135c4bbdfSmrgEOF 274235c4bbdfSmrg $MV "${write_libobj}T" "$write_libobj" 274335c4bbdfSmrg } 27444642e01fSmrg} 274505b261ecSmrg 274635c4bbdfSmrg 274735c4bbdfSmrg################################################## 274835c4bbdfSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274935c4bbdfSmrg################################################## 275035c4bbdfSmrg 275135c4bbdfSmrg# func_convert_core_file_wine_to_w32 ARG 275235c4bbdfSmrg# Helper function used by file name conversion functions when $build is *nix, 275335c4bbdfSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275435c4bbdfSmrg# correctly configured wine environment available, with the winepath program 275535c4bbdfSmrg# in $build's $PATH. 275635c4bbdfSmrg# 275735c4bbdfSmrg# ARG is the $build file name to be converted to w32 format. 275835c4bbdfSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275935c4bbdfSmrg# be empty on error (or when ARG is empty) 276035c4bbdfSmrgfunc_convert_core_file_wine_to_w32 () 27614642e01fSmrg{ 276235c4bbdfSmrg $debug_cmd 276335c4bbdfSmrg 276435c4bbdfSmrg func_convert_core_file_wine_to_w32_result=$1 276535c4bbdfSmrg if test -n "$1"; then 276635c4bbdfSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276735c4bbdfSmrg # are forced to check the contents of stdout. On the other hand, if the 276835c4bbdfSmrg # command is not found, the shell will set an exit code of 127 and print 276935c4bbdfSmrg # *an error message* to stdout. So we must check for both error code of 277035c4bbdfSmrg # zero AND non-empty stdout, which explains the odd construction: 277135c4bbdfSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277235c4bbdfSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277335c4bbdfSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277435c4bbdfSmrg $SED -e "$sed_naive_backslashify"` 277505b261ecSmrg else 277635c4bbdfSmrg func_convert_core_file_wine_to_w32_result= 277705b261ecSmrg fi 277835c4bbdfSmrg fi 277935c4bbdfSmrg} 278035c4bbdfSmrg# end: func_convert_core_file_wine_to_w32 27814642e01fSmrg 278235c4bbdfSmrg 278335c4bbdfSmrg# func_convert_core_path_wine_to_w32 ARG 278435c4bbdfSmrg# Helper function used by path conversion functions when $build is *nix, and 278535c4bbdfSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278635c4bbdfSmrg# configured wine environment available, with the winepath program in $build's 278735c4bbdfSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278835c4bbdfSmrg# 278935c4bbdfSmrg# ARG is path to be converted from $build format to win32. 279035c4bbdfSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279135c4bbdfSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279235c4bbdfSmrg# are convertible, then the result may be empty. 279335c4bbdfSmrgfunc_convert_core_path_wine_to_w32 () 279435c4bbdfSmrg{ 279535c4bbdfSmrg $debug_cmd 279635c4bbdfSmrg 279735c4bbdfSmrg # unfortunately, winepath doesn't convert paths, only file names 279835c4bbdfSmrg func_convert_core_path_wine_to_w32_result= 279935c4bbdfSmrg if test -n "$1"; then 280035c4bbdfSmrg oldIFS=$IFS 280135c4bbdfSmrg IFS=: 280235c4bbdfSmrg for func_convert_core_path_wine_to_w32_f in $1; do 280335c4bbdfSmrg IFS=$oldIFS 280435c4bbdfSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280535c4bbdfSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280635c4bbdfSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280735c4bbdfSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280835c4bbdfSmrg else 280935c4bbdfSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281035c4bbdfSmrg fi 281135c4bbdfSmrg fi 281235c4bbdfSmrg done 281335c4bbdfSmrg IFS=$oldIFS 281435c4bbdfSmrg fi 28154642e01fSmrg} 281635c4bbdfSmrg# end: func_convert_core_path_wine_to_w32 281735c4bbdfSmrg 281835c4bbdfSmrg 281935c4bbdfSmrg# func_cygpath ARGS... 282035c4bbdfSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282135c4bbdfSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282235c4bbdfSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282335c4bbdfSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282435c4bbdfSmrg# file name or path is assumed to be in w32 format, as previously converted 282535c4bbdfSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282635c4bbdfSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 282735c4bbdfSmrg# Cygwin format). Returns an empty string on error. 282835c4bbdfSmrg# 282935c4bbdfSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 283035c4bbdfSmrg# be converted. 283135c4bbdfSmrg# 283235c4bbdfSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283335c4bbdfSmrg# environment variable; do not put it in $PATH. 283435c4bbdfSmrgfunc_cygpath () 283535c4bbdfSmrg{ 283635c4bbdfSmrg $debug_cmd 283705b261ecSmrg 283835c4bbdfSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283935c4bbdfSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284035c4bbdfSmrg if test "$?" -ne 0; then 284135c4bbdfSmrg # on failure, ensure result is empty 284235c4bbdfSmrg func_cygpath_result= 284335c4bbdfSmrg fi 284435c4bbdfSmrg else 284535c4bbdfSmrg func_cygpath_result= 284635c4bbdfSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284735c4bbdfSmrg fi 284835c4bbdfSmrg} 284935c4bbdfSmrg#end: func_cygpath 285035c4bbdfSmrg 285135c4bbdfSmrg 285235c4bbdfSmrg# func_convert_core_msys_to_w32 ARG 285335c4bbdfSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 285435c4bbdfSmrg# result in func_convert_core_msys_to_w32_result. 285535c4bbdfSmrgfunc_convert_core_msys_to_w32 () 28564642e01fSmrg{ 285735c4bbdfSmrg $debug_cmd 285805b261ecSmrg 285935c4bbdfSmrg # awkward: cmd appends spaces to result 286035c4bbdfSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286135c4bbdfSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286235c4bbdfSmrg} 286335c4bbdfSmrg#end: func_convert_core_msys_to_w32 286405b261ecSmrg 286505b261ecSmrg 286635c4bbdfSmrg# func_convert_file_check ARG1 ARG2 286735c4bbdfSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 286835c4bbdfSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286935c4bbdfSmrg# func_to_host_file_result to ARG1). 287035c4bbdfSmrgfunc_convert_file_check () 287135c4bbdfSmrg{ 287235c4bbdfSmrg $debug_cmd 287335c4bbdfSmrg 287435c4bbdfSmrg if test -z "$2" && test -n "$1"; then 287535c4bbdfSmrg func_error "Could not determine host file name corresponding to" 287635c4bbdfSmrg func_error " '$1'" 287735c4bbdfSmrg func_error "Continuing, but uninstalled executables may not work." 287835c4bbdfSmrg # Fallback: 287935c4bbdfSmrg func_to_host_file_result=$1 288035c4bbdfSmrg fi 28814642e01fSmrg} 288235c4bbdfSmrg# end func_convert_file_check 28834642e01fSmrg 288435c4bbdfSmrg 288535c4bbdfSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288635c4bbdfSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288735c4bbdfSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288835c4bbdfSmrg# func_to_host_file_result to a simplistic fallback value (see below). 288935c4bbdfSmrgfunc_convert_path_check () 28904642e01fSmrg{ 289135c4bbdfSmrg $debug_cmd 289235c4bbdfSmrg 289335c4bbdfSmrg if test -z "$4" && test -n "$3"; then 289435c4bbdfSmrg func_error "Could not determine the host path corresponding to" 289535c4bbdfSmrg func_error " '$3'" 289635c4bbdfSmrg func_error "Continuing, but uninstalled executables may not work." 289735c4bbdfSmrg # Fallback. This is a deliberately simplistic "conversion" and 289835c4bbdfSmrg # should not be "improved". See libtool.info. 289935c4bbdfSmrg if test "x$1" != "x$2"; then 290035c4bbdfSmrg lt_replace_pathsep_chars="s|$1|$2|g" 290135c4bbdfSmrg func_to_host_path_result=`echo "$3" | 290235c4bbdfSmrg $SED -e "$lt_replace_pathsep_chars"` 290335c4bbdfSmrg else 290435c4bbdfSmrg func_to_host_path_result=$3 290535c4bbdfSmrg fi 290635c4bbdfSmrg fi 290735c4bbdfSmrg} 290835c4bbdfSmrg# end func_convert_path_check 29096747b715Smrg 291035c4bbdfSmrg 291135c4bbdfSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291235c4bbdfSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291335c4bbdfSmrg# and appending REPL if ORIG matches BACKPAT. 291435c4bbdfSmrgfunc_convert_path_front_back_pathsep () 291535c4bbdfSmrg{ 291635c4bbdfSmrg $debug_cmd 291735c4bbdfSmrg 291835c4bbdfSmrg case $4 in 291935c4bbdfSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920475c125cSmrg ;; 292135c4bbdfSmrg esac 292235c4bbdfSmrg case $4 in 292335c4bbdfSmrg $2 ) func_append func_to_host_path_result "$3" 2924475c125cSmrg ;; 2925475c125cSmrg esac 292635c4bbdfSmrg} 292735c4bbdfSmrg# end func_convert_path_front_back_pathsep 29286747b715Smrg 2929475c125cSmrg 293035c4bbdfSmrg################################################## 293135c4bbdfSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293235c4bbdfSmrg################################################## 293335c4bbdfSmrg# invoked via '$to_host_file_cmd ARG' 293435c4bbdfSmrg# 293535c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format. 293635c4bbdfSmrg# Result will be available in $func_to_host_file_result. 29374642e01fSmrg 29384642e01fSmrg 293935c4bbdfSmrg# func_to_host_file ARG 294035c4bbdfSmrg# Converts the file name ARG from $build format to $host format. Return result 294135c4bbdfSmrg# in func_to_host_file_result. 294235c4bbdfSmrgfunc_to_host_file () 294335c4bbdfSmrg{ 294435c4bbdfSmrg $debug_cmd 294535c4bbdfSmrg 294635c4bbdfSmrg $to_host_file_cmd "$1" 294735c4bbdfSmrg} 294835c4bbdfSmrg# end func_to_host_file 294935c4bbdfSmrg 295035c4bbdfSmrg 295135c4bbdfSmrg# func_to_tool_file ARG LAZY 295235c4bbdfSmrg# converts the file name ARG from $build format to toolchain format. Return 295335c4bbdfSmrg# result in func_to_tool_file_result. If the conversion in use is listed 295435c4bbdfSmrg# in (the comma separated) LAZY, no conversion takes place. 295535c4bbdfSmrgfunc_to_tool_file () 295635c4bbdfSmrg{ 295735c4bbdfSmrg $debug_cmd 295835c4bbdfSmrg 295935c4bbdfSmrg case ,$2, in 296035c4bbdfSmrg *,"$to_tool_file_cmd",*) 296135c4bbdfSmrg func_to_tool_file_result=$1 296205b261ecSmrg ;; 296305b261ecSmrg *) 296435c4bbdfSmrg $to_tool_file_cmd "$1" 296535c4bbdfSmrg func_to_tool_file_result=$func_to_host_file_result 29664642e01fSmrg ;; 29674642e01fSmrg esac 296835c4bbdfSmrg} 296935c4bbdfSmrg# end func_to_tool_file 297005b261ecSmrg 297135c4bbdfSmrg 297235c4bbdfSmrg# func_convert_file_noop ARG 297335c4bbdfSmrg# Copy ARG to func_to_host_file_result. 297435c4bbdfSmrgfunc_convert_file_noop () 297535c4bbdfSmrg{ 297635c4bbdfSmrg func_to_host_file_result=$1 2977475c125cSmrg} 297835c4bbdfSmrg# end func_convert_file_noop 29794642e01fSmrg 298035c4bbdfSmrg 298135c4bbdfSmrg# func_convert_file_msys_to_w32 ARG 298235c4bbdfSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298335c4bbdfSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 298435c4bbdfSmrg# func_to_host_file_result. 298535c4bbdfSmrgfunc_convert_file_msys_to_w32 () 2986475c125cSmrg{ 298735c4bbdfSmrg $debug_cmd 29884642e01fSmrg 298935c4bbdfSmrg func_to_host_file_result=$1 299035c4bbdfSmrg if test -n "$1"; then 299135c4bbdfSmrg func_convert_core_msys_to_w32 "$1" 299235c4bbdfSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993475c125cSmrg fi 299435c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 2995475c125cSmrg} 299635c4bbdfSmrg# end func_convert_file_msys_to_w32 29974642e01fSmrg 299805b261ecSmrg 299935c4bbdfSmrg# func_convert_file_cygwin_to_w32 ARG 300035c4bbdfSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300135c4bbdfSmrg# func_to_host_file_result. 300235c4bbdfSmrgfunc_convert_file_cygwin_to_w32 () 300335c4bbdfSmrg{ 300435c4bbdfSmrg $debug_cmd 30054642e01fSmrg 300635c4bbdfSmrg func_to_host_file_result=$1 300735c4bbdfSmrg if test -n "$1"; then 300835c4bbdfSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300935c4bbdfSmrg # LT_CYGPATH in this case. 301035c4bbdfSmrg func_to_host_file_result=`cygpath -m "$1"` 3011475c125cSmrg fi 301235c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 301335c4bbdfSmrg} 301435c4bbdfSmrg# end func_convert_file_cygwin_to_w32 30154642e01fSmrg 3016475c125cSmrg 301735c4bbdfSmrg# func_convert_file_nix_to_w32 ARG 301835c4bbdfSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301935c4bbdfSmrg# and a working winepath. Returns result in func_to_host_file_result. 302035c4bbdfSmrgfunc_convert_file_nix_to_w32 () 302135c4bbdfSmrg{ 302235c4bbdfSmrg $debug_cmd 3023475c125cSmrg 302435c4bbdfSmrg func_to_host_file_result=$1 302535c4bbdfSmrg if test -n "$1"; then 302635c4bbdfSmrg func_convert_core_file_wine_to_w32 "$1" 302735c4bbdfSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028475c125cSmrg fi 302935c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3030475c125cSmrg} 303135c4bbdfSmrg# end func_convert_file_nix_to_w32 303205b261ecSmrg 303305b261ecSmrg 303435c4bbdfSmrg# func_convert_file_msys_to_cygwin ARG 303535c4bbdfSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303635c4bbdfSmrg# Returns result in func_to_host_file_result. 303735c4bbdfSmrgfunc_convert_file_msys_to_cygwin () 30384642e01fSmrg{ 303935c4bbdfSmrg $debug_cmd 304005b261ecSmrg 304135c4bbdfSmrg func_to_host_file_result=$1 304235c4bbdfSmrg if test -n "$1"; then 304335c4bbdfSmrg func_convert_core_msys_to_w32 "$1" 304435c4bbdfSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304535c4bbdfSmrg func_to_host_file_result=$func_cygpath_result 304635c4bbdfSmrg fi 304735c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30484642e01fSmrg} 304935c4bbdfSmrg# end func_convert_file_msys_to_cygwin 305005b261ecSmrg 305105b261ecSmrg 305235c4bbdfSmrg# func_convert_file_nix_to_cygwin ARG 305335c4bbdfSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305435c4bbdfSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305535c4bbdfSmrg# in func_to_host_file_result. 305635c4bbdfSmrgfunc_convert_file_nix_to_cygwin () 30574642e01fSmrg{ 305835c4bbdfSmrg $debug_cmd 305935c4bbdfSmrg 306035c4bbdfSmrg func_to_host_file_result=$1 306135c4bbdfSmrg if test -n "$1"; then 306235c4bbdfSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306335c4bbdfSmrg func_convert_core_file_wine_to_w32 "$1" 306435c4bbdfSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306535c4bbdfSmrg func_to_host_file_result=$func_cygpath_result 306635c4bbdfSmrg fi 306735c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30684642e01fSmrg} 306935c4bbdfSmrg# end func_convert_file_nix_to_cygwin 307005b261ecSmrg 307135c4bbdfSmrg 307235c4bbdfSmrg############################################# 307335c4bbdfSmrg# $build to $host PATH CONVERSION FUNCTIONS # 307435c4bbdfSmrg############################################# 307535c4bbdfSmrg# invoked via '$to_host_path_cmd ARG' 307635c4bbdfSmrg# 307735c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format. 307835c4bbdfSmrg# The result will be available in $func_to_host_path_result. 307935c4bbdfSmrg# 308035c4bbdfSmrg# Path separators are also converted from $build format to $host format. If 308135c4bbdfSmrg# ARG begins or ends with a path separator character, it is preserved (but 308235c4bbdfSmrg# converted to $host format) on output. 308335c4bbdfSmrg# 308435c4bbdfSmrg# All path conversion functions are named using the following convention: 308535c4bbdfSmrg# file name conversion function : func_convert_file_X_to_Y () 308635c4bbdfSmrg# path conversion function : func_convert_path_X_to_Y () 308735c4bbdfSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308835c4bbdfSmrg# same. If conversion functions are added for new $build/$host combinations, 308935c4bbdfSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309035c4bbdfSmrg# will break. 309135c4bbdfSmrg 309235c4bbdfSmrg 309335c4bbdfSmrg# func_init_to_host_path_cmd 309435c4bbdfSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309535c4bbdfSmrg# appropriate value, based on the value of $to_host_file_cmd. 309635c4bbdfSmrgto_host_path_cmd= 309735c4bbdfSmrgfunc_init_to_host_path_cmd () 30984642e01fSmrg{ 309935c4bbdfSmrg $debug_cmd 310035c4bbdfSmrg 310135c4bbdfSmrg if test -z "$to_host_path_cmd"; then 310235c4bbdfSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310335c4bbdfSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 310435c4bbdfSmrg fi 31054642e01fSmrg} 31064642e01fSmrg 310735c4bbdfSmrg 310835c4bbdfSmrg# func_to_host_path ARG 310935c4bbdfSmrg# Converts the path ARG from $build format to $host format. Return result 311035c4bbdfSmrg# in func_to_host_path_result. 311135c4bbdfSmrgfunc_to_host_path () 31124642e01fSmrg{ 311335c4bbdfSmrg $debug_cmd 311435c4bbdfSmrg 311535c4bbdfSmrg func_init_to_host_path_cmd 311635c4bbdfSmrg $to_host_path_cmd "$1" 31174642e01fSmrg} 311835c4bbdfSmrg# end func_to_host_path 31194642e01fSmrg 31204642e01fSmrg 312135c4bbdfSmrg# func_convert_path_noop ARG 312235c4bbdfSmrg# Copy ARG to func_to_host_path_result. 312335c4bbdfSmrgfunc_convert_path_noop () 31244642e01fSmrg{ 312535c4bbdfSmrg func_to_host_path_result=$1 31264642e01fSmrg} 312735c4bbdfSmrg# end func_convert_path_noop 31284642e01fSmrg 31294642e01fSmrg 313035c4bbdfSmrg# func_convert_path_msys_to_w32 ARG 313135c4bbdfSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313235c4bbdfSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 313335c4bbdfSmrg# func_to_host_path_result. 313435c4bbdfSmrgfunc_convert_path_msys_to_w32 () 31354642e01fSmrg{ 313635c4bbdfSmrg $debug_cmd 313735c4bbdfSmrg 313835c4bbdfSmrg func_to_host_path_result=$1 313935c4bbdfSmrg if test -n "$1"; then 314035c4bbdfSmrg # Remove leading and trailing path separator characters from ARG. MSYS 314135c4bbdfSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314235c4bbdfSmrg # and winepath ignores them completely. 314335c4bbdfSmrg func_stripname : : "$1" 314435c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 314535c4bbdfSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314635c4bbdfSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314735c4bbdfSmrg func_convert_path_check : ";" \ 314835c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314935c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315035c4bbdfSmrg fi 31514642e01fSmrg} 315235c4bbdfSmrg# end func_convert_path_msys_to_w32 31534642e01fSmrg 31544642e01fSmrg 315535c4bbdfSmrg# func_convert_path_cygwin_to_w32 ARG 315635c4bbdfSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 315735c4bbdfSmrg# func_to_host_file_result. 315835c4bbdfSmrgfunc_convert_path_cygwin_to_w32 () 31594642e01fSmrg{ 316035c4bbdfSmrg $debug_cmd 316135c4bbdfSmrg 316235c4bbdfSmrg func_to_host_path_result=$1 316335c4bbdfSmrg if test -n "$1"; then 316435c4bbdfSmrg # See func_convert_path_msys_to_w32: 316535c4bbdfSmrg func_stripname : : "$1" 316635c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 316735c4bbdfSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316835c4bbdfSmrg func_convert_path_check : ";" \ 316935c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317035c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317135c4bbdfSmrg fi 31726747b715Smrg} 317335c4bbdfSmrg# end func_convert_path_cygwin_to_w32 31746747b715Smrg 31756747b715Smrg 317635c4bbdfSmrg# func_convert_path_nix_to_w32 ARG 317735c4bbdfSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317835c4bbdfSmrg# a working winepath. Returns result in func_to_host_file_result. 317935c4bbdfSmrgfunc_convert_path_nix_to_w32 () 318035c4bbdfSmrg{ 318135c4bbdfSmrg $debug_cmd 31826747b715Smrg 318335c4bbdfSmrg func_to_host_path_result=$1 318435c4bbdfSmrg if test -n "$1"; then 318535c4bbdfSmrg # See func_convert_path_msys_to_w32: 318635c4bbdfSmrg func_stripname : : "$1" 318735c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 318835c4bbdfSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318935c4bbdfSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319035c4bbdfSmrg func_convert_path_check : ";" \ 319135c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319235c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319335c4bbdfSmrg fi 319435c4bbdfSmrg} 319535c4bbdfSmrg# end func_convert_path_nix_to_w32 319635c4bbdfSmrg 319735c4bbdfSmrg 319835c4bbdfSmrg# func_convert_path_msys_to_cygwin ARG 319935c4bbdfSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320035c4bbdfSmrg# Returns result in func_to_host_file_result. 320135c4bbdfSmrgfunc_convert_path_msys_to_cygwin () 32026747b715Smrg{ 320335c4bbdfSmrg $debug_cmd 32046747b715Smrg 320535c4bbdfSmrg func_to_host_path_result=$1 320635c4bbdfSmrg if test -n "$1"; then 320735c4bbdfSmrg # See func_convert_path_msys_to_w32: 320835c4bbdfSmrg func_stripname : : "$1" 320935c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 321035c4bbdfSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321135c4bbdfSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321235c4bbdfSmrg func_to_host_path_result=$func_cygpath_result 321335c4bbdfSmrg func_convert_path_check : : \ 321435c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321535c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321635c4bbdfSmrg fi 321735c4bbdfSmrg} 321835c4bbdfSmrg# end func_convert_path_msys_to_cygwin 32196747b715Smrg 32206747b715Smrg 322135c4bbdfSmrg# func_convert_path_nix_to_cygwin ARG 322235c4bbdfSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322335c4bbdfSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322435c4bbdfSmrg# func_to_host_file_result. 322535c4bbdfSmrgfunc_convert_path_nix_to_cygwin () 322635c4bbdfSmrg{ 322735c4bbdfSmrg $debug_cmd 32286747b715Smrg 322935c4bbdfSmrg func_to_host_path_result=$1 323035c4bbdfSmrg if test -n "$1"; then 323135c4bbdfSmrg # Remove leading and trailing path separator characters from 323235c4bbdfSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 323335c4bbdfSmrg # into '.;' and ';.', and winepath ignores them completely. 323435c4bbdfSmrg func_stripname : : "$1" 323535c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 323635c4bbdfSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323735c4bbdfSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323835c4bbdfSmrg func_to_host_path_result=$func_cygpath_result 323935c4bbdfSmrg func_convert_path_check : : \ 324035c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324135c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324235c4bbdfSmrg fi 324335c4bbdfSmrg} 324435c4bbdfSmrg# end func_convert_path_nix_to_cygwin 32456747b715Smrg 324635c4bbdfSmrg 324735c4bbdfSmrg# func_dll_def_p FILE 324835c4bbdfSmrg# True iff FILE is a Windows DLL '.def' file. 324935c4bbdfSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325035c4bbdfSmrgfunc_dll_def_p () 325135c4bbdfSmrg{ 325235c4bbdfSmrg $debug_cmd 325335c4bbdfSmrg 325435c4bbdfSmrg func_dll_def_p_tmp=`$SED -n \ 325535c4bbdfSmrg -e 's/^[ ]*//' \ 325635c4bbdfSmrg -e '/^\(;.*\)*$/d' \ 325735c4bbdfSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325835c4bbdfSmrg -e q \ 325935c4bbdfSmrg "$1"` 326035c4bbdfSmrg test DEF = "$func_dll_def_p_tmp" 32616747b715Smrg} 32626747b715Smrg 326335c4bbdfSmrg 32644642e01fSmrg# func_mode_compile arg... 32654642e01fSmrgfunc_mode_compile () 32664642e01fSmrg{ 326735c4bbdfSmrg $debug_cmd 326835c4bbdfSmrg 32694642e01fSmrg # Get the compilation command and the source file. 32704642e01fSmrg base_compile= 327135c4bbdfSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 32724642e01fSmrg suppress_opt=yes 32734642e01fSmrg suppress_output= 32744642e01fSmrg arg_mode=normal 32754642e01fSmrg libobj= 32764642e01fSmrg later= 32774642e01fSmrg pie_flag= 32784642e01fSmrg 32794642e01fSmrg for arg 32804642e01fSmrg do 32814642e01fSmrg case $arg_mode in 32824642e01fSmrg arg ) 32834642e01fSmrg # do not "continue". Instead, add this to base_compile 328435c4bbdfSmrg lastarg=$arg 32854642e01fSmrg arg_mode=normal 32864642e01fSmrg ;; 32874642e01fSmrg 32884642e01fSmrg target ) 328935c4bbdfSmrg libobj=$arg 32904642e01fSmrg arg_mode=normal 32914642e01fSmrg continue 32924642e01fSmrg ;; 32934642e01fSmrg 32944642e01fSmrg normal ) 32954642e01fSmrg # Accept any command-line options. 32964642e01fSmrg case $arg in 32974642e01fSmrg -o) 32984642e01fSmrg test -n "$libobj" && \ 329935c4bbdfSmrg func_fatal_error "you cannot specify '-o' more than once" 33004642e01fSmrg arg_mode=target 33014642e01fSmrg continue 33024642e01fSmrg ;; 33034642e01fSmrg 33044642e01fSmrg -pie | -fpie | -fPIE) 330535c4bbdfSmrg func_append pie_flag " $arg" 33064642e01fSmrg continue 33074642e01fSmrg ;; 33084642e01fSmrg 33094642e01fSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 331035c4bbdfSmrg func_append later " $arg" 33114642e01fSmrg continue 33124642e01fSmrg ;; 33134642e01fSmrg 33144642e01fSmrg -no-suppress) 331505b261ecSmrg suppress_opt=no 331605b261ecSmrg continue 331705b261ecSmrg ;; 331805b261ecSmrg 331905b261ecSmrg -Xcompiler) 332005b261ecSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 332105b261ecSmrg continue # The current "srcfile" will either be retained or 332205b261ecSmrg ;; # replaced later. I would guess that would be a bug. 332305b261ecSmrg 332405b261ecSmrg -Wc,*) 33254642e01fSmrg func_stripname '-Wc,' '' "$arg" 33264642e01fSmrg args=$func_stripname_result 332705b261ecSmrg lastarg= 332835c4bbdfSmrg save_ifs=$IFS; IFS=, 33294642e01fSmrg for arg in $args; do 333035c4bbdfSmrg IFS=$save_ifs 333135c4bbdfSmrg func_append_quoted lastarg "$arg" 333205b261ecSmrg done 333335c4bbdfSmrg IFS=$save_ifs 33344642e01fSmrg func_stripname ' ' '' "$lastarg" 33354642e01fSmrg lastarg=$func_stripname_result 333605b261ecSmrg 333705b261ecSmrg # Add the arguments to base_compile. 333835c4bbdfSmrg func_append base_compile " $lastarg" 333905b261ecSmrg continue 334005b261ecSmrg ;; 334105b261ecSmrg 33424642e01fSmrg *) 334305b261ecSmrg # Accept the current argument as the source file. 334405b261ecSmrg # The previous "srcfile" becomes the current argument. 334505b261ecSmrg # 334635c4bbdfSmrg lastarg=$srcfile 334735c4bbdfSmrg srcfile=$arg 334805b261ecSmrg ;; 334905b261ecSmrg esac # case $arg 335005b261ecSmrg ;; 335105b261ecSmrg esac # case $arg_mode 335205b261ecSmrg 335305b261ecSmrg # Aesthetically quote the previous argument. 335435c4bbdfSmrg func_append_quoted base_compile "$lastarg" 335505b261ecSmrg done # for arg 335605b261ecSmrg 335705b261ecSmrg case $arg_mode in 335805b261ecSmrg arg) 33594642e01fSmrg func_fatal_error "you must specify an argument for -Xcompile" 336005b261ecSmrg ;; 336105b261ecSmrg target) 336235c4bbdfSmrg func_fatal_error "you must specify a target with '-o'" 336305b261ecSmrg ;; 336405b261ecSmrg *) 336505b261ecSmrg # Get the name of the library object. 33664642e01fSmrg test -z "$libobj" && { 33674642e01fSmrg func_basename "$srcfile" 336835c4bbdfSmrg libobj=$func_basename_result 33694642e01fSmrg } 337005b261ecSmrg ;; 337105b261ecSmrg esac 337205b261ecSmrg 337305b261ecSmrg # Recognize several different file suffixes. 337405b261ecSmrg # If the user specifies -o file.o, it is replaced with file.lo 337505b261ecSmrg case $libobj in 33764642e01fSmrg *.[cCFSifmso] | \ 33774642e01fSmrg *.ada | *.adb | *.ads | *.asm | \ 33784642e01fSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 337935c4bbdfSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 33804642e01fSmrg func_xform "$libobj" 33814642e01fSmrg libobj=$func_xform_result 33824642e01fSmrg ;; 338305b261ecSmrg esac 338405b261ecSmrg 338505b261ecSmrg case $libobj in 33864642e01fSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338705b261ecSmrg *) 338835c4bbdfSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 338905b261ecSmrg ;; 339005b261ecSmrg esac 339105b261ecSmrg 339205b261ecSmrg func_infer_tag $base_compile 339305b261ecSmrg 339405b261ecSmrg for arg in $later; do 339505b261ecSmrg case $arg in 33964642e01fSmrg -shared) 339735c4bbdfSmrg test yes = "$build_libtool_libs" \ 339835c4bbdfSmrg || func_fatal_configuration "cannot build a shared library" 33994642e01fSmrg build_old_libs=no 34004642e01fSmrg continue 34014642e01fSmrg ;; 34024642e01fSmrg 340305b261ecSmrg -static) 34044642e01fSmrg build_libtool_libs=no 340505b261ecSmrg build_old_libs=yes 340605b261ecSmrg continue 340705b261ecSmrg ;; 340805b261ecSmrg 340905b261ecSmrg -prefer-pic) 341005b261ecSmrg pic_mode=yes 341105b261ecSmrg continue 341205b261ecSmrg ;; 341305b261ecSmrg 341405b261ecSmrg -prefer-non-pic) 341505b261ecSmrg pic_mode=no 341605b261ecSmrg continue 341705b261ecSmrg ;; 341805b261ecSmrg esac 341905b261ecSmrg done 342005b261ecSmrg 34214642e01fSmrg func_quote_for_eval "$libobj" 34224642e01fSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 34234642e01fSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342435c4bbdfSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 34254642e01fSmrg func_dirname_and_basename "$obj" "/" "" 342635c4bbdfSmrg objname=$func_basename_result 342735c4bbdfSmrg xdir=$func_dirname_result 342835c4bbdfSmrg lobj=$xdir$objdir/$objname 342905b261ecSmrg 34304642e01fSmrg test -z "$base_compile" && \ 34314642e01fSmrg func_fatal_help "you must specify a compilation command" 343205b261ecSmrg 343305b261ecSmrg # Delete any leftover library objects. 343435c4bbdfSmrg if test yes = "$build_old_libs"; then 343505b261ecSmrg removelist="$obj $lobj $libobj ${libobj}T" 343605b261ecSmrg else 343705b261ecSmrg removelist="$lobj $libobj ${libobj}T" 343805b261ecSmrg fi 343905b261ecSmrg 344005b261ecSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 344105b261ecSmrg case $host_os in 34424642e01fSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344305b261ecSmrg pic_mode=default 344405b261ecSmrg ;; 344505b261ecSmrg esac 344635c4bbdfSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344705b261ecSmrg # non-PIC code in shared libraries is not supported 344805b261ecSmrg pic_mode=default 344905b261ecSmrg fi 345005b261ecSmrg 345105b261ecSmrg # Calculate the filename of the output object if compiler does 345205b261ecSmrg # not support -o with -c 345335c4bbdfSmrg if test no = "$compiler_c_o"; then 345435c4bbdfSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345535c4bbdfSmrg lockfile=$output_obj.lock 345605b261ecSmrg else 345705b261ecSmrg output_obj= 345805b261ecSmrg need_locks=no 345905b261ecSmrg lockfile= 346005b261ecSmrg fi 346105b261ecSmrg 346205b261ecSmrg # Lock this critical section if it is needed 346305b261ecSmrg # We use this script file to make the link, it avoids creating a new file 346435c4bbdfSmrg if test yes = "$need_locks"; then 34654642e01fSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 34664642e01fSmrg func_echo "Waiting for $lockfile to be removed" 346705b261ecSmrg sleep 2 346805b261ecSmrg done 346935c4bbdfSmrg elif test warn = "$need_locks"; then 347005b261ecSmrg if test -f "$lockfile"; then 34714642e01fSmrg $ECHO "\ 347205b261ecSmrg*** ERROR, $lockfile exists and contains: 347305b261ecSmrg`cat $lockfile 2>/dev/null` 347405b261ecSmrg 347505b261ecSmrgThis indicates that another process is trying to use the same 347605b261ecSmrgtemporary object file, and libtool could not work around it because 347735c4bbdfSmrgyour compiler does not support '-c' and '-o' together. If you 347805b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better 347905b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better 348005b261ecSmrgcompiler." 348105b261ecSmrg 34824642e01fSmrg $opt_dry_run || $RM $removelist 348305b261ecSmrg exit $EXIT_FAILURE 348405b261ecSmrg fi 348535c4bbdfSmrg func_append removelist " $output_obj" 34864642e01fSmrg $ECHO "$srcfile" > "$lockfile" 348705b261ecSmrg fi 348805b261ecSmrg 34894642e01fSmrg $opt_dry_run || $RM $removelist 349035c4bbdfSmrg func_append removelist " $lockfile" 34914642e01fSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 34924642e01fSmrg 349335c4bbdfSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349435c4bbdfSmrg srcfile=$func_to_tool_file_result 34954642e01fSmrg func_quote_for_eval "$srcfile" 34964642e01fSmrg qsrcfile=$func_quote_for_eval_result 349705b261ecSmrg 349805b261ecSmrg # Only build a PIC object if we are building libtool libraries. 349935c4bbdfSmrg if test yes = "$build_libtool_libs"; then 350005b261ecSmrg # Without this assignment, base_compile gets emptied. 350105b261ecSmrg fbsd_hideous_sh_bug=$base_compile 350205b261ecSmrg 350335c4bbdfSmrg if test no != "$pic_mode"; then 350405b261ecSmrg command="$base_compile $qsrcfile $pic_flag" 350505b261ecSmrg else 350605b261ecSmrg # Don't build PIC code 350705b261ecSmrg command="$base_compile $qsrcfile" 350805b261ecSmrg fi 350905b261ecSmrg 35104642e01fSmrg func_mkdir_p "$xdir$objdir" 351105b261ecSmrg 351205b261ecSmrg if test -z "$output_obj"; then 351305b261ecSmrg # Place PIC objects in $objdir 351435c4bbdfSmrg func_append command " -o $lobj" 351505b261ecSmrg fi 351605b261ecSmrg 35174642e01fSmrg func_show_eval_locale "$command" \ 35184642e01fSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 351905b261ecSmrg 352035c4bbdfSmrg if test warn = "$need_locks" && 352105b261ecSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35224642e01fSmrg $ECHO "\ 352305b261ecSmrg*** ERROR, $lockfile contains: 352405b261ecSmrg`cat $lockfile 2>/dev/null` 352505b261ecSmrg 352605b261ecSmrgbut it should contain: 352705b261ecSmrg$srcfile 352805b261ecSmrg 352905b261ecSmrgThis indicates that another process is trying to use the same 353005b261ecSmrgtemporary object file, and libtool could not work around it because 353135c4bbdfSmrgyour compiler does not support '-c' and '-o' together. If you 353205b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better 353305b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better 353405b261ecSmrgcompiler." 353505b261ecSmrg 35364642e01fSmrg $opt_dry_run || $RM $removelist 353705b261ecSmrg exit $EXIT_FAILURE 353805b261ecSmrg fi 353905b261ecSmrg 354005b261ecSmrg # Just move the object if needed, then go on to compile the next one 354105b261ecSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 35424642e01fSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 35434642e01fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354405b261ecSmrg fi 354505b261ecSmrg 354605b261ecSmrg # Allow error messages only from the first compilation. 354735c4bbdfSmrg if test yes = "$suppress_opt"; then 35484642e01fSmrg suppress_output=' >/dev/null 2>&1' 354905b261ecSmrg fi 355005b261ecSmrg fi 355105b261ecSmrg 355205b261ecSmrg # Only build a position-dependent object if we build old libraries. 355335c4bbdfSmrg if test yes = "$build_old_libs"; then 355435c4bbdfSmrg if test yes != "$pic_mode"; then 355505b261ecSmrg # Don't build PIC code 35564642e01fSmrg command="$base_compile $qsrcfile$pie_flag" 355705b261ecSmrg else 355805b261ecSmrg command="$base_compile $qsrcfile $pic_flag" 355905b261ecSmrg fi 356035c4bbdfSmrg if test yes = "$compiler_c_o"; then 356135c4bbdfSmrg func_append command " -o $obj" 356205b261ecSmrg fi 356305b261ecSmrg 356405b261ecSmrg # Suppress compiler output if we already did a PIC compilation. 356535c4bbdfSmrg func_append command "$suppress_output" 35664642e01fSmrg func_show_eval_locale "$command" \ 35674642e01fSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 356805b261ecSmrg 356935c4bbdfSmrg if test warn = "$need_locks" && 357005b261ecSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35714642e01fSmrg $ECHO "\ 357205b261ecSmrg*** ERROR, $lockfile contains: 357305b261ecSmrg`cat $lockfile 2>/dev/null` 357405b261ecSmrg 357505b261ecSmrgbut it should contain: 357605b261ecSmrg$srcfile 357705b261ecSmrg 357805b261ecSmrgThis indicates that another process is trying to use the same 357905b261ecSmrgtemporary object file, and libtool could not work around it because 358035c4bbdfSmrgyour compiler does not support '-c' and '-o' together. If you 358105b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better 358205b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better 358305b261ecSmrgcompiler." 358405b261ecSmrg 35854642e01fSmrg $opt_dry_run || $RM $removelist 358605b261ecSmrg exit $EXIT_FAILURE 358705b261ecSmrg fi 358805b261ecSmrg 358905b261ecSmrg # Just move the object if needed 359005b261ecSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 35914642e01fSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 35924642e01fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359305b261ecSmrg fi 359405b261ecSmrg fi 359505b261ecSmrg 35964642e01fSmrg $opt_dry_run || { 35974642e01fSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 359805b261ecSmrg 35994642e01fSmrg # Unlock the critical section if it was locked 360035c4bbdfSmrg if test no != "$need_locks"; then 36014642e01fSmrg removelist=$lockfile 36024642e01fSmrg $RM "$lockfile" 36034642e01fSmrg fi 36044642e01fSmrg } 360505b261ecSmrg 360605b261ecSmrg exit $EXIT_SUCCESS 36074642e01fSmrg} 360805b261ecSmrg 36094642e01fSmrg$opt_help || { 361035c4bbdfSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 36114642e01fSmrg} 361205b261ecSmrg 36134642e01fSmrgfunc_mode_help () 36144642e01fSmrg{ 36154642e01fSmrg # We need to display help for each of the modes. 361635c4bbdfSmrg case $opt_mode in 36174642e01fSmrg "") 36184642e01fSmrg # Generic help is extracted from the usage comments 36194642e01fSmrg # at the start of this file. 36204642e01fSmrg func_help 36214642e01fSmrg ;; 362205b261ecSmrg 36234642e01fSmrg clean) 36244642e01fSmrg $ECHO \ 36254642e01fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 362605b261ecSmrg 36274642e01fSmrgRemove files from the build directory. 362805b261ecSmrg 36294642e01fSmrgRM is the name of the program to use to delete files associated with each FILE 363035c4bbdfSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 36314642e01fSmrgto RM. 363205b261ecSmrg 36334642e01fSmrgIf FILE is a libtool library, object or program, all the files associated 36344642e01fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 36354642e01fSmrg ;; 363605b261ecSmrg 36374642e01fSmrg compile) 36384642e01fSmrg $ECHO \ 36394642e01fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 364005b261ecSmrg 36414642e01fSmrgCompile a source file into a libtool library object. 364205b261ecSmrg 36434642e01fSmrgThis mode accepts the following additional options: 364405b261ecSmrg 36454642e01fSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 36464642e01fSmrg -no-suppress do not suppress compiler output for multiple passes 36476747b715Smrg -prefer-pic try to build PIC objects only 36486747b715Smrg -prefer-non-pic try to build non-PIC objects only 364935c4bbdfSmrg -shared do not build a '.o' file suitable for static linking 365035c4bbdfSmrg -static only build a '.o' file suitable for static linking 36516747b715Smrg -Wc,FLAG pass FLAG directly to the compiler 365205b261ecSmrg 365335c4bbdfSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 36544642e01fSmrgfrom the given SOURCEFILE. 365505b261ecSmrg 36564642e01fSmrgThe output file name is determined by removing the directory component from 365735c4bbdfSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365835c4bbdfSmrglibrary object suffix, '.lo'." 36594642e01fSmrg ;; 366005b261ecSmrg 36614642e01fSmrg execute) 36624642e01fSmrg $ECHO \ 36634642e01fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 366405b261ecSmrg 36654642e01fSmrgAutomatically set library path, then run a program. 366605b261ecSmrg 36674642e01fSmrgThis mode accepts the following additional options: 366805b261ecSmrg 36694642e01fSmrg -dlopen FILE add the directory containing FILE to the library path 367005b261ecSmrg 367135c4bbdfSmrgThis mode sets the library path environment variable according to '-dlopen' 36724642e01fSmrgflags. 367305b261ecSmrg 36744642e01fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 36754642e01fSmrginto their corresponding uninstalled binary, and any of their required library 36764642e01fSmrgdirectories are added to the library path. 367705b261ecSmrg 36784642e01fSmrgThen, COMMAND is executed, with ARGS as arguments." 36794642e01fSmrg ;; 368005b261ecSmrg 36814642e01fSmrg finish) 36824642e01fSmrg $ECHO \ 36834642e01fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368405b261ecSmrg 36854642e01fSmrgComplete the installation of libtool libraries. 368605b261ecSmrg 36874642e01fSmrgEach LIBDIR is a directory that contains libtool libraries. 368805b261ecSmrg 36894642e01fSmrgThe commands that this mode executes may require superuser privileges. Use 369035c4bbdfSmrgthe '--dry-run' option if you just want to see what would be executed." 36914642e01fSmrg ;; 369205b261ecSmrg 36934642e01fSmrg install) 36944642e01fSmrg $ECHO \ 36954642e01fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369605b261ecSmrg 36974642e01fSmrgInstall executables or libraries. 369805b261ecSmrg 36994642e01fSmrgINSTALL-COMMAND is the installation command. The first component should be 370035c4bbdfSmrgeither the 'install' or 'cp' program. 370105b261ecSmrg 37024642e01fSmrgThe following components of INSTALL-COMMAND are treated specially: 370305b261ecSmrg 37046747b715Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370505b261ecSmrg 37064642e01fSmrgThe rest of the components are interpreted as arguments to that command (only 37074642e01fSmrgBSD-compatible install options are recognized)." 37084642e01fSmrg ;; 370905b261ecSmrg 37104642e01fSmrg link) 37114642e01fSmrg $ECHO \ 37124642e01fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371305b261ecSmrg 37144642e01fSmrgLink object files or libraries together to form another library, or to 37154642e01fSmrgcreate an executable program. 371605b261ecSmrg 37174642e01fSmrgLINK-COMMAND is a command using the C compiler that you would use to create 37184642e01fSmrga program from several object files. 371905b261ecSmrg 37204642e01fSmrgThe following components of LINK-COMMAND are treated specially: 372105b261ecSmrg 37224642e01fSmrg -all-static do not do any dynamic linking at all 37234642e01fSmrg -avoid-version do not add a version suffix if possible 37246747b715Smrg -bindir BINDIR specify path to binaries directory (for systems where 37256747b715Smrg libraries must be found in the PATH setting at runtime) 372635c4bbdfSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 37274642e01fSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 37284642e01fSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 37294642e01fSmrg -export-symbols SYMFILE 37304642e01fSmrg try to export only the symbols listed in SYMFILE 37314642e01fSmrg -export-symbols-regex REGEX 37324642e01fSmrg try to export only the symbols matching REGEX 37334642e01fSmrg -LLIBDIR search LIBDIR for required installed libraries 37344642e01fSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 37354642e01fSmrg -module build a library that can dlopened 37364642e01fSmrg -no-fast-install disable the fast-install mode 37374642e01fSmrg -no-install link a not-installable executable 37384642e01fSmrg -no-undefined declare that a library does not refer to external symbols 37394642e01fSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374035c4bbdfSmrg -objectlist FILE use a list of object files found in FILE to specify objects 374135c4bbdfSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 37424642e01fSmrg -precious-files-regex REGEX 37434642e01fSmrg don't remove output files matching REGEX 37444642e01fSmrg -release RELEASE specify package release information 37454642e01fSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 37464642e01fSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 37474642e01fSmrg -shared only do dynamic linking of libtool libraries 37484642e01fSmrg -shrext SUFFIX override the standard shared library file extension 37494642e01fSmrg -static do not do any dynamic linking of uninstalled libtool libraries 37504642e01fSmrg -static-libtool-libs 37514642e01fSmrg do not do any dynamic linking of libtool libraries 37524642e01fSmrg -version-info CURRENT[:REVISION[:AGE]] 37534642e01fSmrg specify library version info [each variable defaults to 0] 37544642e01fSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 37556747b715Smrg -Wc,FLAG 37566747b715Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 37576747b715Smrg -Wl,FLAG 37586747b715Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 37596747b715Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376005b261ecSmrg 376135c4bbdfSmrgAll other options (arguments beginning with '-') are ignored. 376205b261ecSmrg 376335c4bbdfSmrgEvery other argument is treated as a filename. Files ending in '.la' are 37644642e01fSmrgtreated as uninstalled libtool libraries, other files are standard or library 37654642e01fSmrgobject files. 376605b261ecSmrg 376735c4bbdfSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376835c4bbdfSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 37694642e01fSmrgrequired, except when creating a convenience library. 377005b261ecSmrg 377135c4bbdfSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377235c4bbdfSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377305b261ecSmrg 377435c4bbdfSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 37754642e01fSmrgis created, otherwise an executable program is created." 377605b261ecSmrg ;; 377705b261ecSmrg 37784642e01fSmrg uninstall) 37794642e01fSmrg $ECHO \ 37804642e01fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378105b261ecSmrg 37824642e01fSmrgRemove libraries from an installation directory. 378305b261ecSmrg 37844642e01fSmrgRM is the name of the program to use to delete files associated with each FILE 378535c4bbdfSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 37864642e01fSmrgto RM. 378705b261ecSmrg 37884642e01fSmrgIf FILE is a libtool library, all the files associated with it are deleted. 37894642e01fSmrgOtherwise, only FILE itself is deleted using RM." 37904642e01fSmrg ;; 379105b261ecSmrg 37924642e01fSmrg *) 379335c4bbdfSmrg func_fatal_help "invalid operation mode '$opt_mode'" 37944642e01fSmrg ;; 37954642e01fSmrg esac 379605b261ecSmrg 37976747b715Smrg echo 379835c4bbdfSmrg $ECHO "Try '$progname --help' for more information about other modes." 37994642e01fSmrg} 380005b261ecSmrg 38016747b715Smrg# Now that we've collected a possible --mode arg, show help if necessary 38026747b715Smrgif $opt_help; then 380335c4bbdfSmrg if test : = "$opt_help"; then 38046747b715Smrg func_mode_help 38056747b715Smrg else 38066747b715Smrg { 38076747b715Smrg func_help noexit 380835c4bbdfSmrg for opt_mode in compile link execute install finish uninstall clean; do 38096747b715Smrg func_mode_help 38106747b715Smrg done 381135c4bbdfSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 38126747b715Smrg { 38136747b715Smrg func_help noexit 381435c4bbdfSmrg for opt_mode in compile link execute install finish uninstall clean; do 38156747b715Smrg echo 38166747b715Smrg func_mode_help 38176747b715Smrg done 38186747b715Smrg } | 381935c4bbdfSmrg $SED '1d 38206747b715Smrg /^When reporting/,/^Report/{ 38216747b715Smrg H 38226747b715Smrg d 38236747b715Smrg } 38246747b715Smrg $x 38256747b715Smrg /information about other modes/d 38266747b715Smrg /more detailed .*MODE/d 38276747b715Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 38286747b715Smrg fi 38296747b715Smrg exit $? 38306747b715Smrgfi 383105b261ecSmrg 383205b261ecSmrg 38334642e01fSmrg# func_mode_execute arg... 38344642e01fSmrgfunc_mode_execute () 38354642e01fSmrg{ 383635c4bbdfSmrg $debug_cmd 383735c4bbdfSmrg 38384642e01fSmrg # The first argument is the command name. 383935c4bbdfSmrg cmd=$nonopt 38404642e01fSmrg test -z "$cmd" && \ 38414642e01fSmrg func_fatal_help "you must specify a COMMAND" 384205b261ecSmrg 38434642e01fSmrg # Handle -dlopen flags immediately. 384435c4bbdfSmrg for file in $opt_dlopen; do 38454642e01fSmrg test -f "$file" \ 384635c4bbdfSmrg || func_fatal_help "'$file' is not a file" 384705b261ecSmrg 38484642e01fSmrg dir= 38494642e01fSmrg case $file in 38504642e01fSmrg *.la) 385135c4bbdfSmrg func_resolve_sysroot "$file" 385235c4bbdfSmrg file=$func_resolve_sysroot_result 385335c4bbdfSmrg 38544642e01fSmrg # Check to see that this really is a libtool archive. 38554642e01fSmrg func_lalib_unsafe_p "$file" \ 385635c4bbdfSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 385705b261ecSmrg 38584642e01fSmrg # Read the libtool library. 38594642e01fSmrg dlname= 38604642e01fSmrg library_names= 38614642e01fSmrg func_source "$file" 386205b261ecSmrg 38634642e01fSmrg # Skip this library if it cannot be dlopened. 38644642e01fSmrg if test -z "$dlname"; then 38654642e01fSmrg # Warn if it was a shared library. 38664642e01fSmrg test -n "$library_names" && \ 386735c4bbdfSmrg func_warning "'$file' was not linked with '-export-dynamic'" 38684642e01fSmrg continue 38694642e01fSmrg fi 387005b261ecSmrg 38714642e01fSmrg func_dirname "$file" "" "." 387235c4bbdfSmrg dir=$func_dirname_result 387305b261ecSmrg 38744642e01fSmrg if test -f "$dir/$objdir/$dlname"; then 387535c4bbdfSmrg func_append dir "/$objdir" 38764642e01fSmrg else 38774642e01fSmrg if test ! -f "$dir/$dlname"; then 387835c4bbdfSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 38794642e01fSmrg fi 38804642e01fSmrg fi 388105b261ecSmrg ;; 388205b261ecSmrg 38834642e01fSmrg *.lo) 38844642e01fSmrg # Just add the directory containing the .lo file. 38854642e01fSmrg func_dirname "$file" "" "." 388635c4bbdfSmrg dir=$func_dirname_result 388705b261ecSmrg ;; 388805b261ecSmrg 38894642e01fSmrg *) 389035c4bbdfSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 389105b261ecSmrg continue 389205b261ecSmrg ;; 38934642e01fSmrg esac 389405b261ecSmrg 38954642e01fSmrg # Get the absolute pathname. 38964642e01fSmrg absdir=`cd "$dir" && pwd` 389735c4bbdfSmrg test -n "$absdir" && dir=$absdir 389805b261ecSmrg 38994642e01fSmrg # Now add the directory to shlibpath_var. 39004642e01fSmrg if eval "test -z \"\$$shlibpath_var\""; then 39014642e01fSmrg eval "$shlibpath_var=\"\$dir\"" 39024642e01fSmrg else 39034642e01fSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 39044642e01fSmrg fi 39054642e01fSmrg done 390605b261ecSmrg 39074642e01fSmrg # This variable tells wrapper scripts just to set shlibpath_var 39084642e01fSmrg # rather than running their programs. 390935c4bbdfSmrg libtool_execute_magic=$magic 391005b261ecSmrg 39114642e01fSmrg # Check if any of the arguments is a wrapper script. 39124642e01fSmrg args= 39134642e01fSmrg for file 39144642e01fSmrg do 39154642e01fSmrg case $file in 39166747b715Smrg -* | *.la | *.lo ) ;; 39174642e01fSmrg *) 39184642e01fSmrg # Do a test to see if this is really a libtool program. 39194642e01fSmrg if func_ltwrapper_script_p "$file"; then 39204642e01fSmrg func_source "$file" 39214642e01fSmrg # Transform arg to wrapped name. 392235c4bbdfSmrg file=$progdir/$program 39234642e01fSmrg elif func_ltwrapper_executable_p "$file"; then 39244642e01fSmrg func_ltwrapper_scriptname "$file" 39254642e01fSmrg func_source "$func_ltwrapper_scriptname_result" 39264642e01fSmrg # Transform arg to wrapped name. 392735c4bbdfSmrg file=$progdir/$program 39284642e01fSmrg fi 39294642e01fSmrg ;; 39304642e01fSmrg esac 39314642e01fSmrg # Quote arguments (to preserve shell metacharacters). 393235c4bbdfSmrg func_append_quoted args "$file" 39334642e01fSmrg done 393405b261ecSmrg 393535c4bbdfSmrg if $opt_dry_run; then 393635c4bbdfSmrg # Display what would be done. 393735c4bbdfSmrg if test -n "$shlibpath_var"; then 393835c4bbdfSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393935c4bbdfSmrg echo "export $shlibpath_var" 394035c4bbdfSmrg fi 394135c4bbdfSmrg $ECHO "$cmd$args" 394235c4bbdfSmrg exit $EXIT_SUCCESS 394335c4bbdfSmrg else 39444642e01fSmrg if test -n "$shlibpath_var"; then 39454642e01fSmrg # Export the shlibpath_var. 39464642e01fSmrg eval "export $shlibpath_var" 39474642e01fSmrg fi 394805b261ecSmrg 39494642e01fSmrg # Restore saved environment variables 39504642e01fSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 39514642e01fSmrg do 39524642e01fSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 39534642e01fSmrg $lt_var=\$save_$lt_var; export $lt_var 395405b261ecSmrg else 39554642e01fSmrg $lt_unset $lt_var 39564642e01fSmrg fi" 39574642e01fSmrg done 395805b261ecSmrg 39594642e01fSmrg # Now prepare to actually exec the command. 396035c4bbdfSmrg exec_cmd=\$cmd$args 39614642e01fSmrg fi 39624642e01fSmrg} 396305b261ecSmrg 396435c4bbdfSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 396505b261ecSmrg 396605b261ecSmrg 39674642e01fSmrg# func_mode_finish arg... 39684642e01fSmrgfunc_mode_finish () 39694642e01fSmrg{ 397035c4bbdfSmrg $debug_cmd 397135c4bbdfSmrg 397235c4bbdfSmrg libs= 397335c4bbdfSmrg libdirs= 39744642e01fSmrg admincmds= 397505b261ecSmrg 397635c4bbdfSmrg for opt in "$nonopt" ${1+"$@"} 397735c4bbdfSmrg do 397835c4bbdfSmrg if test -d "$opt"; then 397935c4bbdfSmrg func_append libdirs " $opt" 398035c4bbdfSmrg 398135c4bbdfSmrg elif test -f "$opt"; then 398235c4bbdfSmrg if func_lalib_unsafe_p "$opt"; then 398335c4bbdfSmrg func_append libs " $opt" 398435c4bbdfSmrg else 398535c4bbdfSmrg func_warning "'$opt' is not a valid libtool archive" 398635c4bbdfSmrg fi 398735c4bbdfSmrg 398835c4bbdfSmrg else 398935c4bbdfSmrg func_fatal_error "invalid argument '$opt'" 399035c4bbdfSmrg fi 399135c4bbdfSmrg done 399235c4bbdfSmrg 399335c4bbdfSmrg if test -n "$libs"; then 399435c4bbdfSmrg if test -n "$lt_sysroot"; then 399535c4bbdfSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399635c4bbdfSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399735c4bbdfSmrg else 399835c4bbdfSmrg sysroot_cmd= 399935c4bbdfSmrg fi 4000475c125cSmrg 400135c4bbdfSmrg # Remove sysroot references 400235c4bbdfSmrg if $opt_dry_run; then 400335c4bbdfSmrg for lib in $libs; do 400435c4bbdfSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400535c4bbdfSmrg done 400635c4bbdfSmrg else 400735c4bbdfSmrg tmpdir=`func_mktempdir` 400835c4bbdfSmrg for lib in $libs; do 400935c4bbdfSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401035c4bbdfSmrg > $tmpdir/tmp-la 401135c4bbdfSmrg mv -f $tmpdir/tmp-la $lib 401235c4bbdfSmrg done 401335c4bbdfSmrg ${RM}r "$tmpdir" 401435c4bbdfSmrg fi 401535c4bbdfSmrg fi 401635c4bbdfSmrg 401735c4bbdfSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40184642e01fSmrg for libdir in $libdirs; do 40194642e01fSmrg if test -n "$finish_cmds"; then 40204642e01fSmrg # Do each command in the finish commands. 40214642e01fSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 40224642e01fSmrg'"$cmd"'"' 402305b261ecSmrg fi 40244642e01fSmrg if test -n "$finish_eval"; then 40254642e01fSmrg # Do the single finish_eval. 40264642e01fSmrg eval cmds=\"$finish_eval\" 402735c4bbdfSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 40284642e01fSmrg $cmds" 40294642e01fSmrg fi 40304642e01fSmrg done 40314642e01fSmrg fi 403205b261ecSmrg 40334642e01fSmrg # Exit here if they wanted silent mode. 403435c4bbdfSmrg $opt_quiet && exit $EXIT_SUCCESS 403505b261ecSmrg 403635c4bbdfSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403735c4bbdfSmrg echo "----------------------------------------------------------------------" 403835c4bbdfSmrg echo "Libraries have been installed in:" 403935c4bbdfSmrg for libdir in $libdirs; do 404035c4bbdfSmrg $ECHO " $libdir" 404135c4bbdfSmrg done 404235c4bbdfSmrg echo 404335c4bbdfSmrg echo "If you ever happen to want to link against installed libraries" 404435c4bbdfSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404535c4bbdfSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404635c4bbdfSmrg echo "flag during linking and do at least one of the following:" 404735c4bbdfSmrg if test -n "$shlibpath_var"; then 404835c4bbdfSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404935c4bbdfSmrg echo " during execution" 405035c4bbdfSmrg fi 405135c4bbdfSmrg if test -n "$runpath_var"; then 405235c4bbdfSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405335c4bbdfSmrg echo " during linking" 405435c4bbdfSmrg fi 405535c4bbdfSmrg if test -n "$hardcode_libdir_flag_spec"; then 405635c4bbdfSmrg libdir=LIBDIR 405735c4bbdfSmrg eval flag=\"$hardcode_libdir_flag_spec\" 40584642e01fSmrg 405935c4bbdfSmrg $ECHO " - use the '$flag' linker flag" 406035c4bbdfSmrg fi 406135c4bbdfSmrg if test -n "$admincmds"; then 406235c4bbdfSmrg $ECHO " - have your system administrator run these commands:$admincmds" 406335c4bbdfSmrg fi 406435c4bbdfSmrg if test -f /etc/ld.so.conf; then 406535c4bbdfSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406635c4bbdfSmrg fi 406735c4bbdfSmrg echo 4068475c125cSmrg 406935c4bbdfSmrg echo "See any operating system documentation about shared libraries for" 407035c4bbdfSmrg case $host in 407135c4bbdfSmrg solaris2.[6789]|solaris2.1[0-9]) 407235c4bbdfSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407335c4bbdfSmrg echo "pages." 407435c4bbdfSmrg ;; 407535c4bbdfSmrg *) 407635c4bbdfSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 407735c4bbdfSmrg ;; 407835c4bbdfSmrg esac 407935c4bbdfSmrg echo "----------------------------------------------------------------------" 408035c4bbdfSmrg fi 40814642e01fSmrg exit $EXIT_SUCCESS 40824642e01fSmrg} 40834642e01fSmrg 408435c4bbdfSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 40854642e01fSmrg 40864642e01fSmrg 40874642e01fSmrg# func_mode_install arg... 40884642e01fSmrgfunc_mode_install () 40894642e01fSmrg{ 409035c4bbdfSmrg $debug_cmd 409135c4bbdfSmrg 40924642e01fSmrg # There may be an optional sh(1) argument at the beginning of 40934642e01fSmrg # install_prog (especially on Windows NT). 409435c4bbdfSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 40954642e01fSmrg # Allow the use of GNU shtool's install command. 409635c4bbdfSmrg case $nonopt in *shtool*) :;; *) false;; esac 409735c4bbdfSmrg then 40984642e01fSmrg # Aesthetically quote it. 40994642e01fSmrg func_quote_for_eval "$nonopt" 41004642e01fSmrg install_prog="$func_quote_for_eval_result " 41014642e01fSmrg arg=$1 41024642e01fSmrg shift 41034642e01fSmrg else 41044642e01fSmrg install_prog= 41054642e01fSmrg arg=$nonopt 41064642e01fSmrg fi 41074642e01fSmrg 41084642e01fSmrg # The real first argument should be the name of the installation program. 41094642e01fSmrg # Aesthetically quote it. 41104642e01fSmrg func_quote_for_eval "$arg" 411135c4bbdfSmrg func_append install_prog "$func_quote_for_eval_result" 41126747b715Smrg install_shared_prog=$install_prog 41136747b715Smrg case " $install_prog " in 41146747b715Smrg *[\\\ /]cp\ *) install_cp=: ;; 41156747b715Smrg *) install_cp=false ;; 41166747b715Smrg esac 41174642e01fSmrg 41184642e01fSmrg # We need to accept at least all the BSD install flags. 41194642e01fSmrg dest= 41204642e01fSmrg files= 41214642e01fSmrg opts= 41224642e01fSmrg prev= 41234642e01fSmrg install_type= 412435c4bbdfSmrg isdir=false 41254642e01fSmrg stripme= 41266747b715Smrg no_mode=: 41274642e01fSmrg for arg 41284642e01fSmrg do 41296747b715Smrg arg2= 41304642e01fSmrg if test -n "$dest"; then 413135c4bbdfSmrg func_append files " $dest" 41324642e01fSmrg dest=$arg 41334642e01fSmrg continue 41344642e01fSmrg fi 41354642e01fSmrg 41364642e01fSmrg case $arg in 413735c4bbdfSmrg -d) isdir=: ;; 41384642e01fSmrg -f) 41396747b715Smrg if $install_cp; then :; else 41406747b715Smrg prev=$arg 41416747b715Smrg fi 41424642e01fSmrg ;; 41434642e01fSmrg -g | -m | -o) 41444642e01fSmrg prev=$arg 41454642e01fSmrg ;; 41464642e01fSmrg -s) 41474642e01fSmrg stripme=" -s" 41484642e01fSmrg continue 41494642e01fSmrg ;; 41504642e01fSmrg -*) 41514642e01fSmrg ;; 41524642e01fSmrg *) 41534642e01fSmrg # If the previous option needed an argument, then skip it. 41544642e01fSmrg if test -n "$prev"; then 415535c4bbdfSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 41566747b715Smrg arg2=$install_override_mode 41576747b715Smrg no_mode=false 41586747b715Smrg fi 415905b261ecSmrg prev= 416005b261ecSmrg else 41614642e01fSmrg dest=$arg 41624642e01fSmrg continue 416305b261ecSmrg fi 416405b261ecSmrg ;; 41654642e01fSmrg esac 416605b261ecSmrg 41674642e01fSmrg # Aesthetically quote the argument. 41684642e01fSmrg func_quote_for_eval "$arg" 416935c4bbdfSmrg func_append install_prog " $func_quote_for_eval_result" 41706747b715Smrg if test -n "$arg2"; then 41716747b715Smrg func_quote_for_eval "$arg2" 41726747b715Smrg fi 417335c4bbdfSmrg func_append install_shared_prog " $func_quote_for_eval_result" 41744642e01fSmrg done 417505b261ecSmrg 41764642e01fSmrg test -z "$install_prog" && \ 41774642e01fSmrg func_fatal_help "you must specify an install program" 417805b261ecSmrg 41794642e01fSmrg test -n "$prev" && \ 418035c4bbdfSmrg func_fatal_help "the '$prev' option requires an argument" 418105b261ecSmrg 41826747b715Smrg if test -n "$install_override_mode" && $no_mode; then 41836747b715Smrg if $install_cp; then :; else 41846747b715Smrg func_quote_for_eval "$install_override_mode" 418535c4bbdfSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 41866747b715Smrg fi 41876747b715Smrg fi 41886747b715Smrg 41894642e01fSmrg if test -z "$files"; then 41904642e01fSmrg if test -z "$dest"; then 41914642e01fSmrg func_fatal_help "no file or destination specified" 41924642e01fSmrg else 41934642e01fSmrg func_fatal_help "you must specify a destination" 41944642e01fSmrg fi 419505b261ecSmrg fi 419605b261ecSmrg 41974642e01fSmrg # Strip any trailing slash from the destination. 41984642e01fSmrg func_stripname '' '/' "$dest" 41994642e01fSmrg dest=$func_stripname_result 420005b261ecSmrg 42014642e01fSmrg # Check to see that the destination is a directory. 420235c4bbdfSmrg test -d "$dest" && isdir=: 420335c4bbdfSmrg if $isdir; then 420435c4bbdfSmrg destdir=$dest 42054642e01fSmrg destname= 420605b261ecSmrg else 42074642e01fSmrg func_dirname_and_basename "$dest" "" "." 420835c4bbdfSmrg destdir=$func_dirname_result 420935c4bbdfSmrg destname=$func_basename_result 421005b261ecSmrg 42114642e01fSmrg # Not a directory, so check to see that there is only one file specified. 42124642e01fSmrg set dummy $files; shift 42134642e01fSmrg test "$#" -gt 1 && \ 421435c4bbdfSmrg func_fatal_help "'$dest' is not a directory" 421505b261ecSmrg fi 42164642e01fSmrg case $destdir in 42174642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 421805b261ecSmrg *) 42194642e01fSmrg for file in $files; do 42204642e01fSmrg case $file in 42214642e01fSmrg *.lo) ;; 42224642e01fSmrg *) 422335c4bbdfSmrg func_fatal_help "'$destdir' must be an absolute directory name" 42244642e01fSmrg ;; 42254642e01fSmrg esac 42264642e01fSmrg done 422705b261ecSmrg ;; 422805b261ecSmrg esac 422905b261ecSmrg 42304642e01fSmrg # This variable tells wrapper scripts just to set variables rather 42314642e01fSmrg # than running their programs. 423235c4bbdfSmrg libtool_install_magic=$magic 423305b261ecSmrg 42344642e01fSmrg staticlibs= 42354642e01fSmrg future_libdirs= 42364642e01fSmrg current_libdirs= 42374642e01fSmrg for file in $files; do 423805b261ecSmrg 42394642e01fSmrg # Do each installation. 42404642e01fSmrg case $file in 42414642e01fSmrg *.$libext) 42424642e01fSmrg # Do the static libraries later. 424335c4bbdfSmrg func_append staticlibs " $file" 42444642e01fSmrg ;; 42454642e01fSmrg 42464642e01fSmrg *.la) 424735c4bbdfSmrg func_resolve_sysroot "$file" 424835c4bbdfSmrg file=$func_resolve_sysroot_result 424935c4bbdfSmrg 42504642e01fSmrg # Check to see that this really is a libtool archive. 42514642e01fSmrg func_lalib_unsafe_p "$file" \ 425235c4bbdfSmrg || func_fatal_help "'$file' is not a valid libtool archive" 42534642e01fSmrg 42544642e01fSmrg library_names= 42554642e01fSmrg old_library= 42564642e01fSmrg relink_command= 42574642e01fSmrg func_source "$file" 42584642e01fSmrg 42594642e01fSmrg # Add the libdir to current_libdirs if it is the destination. 42604642e01fSmrg if test "X$destdir" = "X$libdir"; then 42614642e01fSmrg case "$current_libdirs " in 42624642e01fSmrg *" $libdir "*) ;; 426335c4bbdfSmrg *) func_append current_libdirs " $libdir" ;; 426405b261ecSmrg esac 42654642e01fSmrg else 42664642e01fSmrg # Note the libdir as a future libdir. 42674642e01fSmrg case "$future_libdirs " in 42684642e01fSmrg *" $libdir "*) ;; 426935c4bbdfSmrg *) func_append future_libdirs " $libdir" ;; 42704642e01fSmrg esac 42714642e01fSmrg fi 427205b261ecSmrg 42734642e01fSmrg func_dirname "$file" "/" "" 427435c4bbdfSmrg dir=$func_dirname_result 427535c4bbdfSmrg func_append dir "$objdir" 42764642e01fSmrg 42774642e01fSmrg if test -n "$relink_command"; then 42784642e01fSmrg # Determine the prefix the user has applied to our future dir. 42796747b715Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 42804642e01fSmrg 42814642e01fSmrg # Don't allow the user to place us outside of our expected 42824642e01fSmrg # location b/c this prevents finding dependent libraries that 42834642e01fSmrg # are installed to the same prefix. 42844642e01fSmrg # At present, this check doesn't affect windows .dll's that 42854642e01fSmrg # are installed into $libdir/../bin (currently, that works fine) 42864642e01fSmrg # but it's something to keep an eye on. 42874642e01fSmrg test "$inst_prefix_dir" = "$destdir" && \ 428835c4bbdfSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 42894642e01fSmrg 42904642e01fSmrg if test -n "$inst_prefix_dir"; then 42914642e01fSmrg # Stick the inst_prefix_dir data into the link command. 42926747b715Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 42934642e01fSmrg else 42946747b715Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 42954642e01fSmrg fi 42964642e01fSmrg 429735c4bbdfSmrg func_warning "relinking '$file'" 42984642e01fSmrg func_show_eval "$relink_command" \ 429935c4bbdfSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 43004642e01fSmrg fi 43014642e01fSmrg 43024642e01fSmrg # See the names of the shared library. 43034642e01fSmrg set dummy $library_names; shift 43044642e01fSmrg if test -n "$1"; then 430535c4bbdfSmrg realname=$1 43064642e01fSmrg shift 43074642e01fSmrg 430835c4bbdfSmrg srcname=$realname 430935c4bbdfSmrg test -n "$relink_command" && srcname=${realname}T 43104642e01fSmrg 43114642e01fSmrg # Install the shared library and build the symlinks. 43126747b715Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 43134642e01fSmrg 'exit $?' 431435c4bbdfSmrg tstripme=$stripme 43154642e01fSmrg case $host_os in 43164642e01fSmrg cygwin* | mingw* | pw32* | cegcc*) 43174642e01fSmrg case $realname in 43184642e01fSmrg *.dll.a) 431935c4bbdfSmrg tstripme= 432035c4bbdfSmrg ;; 432135c4bbdfSmrg esac 432235c4bbdfSmrg ;; 432335c4bbdfSmrg os2*) 432435c4bbdfSmrg case $realname in 432535c4bbdfSmrg *_dll.a) 432635c4bbdfSmrg tstripme= 43274642e01fSmrg ;; 43284642e01fSmrg esac 432905b261ecSmrg ;; 433005b261ecSmrg esac 43314642e01fSmrg if test -n "$tstripme" && test -n "$striplib"; then 43324642e01fSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 433305b261ecSmrg fi 43344642e01fSmrg 43354642e01fSmrg if test "$#" -gt 0; then 43364642e01fSmrg # Delete the old symlinks, and create new ones. 433735c4bbdfSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 43384642e01fSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 43394642e01fSmrg # so we also need to try rm && ln -s. 43404642e01fSmrg for linkname 43414642e01fSmrg do 43424642e01fSmrg test "$linkname" != "$realname" \ 43434642e01fSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 434405b261ecSmrg done 434505b261ecSmrg fi 434605b261ecSmrg 43474642e01fSmrg # Do each command in the postinstall commands. 434835c4bbdfSmrg lib=$destdir/$realname 43494642e01fSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 435005b261ecSmrg fi 435105b261ecSmrg 43524642e01fSmrg # Install the pseudo-library for information purposes. 43534642e01fSmrg func_basename "$file" 435435c4bbdfSmrg name=$func_basename_result 435535c4bbdfSmrg instname=$dir/${name}i 43564642e01fSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 435705b261ecSmrg 43584642e01fSmrg # Maybe install the static library, too. 435935c4bbdfSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 43604642e01fSmrg ;; 436105b261ecSmrg 43624642e01fSmrg *.lo) 43634642e01fSmrg # Install (i.e. copy) a libtool object. 436405b261ecSmrg 43654642e01fSmrg # Figure out destination file name, if it wasn't already specified. 43664642e01fSmrg if test -n "$destname"; then 436735c4bbdfSmrg destfile=$destdir/$destname 43684642e01fSmrg else 43694642e01fSmrg func_basename "$file" 437035c4bbdfSmrg destfile=$func_basename_result 437135c4bbdfSmrg destfile=$destdir/$destfile 43724642e01fSmrg fi 43734642e01fSmrg 43744642e01fSmrg # Deduce the name of the destination old-style object file. 43754642e01fSmrg case $destfile in 43764642e01fSmrg *.lo) 43774642e01fSmrg func_lo2o "$destfile" 43784642e01fSmrg staticdest=$func_lo2o_result 43794642e01fSmrg ;; 43804642e01fSmrg *.$objext) 438135c4bbdfSmrg staticdest=$destfile 43824642e01fSmrg destfile= 43834642e01fSmrg ;; 43844642e01fSmrg *) 438535c4bbdfSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 43864642e01fSmrg ;; 438705b261ecSmrg esac 438805b261ecSmrg 43894642e01fSmrg # Install the libtool object if requested. 43904642e01fSmrg test -n "$destfile" && \ 43914642e01fSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 43924642e01fSmrg 43934642e01fSmrg # Install the old object if enabled. 439435c4bbdfSmrg if test yes = "$build_old_libs"; then 43954642e01fSmrg # Deduce the name of the old-style object file. 43964642e01fSmrg func_lo2o "$file" 43974642e01fSmrg staticobj=$func_lo2o_result 43984642e01fSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439905b261ecSmrg fi 44004642e01fSmrg exit $EXIT_SUCCESS 44014642e01fSmrg ;; 440205b261ecSmrg 44034642e01fSmrg *) 44044642e01fSmrg # Figure out destination file name, if it wasn't already specified. 44054642e01fSmrg if test -n "$destname"; then 440635c4bbdfSmrg destfile=$destdir/$destname 44074642e01fSmrg else 44084642e01fSmrg func_basename "$file" 440935c4bbdfSmrg destfile=$func_basename_result 441035c4bbdfSmrg destfile=$destdir/$destfile 44114642e01fSmrg fi 441205b261ecSmrg 44134642e01fSmrg # If the file is missing, and there is a .exe on the end, strip it 44144642e01fSmrg # because it is most likely a libtool script we actually want to 44154642e01fSmrg # install 441635c4bbdfSmrg stripped_ext= 44174642e01fSmrg case $file in 44184642e01fSmrg *.exe) 44194642e01fSmrg if test ! -f "$file"; then 44204642e01fSmrg func_stripname '' '.exe' "$file" 44214642e01fSmrg file=$func_stripname_result 442235c4bbdfSmrg stripped_ext=.exe 44234642e01fSmrg fi 44244642e01fSmrg ;; 44254642e01fSmrg esac 442605b261ecSmrg 44274642e01fSmrg # Do a test to see if this is really a libtool program. 44284642e01fSmrg case $host in 44294642e01fSmrg *cygwin* | *mingw*) 44304642e01fSmrg if func_ltwrapper_executable_p "$file"; then 44314642e01fSmrg func_ltwrapper_scriptname "$file" 44324642e01fSmrg wrapper=$func_ltwrapper_scriptname_result 44334642e01fSmrg else 44344642e01fSmrg func_stripname '' '.exe' "$file" 44354642e01fSmrg wrapper=$func_stripname_result 44364642e01fSmrg fi 44374642e01fSmrg ;; 44384642e01fSmrg *) 44394642e01fSmrg wrapper=$file 44404642e01fSmrg ;; 44414642e01fSmrg esac 44424642e01fSmrg if func_ltwrapper_script_p "$wrapper"; then 44434642e01fSmrg notinst_deplibs= 44444642e01fSmrg relink_command= 444505b261ecSmrg 44464642e01fSmrg func_source "$wrapper" 44474642e01fSmrg 44484642e01fSmrg # Check the variables that should have been set. 44494642e01fSmrg test -z "$generated_by_libtool_version" && \ 445035c4bbdfSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 44514642e01fSmrg 445235c4bbdfSmrg finalize=: 44534642e01fSmrg for lib in $notinst_deplibs; do 44544642e01fSmrg # Check to see that each library is installed. 44554642e01fSmrg libdir= 44564642e01fSmrg if test -f "$lib"; then 44574642e01fSmrg func_source "$lib" 44584642e01fSmrg fi 445935c4bbdfSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 44604642e01fSmrg if test -n "$libdir" && test ! -f "$libfile"; then 446135c4bbdfSmrg func_warning "'$lib' has not been installed in '$libdir'" 446235c4bbdfSmrg finalize=false 44634642e01fSmrg fi 44644642e01fSmrg done 44654642e01fSmrg 44664642e01fSmrg relink_command= 44674642e01fSmrg func_source "$wrapper" 44684642e01fSmrg 44694642e01fSmrg outputname= 447035c4bbdfSmrg if test no = "$fast_install" && test -n "$relink_command"; then 44714642e01fSmrg $opt_dry_run || { 447235c4bbdfSmrg if $finalize; then 44734642e01fSmrg tmpdir=`func_mktempdir` 44744642e01fSmrg func_basename "$file$stripped_ext" 447535c4bbdfSmrg file=$func_basename_result 447635c4bbdfSmrg outputname=$tmpdir/$file 44774642e01fSmrg # Replace the output file specification. 44786747b715Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 44794642e01fSmrg 448035c4bbdfSmrg $opt_quiet || { 44814642e01fSmrg func_quote_for_expand "$relink_command" 44824642e01fSmrg eval "func_echo $func_quote_for_expand_result" 44834642e01fSmrg } 44844642e01fSmrg if eval "$relink_command"; then : 44854642e01fSmrg else 448635c4bbdfSmrg func_error "error: relink '$file' with the above command before installing it" 44874642e01fSmrg $opt_dry_run || ${RM}r "$tmpdir" 44884642e01fSmrg continue 44894642e01fSmrg fi 449035c4bbdfSmrg file=$outputname 44914642e01fSmrg else 449235c4bbdfSmrg func_warning "cannot relink '$file'" 44934642e01fSmrg fi 44944642e01fSmrg } 449505b261ecSmrg else 44964642e01fSmrg # Install the binary that we compiled earlier. 44976747b715Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 449805b261ecSmrg fi 44994642e01fSmrg fi 450005b261ecSmrg 45014642e01fSmrg # remove .exe since cygwin /usr/bin/install will append another 45024642e01fSmrg # one anyway 45034642e01fSmrg case $install_prog,$host in 45044642e01fSmrg */usr/bin/install*,*cygwin*) 45054642e01fSmrg case $file:$destfile in 45064642e01fSmrg *.exe:*.exe) 45074642e01fSmrg # this is ok 45084642e01fSmrg ;; 45094642e01fSmrg *.exe:*) 45104642e01fSmrg destfile=$destfile.exe 45114642e01fSmrg ;; 45124642e01fSmrg *:*.exe) 45134642e01fSmrg func_stripname '' '.exe' "$destfile" 45144642e01fSmrg destfile=$func_stripname_result 45154642e01fSmrg ;; 45164642e01fSmrg esac 451705b261ecSmrg ;; 451805b261ecSmrg esac 45194642e01fSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 45204642e01fSmrg $opt_dry_run || if test -n "$outputname"; then 45214642e01fSmrg ${RM}r "$tmpdir" 45224642e01fSmrg fi 45234642e01fSmrg ;; 45244642e01fSmrg esac 45254642e01fSmrg done 452605b261ecSmrg 45274642e01fSmrg for file in $staticlibs; do 45284642e01fSmrg func_basename "$file" 452935c4bbdfSmrg name=$func_basename_result 45304642e01fSmrg 45314642e01fSmrg # Set up the ranlib parameters. 453235c4bbdfSmrg oldlib=$destdir/$name 453335c4bbdfSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 453435c4bbdfSmrg tool_oldlib=$func_to_tool_file_result 45354642e01fSmrg 45364642e01fSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45374642e01fSmrg 45384642e01fSmrg if test -n "$stripme" && test -n "$old_striplib"; then 453935c4bbdfSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 45404642e01fSmrg fi 45414642e01fSmrg 45424642e01fSmrg # Do each command in the postinstall commands. 45434642e01fSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 45444642e01fSmrg done 45454642e01fSmrg 45464642e01fSmrg test -n "$future_libdirs" && \ 454735c4bbdfSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 45484642e01fSmrg 45494642e01fSmrg if test -n "$current_libdirs"; then 45504642e01fSmrg # Maybe just do a dry run. 45514642e01fSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455235c4bbdfSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 45534642e01fSmrg else 45544642e01fSmrg exit $EXIT_SUCCESS 45554642e01fSmrg fi 45564642e01fSmrg} 45574642e01fSmrg 455835c4bbdfSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45594642e01fSmrg 45604642e01fSmrg 45614642e01fSmrg# func_generate_dlsyms outputname originator pic_p 45624642e01fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 45634642e01fSmrg# a dlpreopen symbol table. 45644642e01fSmrgfunc_generate_dlsyms () 45654642e01fSmrg{ 456635c4bbdfSmrg $debug_cmd 456735c4bbdfSmrg 456835c4bbdfSmrg my_outputname=$1 456935c4bbdfSmrg my_originator=$2 457035c4bbdfSmrg my_pic_p=${3-false} 457135c4bbdfSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 45724642e01fSmrg my_dlsyms= 45734642e01fSmrg 457435c4bbdfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 45754642e01fSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457635c4bbdfSmrg my_dlsyms=${my_outputname}S.c 45774642e01fSmrg else 45784642e01fSmrg func_error "not configured to extract global symbols from dlpreopened files" 45794642e01fSmrg fi 45804642e01fSmrg fi 45814642e01fSmrg 45824642e01fSmrg if test -n "$my_dlsyms"; then 45834642e01fSmrg case $my_dlsyms in 45844642e01fSmrg "") ;; 45854642e01fSmrg *.c) 45864642e01fSmrg # Discover the nlist of each of the dlfiles. 458735c4bbdfSmrg nlist=$output_objdir/$my_outputname.nm 45884642e01fSmrg 45894642e01fSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 45904642e01fSmrg 45914642e01fSmrg # Parse the name list into a source file. 45924642e01fSmrg func_verbose "creating $output_objdir/$my_dlsyms" 45934642e01fSmrg 45944642e01fSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459535c4bbdfSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459635c4bbdfSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 45974642e01fSmrg 45984642e01fSmrg#ifdef __cplusplus 45994642e01fSmrgextern \"C\" { 46004642e01fSmrg#endif 46014642e01fSmrg 460235c4bbdfSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 46036747b715Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 46046747b715Smrg#endif 46056747b715Smrg 460635c4bbdfSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460735c4bbdfSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460835c4bbdfSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460935c4bbdfSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461035c4bbdfSmrg# define LT_DLSYM_CONST 461135c4bbdfSmrg#elif defined __osf__ 461235c4bbdfSmrg/* This system does not cope well with relocations in const data. */ 461335c4bbdfSmrg# define LT_DLSYM_CONST 461435c4bbdfSmrg#else 461535c4bbdfSmrg# define LT_DLSYM_CONST const 461635c4bbdfSmrg#endif 461735c4bbdfSmrg 461835c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461935c4bbdfSmrg 46204642e01fSmrg/* External symbol declarations for the compiler. */\ 46214642e01fSmrg" 46224642e01fSmrg 462335c4bbdfSmrg if test yes = "$dlself"; then 462435c4bbdfSmrg func_verbose "generating symbol list for '$output'" 46254642e01fSmrg 46264642e01fSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 46274642e01fSmrg 46284642e01fSmrg # Add our own program objects to the symbol list. 46296747b715Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 46304642e01fSmrg for progfile in $progfiles; do 463135c4bbdfSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463235c4bbdfSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463335c4bbdfSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 46344642e01fSmrg done 46354642e01fSmrg 46364642e01fSmrg if test -n "$exclude_expsyms"; then 46374642e01fSmrg $opt_dry_run || { 46384642e01fSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 46394642e01fSmrg eval '$MV "$nlist"T "$nlist"' 46404642e01fSmrg } 464105b261ecSmrg fi 46424642e01fSmrg 46434642e01fSmrg if test -n "$export_symbols_regex"; then 46444642e01fSmrg $opt_dry_run || { 46454642e01fSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 46464642e01fSmrg eval '$MV "$nlist"T "$nlist"' 46474642e01fSmrg } 46484642e01fSmrg fi 46494642e01fSmrg 46504642e01fSmrg # Prepare the list of exported symbols 46514642e01fSmrg if test -z "$export_symbols"; then 465235c4bbdfSmrg export_symbols=$output_objdir/$outputname.exp 46534642e01fSmrg $opt_dry_run || { 46544642e01fSmrg $RM $export_symbols 465535c4bbdfSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 46564642e01fSmrg case $host in 46574642e01fSmrg *cygwin* | *mingw* | *cegcc* ) 46584642e01fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46594642e01fSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 46604642e01fSmrg ;; 46614642e01fSmrg esac 46624642e01fSmrg } 466305b261ecSmrg else 46644642e01fSmrg $opt_dry_run || { 466535c4bbdfSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 46664642e01fSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 46674642e01fSmrg eval '$MV "$nlist"T "$nlist"' 46684642e01fSmrg case $host in 46696747b715Smrg *cygwin* | *mingw* | *cegcc* ) 46704642e01fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46714642e01fSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 46724642e01fSmrg ;; 46734642e01fSmrg esac 46744642e01fSmrg } 467505b261ecSmrg fi 46764642e01fSmrg fi 467705b261ecSmrg 46784642e01fSmrg for dlprefile in $dlprefiles; do 467935c4bbdfSmrg func_verbose "extracting global C symbols from '$dlprefile'" 46804642e01fSmrg func_basename "$dlprefile" 468135c4bbdfSmrg name=$func_basename_result 468235c4bbdfSmrg case $host in 468335c4bbdfSmrg *cygwin* | *mingw* | *cegcc* ) 468435c4bbdfSmrg # if an import library, we need to obtain dlname 468535c4bbdfSmrg if func_win32_import_lib_p "$dlprefile"; then 468635c4bbdfSmrg func_tr_sh "$dlprefile" 468735c4bbdfSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468835c4bbdfSmrg dlprefile_dlbasename= 468935c4bbdfSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469035c4bbdfSmrg # Use subshell, to avoid clobbering current variable values 469135c4bbdfSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469235c4bbdfSmrg if test -n "$dlprefile_dlname"; then 469335c4bbdfSmrg func_basename "$dlprefile_dlname" 469435c4bbdfSmrg dlprefile_dlbasename=$func_basename_result 469535c4bbdfSmrg else 469635c4bbdfSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 469735c4bbdfSmrg $sharedlib_from_linklib_cmd "$dlprefile" 469835c4bbdfSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469935c4bbdfSmrg fi 470035c4bbdfSmrg fi 470135c4bbdfSmrg $opt_dry_run || { 470235c4bbdfSmrg if test -n "$dlprefile_dlbasename"; then 470335c4bbdfSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470435c4bbdfSmrg else 470535c4bbdfSmrg func_warning "Could not compute DLL name from $name" 470635c4bbdfSmrg eval '$ECHO ": $name " >> "$nlist"' 470735c4bbdfSmrg fi 470835c4bbdfSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470935c4bbdfSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471035c4bbdfSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471135c4bbdfSmrg } 471235c4bbdfSmrg else # not an import lib 471335c4bbdfSmrg $opt_dry_run || { 471435c4bbdfSmrg eval '$ECHO ": $name " >> "$nlist"' 471535c4bbdfSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471635c4bbdfSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471735c4bbdfSmrg } 471835c4bbdfSmrg fi 471935c4bbdfSmrg ;; 472035c4bbdfSmrg *) 472135c4bbdfSmrg $opt_dry_run || { 472235c4bbdfSmrg eval '$ECHO ": $name " >> "$nlist"' 472335c4bbdfSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472435c4bbdfSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472535c4bbdfSmrg } 472635c4bbdfSmrg ;; 472735c4bbdfSmrg esac 47284642e01fSmrg done 47294642e01fSmrg 47304642e01fSmrg $opt_dry_run || { 47314642e01fSmrg # Make sure we have at least an empty file. 47324642e01fSmrg test -f "$nlist" || : > "$nlist" 47334642e01fSmrg 47344642e01fSmrg if test -n "$exclude_expsyms"; then 47354642e01fSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 47364642e01fSmrg $MV "$nlist"T "$nlist" 473705b261ecSmrg fi 47384642e01fSmrg 47394642e01fSmrg # Try sorting and uniquifying the output. 47404642e01fSmrg if $GREP -v "^: " < "$nlist" | 47414642e01fSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 47424642e01fSmrg sort -k 3 47434642e01fSmrg else 47444642e01fSmrg sort +2 47454642e01fSmrg fi | 47464642e01fSmrg uniq > "$nlist"S; then 47474642e01fSmrg : 474805b261ecSmrg else 47494642e01fSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 475005b261ecSmrg fi 475105b261ecSmrg 47524642e01fSmrg if test -f "$nlist"S; then 47534642e01fSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 475405b261ecSmrg else 47556747b715Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 475605b261ecSmrg fi 475705b261ecSmrg 475835c4bbdfSmrg func_show_eval '$RM "${nlist}I"' 475935c4bbdfSmrg if test -n "$global_symbol_to_import"; then 476035c4bbdfSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476135c4bbdfSmrg fi 476235c4bbdfSmrg 47636747b715Smrg echo >> "$output_objdir/$my_dlsyms" "\ 476405b261ecSmrg 47654642e01fSmrg/* The mapping between symbol names and symbols. */ 47664642e01fSmrgtypedef struct { 47674642e01fSmrg const char *name; 47684642e01fSmrg void *address; 47694642e01fSmrg} lt_dlsymlist; 477035c4bbdfSmrgextern LT_DLSYM_CONST lt_dlsymlist 477135c4bbdfSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772475c125cSmrg" 477335c4bbdfSmrg 477435c4bbdfSmrg if test -s "$nlist"I; then 4775475c125cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 477635c4bbdfSmrgstatic void lt_syminit(void) 477735c4bbdfSmrg{ 477835c4bbdfSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477935c4bbdfSmrg for (; symbol->name; ++symbol) 478035c4bbdfSmrg {" 478135c4bbdfSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782475c125cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 478335c4bbdfSmrg } 478435c4bbdfSmrg}" 478535c4bbdfSmrg fi 4786475c125cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 478735c4bbdfSmrgLT_DLSYM_CONST lt_dlsymlist 47884642e01fSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 478935c4bbdfSmrg{ {\"$my_originator\", (void *) 0}," 479035c4bbdfSmrg 479135c4bbdfSmrg if test -s "$nlist"I; then 479235c4bbdfSmrg echo >> "$output_objdir/$my_dlsyms" "\ 479335c4bbdfSmrg {\"@INIT@\", (void *) <_syminit}," 479435c4bbdfSmrg fi 479505b261ecSmrg 47964642e01fSmrg case $need_lib_prefix in 47974642e01fSmrg no) 47984642e01fSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 47994642e01fSmrg ;; 48004642e01fSmrg *) 48014642e01fSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 48024642e01fSmrg ;; 48034642e01fSmrg esac 48046747b715Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48054642e01fSmrg {0, (void *) 0} 48064642e01fSmrg}; 480705b261ecSmrg 48084642e01fSmrg/* This works around a problem in FreeBSD linker */ 48094642e01fSmrg#ifdef FREEBSD_WORKAROUND 48104642e01fSmrgstatic const void *lt_preloaded_setup() { 48114642e01fSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 48124642e01fSmrg} 48134642e01fSmrg#endif 48144642e01fSmrg 48154642e01fSmrg#ifdef __cplusplus 48164642e01fSmrg} 48174642e01fSmrg#endif\ 48184642e01fSmrg" 48194642e01fSmrg } # !$opt_dry_run 48204642e01fSmrg 48214642e01fSmrg pic_flag_for_symtable= 48224642e01fSmrg case "$compile_command " in 48234642e01fSmrg *" -static "*) ;; 48244642e01fSmrg *) 48254642e01fSmrg case $host in 48264642e01fSmrg # compiling the symbol table file with pic_flag works around 48274642e01fSmrg # a FreeBSD bug that causes programs to crash when -lm is 48284642e01fSmrg # linked before any other PIC object. But we must not use 48294642e01fSmrg # pic_flag when linking with -static. The problem exists in 48304642e01fSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 483135c4bbdfSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 48324642e01fSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 48334642e01fSmrg *-*-hpux*) 48344642e01fSmrg pic_flag_for_symtable=" $pic_flag" ;; 48354642e01fSmrg *) 483635c4bbdfSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 48374642e01fSmrg ;; 48384642e01fSmrg esac 48394642e01fSmrg ;; 48404642e01fSmrg esac 48414642e01fSmrg symtab_cflags= 48424642e01fSmrg for arg in $LTCFLAGS; do 48434642e01fSmrg case $arg in 48444642e01fSmrg -pie | -fpie | -fPIE) ;; 484535c4bbdfSmrg *) func_append symtab_cflags " $arg" ;; 48464642e01fSmrg esac 48474642e01fSmrg done 484805b261ecSmrg 48494642e01fSmrg # Now compile the dynamic symbol file. 48504642e01fSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 485105b261ecSmrg 48524642e01fSmrg # Clean up the generated files. 485335c4bbdfSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485405b261ecSmrg 48554642e01fSmrg # Transform the symbol file into the correct name. 485635c4bbdfSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 48574642e01fSmrg case $host in 48584642e01fSmrg *cygwin* | *mingw* | *cegcc* ) 48594642e01fSmrg if test -f "$output_objdir/$my_outputname.def"; then 48606747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48616747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48624642e01fSmrg else 48636747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48646747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486505b261ecSmrg fi 48664642e01fSmrg ;; 48674642e01fSmrg *) 48686747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48696747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48704642e01fSmrg ;; 48714642e01fSmrg esac 48724642e01fSmrg ;; 48734642e01fSmrg *) 487435c4bbdfSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 48754642e01fSmrg ;; 48764642e01fSmrg esac 48774642e01fSmrg else 48784642e01fSmrg # We keep going just in case the user didn't refer to 48794642e01fSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 48804642e01fSmrg # really was required. 488105b261ecSmrg 48824642e01fSmrg # Nullify the symbol file. 48836747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 48846747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48854642e01fSmrg fi 48864642e01fSmrg} 488705b261ecSmrg 488835c4bbdfSmrg# func_cygming_gnu_implib_p ARG 488935c4bbdfSmrg# This predicate returns with zero status (TRUE) if 489035c4bbdfSmrg# ARG is a GNU/binutils-style import library. Returns 489135c4bbdfSmrg# with nonzero status (FALSE) otherwise. 489235c4bbdfSmrgfunc_cygming_gnu_implib_p () 489335c4bbdfSmrg{ 489435c4bbdfSmrg $debug_cmd 489535c4bbdfSmrg 489635c4bbdfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489735c4bbdfSmrg 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)$'` 489835c4bbdfSmrg test -n "$func_cygming_gnu_implib_tmp" 489935c4bbdfSmrg} 490035c4bbdfSmrg 490135c4bbdfSmrg# func_cygming_ms_implib_p ARG 490235c4bbdfSmrg# This predicate returns with zero status (TRUE) if 490335c4bbdfSmrg# ARG is an MS-style import library. Returns 490435c4bbdfSmrg# with nonzero status (FALSE) otherwise. 490535c4bbdfSmrgfunc_cygming_ms_implib_p () 490635c4bbdfSmrg{ 490735c4bbdfSmrg $debug_cmd 490835c4bbdfSmrg 490935c4bbdfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491035c4bbdfSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491135c4bbdfSmrg test -n "$func_cygming_ms_implib_tmp" 491235c4bbdfSmrg} 491335c4bbdfSmrg 49144642e01fSmrg# func_win32_libid arg 49154642e01fSmrg# return the library type of file 'arg' 49164642e01fSmrg# 49174642e01fSmrg# Need a lot of goo to handle *both* DLLs and import libs 49184642e01fSmrg# Has to be a shell function in order to 'eat' the argument 49194642e01fSmrg# that is supplied when $file_magic_command is called. 49206747b715Smrg# Despite the name, also deal with 64 bit binaries. 49214642e01fSmrgfunc_win32_libid () 49224642e01fSmrg{ 492335c4bbdfSmrg $debug_cmd 492435c4bbdfSmrg 492535c4bbdfSmrg win32_libid_type=unknown 49264642e01fSmrg win32_fileres=`file -L $1 2>/dev/null` 49274642e01fSmrg case $win32_fileres in 49284642e01fSmrg *ar\ archive\ import\ library*) # definitely import 49294642e01fSmrg win32_libid_type="x86 archive import" 49304642e01fSmrg ;; 49314642e01fSmrg *ar\ archive*) # could be an import, or static 49326747b715Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 49334642e01fSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 49346747b715Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493535c4bbdfSmrg case $nm_interface in 493635c4bbdfSmrg "MS dumpbin") 493735c4bbdfSmrg if func_cygming_ms_implib_p "$1" || 493835c4bbdfSmrg func_cygming_gnu_implib_p "$1" 493935c4bbdfSmrg then 494035c4bbdfSmrg win32_nmres=import 494135c4bbdfSmrg else 494235c4bbdfSmrg win32_nmres= 494335c4bbdfSmrg fi 494435c4bbdfSmrg ;; 494535c4bbdfSmrg *) 494635c4bbdfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494735c4bbdfSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494835c4bbdfSmrg $SED -n -e ' 49494642e01fSmrg 1,100{ 49504642e01fSmrg / I /{ 495135c4bbdfSmrg s|.*|import| 49524642e01fSmrg p 49534642e01fSmrg q 49544642e01fSmrg } 49554642e01fSmrg }'` 495635c4bbdfSmrg ;; 495735c4bbdfSmrg esac 49584642e01fSmrg case $win32_nmres in 49594642e01fSmrg import*) win32_libid_type="x86 archive import";; 49604642e01fSmrg *) win32_libid_type="x86 archive static";; 49614642e01fSmrg esac 49624642e01fSmrg fi 49634642e01fSmrg ;; 49644642e01fSmrg *DLL*) 49654642e01fSmrg win32_libid_type="x86 DLL" 49664642e01fSmrg ;; 49674642e01fSmrg *executable*) # but shell scripts are "executable" too... 49684642e01fSmrg case $win32_fileres in 49694642e01fSmrg *MS\ Windows\ PE\ Intel*) 49704642e01fSmrg win32_libid_type="x86 DLL" 49714642e01fSmrg ;; 49724642e01fSmrg esac 49734642e01fSmrg ;; 49744642e01fSmrg esac 49754642e01fSmrg $ECHO "$win32_libid_type" 49764642e01fSmrg} 497705b261ecSmrg 497835c4bbdfSmrg# func_cygming_dll_for_implib ARG 497935c4bbdfSmrg# 498035c4bbdfSmrg# Platform-specific function to extract the 498135c4bbdfSmrg# name of the DLL associated with the specified 498235c4bbdfSmrg# import library ARG. 498335c4bbdfSmrg# Invoked by eval'ing the libtool variable 498435c4bbdfSmrg# $sharedlib_from_linklib_cmd 498535c4bbdfSmrg# Result is available in the variable 498635c4bbdfSmrg# $sharedlib_from_linklib_result 498735c4bbdfSmrgfunc_cygming_dll_for_implib () 498835c4bbdfSmrg{ 498935c4bbdfSmrg $debug_cmd 499035c4bbdfSmrg 499135c4bbdfSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499235c4bbdfSmrg} 499335c4bbdfSmrg 499435c4bbdfSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499535c4bbdfSmrg# 499635c4bbdfSmrg# The is the core of a fallback implementation of a 499735c4bbdfSmrg# platform-specific function to extract the name of the 499835c4bbdfSmrg# DLL associated with the specified import library LIBNAME. 499935c4bbdfSmrg# 500035c4bbdfSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500135c4bbdfSmrg# on the platform and compiler that created the implib. 500235c4bbdfSmrg# 500335c4bbdfSmrg# Echos the name of the DLL associated with the 500435c4bbdfSmrg# specified import library. 500535c4bbdfSmrgfunc_cygming_dll_for_implib_fallback_core () 500635c4bbdfSmrg{ 500735c4bbdfSmrg $debug_cmd 500835c4bbdfSmrg 500935c4bbdfSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501035c4bbdfSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501135c4bbdfSmrg $SED '/^Contents of section '"$match_literal"':/{ 501235c4bbdfSmrg # Place marker at beginning of archive member dllname section 501335c4bbdfSmrg s/.*/====MARK====/ 501435c4bbdfSmrg p 501535c4bbdfSmrg d 501635c4bbdfSmrg } 501735c4bbdfSmrg # These lines can sometimes be longer than 43 characters, but 501835c4bbdfSmrg # are always uninteresting 501935c4bbdfSmrg /:[ ]*file format pe[i]\{,1\}-/d 502035c4bbdfSmrg /^In archive [^:]*:/d 502135c4bbdfSmrg # Ensure marker is printed 502235c4bbdfSmrg /^====MARK====/p 502335c4bbdfSmrg # Remove all lines with less than 43 characters 502435c4bbdfSmrg /^.\{43\}/!d 502535c4bbdfSmrg # From remaining lines, remove first 43 characters 502635c4bbdfSmrg s/^.\{43\}//' | 502735c4bbdfSmrg $SED -n ' 502835c4bbdfSmrg # Join marker and all lines until next marker into a single line 502935c4bbdfSmrg /^====MARK====/ b para 503035c4bbdfSmrg H 503135c4bbdfSmrg $ b para 503235c4bbdfSmrg b 503335c4bbdfSmrg :para 503435c4bbdfSmrg x 503535c4bbdfSmrg s/\n//g 503635c4bbdfSmrg # Remove the marker 503735c4bbdfSmrg s/^====MARK====// 503835c4bbdfSmrg # Remove trailing dots and whitespace 503935c4bbdfSmrg s/[\. \t]*$// 504035c4bbdfSmrg # Print 504135c4bbdfSmrg /./p' | 504235c4bbdfSmrg # we now have a list, one entry per line, of the stringified 504335c4bbdfSmrg # contents of the appropriate section of all members of the 504435c4bbdfSmrg # archive that possess that section. Heuristic: eliminate 504535c4bbdfSmrg # all those that have a first or second character that is 504635c4bbdfSmrg # a '.' (that is, objdump's representation of an unprintable 504735c4bbdfSmrg # character.) This should work for all archives with less than 504835c4bbdfSmrg # 0x302f exports -- but will fail for DLLs whose name actually 504935c4bbdfSmrg # begins with a literal '.' or a single character followed by 505035c4bbdfSmrg # a '.'. 505135c4bbdfSmrg # 505235c4bbdfSmrg # Of those that remain, print the first one. 505335c4bbdfSmrg $SED -e '/^\./d;/^.\./d;q' 505435c4bbdfSmrg} 505535c4bbdfSmrg 505635c4bbdfSmrg# func_cygming_dll_for_implib_fallback ARG 505735c4bbdfSmrg# Platform-specific function to extract the 505835c4bbdfSmrg# name of the DLL associated with the specified 505935c4bbdfSmrg# import library ARG. 506035c4bbdfSmrg# 506135c4bbdfSmrg# This fallback implementation is for use when $DLLTOOL 506235c4bbdfSmrg# does not support the --identify-strict option. 506335c4bbdfSmrg# Invoked by eval'ing the libtool variable 506435c4bbdfSmrg# $sharedlib_from_linklib_cmd 506535c4bbdfSmrg# Result is available in the variable 506635c4bbdfSmrg# $sharedlib_from_linklib_result 506735c4bbdfSmrgfunc_cygming_dll_for_implib_fallback () 506835c4bbdfSmrg{ 506935c4bbdfSmrg $debug_cmd 507035c4bbdfSmrg 507135c4bbdfSmrg if func_cygming_gnu_implib_p "$1"; then 507235c4bbdfSmrg # binutils import library 507335c4bbdfSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507435c4bbdfSmrg elif func_cygming_ms_implib_p "$1"; then 507535c4bbdfSmrg # ms-generated import library 507635c4bbdfSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507735c4bbdfSmrg else 507835c4bbdfSmrg # unknown 507935c4bbdfSmrg sharedlib_from_linklib_result= 508035c4bbdfSmrg fi 508135c4bbdfSmrg} 508205b261ecSmrg 508305b261ecSmrg 50844642e01fSmrg# func_extract_an_archive dir oldlib 50854642e01fSmrgfunc_extract_an_archive () 50864642e01fSmrg{ 508735c4bbdfSmrg $debug_cmd 508835c4bbdfSmrg 508935c4bbdfSmrg f_ex_an_ar_dir=$1; shift 509035c4bbdfSmrg f_ex_an_ar_oldlib=$1 509135c4bbdfSmrg if test yes = "$lock_old_archive_extraction"; then 50926747b715Smrg lockfile=$f_ex_an_ar_oldlib.lock 50936747b715Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 50946747b715Smrg func_echo "Waiting for $lockfile to be removed" 50956747b715Smrg sleep 2 50966747b715Smrg done 50976747b715Smrg fi 50986747b715Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 50996747b715Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510035c4bbdfSmrg if test yes = "$lock_old_archive_extraction"; then 51016747b715Smrg $opt_dry_run || rm -f "$lockfile" 51026747b715Smrg fi 51034642e01fSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 51044642e01fSmrg : 51054642e01fSmrg else 51064642e01fSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 51074642e01fSmrg fi 51084642e01fSmrg} 510905b261ecSmrg 511005b261ecSmrg 51114642e01fSmrg# func_extract_archives gentop oldlib ... 51124642e01fSmrgfunc_extract_archives () 51134642e01fSmrg{ 511435c4bbdfSmrg $debug_cmd 511535c4bbdfSmrg 511635c4bbdfSmrg my_gentop=$1; shift 51174642e01fSmrg my_oldlibs=${1+"$@"} 511835c4bbdfSmrg my_oldobjs= 511935c4bbdfSmrg my_xlib= 512035c4bbdfSmrg my_xabs= 512135c4bbdfSmrg my_xdir= 512205b261ecSmrg 51234642e01fSmrg for my_xlib in $my_oldlibs; do 51244642e01fSmrg # Extract the objects. 51254642e01fSmrg case $my_xlib in 512635c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 51274642e01fSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 51284642e01fSmrg esac 51294642e01fSmrg func_basename "$my_xlib" 513035c4bbdfSmrg my_xlib=$func_basename_result 51314642e01fSmrg my_xlib_u=$my_xlib 51324642e01fSmrg while :; do 51334642e01fSmrg case " $extracted_archives " in 51344642e01fSmrg *" $my_xlib_u "*) 51354642e01fSmrg func_arith $extracted_serial + 1 51364642e01fSmrg extracted_serial=$func_arith_result 51374642e01fSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 51384642e01fSmrg *) break ;; 51394642e01fSmrg esac 51404642e01fSmrg done 51414642e01fSmrg extracted_archives="$extracted_archives $my_xlib_u" 514235c4bbdfSmrg my_xdir=$my_gentop/$my_xlib_u 514305b261ecSmrg 51444642e01fSmrg func_mkdir_p "$my_xdir" 514505b261ecSmrg 51464642e01fSmrg case $host in 51474642e01fSmrg *-darwin*) 51484642e01fSmrg func_verbose "Extracting $my_xabs" 51494642e01fSmrg # Do not bother doing anything if just a dry run 51504642e01fSmrg $opt_dry_run || { 51514642e01fSmrg darwin_orig_dir=`pwd` 51524642e01fSmrg cd $my_xdir || exit $? 51534642e01fSmrg darwin_archive=$my_xabs 51544642e01fSmrg darwin_curdir=`pwd` 515535c4bbdfSmrg func_basename "$darwin_archive" 515635c4bbdfSmrg darwin_base_archive=$func_basename_result 51574642e01fSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 51584642e01fSmrg if test -n "$darwin_arches"; then 51594642e01fSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 51604642e01fSmrg darwin_arch= 51614642e01fSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516235c4bbdfSmrg for darwin_arch in $darwin_arches; do 516335c4bbdfSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516435c4bbdfSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516535c4bbdfSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516635c4bbdfSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 51674642e01fSmrg cd "$darwin_curdir" 516835c4bbdfSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 51694642e01fSmrg done # $darwin_arches 51704642e01fSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517135c4bbdfSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 51724642e01fSmrg darwin_file= 51734642e01fSmrg darwin_files= 51744642e01fSmrg for darwin_file in $darwin_filelist; do 51756747b715Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 51764642e01fSmrg $LIPO -create -output "$darwin_file" $darwin_files 51774642e01fSmrg done # $darwin_filelist 51784642e01fSmrg $RM -rf unfat-$$ 51794642e01fSmrg cd "$darwin_orig_dir" 518005b261ecSmrg else 51814642e01fSmrg cd $darwin_orig_dir 51824642e01fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51834642e01fSmrg fi # $darwin_arches 51844642e01fSmrg } # !$opt_dry_run 51854642e01fSmrg ;; 51864642e01fSmrg *) 51874642e01fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51884642e01fSmrg ;; 51894642e01fSmrg esac 51906747b715Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 51914642e01fSmrg done 519205b261ecSmrg 519335c4bbdfSmrg func_extract_archives_result=$my_oldobjs 51944642e01fSmrg} 519505b261ecSmrg 519605b261ecSmrg 51976747b715Smrg# func_emit_wrapper [arg=no] 51986747b715Smrg# 51996747b715Smrg# Emit a libtool wrapper script on stdout. 52006747b715Smrg# Don't directly open a file because we may want to 52016747b715Smrg# incorporate the script contents within a cygwin/mingw 52026747b715Smrg# wrapper executable. Must ONLY be called from within 52036747b715Smrg# func_mode_link because it depends on a number of variables 52046747b715Smrg# set therein. 52054642e01fSmrg# 52066747b715Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 52076747b715Smrg# variable will take. If 'yes', then the emitted script 520835c4bbdfSmrg# will assume that the directory where it is stored is 52096747b715Smrg# the $objdir directory. This is a cygwin/mingw-specific 52106747b715Smrg# behavior. 52116747b715Smrgfunc_emit_wrapper () 52124642e01fSmrg{ 52136747b715Smrg func_emit_wrapper_arg1=${1-no} 521405b261ecSmrg 52154642e01fSmrg $ECHO "\ 52164642e01fSmrg#! $SHELL 521705b261ecSmrg 52184642e01fSmrg# $output - temporary wrapper script for $objdir/$outputname 521935c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 52204642e01fSmrg# 52214642e01fSmrg# The $output program cannot be directly executed until all the libtool 52224642e01fSmrg# libraries that it depends on are installed. 52234642e01fSmrg# 52244642e01fSmrg# This wrapper script should never be moved out of the build directory. 52254642e01fSmrg# If it is, it will not operate correctly. 522605b261ecSmrg 52274642e01fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 52284642e01fSmrg# metacharacters that are still active within double-quoted strings. 52294642e01fSmrgsed_quote_subst='$sed_quote_subst' 523005b261ecSmrg 52314642e01fSmrg# Be Bourne compatible 52324642e01fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 52334642e01fSmrg emulate sh 52344642e01fSmrg NULLCMD=: 52354642e01fSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 52364642e01fSmrg # is contrary to our usage. Disable this feature. 52374642e01fSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 52384642e01fSmrg setopt NO_GLOB_SUBST 52394642e01fSmrgelse 52404642e01fSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 52414642e01fSmrgfi 52424642e01fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 52434642e01fSmrgDUALCASE=1; export DUALCASE # for MKS sh 524405b261ecSmrg 52454642e01fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 52464642e01fSmrg# if CDPATH is set. 52474642e01fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 524805b261ecSmrg 52494642e01fSmrgrelink_command=\"$relink_command\" 525005b261ecSmrg 52514642e01fSmrg# This environment variable determines our operation mode. 52524642e01fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 52534642e01fSmrg # install mode needs the following variables: 52544642e01fSmrg generated_by_libtool_version='$macro_version' 52554642e01fSmrg notinst_deplibs='$notinst_deplibs' 52564642e01fSmrgelse 52574642e01fSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 52584642e01fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 52596747b715Smrg file=\"\$0\"" 52606747b715Smrg 52616747b715Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 52626747b715Smrg $ECHO "\ 52636747b715Smrg 52646747b715Smrg# A function that is used when there is no print builtin or printf. 52656747b715Smrgfunc_fallback_echo () 52666747b715Smrg{ 52676747b715Smrg eval 'cat <<_LTECHO_EOF 52686747b715Smrg\$1 52696747b715Smrg_LTECHO_EOF' 52706747b715Smrg} 52716747b715Smrg ECHO=\"$qECHO\" 52726747b715Smrg fi 52736747b715Smrg 52746747b715Smrg# Very basic option parsing. These options are (a) specific to 52756747b715Smrg# the libtool wrapper, (b) are identical between the wrapper 527635c4bbdfSmrg# /script/ and the wrapper /executable/ that is used only on 52776747b715Smrg# windows platforms, and (c) all begin with the string "--lt-" 527835c4bbdfSmrg# (application programs are unlikely to have options that match 52796747b715Smrg# this pattern). 52806747b715Smrg# 52816747b715Smrg# There are only two supported options: --lt-debug and 52826747b715Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 52836747b715Smrg# 52846747b715Smrg# The first argument to this parsing function should be the 52856747b715Smrg# script's $0 value, followed by "$@". 52866747b715Smrglt_option_debug= 52876747b715Smrgfunc_parse_lt_options () 52886747b715Smrg{ 52896747b715Smrg lt_script_arg0=\$0 52906747b715Smrg shift 52916747b715Smrg for lt_opt 52926747b715Smrg do 52936747b715Smrg case \"\$lt_opt\" in 52946747b715Smrg --lt-debug) lt_option_debug=1 ;; 52956747b715Smrg --lt-dump-script) 52966747b715Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 52976747b715Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 52986747b715Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 52996747b715Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 53006747b715Smrg exit 0 53016747b715Smrg ;; 53026747b715Smrg --lt-*) 53036747b715Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 53046747b715Smrg exit 1 53056747b715Smrg ;; 53066747b715Smrg esac 53076747b715Smrg done 53086747b715Smrg 53096747b715Smrg # Print the debug banner immediately: 53106747b715Smrg if test -n \"\$lt_option_debug\"; then 531135c4bbdfSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 53126747b715Smrg fi 53136747b715Smrg} 53146747b715Smrg 53156747b715Smrg# Used when --lt-debug. Prints its arguments to stdout 53166747b715Smrg# (redirection is the responsibility of the caller) 53176747b715Smrgfunc_lt_dump_args () 53186747b715Smrg{ 53196747b715Smrg lt_dump_args_N=1; 53206747b715Smrg for lt_arg 53216747b715Smrg do 532235c4bbdfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 53236747b715Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 53246747b715Smrg done 53256747b715Smrg} 53266747b715Smrg 53276747b715Smrg# Core function for launching the target application 53286747b715Smrgfunc_exec_program_core () 53296747b715Smrg{ 53304642e01fSmrg" 53316747b715Smrg case $host in 53326747b715Smrg # Backslashes separate directories on plain windows 53336747b715Smrg *-*-mingw | *-*-os2* | *-cegcc*) 53346747b715Smrg $ECHO "\ 53356747b715Smrg if test -n \"\$lt_option_debug\"; then 533635c4bbdfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 53376747b715Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 53386747b715Smrg fi 53396747b715Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 53406747b715Smrg" 53416747b715Smrg ;; 53426747b715Smrg 53436747b715Smrg *) 53446747b715Smrg $ECHO "\ 53456747b715Smrg if test -n \"\$lt_option_debug\"; then 534635c4bbdfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 53476747b715Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 53486747b715Smrg fi 53496747b715Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 53506747b715Smrg" 53516747b715Smrg ;; 53526747b715Smrg esac 53536747b715Smrg $ECHO "\ 53546747b715Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 53556747b715Smrg exit 1 53566747b715Smrg} 53576747b715Smrg 53586747b715Smrg# A function to encapsulate launching the target application 53596747b715Smrg# Strips options in the --lt-* namespace from \$@ and 53606747b715Smrg# launches target application with the remaining arguments. 53616747b715Smrgfunc_exec_program () 53626747b715Smrg{ 536335c4bbdfSmrg case \" \$* \" in 536435c4bbdfSmrg *\\ --lt-*) 536535c4bbdfSmrg for lt_wr_arg 536635c4bbdfSmrg do 536735c4bbdfSmrg case \$lt_wr_arg in 536835c4bbdfSmrg --lt-*) ;; 536935c4bbdfSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 537035c4bbdfSmrg esac 537135c4bbdfSmrg shift 537235c4bbdfSmrg done ;; 537335c4bbdfSmrg esac 53746747b715Smrg func_exec_program_core \${1+\"\$@\"} 53756747b715Smrg} 53766747b715Smrg 53776747b715Smrg # Parse options 53786747b715Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 537905b261ecSmrg 53804642e01fSmrg # Find the directory that this script lives in. 53816747b715Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 53824642e01fSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 538305b261ecSmrg 53844642e01fSmrg # Follow symbolic links until we get to the real thisdir. 53856747b715Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 53864642e01fSmrg while test -n \"\$file\"; do 53876747b715Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 538805b261ecSmrg 53894642e01fSmrg # If there was a directory component, then change thisdir. 53904642e01fSmrg if test \"x\$destdir\" != \"x\$file\"; then 53914642e01fSmrg case \"\$destdir\" in 53924642e01fSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 53934642e01fSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 539405b261ecSmrg esac 53954642e01fSmrg fi 539605b261ecSmrg 53976747b715Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 53986747b715Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 53994642e01fSmrg done 540005b261ecSmrg 54014642e01fSmrg # Usually 'no', except on cygwin/mingw when embedded into 54024642e01fSmrg # the cwrapper. 54036747b715Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 54044642e01fSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 54054642e01fSmrg # special case for '.' 54064642e01fSmrg if test \"\$thisdir\" = \".\"; then 54074642e01fSmrg thisdir=\`pwd\` 54084642e01fSmrg fi 54094642e01fSmrg # remove .libs from thisdir 54104642e01fSmrg case \"\$thisdir\" in 54116747b715Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 54124642e01fSmrg $objdir ) thisdir=. ;; 54134642e01fSmrg esac 54144642e01fSmrg fi 54154642e01fSmrg 54164642e01fSmrg # Try to get the absolute directory name. 54174642e01fSmrg absdir=\`cd \"\$thisdir\" && pwd\` 54184642e01fSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 54194642e01fSmrg" 54204642e01fSmrg 542135c4bbdfSmrg if test yes = "$fast_install"; then 54224642e01fSmrg $ECHO "\ 54234642e01fSmrg program=lt-'$outputname'$exeext 54244642e01fSmrg progdir=\"\$thisdir/$objdir\" 54254642e01fSmrg 54264642e01fSmrg if test ! -f \"\$progdir/\$program\" || 542735c4bbdfSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 54284642e01fSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 54294642e01fSmrg 54304642e01fSmrg file=\"\$\$-\$program\" 54314642e01fSmrg 54324642e01fSmrg if test ! -d \"\$progdir\"; then 54334642e01fSmrg $MKDIR \"\$progdir\" 54344642e01fSmrg else 54354642e01fSmrg $RM \"\$progdir/\$file\" 54364642e01fSmrg fi" 54374642e01fSmrg 54384642e01fSmrg $ECHO "\ 54394642e01fSmrg 54404642e01fSmrg # relink executable if necessary 54414642e01fSmrg if test -n \"\$relink_command\"; then 54424642e01fSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 54434642e01fSmrg else 544435c4bbdfSmrg \$ECHO \"\$relink_command_output\" >&2 54454642e01fSmrg $RM \"\$progdir/\$file\" 54464642e01fSmrg exit 1 544705b261ecSmrg fi 54484642e01fSmrg fi 544905b261ecSmrg 54504642e01fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 54514642e01fSmrg { $RM \"\$progdir/\$program\"; 54524642e01fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 54534642e01fSmrg $RM \"\$progdir/\$file\" 54544642e01fSmrg fi" 54554642e01fSmrg else 54564642e01fSmrg $ECHO "\ 54574642e01fSmrg program='$outputname' 54584642e01fSmrg progdir=\"\$thisdir/$objdir\" 54594642e01fSmrg" 546005b261ecSmrg fi 546105b261ecSmrg 54624642e01fSmrg $ECHO "\ 546305b261ecSmrg 54644642e01fSmrg if test -f \"\$progdir/\$program\"; then" 546505b261ecSmrg 546635c4bbdfSmrg # fixup the dll searchpath if we need to. 546735c4bbdfSmrg # 546835c4bbdfSmrg # Fix the DLL searchpath if we need to. Do this before prepending 546935c4bbdfSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 547035c4bbdfSmrg # libraries must come first. 547135c4bbdfSmrg if test -n "$dllsearchpath"; then 547235c4bbdfSmrg $ECHO "\ 547335c4bbdfSmrg # Add the dll search path components to the executable PATH 547435c4bbdfSmrg PATH=$dllsearchpath:\$PATH 547535c4bbdfSmrg" 547635c4bbdfSmrg fi 547735c4bbdfSmrg 54784642e01fSmrg # Export our shlibpath_var if we have one. 547935c4bbdfSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 54804642e01fSmrg $ECHO "\ 54814642e01fSmrg # Add our own library path to $shlibpath_var 54824642e01fSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 548305b261ecSmrg 54844642e01fSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 54854642e01fSmrg # The second colon is a workaround for a bug in BeOS R4 sed 54866747b715Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 54874642e01fSmrg 54884642e01fSmrg export $shlibpath_var 54894642e01fSmrg" 549005b261ecSmrg fi 549105b261ecSmrg 54924642e01fSmrg $ECHO "\ 54934642e01fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 54944642e01fSmrg # Run the actual program with our arguments. 54956747b715Smrg func_exec_program \${1+\"\$@\"} 54964642e01fSmrg fi 54974642e01fSmrg else 54984642e01fSmrg # The program doesn't exist. 549935c4bbdfSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 55004642e01fSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 55016747b715Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 55024642e01fSmrg exit 1 55034642e01fSmrg fi 55044642e01fSmrgfi\ 55054642e01fSmrg" 55064642e01fSmrg} 550705b261ecSmrg 550805b261ecSmrg 55094642e01fSmrg# func_emit_cwrapperexe_src 55104642e01fSmrg# emit the source code for a wrapper executable on stdout 55114642e01fSmrg# Must ONLY be called from within func_mode_link because 55124642e01fSmrg# it depends on a number of variable set therein. 55134642e01fSmrgfunc_emit_cwrapperexe_src () 55144642e01fSmrg{ 55154642e01fSmrg cat <<EOF 551605b261ecSmrg 55174642e01fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551835c4bbdfSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 551905b261ecSmrg 55204642e01fSmrg The $output program cannot be directly executed until all the libtool 55214642e01fSmrg libraries that it depends on are installed. 552205b261ecSmrg 55234642e01fSmrg This wrapper executable should never be moved out of the build directory. 55244642e01fSmrg If it is, it will not operate correctly. 55254642e01fSmrg*/ 55264642e01fSmrgEOF 55274642e01fSmrg cat <<"EOF" 55286747b715Smrg#ifdef _MSC_VER 55296747b715Smrg# define _CRT_SECURE_NO_DEPRECATE 1 55306747b715Smrg#endif 55314642e01fSmrg#include <stdio.h> 55324642e01fSmrg#include <stdlib.h> 55334642e01fSmrg#ifdef _MSC_VER 55344642e01fSmrg# include <direct.h> 55354642e01fSmrg# include <process.h> 55364642e01fSmrg# include <io.h> 55374642e01fSmrg#else 55384642e01fSmrg# include <unistd.h> 55394642e01fSmrg# include <stdint.h> 55404642e01fSmrg# ifdef __CYGWIN__ 55414642e01fSmrg# include <io.h> 55426747b715Smrg# endif 55436747b715Smrg#endif 55446747b715Smrg#include <malloc.h> 55456747b715Smrg#include <stdarg.h> 55466747b715Smrg#include <assert.h> 55476747b715Smrg#include <string.h> 55486747b715Smrg#include <ctype.h> 55496747b715Smrg#include <errno.h> 55506747b715Smrg#include <fcntl.h> 55516747b715Smrg#include <sys/stat.h> 55526747b715Smrg 555335c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555435c4bbdfSmrg 55556747b715Smrg/* declarations of non-ANSI functions */ 555635c4bbdfSmrg#if defined __MINGW32__ 55576747b715Smrg# ifdef __STRICT_ANSI__ 55586747b715Smrgint _putenv (const char *); 55596747b715Smrg# endif 556035c4bbdfSmrg#elif defined __CYGWIN__ 55616747b715Smrg# ifdef __STRICT_ANSI__ 55624642e01fSmrgchar *realpath (const char *, char *); 55634642e01fSmrgint putenv (char *); 55644642e01fSmrgint setenv (const char *, const char *, int); 55654642e01fSmrg# endif 556635c4bbdfSmrg/* #elif defined other_platform || defined ... */ 55676747b715Smrg#endif 55686747b715Smrg 55696747b715Smrg/* portability defines, excluding path handling macros */ 557035c4bbdfSmrg#if defined _MSC_VER 55716747b715Smrg# define setmode _setmode 55726747b715Smrg# define stat _stat 55736747b715Smrg# define chmod _chmod 55746747b715Smrg# define getcwd _getcwd 55756747b715Smrg# define putenv _putenv 55766747b715Smrg# define S_IXUSR _S_IEXEC 557735c4bbdfSmrg#elif defined __MINGW32__ 55786747b715Smrg# define setmode _setmode 55796747b715Smrg# define stat _stat 55806747b715Smrg# define chmod _chmod 55816747b715Smrg# define getcwd _getcwd 55826747b715Smrg# define putenv _putenv 558335c4bbdfSmrg#elif defined __CYGWIN__ 55846747b715Smrg# define HAVE_SETENV 55856747b715Smrg# define FOPEN_WB "wb" 558635c4bbdfSmrg/* #elif defined other platforms ... */ 55874642e01fSmrg#endif 558805b261ecSmrg 558935c4bbdfSmrg#if defined PATH_MAX 55904642e01fSmrg# define LT_PATHMAX PATH_MAX 559135c4bbdfSmrg#elif defined MAXPATHLEN 55924642e01fSmrg# define LT_PATHMAX MAXPATHLEN 55934642e01fSmrg#else 55944642e01fSmrg# define LT_PATHMAX 1024 55954642e01fSmrg#endif 559605b261ecSmrg 55974642e01fSmrg#ifndef S_IXOTH 55984642e01fSmrg# define S_IXOTH 0 55994642e01fSmrg#endif 56004642e01fSmrg#ifndef S_IXGRP 56014642e01fSmrg# define S_IXGRP 0 56024642e01fSmrg#endif 560305b261ecSmrg 56046747b715Smrg/* path handling portability macros */ 56054642e01fSmrg#ifndef DIR_SEPARATOR 56064642e01fSmrg# define DIR_SEPARATOR '/' 56074642e01fSmrg# define PATH_SEPARATOR ':' 56084642e01fSmrg#endif 560905b261ecSmrg 561035c4bbdfSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561135c4bbdfSmrg defined __OS2__ 56124642e01fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 56134642e01fSmrg# define FOPEN_WB "wb" 56144642e01fSmrg# ifndef DIR_SEPARATOR_2 56154642e01fSmrg# define DIR_SEPARATOR_2 '\\' 56164642e01fSmrg# endif 56174642e01fSmrg# ifndef PATH_SEPARATOR_2 56184642e01fSmrg# define PATH_SEPARATOR_2 ';' 56194642e01fSmrg# endif 56204642e01fSmrg#endif 562105b261ecSmrg 56224642e01fSmrg#ifndef DIR_SEPARATOR_2 56234642e01fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 56244642e01fSmrg#else /* DIR_SEPARATOR_2 */ 56254642e01fSmrg# define IS_DIR_SEPARATOR(ch) \ 56264642e01fSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 56274642e01fSmrg#endif /* DIR_SEPARATOR_2 */ 562805b261ecSmrg 56294642e01fSmrg#ifndef PATH_SEPARATOR_2 56304642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 56314642e01fSmrg#else /* PATH_SEPARATOR_2 */ 56324642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 56334642e01fSmrg#endif /* PATH_SEPARATOR_2 */ 563405b261ecSmrg 56354642e01fSmrg#ifndef FOPEN_WB 56364642e01fSmrg# define FOPEN_WB "w" 56374642e01fSmrg#endif 56384642e01fSmrg#ifndef _O_BINARY 56394642e01fSmrg# define _O_BINARY 0 56404642e01fSmrg#endif 564105b261ecSmrg 56424642e01fSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 56434642e01fSmrg#define XFREE(stale) do { \ 564435c4bbdfSmrg if (stale) { free (stale); stale = 0; } \ 56454642e01fSmrg} while (0) 564605b261ecSmrg 564735c4bbdfSmrg#if defined LT_DEBUGWRAPPER 56486747b715Smrgstatic int lt_debug = 1; 56494642e01fSmrg#else 56506747b715Smrgstatic int lt_debug = 0; 56514642e01fSmrg#endif 565205b261ecSmrg 56536747b715Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565405b261ecSmrg 56554642e01fSmrgvoid *xmalloc (size_t num); 56564642e01fSmrgchar *xstrdup (const char *string); 56574642e01fSmrgconst char *base_name (const char *name); 56584642e01fSmrgchar *find_executable (const char *wrapper); 56594642e01fSmrgchar *chase_symlinks (const char *pathspec); 56604642e01fSmrgint make_executable (const char *path); 56614642e01fSmrgint check_executable (const char *path); 56624642e01fSmrgchar *strendzap (char *str, const char *pat); 56636747b715Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 56646747b715Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 56656747b715Smrgstatic const char *nonnull (const char *s); 56666747b715Smrgstatic const char *nonempty (const char *s); 56674642e01fSmrgvoid lt_setenv (const char *name, const char *value); 56684642e01fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 56694642e01fSmrgvoid lt_update_exe_path (const char *name, const char *value); 56704642e01fSmrgvoid lt_update_lib_path (const char *name, const char *value); 56716747b715Smrgchar **prepare_spawn (char **argv); 56726747b715Smrgvoid lt_dump_script (FILE *f); 56734642e01fSmrgEOF 56744642e01fSmrg 56754642e01fSmrg cat <<EOF 567635c4bbdfSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567735c4bbdfSmrg# define externally_visible volatile 567835c4bbdfSmrg#else 567935c4bbdfSmrg# define externally_visible __attribute__((externally_visible)) volatile 568035c4bbdfSmrg#endif 568135c4bbdfSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 56824642e01fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 56834642e01fSmrgEOF 568405b261ecSmrg 568535c4bbdfSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568635c4bbdfSmrg func_to_host_path "$temp_rpath" 56874642e01fSmrg cat <<EOF 568835c4bbdfSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 56894642e01fSmrgEOF 56904642e01fSmrg else 56914642e01fSmrg cat <<"EOF" 56924642e01fSmrgconst char * LIB_PATH_VALUE = ""; 56934642e01fSmrgEOF 569405b261ecSmrg fi 569505b261ecSmrg 56964642e01fSmrg if test -n "$dllsearchpath"; then 569735c4bbdfSmrg func_to_host_path "$dllsearchpath:" 56984642e01fSmrg cat <<EOF 56994642e01fSmrgconst char * EXE_PATH_VARNAME = "PATH"; 570035c4bbdfSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 570105b261ecSmrgEOF 570205b261ecSmrg else 57034642e01fSmrg cat <<"EOF" 57044642e01fSmrgconst char * EXE_PATH_VARNAME = ""; 57054642e01fSmrgconst char * EXE_PATH_VALUE = ""; 57064642e01fSmrgEOF 570705b261ecSmrg fi 57084642e01fSmrg 570935c4bbdfSmrg if test yes = "$fast_install"; then 57104642e01fSmrg cat <<EOF 57114642e01fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 57124642e01fSmrgEOF 571305b261ecSmrg else 57144642e01fSmrg cat <<EOF 57154642e01fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 57164642e01fSmrgEOF 571705b261ecSmrg fi 571805b261ecSmrg 571905b261ecSmrg 57204642e01fSmrg cat <<"EOF" 572105b261ecSmrg 57224642e01fSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 572305b261ecSmrg 57244642e01fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 57254642e01fSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 57266747b715Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 572705b261ecSmrg 57284642e01fSmrgint 57294642e01fSmrgmain (int argc, char *argv[]) 57304642e01fSmrg{ 57314642e01fSmrg char **newargz; 57324642e01fSmrg int newargc; 57334642e01fSmrg char *tmp_pathspec; 57344642e01fSmrg char *actual_cwrapper_path; 57354642e01fSmrg char *actual_cwrapper_name; 57364642e01fSmrg char *target_name; 57374642e01fSmrg char *lt_argv_zero; 573835c4bbdfSmrg int rval = 127; 573905b261ecSmrg 57404642e01fSmrg int i; 574105b261ecSmrg 57424642e01fSmrg program_name = (char *) xstrdup (base_name (argv[0])); 574335c4bbdfSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 574405b261ecSmrg 57456747b715Smrg /* very simple arg parsing; don't want to rely on getopt 57466747b715Smrg * also, copy all non cwrapper options to newargz, except 57476747b715Smrg * argz[0], which is handled differently 57486747b715Smrg */ 57496747b715Smrg newargc=0; 57504642e01fSmrg for (i = 1; i < argc; i++) 57514642e01fSmrg { 575235c4bbdfSmrg if (STREQ (argv[i], dumpscript_opt)) 57534642e01fSmrg { 57544642e01fSmrgEOF 575535c4bbdfSmrg case $host in 57564642e01fSmrg *mingw* | *cygwin* ) 57574642e01fSmrg # make stdout use "unix" line endings 57584642e01fSmrg echo " setmode(1,_O_BINARY);" 57594642e01fSmrg ;; 57604642e01fSmrg esac 576105b261ecSmrg 57624642e01fSmrg cat <<"EOF" 57636747b715Smrg lt_dump_script (stdout); 57644642e01fSmrg return 0; 57654642e01fSmrg } 576635c4bbdfSmrg if (STREQ (argv[i], debug_opt)) 57676747b715Smrg { 57686747b715Smrg lt_debug = 1; 57696747b715Smrg continue; 57706747b715Smrg } 577135c4bbdfSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 57726747b715Smrg { 57736747b715Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 57746747b715Smrg namespace, but it is not one of the ones we know about and 57756747b715Smrg have already dealt with, above (inluding dump-script), then 57766747b715Smrg report an error. Otherwise, targets might begin to believe 57776747b715Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 57786747b715Smrg namespace. The first time any user complains about this, we'll 57796747b715Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 57806747b715Smrg or a configure.ac-settable value. 57816747b715Smrg */ 57826747b715Smrg lt_fatal (__FILE__, __LINE__, 57836747b715Smrg "unrecognized %s option: '%s'", 57846747b715Smrg ltwrapper_option_prefix, argv[i]); 57856747b715Smrg } 57866747b715Smrg /* otherwise ... */ 57876747b715Smrg newargz[++newargc] = xstrdup (argv[i]); 57884642e01fSmrg } 57896747b715Smrg newargz[++newargc] = NULL; 57906747b715Smrg 57916747b715SmrgEOF 57926747b715Smrg cat <<EOF 57936747b715Smrg /* The GNU banner must be the first non-error debug message */ 579435c4bbdfSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 57956747b715SmrgEOF 57966747b715Smrg cat <<"EOF" 57976747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 57986747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579905b261ecSmrg 58004642e01fSmrg tmp_pathspec = find_executable (argv[0]); 58014642e01fSmrg if (tmp_pathspec == NULL) 58026747b715Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 58036747b715Smrg lt_debugprintf (__FILE__, __LINE__, 58046747b715Smrg "(main) found exe (before symlink chase) at: %s\n", 58056747b715Smrg tmp_pathspec); 58064642e01fSmrg 58074642e01fSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 58086747b715Smrg lt_debugprintf (__FILE__, __LINE__, 58096747b715Smrg "(main) found exe (after symlink chase) at: %s\n", 58106747b715Smrg actual_cwrapper_path); 58114642e01fSmrg XFREE (tmp_pathspec); 58124642e01fSmrg 58136747b715Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 58144642e01fSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 58154642e01fSmrg 58164642e01fSmrg /* wrapper name transforms */ 58174642e01fSmrg strendzap (actual_cwrapper_name, ".exe"); 58184642e01fSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 58194642e01fSmrg XFREE (actual_cwrapper_name); 58204642e01fSmrg actual_cwrapper_name = tmp_pathspec; 58214642e01fSmrg tmp_pathspec = 0; 58224642e01fSmrg 58234642e01fSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 58244642e01fSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 58254642e01fSmrg strendzap (target_name, ".exe"); 58264642e01fSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 58274642e01fSmrg XFREE (target_name); 58284642e01fSmrg target_name = tmp_pathspec; 58294642e01fSmrg tmp_pathspec = 0; 58304642e01fSmrg 58316747b715Smrg lt_debugprintf (__FILE__, __LINE__, 58326747b715Smrg "(main) libtool target name: %s\n", 58336747b715Smrg target_name); 58344642e01fSmrgEOF 583505b261ecSmrg 58364642e01fSmrg cat <<EOF 58374642e01fSmrg newargz[0] = 58384642e01fSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 58394642e01fSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 58404642e01fSmrg strcpy (newargz[0], actual_cwrapper_path); 58414642e01fSmrg strcat (newargz[0], "$objdir"); 58424642e01fSmrg strcat (newargz[0], "/"); 58434642e01fSmrgEOF 584405b261ecSmrg 58454642e01fSmrg cat <<"EOF" 58464642e01fSmrg /* stop here, and copy so we don't have to do this twice */ 58474642e01fSmrg tmp_pathspec = xstrdup (newargz[0]); 584805b261ecSmrg 58494642e01fSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 58504642e01fSmrg strcat (newargz[0], actual_cwrapper_name); 585105b261ecSmrg 58524642e01fSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 58534642e01fSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 58544642e01fSmrg XFREE (tmp_pathspec); 58554642e01fSmrg tmp_pathspec = NULL; 58564642e01fSmrgEOF 585705b261ecSmrg 58584642e01fSmrg case $host_os in 58594642e01fSmrg mingw*) 58604642e01fSmrg cat <<"EOF" 58614642e01fSmrg { 58624642e01fSmrg char* p; 58634642e01fSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 58644642e01fSmrg { 58654642e01fSmrg *p = '/'; 58664642e01fSmrg } 58674642e01fSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 58684642e01fSmrg { 58694642e01fSmrg *p = '/'; 58704642e01fSmrg } 58714642e01fSmrg } 58724642e01fSmrgEOF 58734642e01fSmrg ;; 58744642e01fSmrg esac 587505b261ecSmrg 58764642e01fSmrg cat <<"EOF" 58774642e01fSmrg XFREE (target_name); 58784642e01fSmrg XFREE (actual_cwrapper_path); 58794642e01fSmrg XFREE (actual_cwrapper_name); 588005b261ecSmrg 58814642e01fSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 58824642e01fSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588335c4bbdfSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588435c4bbdfSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588535c4bbdfSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588635c4bbdfSmrg libraries must come first. */ 5887475c125cSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588835c4bbdfSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588905b261ecSmrg 58906747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 58916747b715Smrg nonnull (lt_argv_zero)); 58924642e01fSmrg for (i = 0; i < newargc; i++) 58934642e01fSmrg { 58946747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 58956747b715Smrg i, nonnull (newargz[i])); 58964642e01fSmrg } 589705b261ecSmrg 58984642e01fSmrgEOF 589905b261ecSmrg 59004642e01fSmrg case $host_os in 59014642e01fSmrg mingw*) 59024642e01fSmrg cat <<"EOF" 59034642e01fSmrg /* execv doesn't actually work on mingw as expected on unix */ 59046747b715Smrg newargz = prepare_spawn (newargz); 590535c4bbdfSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 59064642e01fSmrg if (rval == -1) 59074642e01fSmrg { 59084642e01fSmrg /* failed to start process */ 59096747b715Smrg lt_debugprintf (__FILE__, __LINE__, 59106747b715Smrg "(main) failed to launch target \"%s\": %s\n", 59116747b715Smrg lt_argv_zero, nonnull (strerror (errno))); 59124642e01fSmrg return 127; 59134642e01fSmrg } 59144642e01fSmrg return rval; 59154642e01fSmrgEOF 59164642e01fSmrg ;; 59174642e01fSmrg *) 59184642e01fSmrg cat <<"EOF" 59194642e01fSmrg execv (lt_argv_zero, newargz); 59204642e01fSmrg return rval; /* =127, but avoids unused variable warning */ 59214642e01fSmrgEOF 59224642e01fSmrg ;; 59234642e01fSmrg esac 592405b261ecSmrg 59254642e01fSmrg cat <<"EOF" 59264642e01fSmrg} 592705b261ecSmrg 59284642e01fSmrgvoid * 59294642e01fSmrgxmalloc (size_t num) 59304642e01fSmrg{ 59314642e01fSmrg void *p = (void *) malloc (num); 59324642e01fSmrg if (!p) 59336747b715Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 593405b261ecSmrg 59354642e01fSmrg return p; 59364642e01fSmrg} 593705b261ecSmrg 59384642e01fSmrgchar * 59394642e01fSmrgxstrdup (const char *string) 59404642e01fSmrg{ 59414642e01fSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 59424642e01fSmrg string) : NULL; 59434642e01fSmrg} 594405b261ecSmrg 59454642e01fSmrgconst char * 59464642e01fSmrgbase_name (const char *name) 59474642e01fSmrg{ 59484642e01fSmrg const char *base; 594905b261ecSmrg 595035c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 59514642e01fSmrg /* Skip over the disk name in MSDOS pathnames. */ 59524642e01fSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 59534642e01fSmrg name += 2; 59544642e01fSmrg#endif 595505b261ecSmrg 59564642e01fSmrg for (base = name; *name; name++) 59574642e01fSmrg if (IS_DIR_SEPARATOR (*name)) 59584642e01fSmrg base = name + 1; 59594642e01fSmrg return base; 59604642e01fSmrg} 596105b261ecSmrg 59624642e01fSmrgint 59634642e01fSmrgcheck_executable (const char *path) 59644642e01fSmrg{ 59654642e01fSmrg struct stat st; 596605b261ecSmrg 59676747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 59686747b715Smrg nonempty (path)); 59694642e01fSmrg if ((!path) || (!*path)) 59704642e01fSmrg return 0; 597105b261ecSmrg 59724642e01fSmrg if ((stat (path, &st) >= 0) 59734642e01fSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 59744642e01fSmrg return 1; 59754642e01fSmrg else 59764642e01fSmrg return 0; 59774642e01fSmrg} 597805b261ecSmrg 59794642e01fSmrgint 59804642e01fSmrgmake_executable (const char *path) 59814642e01fSmrg{ 59824642e01fSmrg int rval = 0; 59834642e01fSmrg struct stat st; 598405b261ecSmrg 59856747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 59866747b715Smrg nonempty (path)); 59874642e01fSmrg if ((!path) || (!*path)) 59884642e01fSmrg return 0; 598905b261ecSmrg 59904642e01fSmrg if (stat (path, &st) >= 0) 59914642e01fSmrg { 59924642e01fSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 59934642e01fSmrg } 59944642e01fSmrg return rval; 59954642e01fSmrg} 599605b261ecSmrg 59974642e01fSmrg/* Searches for the full path of the wrapper. Returns 59984642e01fSmrg newly allocated full path name if found, NULL otherwise 59994642e01fSmrg Does not chase symlinks, even on platforms that support them. 60004642e01fSmrg*/ 60014642e01fSmrgchar * 60024642e01fSmrgfind_executable (const char *wrapper) 60034642e01fSmrg{ 60044642e01fSmrg int has_slash = 0; 60054642e01fSmrg const char *p; 60064642e01fSmrg const char *p_next; 60074642e01fSmrg /* static buffer for getcwd */ 60084642e01fSmrg char tmp[LT_PATHMAX + 1]; 600935c4bbdfSmrg size_t tmp_len; 60104642e01fSmrg char *concat_name; 601105b261ecSmrg 60126747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 60136747b715Smrg nonempty (wrapper)); 601405b261ecSmrg 60154642e01fSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 60164642e01fSmrg return NULL; 601705b261ecSmrg 60184642e01fSmrg /* Absolute path? */ 601935c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60204642e01fSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 60214642e01fSmrg { 60224642e01fSmrg concat_name = xstrdup (wrapper); 60234642e01fSmrg if (check_executable (concat_name)) 60244642e01fSmrg return concat_name; 60254642e01fSmrg XFREE (concat_name); 60264642e01fSmrg } 60274642e01fSmrg else 60284642e01fSmrg { 60294642e01fSmrg#endif 60304642e01fSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 60314642e01fSmrg { 60324642e01fSmrg concat_name = xstrdup (wrapper); 60334642e01fSmrg if (check_executable (concat_name)) 60344642e01fSmrg return concat_name; 60354642e01fSmrg XFREE (concat_name); 60364642e01fSmrg } 603735c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60384642e01fSmrg } 60394642e01fSmrg#endif 604005b261ecSmrg 60414642e01fSmrg for (p = wrapper; *p; p++) 60424642e01fSmrg if (*p == '/') 60434642e01fSmrg { 60444642e01fSmrg has_slash = 1; 60454642e01fSmrg break; 60464642e01fSmrg } 60474642e01fSmrg if (!has_slash) 60484642e01fSmrg { 60494642e01fSmrg /* no slashes; search PATH */ 60504642e01fSmrg const char *path = getenv ("PATH"); 60514642e01fSmrg if (path != NULL) 60524642e01fSmrg { 60534642e01fSmrg for (p = path; *p; p = p_next) 60544642e01fSmrg { 60554642e01fSmrg const char *q; 60564642e01fSmrg size_t p_len; 60574642e01fSmrg for (q = p; *q; q++) 60584642e01fSmrg if (IS_PATH_SEPARATOR (*q)) 60594642e01fSmrg break; 606035c4bbdfSmrg p_len = (size_t) (q - p); 60614642e01fSmrg p_next = (*q == '\0' ? q : q + 1); 60624642e01fSmrg if (p_len == 0) 60634642e01fSmrg { 60644642e01fSmrg /* empty path: current directory */ 60654642e01fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60666747b715Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60676747b715Smrg nonnull (strerror (errno))); 60684642e01fSmrg tmp_len = strlen (tmp); 60694642e01fSmrg concat_name = 60704642e01fSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60714642e01fSmrg memcpy (concat_name, tmp, tmp_len); 60724642e01fSmrg concat_name[tmp_len] = '/'; 60734642e01fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 60744642e01fSmrg } 60754642e01fSmrg else 60764642e01fSmrg { 60774642e01fSmrg concat_name = 60784642e01fSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 60794642e01fSmrg memcpy (concat_name, p, p_len); 60804642e01fSmrg concat_name[p_len] = '/'; 60814642e01fSmrg strcpy (concat_name + p_len + 1, wrapper); 60824642e01fSmrg } 60834642e01fSmrg if (check_executable (concat_name)) 60844642e01fSmrg return concat_name; 60854642e01fSmrg XFREE (concat_name); 60864642e01fSmrg } 60874642e01fSmrg } 60884642e01fSmrg /* not found in PATH; assume curdir */ 60894642e01fSmrg } 60904642e01fSmrg /* Relative path | not found in path: prepend cwd */ 60914642e01fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60926747b715Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60936747b715Smrg nonnull (strerror (errno))); 60944642e01fSmrg tmp_len = strlen (tmp); 60954642e01fSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60964642e01fSmrg memcpy (concat_name, tmp, tmp_len); 60974642e01fSmrg concat_name[tmp_len] = '/'; 60984642e01fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 609905b261ecSmrg 61004642e01fSmrg if (check_executable (concat_name)) 61014642e01fSmrg return concat_name; 61024642e01fSmrg XFREE (concat_name); 61034642e01fSmrg return NULL; 61044642e01fSmrg} 610505b261ecSmrg 61064642e01fSmrgchar * 61074642e01fSmrgchase_symlinks (const char *pathspec) 61084642e01fSmrg{ 61094642e01fSmrg#ifndef S_ISLNK 61104642e01fSmrg return xstrdup (pathspec); 61114642e01fSmrg#else 61124642e01fSmrg char buf[LT_PATHMAX]; 61134642e01fSmrg struct stat s; 61144642e01fSmrg char *tmp_pathspec = xstrdup (pathspec); 61154642e01fSmrg char *p; 61164642e01fSmrg int has_symlinks = 0; 61174642e01fSmrg while (strlen (tmp_pathspec) && !has_symlinks) 61184642e01fSmrg { 61196747b715Smrg lt_debugprintf (__FILE__, __LINE__, 61206747b715Smrg "checking path component for symlinks: %s\n", 61216747b715Smrg tmp_pathspec); 61224642e01fSmrg if (lstat (tmp_pathspec, &s) == 0) 61234642e01fSmrg { 61244642e01fSmrg if (S_ISLNK (s.st_mode) != 0) 61254642e01fSmrg { 61264642e01fSmrg has_symlinks = 1; 61274642e01fSmrg break; 61284642e01fSmrg } 612905b261ecSmrg 61304642e01fSmrg /* search backwards for last DIR_SEPARATOR */ 61314642e01fSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 61324642e01fSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61334642e01fSmrg p--; 61344642e01fSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61354642e01fSmrg { 61364642e01fSmrg /* no more DIR_SEPARATORS left */ 61374642e01fSmrg break; 61384642e01fSmrg } 61394642e01fSmrg *p = '\0'; 61404642e01fSmrg } 61414642e01fSmrg else 61424642e01fSmrg { 61436747b715Smrg lt_fatal (__FILE__, __LINE__, 61446747b715Smrg "error accessing file \"%s\": %s", 61456747b715Smrg tmp_pathspec, nonnull (strerror (errno))); 61464642e01fSmrg } 61474642e01fSmrg } 61484642e01fSmrg XFREE (tmp_pathspec); 614905b261ecSmrg 61504642e01fSmrg if (!has_symlinks) 61514642e01fSmrg { 61524642e01fSmrg return xstrdup (pathspec); 61534642e01fSmrg } 615405b261ecSmrg 61554642e01fSmrg tmp_pathspec = realpath (pathspec, buf); 61564642e01fSmrg if (tmp_pathspec == 0) 61574642e01fSmrg { 61586747b715Smrg lt_fatal (__FILE__, __LINE__, 61596747b715Smrg "could not follow symlinks for %s", pathspec); 61604642e01fSmrg } 61614642e01fSmrg return xstrdup (tmp_pathspec); 61624642e01fSmrg#endif 61634642e01fSmrg} 616405b261ecSmrg 61654642e01fSmrgchar * 61664642e01fSmrgstrendzap (char *str, const char *pat) 61674642e01fSmrg{ 61684642e01fSmrg size_t len, patlen; 616905b261ecSmrg 61704642e01fSmrg assert (str != NULL); 61714642e01fSmrg assert (pat != NULL); 617205b261ecSmrg 61734642e01fSmrg len = strlen (str); 61744642e01fSmrg patlen = strlen (pat); 617505b261ecSmrg 61764642e01fSmrg if (patlen <= len) 61774642e01fSmrg { 61784642e01fSmrg str += len - patlen; 617935c4bbdfSmrg if (STREQ (str, pat)) 61804642e01fSmrg *str = '\0'; 61814642e01fSmrg } 61824642e01fSmrg return str; 61834642e01fSmrg} 618405b261ecSmrg 61856747b715Smrgvoid 61866747b715Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 61876747b715Smrg{ 61886747b715Smrg va_list args; 61896747b715Smrg if (lt_debug) 61906747b715Smrg { 61916747b715Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 61926747b715Smrg va_start (args, fmt); 61936747b715Smrg (void) vfprintf (stderr, fmt, args); 61946747b715Smrg va_end (args); 61956747b715Smrg } 61966747b715Smrg} 61976747b715Smrg 61984642e01fSmrgstatic void 61996747b715Smrglt_error_core (int exit_status, const char *file, 62006747b715Smrg int line, const char *mode, 62014642e01fSmrg const char *message, va_list ap) 62024642e01fSmrg{ 62036747b715Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 62044642e01fSmrg vfprintf (stderr, message, ap); 62054642e01fSmrg fprintf (stderr, ".\n"); 620605b261ecSmrg 62074642e01fSmrg if (exit_status >= 0) 62084642e01fSmrg exit (exit_status); 62094642e01fSmrg} 621005b261ecSmrg 62114642e01fSmrgvoid 62126747b715Smrglt_fatal (const char *file, int line, const char *message, ...) 62134642e01fSmrg{ 62144642e01fSmrg va_list ap; 62154642e01fSmrg va_start (ap, message); 62166747b715Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 62174642e01fSmrg va_end (ap); 62184642e01fSmrg} 621905b261ecSmrg 62206747b715Smrgstatic const char * 62216747b715Smrgnonnull (const char *s) 62226747b715Smrg{ 62236747b715Smrg return s ? s : "(null)"; 62246747b715Smrg} 62256747b715Smrg 62266747b715Smrgstatic const char * 62276747b715Smrgnonempty (const char *s) 62286747b715Smrg{ 62296747b715Smrg return (s && !*s) ? "(empty)" : nonnull (s); 62306747b715Smrg} 62316747b715Smrg 62324642e01fSmrgvoid 62334642e01fSmrglt_setenv (const char *name, const char *value) 62344642e01fSmrg{ 62356747b715Smrg lt_debugprintf (__FILE__, __LINE__, 62366747b715Smrg "(lt_setenv) setting '%s' to '%s'\n", 62376747b715Smrg nonnull (name), nonnull (value)); 62384642e01fSmrg { 62394642e01fSmrg#ifdef HAVE_SETENV 62404642e01fSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 62414642e01fSmrg char *str = xstrdup (value); 62424642e01fSmrg setenv (name, str, 1); 62434642e01fSmrg#else 624435c4bbdfSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 62454642e01fSmrg char *str = XMALLOC (char, len); 62464642e01fSmrg sprintf (str, "%s=%s", name, value); 62474642e01fSmrg if (putenv (str) != EXIT_SUCCESS) 62484642e01fSmrg { 62494642e01fSmrg XFREE (str); 62504642e01fSmrg } 62514642e01fSmrg#endif 62524642e01fSmrg } 62534642e01fSmrg} 625405b261ecSmrg 62554642e01fSmrgchar * 62564642e01fSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 62574642e01fSmrg{ 62584642e01fSmrg char *new_value; 62594642e01fSmrg if (orig_value && *orig_value) 62604642e01fSmrg { 626135c4bbdfSmrg size_t orig_value_len = strlen (orig_value); 626235c4bbdfSmrg size_t add_len = strlen (add); 62634642e01fSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 62644642e01fSmrg if (to_end) 62654642e01fSmrg { 62664642e01fSmrg strcpy (new_value, orig_value); 62674642e01fSmrg strcpy (new_value + orig_value_len, add); 62684642e01fSmrg } 62694642e01fSmrg else 62704642e01fSmrg { 62714642e01fSmrg strcpy (new_value, add); 62724642e01fSmrg strcpy (new_value + add_len, orig_value); 62734642e01fSmrg } 62744642e01fSmrg } 62754642e01fSmrg else 62764642e01fSmrg { 62774642e01fSmrg new_value = xstrdup (add); 62784642e01fSmrg } 62794642e01fSmrg return new_value; 62804642e01fSmrg} 628105b261ecSmrg 62824642e01fSmrgvoid 62834642e01fSmrglt_update_exe_path (const char *name, const char *value) 62844642e01fSmrg{ 62856747b715Smrg lt_debugprintf (__FILE__, __LINE__, 62866747b715Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 62876747b715Smrg nonnull (name), nonnull (value)); 628805b261ecSmrg 62894642e01fSmrg if (name && *name && value && *value) 62904642e01fSmrg { 62914642e01fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 62924642e01fSmrg /* some systems can't cope with a ':'-terminated path #' */ 629335c4bbdfSmrg size_t len = strlen (new_value); 629435c4bbdfSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 62954642e01fSmrg { 629635c4bbdfSmrg new_value[--len] = '\0'; 62974642e01fSmrg } 62984642e01fSmrg lt_setenv (name, new_value); 62994642e01fSmrg XFREE (new_value); 63004642e01fSmrg } 63014642e01fSmrg} 630205b261ecSmrg 63034642e01fSmrgvoid 63044642e01fSmrglt_update_lib_path (const char *name, const char *value) 63054642e01fSmrg{ 63066747b715Smrg lt_debugprintf (__FILE__, __LINE__, 63076747b715Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 63086747b715Smrg nonnull (name), nonnull (value)); 630905b261ecSmrg 63104642e01fSmrg if (name && *name && value && *value) 63114642e01fSmrg { 63124642e01fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 63134642e01fSmrg lt_setenv (name, new_value); 63144642e01fSmrg XFREE (new_value); 63154642e01fSmrg } 63164642e01fSmrg} 631705b261ecSmrg 63186747b715SmrgEOF 63196747b715Smrg case $host_os in 63206747b715Smrg mingw*) 63216747b715Smrg cat <<"EOF" 63226747b715Smrg 63236747b715Smrg/* Prepares an argument vector before calling spawn(). 63246747b715Smrg Note that spawn() does not by itself call the command interpreter 63256747b715Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 63266747b715Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 63276747b715Smrg GetVersionEx(&v); 63286747b715Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 63296747b715Smrg }) ? "cmd.exe" : "command.com"). 63306747b715Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 63316747b715Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 63326747b715Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 63336747b715Smrg special way: 63346747b715Smrg - Space and tab are interpreted as delimiters. They are not treated as 63356747b715Smrg delimiters if they are surrounded by double quotes: "...". 63366747b715Smrg - Unescaped double quotes are removed from the input. Their only effect is 63376747b715Smrg that within double quotes, space and tab are treated like normal 63386747b715Smrg characters. 63396747b715Smrg - Backslashes not followed by double quotes are not special. 63406747b715Smrg - But 2*n+1 backslashes followed by a double quote become 63416747b715Smrg n backslashes followed by a double quote (n >= 0): 63426747b715Smrg \" -> " 63436747b715Smrg \\\" -> \" 63446747b715Smrg \\\\\" -> \\" 63456747b715Smrg */ 63466747b715Smrg#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" 63476747b715Smrg#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" 63486747b715Smrgchar ** 63496747b715Smrgprepare_spawn (char **argv) 63506747b715Smrg{ 63516747b715Smrg size_t argc; 63526747b715Smrg char **new_argv; 63536747b715Smrg size_t i; 63546747b715Smrg 63556747b715Smrg /* Count number of arguments. */ 63566747b715Smrg for (argc = 0; argv[argc] != NULL; argc++) 63576747b715Smrg ; 63586747b715Smrg 63596747b715Smrg /* Allocate new argument vector. */ 63606747b715Smrg new_argv = XMALLOC (char *, argc + 1); 63616747b715Smrg 63626747b715Smrg /* Put quoted arguments into the new argument vector. */ 63636747b715Smrg for (i = 0; i < argc; i++) 63646747b715Smrg { 63656747b715Smrg const char *string = argv[i]; 63666747b715Smrg 63676747b715Smrg if (string[0] == '\0') 63686747b715Smrg new_argv[i] = xstrdup ("\"\""); 63696747b715Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 63706747b715Smrg { 63716747b715Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 63726747b715Smrg size_t length; 63736747b715Smrg unsigned int backslashes; 63746747b715Smrg const char *s; 63756747b715Smrg char *quoted_string; 63766747b715Smrg char *p; 63776747b715Smrg 63786747b715Smrg length = 0; 63796747b715Smrg backslashes = 0; 63806747b715Smrg if (quote_around) 63816747b715Smrg length++; 63826747b715Smrg for (s = string; *s != '\0'; s++) 63836747b715Smrg { 63846747b715Smrg char c = *s; 63856747b715Smrg if (c == '"') 63866747b715Smrg length += backslashes + 1; 63876747b715Smrg length++; 63886747b715Smrg if (c == '\\') 63896747b715Smrg backslashes++; 63906747b715Smrg else 63916747b715Smrg backslashes = 0; 63926747b715Smrg } 63936747b715Smrg if (quote_around) 63946747b715Smrg length += backslashes + 1; 63956747b715Smrg 63966747b715Smrg quoted_string = XMALLOC (char, length + 1); 63976747b715Smrg 63986747b715Smrg p = quoted_string; 63996747b715Smrg backslashes = 0; 64006747b715Smrg if (quote_around) 64016747b715Smrg *p++ = '"'; 64026747b715Smrg for (s = string; *s != '\0'; s++) 64036747b715Smrg { 64046747b715Smrg char c = *s; 64056747b715Smrg if (c == '"') 64066747b715Smrg { 64076747b715Smrg unsigned int j; 64086747b715Smrg for (j = backslashes + 1; j > 0; j--) 64096747b715Smrg *p++ = '\\'; 64106747b715Smrg } 64116747b715Smrg *p++ = c; 64126747b715Smrg if (c == '\\') 64136747b715Smrg backslashes++; 64146747b715Smrg else 64156747b715Smrg backslashes = 0; 64166747b715Smrg } 64176747b715Smrg if (quote_around) 64186747b715Smrg { 64196747b715Smrg unsigned int j; 64206747b715Smrg for (j = backslashes; j > 0; j--) 64216747b715Smrg *p++ = '\\'; 64226747b715Smrg *p++ = '"'; 64236747b715Smrg } 64246747b715Smrg *p = '\0'; 64256747b715Smrg 64266747b715Smrg new_argv[i] = quoted_string; 64276747b715Smrg } 64286747b715Smrg else 64296747b715Smrg new_argv[i] = (char *) string; 64306747b715Smrg } 64316747b715Smrg new_argv[argc] = NULL; 64326747b715Smrg 64336747b715Smrg return new_argv; 64346747b715Smrg} 64356747b715SmrgEOF 64366747b715Smrg ;; 64376747b715Smrg esac 64386747b715Smrg 64396747b715Smrg cat <<"EOF" 64406747b715Smrgvoid lt_dump_script (FILE* f) 64416747b715Smrg{ 64426747b715SmrgEOF 64436747b715Smrg func_emit_wrapper yes | 644435c4bbdfSmrg $SED -n -e ' 644535c4bbdfSmrgs/^\(.\{79\}\)\(..*\)/\1\ 644635c4bbdfSmrg\2/ 644735c4bbdfSmrgh 644835c4bbdfSmrgs/\([\\"]\)/\\\1/g 644935c4bbdfSmrgs/$/\\n/ 645035c4bbdfSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 645135c4bbdfSmrgg 645235c4bbdfSmrgD' 64536747b715Smrg cat <<"EOF" 64546747b715Smrg} 64554642e01fSmrgEOF 64564642e01fSmrg} 64574642e01fSmrg# end: func_emit_cwrapperexe_src 645805b261ecSmrg 64596747b715Smrg# func_win32_import_lib_p ARG 64606747b715Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 64616747b715Smrgfunc_win32_import_lib_p () 64626747b715Smrg{ 646335c4bbdfSmrg $debug_cmd 646435c4bbdfSmrg 64656747b715Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 64666747b715Smrg *import*) : ;; 64676747b715Smrg *) false ;; 64686747b715Smrg esac 64696747b715Smrg} 64706747b715Smrg 647135c4bbdfSmrg# func_suncc_cstd_abi 647235c4bbdfSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647335c4bbdfSmrg# Several compiler flags select an ABI that is incompatible with the 647435c4bbdfSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647535c4bbdfSmrgfunc_suncc_cstd_abi () 647635c4bbdfSmrg{ 647735c4bbdfSmrg $debug_cmd 647835c4bbdfSmrg 647935c4bbdfSmrg case " $compile_command " in 648035c4bbdfSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648135c4bbdfSmrg suncc_use_cstd_abi=no 648235c4bbdfSmrg ;; 648335c4bbdfSmrg *) 648435c4bbdfSmrg suncc_use_cstd_abi=yes 648535c4bbdfSmrg ;; 648635c4bbdfSmrg esac 648735c4bbdfSmrg} 648835c4bbdfSmrg 64894642e01fSmrg# func_mode_link arg... 64904642e01fSmrgfunc_mode_link () 64914642e01fSmrg{ 649235c4bbdfSmrg $debug_cmd 649335c4bbdfSmrg 64944642e01fSmrg case $host in 64954642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 64964642e01fSmrg # It is impossible to link a dll without this setting, and 64974642e01fSmrg # we shouldn't force the makefile maintainer to figure out 649835c4bbdfSmrg # what system we are compiling for in order to pass an extra 64994642e01fSmrg # flag for every libtool invocation. 65004642e01fSmrg # allow_undefined=no 650105b261ecSmrg 65024642e01fSmrg # FIXME: Unfortunately, there are problems with the above when trying 650335c4bbdfSmrg # to make a dll that has undefined symbols, in which case not 65044642e01fSmrg # even a static library is built. For now, we need to specify 65054642e01fSmrg # -no-undefined on the libtool link line when we can be certain 65064642e01fSmrg # that all symbols are satisfied, otherwise we get a static library. 65074642e01fSmrg allow_undefined=yes 65084642e01fSmrg ;; 65094642e01fSmrg *) 65104642e01fSmrg allow_undefined=yes 65114642e01fSmrg ;; 65124642e01fSmrg esac 65134642e01fSmrg libtool_args=$nonopt 65144642e01fSmrg base_compile="$nonopt $@" 65154642e01fSmrg compile_command=$nonopt 65164642e01fSmrg finalize_command=$nonopt 651705b261ecSmrg 65184642e01fSmrg compile_rpath= 65194642e01fSmrg finalize_rpath= 65204642e01fSmrg compile_shlibpath= 65214642e01fSmrg finalize_shlibpath= 65224642e01fSmrg convenience= 65234642e01fSmrg old_convenience= 65244642e01fSmrg deplibs= 65254642e01fSmrg old_deplibs= 65264642e01fSmrg compiler_flags= 65274642e01fSmrg linker_flags= 65284642e01fSmrg dllsearchpath= 65294642e01fSmrg lib_search_path=`pwd` 65304642e01fSmrg inst_prefix_dir= 65314642e01fSmrg new_inherited_linker_flags= 653205b261ecSmrg 65334642e01fSmrg avoid_version=no 65346747b715Smrg bindir= 65354642e01fSmrg dlfiles= 65364642e01fSmrg dlprefiles= 65374642e01fSmrg dlself=no 65384642e01fSmrg export_dynamic=no 65394642e01fSmrg export_symbols= 65404642e01fSmrg export_symbols_regex= 65414642e01fSmrg generated= 65424642e01fSmrg libobjs= 65434642e01fSmrg ltlibs= 65444642e01fSmrg module=no 65454642e01fSmrg no_install=no 65464642e01fSmrg objs= 654735c4bbdfSmrg os2dllname= 65484642e01fSmrg non_pic_objects= 65494642e01fSmrg precious_files_regex= 65504642e01fSmrg prefer_static_libs=no 655135c4bbdfSmrg preload=false 65524642e01fSmrg prev= 65534642e01fSmrg prevarg= 65544642e01fSmrg release= 65554642e01fSmrg rpath= 65564642e01fSmrg xrpath= 65574642e01fSmrg perm_rpath= 65584642e01fSmrg temp_rpath= 65594642e01fSmrg thread_safe=no 65604642e01fSmrg vinfo= 65614642e01fSmrg vinfo_number=no 65624642e01fSmrg weak_libs= 656335c4bbdfSmrg single_module=$wl-single_module 65644642e01fSmrg func_infer_tag $base_compile 656505b261ecSmrg 65664642e01fSmrg # We need to know -static, to get the right output filenames. 65674642e01fSmrg for arg 65684642e01fSmrg do 65694642e01fSmrg case $arg in 65704642e01fSmrg -shared) 657135c4bbdfSmrg test yes != "$build_libtool_libs" \ 657235c4bbdfSmrg && func_fatal_configuration "cannot build a shared library" 65734642e01fSmrg build_old_libs=no 65744642e01fSmrg break 65754642e01fSmrg ;; 65764642e01fSmrg -all-static | -static | -static-libtool-libs) 65774642e01fSmrg case $arg in 65784642e01fSmrg -all-static) 657935c4bbdfSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 65804642e01fSmrg func_warning "complete static linking is impossible in this configuration" 65814642e01fSmrg fi 65824642e01fSmrg if test -n "$link_static_flag"; then 65834642e01fSmrg dlopen_self=$dlopen_self_static 65844642e01fSmrg fi 65854642e01fSmrg prefer_static_libs=yes 65864642e01fSmrg ;; 65874642e01fSmrg -static) 65884642e01fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65894642e01fSmrg dlopen_self=$dlopen_self_static 65904642e01fSmrg fi 65914642e01fSmrg prefer_static_libs=built 65924642e01fSmrg ;; 65934642e01fSmrg -static-libtool-libs) 65944642e01fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65954642e01fSmrg dlopen_self=$dlopen_self_static 65964642e01fSmrg fi 65974642e01fSmrg prefer_static_libs=yes 65984642e01fSmrg ;; 65994642e01fSmrg esac 66004642e01fSmrg build_libtool_libs=no 66014642e01fSmrg build_old_libs=yes 66024642e01fSmrg break 66034642e01fSmrg ;; 66044642e01fSmrg esac 66054642e01fSmrg done 660605b261ecSmrg 66074642e01fSmrg # See if our shared archives depend on static archives. 66084642e01fSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 660905b261ecSmrg 66104642e01fSmrg # Go through the arguments, transforming them on the way. 66114642e01fSmrg while test "$#" -gt 0; do 661235c4bbdfSmrg arg=$1 66134642e01fSmrg shift 66144642e01fSmrg func_quote_for_eval "$arg" 66154642e01fSmrg qarg=$func_quote_for_eval_unquoted_result 66164642e01fSmrg func_append libtool_args " $func_quote_for_eval_result" 661705b261ecSmrg 66184642e01fSmrg # If the previous option needs an argument, assign it. 66194642e01fSmrg if test -n "$prev"; then 66204642e01fSmrg case $prev in 66214642e01fSmrg output) 66224642e01fSmrg func_append compile_command " @OUTPUT@" 66234642e01fSmrg func_append finalize_command " @OUTPUT@" 66244642e01fSmrg ;; 66254642e01fSmrg esac 662605b261ecSmrg 66274642e01fSmrg case $prev in 66286747b715Smrg bindir) 662935c4bbdfSmrg bindir=$arg 66306747b715Smrg prev= 66316747b715Smrg continue 66326747b715Smrg ;; 66334642e01fSmrg dlfiles|dlprefiles) 663435c4bbdfSmrg $preload || { 66354642e01fSmrg # Add the symbol object into the linking commands. 66364642e01fSmrg func_append compile_command " @SYMFILE@" 66374642e01fSmrg func_append finalize_command " @SYMFILE@" 663835c4bbdfSmrg preload=: 663935c4bbdfSmrg } 66404642e01fSmrg case $arg in 66414642e01fSmrg *.la | *.lo) ;; # We handle these cases below. 66424642e01fSmrg force) 664335c4bbdfSmrg if test no = "$dlself"; then 66444642e01fSmrg dlself=needless 66454642e01fSmrg export_dynamic=yes 66464642e01fSmrg fi 66474642e01fSmrg prev= 66484642e01fSmrg continue 66494642e01fSmrg ;; 66504642e01fSmrg self) 665135c4bbdfSmrg if test dlprefiles = "$prev"; then 66524642e01fSmrg dlself=yes 665335c4bbdfSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 66544642e01fSmrg dlself=yes 66554642e01fSmrg else 66564642e01fSmrg dlself=needless 66574642e01fSmrg export_dynamic=yes 66584642e01fSmrg fi 66594642e01fSmrg prev= 66604642e01fSmrg continue 66614642e01fSmrg ;; 66624642e01fSmrg *) 666335c4bbdfSmrg if test dlfiles = "$prev"; then 666435c4bbdfSmrg func_append dlfiles " $arg" 66654642e01fSmrg else 666635c4bbdfSmrg func_append dlprefiles " $arg" 66674642e01fSmrg fi 66684642e01fSmrg prev= 66694642e01fSmrg continue 66704642e01fSmrg ;; 66714642e01fSmrg esac 66724642e01fSmrg ;; 66734642e01fSmrg expsyms) 667435c4bbdfSmrg export_symbols=$arg 66754642e01fSmrg test -f "$arg" \ 667635c4bbdfSmrg || func_fatal_error "symbol file '$arg' does not exist" 66774642e01fSmrg prev= 66784642e01fSmrg continue 66794642e01fSmrg ;; 66804642e01fSmrg expsyms_regex) 668135c4bbdfSmrg export_symbols_regex=$arg 66824642e01fSmrg prev= 66834642e01fSmrg continue 66844642e01fSmrg ;; 66854642e01fSmrg framework) 668605b261ecSmrg case $host in 66874642e01fSmrg *-*-darwin*) 66884642e01fSmrg case "$deplibs " in 66894642e01fSmrg *" $qarg.ltframework "*) ;; 669035c4bbdfSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 66914642e01fSmrg ;; 66924642e01fSmrg esac 66934642e01fSmrg ;; 669405b261ecSmrg esac 66954642e01fSmrg prev= 66964642e01fSmrg continue 669705b261ecSmrg ;; 66984642e01fSmrg inst_prefix) 669935c4bbdfSmrg inst_prefix_dir=$arg 670035c4bbdfSmrg prev= 670135c4bbdfSmrg continue 670235c4bbdfSmrg ;; 670335c4bbdfSmrg mllvm) 670435c4bbdfSmrg # Clang does not use LLVM to link, so we can simply discard any 670535c4bbdfSmrg # '-mllvm $arg' options when doing the link step. 67064642e01fSmrg prev= 67074642e01fSmrg continue 670805b261ecSmrg ;; 67094642e01fSmrg objectlist) 67104642e01fSmrg if test -f "$arg"; then 67114642e01fSmrg save_arg=$arg 67124642e01fSmrg moreargs= 67134642e01fSmrg for fil in `cat "$save_arg"` 67144642e01fSmrg do 671535c4bbdfSmrg# func_append moreargs " $fil" 67164642e01fSmrg arg=$fil 67174642e01fSmrg # A libtool-controlled object. 671805b261ecSmrg 67194642e01fSmrg # Check to see that this really is a libtool object. 67204642e01fSmrg if func_lalib_unsafe_p "$arg"; then 67214642e01fSmrg pic_object= 67224642e01fSmrg non_pic_object= 672305b261ecSmrg 67244642e01fSmrg # Read the .lo file 67254642e01fSmrg func_source "$arg" 672605b261ecSmrg 67274642e01fSmrg if test -z "$pic_object" || 67284642e01fSmrg test -z "$non_pic_object" || 672935c4bbdfSmrg test none = "$pic_object" && 673035c4bbdfSmrg test none = "$non_pic_object"; then 673135c4bbdfSmrg func_fatal_error "cannot find name of object for '$arg'" 67324642e01fSmrg fi 673305b261ecSmrg 67344642e01fSmrg # Extract subdirectory from the argument. 67354642e01fSmrg func_dirname "$arg" "/" "" 673635c4bbdfSmrg xdir=$func_dirname_result 673705b261ecSmrg 673835c4bbdfSmrg if test none != "$pic_object"; then 67394642e01fSmrg # Prepend the subdirectory the object is found in. 674035c4bbdfSmrg pic_object=$xdir$pic_object 674105b261ecSmrg 674235c4bbdfSmrg if test dlfiles = "$prev"; then 674335c4bbdfSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674435c4bbdfSmrg func_append dlfiles " $pic_object" 67454642e01fSmrg prev= 67464642e01fSmrg continue 67474642e01fSmrg else 67484642e01fSmrg # If libtool objects are unsupported, then we need to preload. 67494642e01fSmrg prev=dlprefiles 67504642e01fSmrg fi 67514642e01fSmrg fi 675205b261ecSmrg 67534642e01fSmrg # CHECK ME: I think I busted this. -Ossama 675435c4bbdfSmrg if test dlprefiles = "$prev"; then 67554642e01fSmrg # Preload the old-style object. 675635c4bbdfSmrg func_append dlprefiles " $pic_object" 67574642e01fSmrg prev= 67584642e01fSmrg fi 675905b261ecSmrg 67604642e01fSmrg # A PIC object. 67614642e01fSmrg func_append libobjs " $pic_object" 676235c4bbdfSmrg arg=$pic_object 67634642e01fSmrg fi 676405b261ecSmrg 67654642e01fSmrg # Non-PIC object. 676635c4bbdfSmrg if test none != "$non_pic_object"; then 67674642e01fSmrg # Prepend the subdirectory the object is found in. 676835c4bbdfSmrg non_pic_object=$xdir$non_pic_object 676905b261ecSmrg 67704642e01fSmrg # A standard non-PIC object 67714642e01fSmrg func_append non_pic_objects " $non_pic_object" 677235c4bbdfSmrg if test -z "$pic_object" || test none = "$pic_object"; then 677335c4bbdfSmrg arg=$non_pic_object 67744642e01fSmrg fi 67754642e01fSmrg else 67764642e01fSmrg # If the PIC object exists, use it instead. 67774642e01fSmrg # $xdir was prepended to $pic_object above. 677835c4bbdfSmrg non_pic_object=$pic_object 67794642e01fSmrg func_append non_pic_objects " $non_pic_object" 67804642e01fSmrg fi 67814642e01fSmrg else 67824642e01fSmrg # Only an error if not doing a dry-run. 67834642e01fSmrg if $opt_dry_run; then 67844642e01fSmrg # Extract subdirectory from the argument. 67854642e01fSmrg func_dirname "$arg" "/" "" 678635c4bbdfSmrg xdir=$func_dirname_result 67874642e01fSmrg 67884642e01fSmrg func_lo2o "$arg" 67894642e01fSmrg pic_object=$xdir$objdir/$func_lo2o_result 67904642e01fSmrg non_pic_object=$xdir$func_lo2o_result 67914642e01fSmrg func_append libobjs " $pic_object" 67924642e01fSmrg func_append non_pic_objects " $non_pic_object" 67934642e01fSmrg else 679435c4bbdfSmrg func_fatal_error "'$arg' is not a valid libtool object" 67954642e01fSmrg fi 67964642e01fSmrg fi 67974642e01fSmrg done 679805b261ecSmrg else 679935c4bbdfSmrg func_fatal_error "link input file '$arg' does not exist" 680005b261ecSmrg fi 68014642e01fSmrg arg=$save_arg 68024642e01fSmrg prev= 68034642e01fSmrg continue 68044642e01fSmrg ;; 680535c4bbdfSmrg os2dllname) 680635c4bbdfSmrg os2dllname=$arg 680735c4bbdfSmrg prev= 680835c4bbdfSmrg continue 680935c4bbdfSmrg ;; 68104642e01fSmrg precious_regex) 681135c4bbdfSmrg precious_files_regex=$arg 68124642e01fSmrg prev= 68134642e01fSmrg continue 68144642e01fSmrg ;; 68154642e01fSmrg release) 681635c4bbdfSmrg release=-$arg 68174642e01fSmrg prev= 68184642e01fSmrg continue 68194642e01fSmrg ;; 68204642e01fSmrg rpath | xrpath) 68214642e01fSmrg # We need an absolute path. 68224642e01fSmrg case $arg in 68234642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 68244642e01fSmrg *) 68254642e01fSmrg func_fatal_error "only absolute run-paths are allowed" 68264642e01fSmrg ;; 68274642e01fSmrg esac 682835c4bbdfSmrg if test rpath = "$prev"; then 68294642e01fSmrg case "$rpath " in 68304642e01fSmrg *" $arg "*) ;; 683135c4bbdfSmrg *) func_append rpath " $arg" ;; 68324642e01fSmrg esac 683305b261ecSmrg else 68344642e01fSmrg case "$xrpath " in 68354642e01fSmrg *" $arg "*) ;; 683635c4bbdfSmrg *) func_append xrpath " $arg" ;; 68374642e01fSmrg esac 683805b261ecSmrg fi 68394642e01fSmrg prev= 68404642e01fSmrg continue 68414642e01fSmrg ;; 68424642e01fSmrg shrext) 684335c4bbdfSmrg shrext_cmds=$arg 68444642e01fSmrg prev= 68454642e01fSmrg continue 68464642e01fSmrg ;; 68474642e01fSmrg weak) 684835c4bbdfSmrg func_append weak_libs " $arg" 68494642e01fSmrg prev= 68504642e01fSmrg continue 68514642e01fSmrg ;; 68524642e01fSmrg xcclinker) 685335c4bbdfSmrg func_append linker_flags " $qarg" 685435c4bbdfSmrg func_append compiler_flags " $qarg" 68554642e01fSmrg prev= 68564642e01fSmrg func_append compile_command " $qarg" 68574642e01fSmrg func_append finalize_command " $qarg" 68584642e01fSmrg continue 68594642e01fSmrg ;; 68604642e01fSmrg xcompiler) 686135c4bbdfSmrg func_append compiler_flags " $qarg" 68624642e01fSmrg prev= 68634642e01fSmrg func_append compile_command " $qarg" 68644642e01fSmrg func_append finalize_command " $qarg" 68654642e01fSmrg continue 68664642e01fSmrg ;; 68674642e01fSmrg xlinker) 686835c4bbdfSmrg func_append linker_flags " $qarg" 686935c4bbdfSmrg func_append compiler_flags " $wl$qarg" 68704642e01fSmrg prev= 68714642e01fSmrg func_append compile_command " $wl$qarg" 68724642e01fSmrg func_append finalize_command " $wl$qarg" 68734642e01fSmrg continue 68744642e01fSmrg ;; 68754642e01fSmrg *) 68764642e01fSmrg eval "$prev=\"\$arg\"" 68774642e01fSmrg prev= 68784642e01fSmrg continue 68794642e01fSmrg ;; 688005b261ecSmrg esac 68814642e01fSmrg fi # test -n "$prev" 688205b261ecSmrg 688335c4bbdfSmrg prevarg=$arg 688405b261ecSmrg 68854642e01fSmrg case $arg in 68864642e01fSmrg -all-static) 68874642e01fSmrg if test -n "$link_static_flag"; then 68884642e01fSmrg # See comment for -static flag below, for more details. 68894642e01fSmrg func_append compile_command " $link_static_flag" 68904642e01fSmrg func_append finalize_command " $link_static_flag" 68914642e01fSmrg fi 68924642e01fSmrg continue 68934642e01fSmrg ;; 689405b261ecSmrg 68954642e01fSmrg -allow-undefined) 68964642e01fSmrg # FIXME: remove this flag sometime in the future. 689735c4bbdfSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 68984642e01fSmrg ;; 689905b261ecSmrg 69004642e01fSmrg -avoid-version) 69014642e01fSmrg avoid_version=yes 69024642e01fSmrg continue 69034642e01fSmrg ;; 690405b261ecSmrg 69056747b715Smrg -bindir) 69066747b715Smrg prev=bindir 69076747b715Smrg continue 69086747b715Smrg ;; 69096747b715Smrg 69104642e01fSmrg -dlopen) 69114642e01fSmrg prev=dlfiles 69124642e01fSmrg continue 69134642e01fSmrg ;; 691405b261ecSmrg 69154642e01fSmrg -dlpreopen) 69164642e01fSmrg prev=dlprefiles 69174642e01fSmrg continue 69184642e01fSmrg ;; 691905b261ecSmrg 69204642e01fSmrg -export-dynamic) 69214642e01fSmrg export_dynamic=yes 69224642e01fSmrg continue 69234642e01fSmrg ;; 692405b261ecSmrg 69254642e01fSmrg -export-symbols | -export-symbols-regex) 69264642e01fSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 69274642e01fSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 69284642e01fSmrg fi 692935c4bbdfSmrg if test X-export-symbols = "X$arg"; then 69304642e01fSmrg prev=expsyms 69314642e01fSmrg else 69324642e01fSmrg prev=expsyms_regex 69334642e01fSmrg fi 69344642e01fSmrg continue 69354642e01fSmrg ;; 693605b261ecSmrg 69374642e01fSmrg -framework) 69384642e01fSmrg prev=framework 69394642e01fSmrg continue 69404642e01fSmrg ;; 694105b261ecSmrg 69424642e01fSmrg -inst-prefix-dir) 69434642e01fSmrg prev=inst_prefix 69444642e01fSmrg continue 69454642e01fSmrg ;; 694605b261ecSmrg 69474642e01fSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 69484642e01fSmrg # so, if we see these flags be careful not to treat them like -L 69494642e01fSmrg -L[A-Z][A-Z]*:*) 69504642e01fSmrg case $with_gcc/$host in 69514642e01fSmrg no/*-*-irix* | /*-*-irix*) 69524642e01fSmrg func_append compile_command " $arg" 69534642e01fSmrg func_append finalize_command " $arg" 69544642e01fSmrg ;; 69554642e01fSmrg esac 69564642e01fSmrg continue 69574642e01fSmrg ;; 695805b261ecSmrg 69594642e01fSmrg -L*) 696035c4bbdfSmrg func_stripname "-L" '' "$arg" 696135c4bbdfSmrg if test -z "$func_stripname_result"; then 69624642e01fSmrg if test "$#" -gt 0; then 696335c4bbdfSmrg func_fatal_error "require no space between '-L' and '$1'" 69644642e01fSmrg else 696535c4bbdfSmrg func_fatal_error "need path for '-L' option" 69664642e01fSmrg fi 69674642e01fSmrg fi 696835c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 696935c4bbdfSmrg dir=$func_resolve_sysroot_result 69704642e01fSmrg # We need an absolute path. 69714642e01fSmrg case $dir in 69724642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 69734642e01fSmrg *) 69744642e01fSmrg absdir=`cd "$dir" && pwd` 69754642e01fSmrg test -z "$absdir" && \ 697635c4bbdfSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697735c4bbdfSmrg dir=$absdir 69784642e01fSmrg ;; 69794642e01fSmrg esac 69804642e01fSmrg case "$deplibs " in 698135c4bbdfSmrg *" -L$dir "* | *" $arg "*) 698235c4bbdfSmrg # Will only happen for absolute or sysroot arguments 698335c4bbdfSmrg ;; 69844642e01fSmrg *) 698535c4bbdfSmrg # Preserve sysroot, but never include relative directories 698635c4bbdfSmrg case $dir in 698735c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698835c4bbdfSmrg *) func_append deplibs " -L$dir" ;; 698935c4bbdfSmrg esac 699035c4bbdfSmrg func_append lib_search_path " $dir" 69914642e01fSmrg ;; 69924642e01fSmrg esac 69934642e01fSmrg case $host in 69944642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 69956747b715Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 69964642e01fSmrg case :$dllsearchpath: in 69974642e01fSmrg *":$dir:"*) ;; 69984642e01fSmrg ::) dllsearchpath=$dir;; 699935c4bbdfSmrg *) func_append dllsearchpath ":$dir";; 70004642e01fSmrg esac 70014642e01fSmrg case :$dllsearchpath: in 70024642e01fSmrg *":$testbindir:"*) ;; 70034642e01fSmrg ::) dllsearchpath=$testbindir;; 700435c4bbdfSmrg *) func_append dllsearchpath ":$testbindir";; 70054642e01fSmrg esac 70064642e01fSmrg ;; 70074642e01fSmrg esac 70084642e01fSmrg continue 70094642e01fSmrg ;; 701005b261ecSmrg 70114642e01fSmrg -l*) 701235c4bbdfSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 70134642e01fSmrg case $host in 70146747b715Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 70154642e01fSmrg # These systems don't actually have a C or math library (as such) 70164642e01fSmrg continue 70174642e01fSmrg ;; 70184642e01fSmrg *-*-os2*) 70194642e01fSmrg # These systems don't actually have a C library (as such) 702035c4bbdfSmrg test X-lc = "X$arg" && continue 70214642e01fSmrg ;; 702235c4bbdfSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70234642e01fSmrg # Do not include libc due to us having libc/libc_r. 702435c4bbdfSmrg test X-lc = "X$arg" && continue 70254642e01fSmrg ;; 70264642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 70274642e01fSmrg # Rhapsody C and math libraries are in the System framework 702835c4bbdfSmrg func_append deplibs " System.ltframework" 70294642e01fSmrg continue 70304642e01fSmrg ;; 70314642e01fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 70324642e01fSmrg # Causes problems with __ctype 703335c4bbdfSmrg test X-lc = "X$arg" && continue 70344642e01fSmrg ;; 70354642e01fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 70364642e01fSmrg # Compiler inserts libc in the correct place for threads to work 703735c4bbdfSmrg test X-lc = "X$arg" && continue 70384642e01fSmrg ;; 70394642e01fSmrg esac 704035c4bbdfSmrg elif test X-lc_r = "X$arg"; then 70414642e01fSmrg case $host in 704235c4bbdfSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70434642e01fSmrg # Do not include libc_r directly, use -pthread flag. 70444642e01fSmrg continue 70454642e01fSmrg ;; 70464642e01fSmrg esac 70474642e01fSmrg fi 704835c4bbdfSmrg func_append deplibs " $arg" 704935c4bbdfSmrg continue 705035c4bbdfSmrg ;; 705135c4bbdfSmrg 705235c4bbdfSmrg -mllvm) 705335c4bbdfSmrg prev=mllvm 70544642e01fSmrg continue 70554642e01fSmrg ;; 705605b261ecSmrg 70574642e01fSmrg -module) 70584642e01fSmrg module=yes 70594642e01fSmrg continue 70604642e01fSmrg ;; 706105b261ecSmrg 70624642e01fSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 70634642e01fSmrg # classes, name mangling, and exception handling. 70644642e01fSmrg # Darwin uses the -arch flag to determine output architecture. 706535c4bbdfSmrg -model|-arch|-isysroot|--sysroot) 706635c4bbdfSmrg func_append compiler_flags " $arg" 70674642e01fSmrg func_append compile_command " $arg" 70684642e01fSmrg func_append finalize_command " $arg" 70694642e01fSmrg prev=xcompiler 70704642e01fSmrg continue 70714642e01fSmrg ;; 707205b261ecSmrg 707335c4bbdfSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 707435c4bbdfSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707535c4bbdfSmrg func_append compiler_flags " $arg" 70764642e01fSmrg func_append compile_command " $arg" 70774642e01fSmrg func_append finalize_command " $arg" 70784642e01fSmrg case "$new_inherited_linker_flags " in 70794642e01fSmrg *" $arg "*) ;; 708035c4bbdfSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 70814642e01fSmrg esac 70824642e01fSmrg continue 70834642e01fSmrg ;; 708405b261ecSmrg 70854642e01fSmrg -multi_module) 708635c4bbdfSmrg single_module=$wl-multi_module 70874642e01fSmrg continue 70884642e01fSmrg ;; 708905b261ecSmrg 70904642e01fSmrg -no-fast-install) 70914642e01fSmrg fast_install=no 70924642e01fSmrg continue 70934642e01fSmrg ;; 709405b261ecSmrg 70954642e01fSmrg -no-install) 70964642e01fSmrg case $host in 70974642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 70984642e01fSmrg # The PATH hackery in wrapper scripts is required on Windows 70994642e01fSmrg # and Darwin in order for the loader to find any dlls it needs. 710035c4bbdfSmrg func_warning "'-no-install' is ignored for $host" 710135c4bbdfSmrg func_warning "assuming '-no-fast-install' instead" 71024642e01fSmrg fast_install=no 71034642e01fSmrg ;; 71044642e01fSmrg *) no_install=yes ;; 71054642e01fSmrg esac 71064642e01fSmrg continue 71074642e01fSmrg ;; 710805b261ecSmrg 71094642e01fSmrg -no-undefined) 71104642e01fSmrg allow_undefined=no 71114642e01fSmrg continue 71124642e01fSmrg ;; 711305b261ecSmrg 71144642e01fSmrg -objectlist) 71154642e01fSmrg prev=objectlist 71164642e01fSmrg continue 71174642e01fSmrg ;; 711805b261ecSmrg 711935c4bbdfSmrg -os2dllname) 712035c4bbdfSmrg prev=os2dllname 712135c4bbdfSmrg continue 712235c4bbdfSmrg ;; 712335c4bbdfSmrg 71244642e01fSmrg -o) prev=output ;; 712505b261ecSmrg 71264642e01fSmrg -precious-files-regex) 71274642e01fSmrg prev=precious_regex 71284642e01fSmrg continue 71294642e01fSmrg ;; 713005b261ecSmrg 71314642e01fSmrg -release) 71324642e01fSmrg prev=release 71334642e01fSmrg continue 71344642e01fSmrg ;; 713505b261ecSmrg 71364642e01fSmrg -rpath) 71374642e01fSmrg prev=rpath 71384642e01fSmrg continue 71394642e01fSmrg ;; 714005b261ecSmrg 71414642e01fSmrg -R) 71424642e01fSmrg prev=xrpath 71434642e01fSmrg continue 71444642e01fSmrg ;; 714505b261ecSmrg 71464642e01fSmrg -R*) 71474642e01fSmrg func_stripname '-R' '' "$arg" 71484642e01fSmrg dir=$func_stripname_result 71494642e01fSmrg # We need an absolute path. 71504642e01fSmrg case $dir in 71514642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715235c4bbdfSmrg =*) 715335c4bbdfSmrg func_stripname '=' '' "$dir" 715435c4bbdfSmrg dir=$lt_sysroot$func_stripname_result 715535c4bbdfSmrg ;; 71564642e01fSmrg *) 71574642e01fSmrg func_fatal_error "only absolute run-paths are allowed" 71584642e01fSmrg ;; 71594642e01fSmrg esac 71604642e01fSmrg case "$xrpath " in 71614642e01fSmrg *" $dir "*) ;; 716235c4bbdfSmrg *) func_append xrpath " $dir" ;; 71634642e01fSmrg esac 71644642e01fSmrg continue 71654642e01fSmrg ;; 716605b261ecSmrg 71674642e01fSmrg -shared) 71684642e01fSmrg # The effects of -shared are defined in a previous loop. 71694642e01fSmrg continue 71704642e01fSmrg ;; 717105b261ecSmrg 71724642e01fSmrg -shrext) 71734642e01fSmrg prev=shrext 71744642e01fSmrg continue 71754642e01fSmrg ;; 717605b261ecSmrg 71774642e01fSmrg -static | -static-libtool-libs) 71784642e01fSmrg # The effects of -static are defined in a previous loop. 71794642e01fSmrg # We used to do the same as -all-static on platforms that 71804642e01fSmrg # didn't have a PIC flag, but the assumption that the effects 71814642e01fSmrg # would be equivalent was wrong. It would break on at least 71824642e01fSmrg # Digital Unix and AIX. 71834642e01fSmrg continue 71844642e01fSmrg ;; 718505b261ecSmrg 71864642e01fSmrg -thread-safe) 71874642e01fSmrg thread_safe=yes 71884642e01fSmrg continue 71894642e01fSmrg ;; 719005b261ecSmrg 71914642e01fSmrg -version-info) 71924642e01fSmrg prev=vinfo 71934642e01fSmrg continue 71944642e01fSmrg ;; 719505b261ecSmrg 71964642e01fSmrg -version-number) 71974642e01fSmrg prev=vinfo 71984642e01fSmrg vinfo_number=yes 71994642e01fSmrg continue 72004642e01fSmrg ;; 720105b261ecSmrg 72024642e01fSmrg -weak) 72034642e01fSmrg prev=weak 72044642e01fSmrg continue 72054642e01fSmrg ;; 720605b261ecSmrg 72074642e01fSmrg -Wc,*) 72084642e01fSmrg func_stripname '-Wc,' '' "$arg" 72094642e01fSmrg args=$func_stripname_result 72104642e01fSmrg arg= 721135c4bbdfSmrg save_ifs=$IFS; IFS=, 72124642e01fSmrg for flag in $args; do 721335c4bbdfSmrg IFS=$save_ifs 72144642e01fSmrg func_quote_for_eval "$flag" 721535c4bbdfSmrg func_append arg " $func_quote_for_eval_result" 721635c4bbdfSmrg func_append compiler_flags " $func_quote_for_eval_result" 72174642e01fSmrg done 721835c4bbdfSmrg IFS=$save_ifs 72194642e01fSmrg func_stripname ' ' '' "$arg" 72204642e01fSmrg arg=$func_stripname_result 72214642e01fSmrg ;; 722205b261ecSmrg 72234642e01fSmrg -Wl,*) 72244642e01fSmrg func_stripname '-Wl,' '' "$arg" 72254642e01fSmrg args=$func_stripname_result 72264642e01fSmrg arg= 722735c4bbdfSmrg save_ifs=$IFS; IFS=, 72284642e01fSmrg for flag in $args; do 722935c4bbdfSmrg IFS=$save_ifs 72304642e01fSmrg func_quote_for_eval "$flag" 723135c4bbdfSmrg func_append arg " $wl$func_quote_for_eval_result" 723235c4bbdfSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 723335c4bbdfSmrg func_append linker_flags " $func_quote_for_eval_result" 72344642e01fSmrg done 723535c4bbdfSmrg IFS=$save_ifs 72364642e01fSmrg func_stripname ' ' '' "$arg" 72374642e01fSmrg arg=$func_stripname_result 72384642e01fSmrg ;; 723905b261ecSmrg 72404642e01fSmrg -Xcompiler) 72414642e01fSmrg prev=xcompiler 72424642e01fSmrg continue 72434642e01fSmrg ;; 724405b261ecSmrg 72454642e01fSmrg -Xlinker) 72464642e01fSmrg prev=xlinker 72474642e01fSmrg continue 72484642e01fSmrg ;; 724905b261ecSmrg 72504642e01fSmrg -XCClinker) 72514642e01fSmrg prev=xcclinker 72524642e01fSmrg continue 72534642e01fSmrg ;; 725405b261ecSmrg 72554642e01fSmrg # -msg_* for osf cc 72564642e01fSmrg -msg_*) 72574642e01fSmrg func_quote_for_eval "$arg" 725835c4bbdfSmrg arg=$func_quote_for_eval_result 72594642e01fSmrg ;; 726005b261ecSmrg 72616747b715Smrg # Flags to be passed through unchanged, with rationale: 72626747b715Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 72636747b715Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 72646747b715Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 72656747b715Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 72666747b715Smrg # -q* compiler args for the IBM compiler 72676747b715Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 72686747b715Smrg # -F/path path to uninstalled frameworks, gcc on darwin 72696747b715Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727035c4bbdfSmrg # -fstack-protector* stack protector flags for GCC 72716747b715Smrg # @file GCC response files 72726747b715Smrg # -tp=* Portland pgcc target processor selection 727335c4bbdfSmrg # --sysroot=* for sysroot support 727435c4bbdfSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 72751b5d61b8Smrg # -specs=* GCC specs files 727635c4bbdfSmrg # -stdlib=* select c++ std lib with clang 72774642e01fSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727835c4bbdfSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 72791b5d61b8Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 72801b5d61b8Smrg -specs=*) 72814642e01fSmrg func_quote_for_eval "$arg" 728235c4bbdfSmrg arg=$func_quote_for_eval_result 72834642e01fSmrg func_append compile_command " $arg" 72844642e01fSmrg func_append finalize_command " $arg" 728535c4bbdfSmrg func_append compiler_flags " $arg" 72864642e01fSmrg continue 72874642e01fSmrg ;; 728805b261ecSmrg 728935c4bbdfSmrg -Z*) 729035c4bbdfSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 729135c4bbdfSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 729235c4bbdfSmrg compiler_flags="$compiler_flags $arg" 729335c4bbdfSmrg func_append compile_command " $arg" 729435c4bbdfSmrg func_append finalize_command " $arg" 729535c4bbdfSmrg case $arg in 729635c4bbdfSmrg -Zlinker | -Zstack) 729735c4bbdfSmrg prev=xcompiler 729835c4bbdfSmrg ;; 729935c4bbdfSmrg esac 730035c4bbdfSmrg continue 730135c4bbdfSmrg else 730235c4bbdfSmrg # Otherwise treat like 'Some other compiler flag' below 730335c4bbdfSmrg func_quote_for_eval "$arg" 730435c4bbdfSmrg arg=$func_quote_for_eval_result 730535c4bbdfSmrg fi 730635c4bbdfSmrg ;; 730735c4bbdfSmrg 73084642e01fSmrg # Some other compiler flag. 73094642e01fSmrg -* | +*) 73104642e01fSmrg func_quote_for_eval "$arg" 731135c4bbdfSmrg arg=$func_quote_for_eval_result 73124642e01fSmrg ;; 731305b261ecSmrg 73144642e01fSmrg *.$objext) 73154642e01fSmrg # A standard object. 731635c4bbdfSmrg func_append objs " $arg" 73174642e01fSmrg ;; 731805b261ecSmrg 73194642e01fSmrg *.lo) 73204642e01fSmrg # A libtool-controlled object. 732105b261ecSmrg 73224642e01fSmrg # Check to see that this really is a libtool object. 73234642e01fSmrg if func_lalib_unsafe_p "$arg"; then 73244642e01fSmrg pic_object= 73254642e01fSmrg non_pic_object= 732605b261ecSmrg 73274642e01fSmrg # Read the .lo file 73284642e01fSmrg func_source "$arg" 732905b261ecSmrg 73304642e01fSmrg if test -z "$pic_object" || 73314642e01fSmrg test -z "$non_pic_object" || 733235c4bbdfSmrg test none = "$pic_object" && 733335c4bbdfSmrg test none = "$non_pic_object"; then 733435c4bbdfSmrg func_fatal_error "cannot find name of object for '$arg'" 73354642e01fSmrg fi 733605b261ecSmrg 73374642e01fSmrg # Extract subdirectory from the argument. 73384642e01fSmrg func_dirname "$arg" "/" "" 733935c4bbdfSmrg xdir=$func_dirname_result 734005b261ecSmrg 734135c4bbdfSmrg test none = "$pic_object" || { 73424642e01fSmrg # Prepend the subdirectory the object is found in. 734335c4bbdfSmrg pic_object=$xdir$pic_object 734405b261ecSmrg 734535c4bbdfSmrg if test dlfiles = "$prev"; then 734635c4bbdfSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734735c4bbdfSmrg func_append dlfiles " $pic_object" 73484642e01fSmrg prev= 73494642e01fSmrg continue 73504642e01fSmrg else 73514642e01fSmrg # If libtool objects are unsupported, then we need to preload. 73524642e01fSmrg prev=dlprefiles 73534642e01fSmrg fi 73544642e01fSmrg fi 735505b261ecSmrg 73564642e01fSmrg # CHECK ME: I think I busted this. -Ossama 735735c4bbdfSmrg if test dlprefiles = "$prev"; then 73584642e01fSmrg # Preload the old-style object. 735935c4bbdfSmrg func_append dlprefiles " $pic_object" 73604642e01fSmrg prev= 73614642e01fSmrg fi 736205b261ecSmrg 73634642e01fSmrg # A PIC object. 73644642e01fSmrg func_append libobjs " $pic_object" 736535c4bbdfSmrg arg=$pic_object 736635c4bbdfSmrg } 736705b261ecSmrg 73684642e01fSmrg # Non-PIC object. 736935c4bbdfSmrg if test none != "$non_pic_object"; then 73704642e01fSmrg # Prepend the subdirectory the object is found in. 737135c4bbdfSmrg non_pic_object=$xdir$non_pic_object 737205b261ecSmrg 73734642e01fSmrg # A standard non-PIC object 73744642e01fSmrg func_append non_pic_objects " $non_pic_object" 737535c4bbdfSmrg if test -z "$pic_object" || test none = "$pic_object"; then 737635c4bbdfSmrg arg=$non_pic_object 73774642e01fSmrg fi 73784642e01fSmrg else 73794642e01fSmrg # If the PIC object exists, use it instead. 73804642e01fSmrg # $xdir was prepended to $pic_object above. 738135c4bbdfSmrg non_pic_object=$pic_object 73824642e01fSmrg func_append non_pic_objects " $non_pic_object" 73834642e01fSmrg fi 73844642e01fSmrg else 73854642e01fSmrg # Only an error if not doing a dry-run. 73864642e01fSmrg if $opt_dry_run; then 73874642e01fSmrg # Extract subdirectory from the argument. 73884642e01fSmrg func_dirname "$arg" "/" "" 738935c4bbdfSmrg xdir=$func_dirname_result 73904642e01fSmrg 73914642e01fSmrg func_lo2o "$arg" 73924642e01fSmrg pic_object=$xdir$objdir/$func_lo2o_result 73934642e01fSmrg non_pic_object=$xdir$func_lo2o_result 73944642e01fSmrg func_append libobjs " $pic_object" 73954642e01fSmrg func_append non_pic_objects " $non_pic_object" 73964642e01fSmrg else 739735c4bbdfSmrg func_fatal_error "'$arg' is not a valid libtool object" 73984642e01fSmrg fi 73994642e01fSmrg fi 74004642e01fSmrg ;; 74014642e01fSmrg 74024642e01fSmrg *.$libext) 74034642e01fSmrg # An archive. 740435c4bbdfSmrg func_append deplibs " $arg" 740535c4bbdfSmrg func_append old_deplibs " $arg" 74064642e01fSmrg continue 74074642e01fSmrg ;; 74084642e01fSmrg 74094642e01fSmrg *.la) 74104642e01fSmrg # A libtool-controlled library. 74114642e01fSmrg 741235c4bbdfSmrg func_resolve_sysroot "$arg" 741335c4bbdfSmrg if test dlfiles = "$prev"; then 74144642e01fSmrg # This library was specified with -dlopen. 741535c4bbdfSmrg func_append dlfiles " $func_resolve_sysroot_result" 74164642e01fSmrg prev= 741735c4bbdfSmrg elif test dlprefiles = "$prev"; then 74184642e01fSmrg # The library was specified with -dlpreopen. 741935c4bbdfSmrg func_append dlprefiles " $func_resolve_sysroot_result" 74204642e01fSmrg prev= 74214642e01fSmrg else 742235c4bbdfSmrg func_append deplibs " $func_resolve_sysroot_result" 74234642e01fSmrg fi 74244642e01fSmrg continue 74254642e01fSmrg ;; 74264642e01fSmrg 74274642e01fSmrg # Some other compiler argument. 74284642e01fSmrg *) 74294642e01fSmrg # Unknown arguments in both finalize_command and compile_command need 74304642e01fSmrg # to be aesthetically quoted because they are evaled later. 74314642e01fSmrg func_quote_for_eval "$arg" 743235c4bbdfSmrg arg=$func_quote_for_eval_result 74334642e01fSmrg ;; 74344642e01fSmrg esac # arg 74354642e01fSmrg 74364642e01fSmrg # Now actually substitute the argument into the commands. 74374642e01fSmrg if test -n "$arg"; then 74384642e01fSmrg func_append compile_command " $arg" 74394642e01fSmrg func_append finalize_command " $arg" 74404642e01fSmrg fi 74414642e01fSmrg done # argument parsing loop 74424642e01fSmrg 74434642e01fSmrg test -n "$prev" && \ 744435c4bbdfSmrg func_fatal_help "the '$prevarg' option requires an argument" 74454642e01fSmrg 744635c4bbdfSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 74474642e01fSmrg eval arg=\"$export_dynamic_flag_spec\" 74484642e01fSmrg func_append compile_command " $arg" 74494642e01fSmrg func_append finalize_command " $arg" 74504642e01fSmrg fi 74514642e01fSmrg 74524642e01fSmrg oldlibs= 74534642e01fSmrg # calculate the name of the file, without its directory 74544642e01fSmrg func_basename "$output" 745535c4bbdfSmrg outputname=$func_basename_result 745635c4bbdfSmrg libobjs_save=$libobjs 74574642e01fSmrg 74584642e01fSmrg if test -n "$shlibpath_var"; then 74594642e01fSmrg # get the directories listed in $shlibpath_var 746035c4bbdfSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 74614642e01fSmrg else 74624642e01fSmrg shlib_search_path= 74634642e01fSmrg fi 74644642e01fSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 74654642e01fSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 74664642e01fSmrg 746735c4bbdfSmrg # Definition is injected by LT_CONFIG during libtool generation. 746835c4bbdfSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 746935c4bbdfSmrg 74704642e01fSmrg func_dirname "$output" "/" "" 747135c4bbdfSmrg output_objdir=$func_dirname_result$objdir 747235c4bbdfSmrg func_to_tool_file "$output_objdir/" 747335c4bbdfSmrg tool_output_objdir=$func_to_tool_file_result 74744642e01fSmrg # Create the object directory. 74754642e01fSmrg func_mkdir_p "$output_objdir" 74764642e01fSmrg 74774642e01fSmrg # Determine the type of output 74784642e01fSmrg case $output in 74794642e01fSmrg "") 74804642e01fSmrg func_fatal_help "you must specify an output file" 74814642e01fSmrg ;; 74824642e01fSmrg *.$libext) linkmode=oldlib ;; 74834642e01fSmrg *.lo | *.$objext) linkmode=obj ;; 74844642e01fSmrg *.la) linkmode=lib ;; 74854642e01fSmrg *) linkmode=prog ;; # Anything else should be a program. 74864642e01fSmrg esac 74874642e01fSmrg 74884642e01fSmrg specialdeplibs= 74894642e01fSmrg 74904642e01fSmrg libs= 74914642e01fSmrg # Find all interdependent deplibs by searching for libraries 74924642e01fSmrg # that are linked more than once (e.g. -la -lb -la) 74934642e01fSmrg for deplib in $deplibs; do 749435c4bbdfSmrg if $opt_preserve_dup_deps; then 74954642e01fSmrg case "$libs " in 749635c4bbdfSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 74974642e01fSmrg esac 74984642e01fSmrg fi 749935c4bbdfSmrg func_append libs " $deplib" 75004642e01fSmrg done 75014642e01fSmrg 750235c4bbdfSmrg if test lib = "$linkmode"; then 75034642e01fSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 75044642e01fSmrg 75054642e01fSmrg # Compute libraries that are listed more than once in $predeps 75064642e01fSmrg # $postdeps and mark them as special (i.e., whose duplicates are 75074642e01fSmrg # not to be eliminated). 75084642e01fSmrg pre_post_deps= 75094642e01fSmrg if $opt_duplicate_compiler_generated_deps; then 75104642e01fSmrg for pre_post_dep in $predeps $postdeps; do 75114642e01fSmrg case "$pre_post_deps " in 751235c4bbdfSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 75134642e01fSmrg esac 751435c4bbdfSmrg func_append pre_post_deps " $pre_post_dep" 75154642e01fSmrg done 75164642e01fSmrg fi 75174642e01fSmrg pre_post_deps= 75184642e01fSmrg fi 75194642e01fSmrg 75204642e01fSmrg deplibs= 75214642e01fSmrg newdependency_libs= 75224642e01fSmrg newlib_search_path= 75234642e01fSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 75244642e01fSmrg notinst_deplibs= # not-installed libtool libraries 75254642e01fSmrg notinst_path= # paths that contain not-installed libtool libraries 75264642e01fSmrg 75274642e01fSmrg case $linkmode in 75284642e01fSmrg lib) 75294642e01fSmrg passes="conv dlpreopen link" 75304642e01fSmrg for file in $dlfiles $dlprefiles; do 75314642e01fSmrg case $file in 75324642e01fSmrg *.la) ;; 75334642e01fSmrg *) 753435c4bbdfSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 75354642e01fSmrg ;; 75364642e01fSmrg esac 75374642e01fSmrg done 75384642e01fSmrg ;; 75394642e01fSmrg prog) 75404642e01fSmrg compile_deplibs= 75414642e01fSmrg finalize_deplibs= 754235c4bbdfSmrg alldeplibs=false 75434642e01fSmrg newdlfiles= 75444642e01fSmrg newdlprefiles= 75454642e01fSmrg passes="conv scan dlopen dlpreopen link" 75464642e01fSmrg ;; 75474642e01fSmrg *) passes="conv" 75484642e01fSmrg ;; 75494642e01fSmrg esac 75504642e01fSmrg 75514642e01fSmrg for pass in $passes; do 75524642e01fSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 75534642e01fSmrg # so that -L comes before libs that need it for instance... 755435c4bbdfSmrg if test lib,link = "$linkmode,$pass"; then 75554642e01fSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 75564642e01fSmrg ## order, and fix it there properly 75574642e01fSmrg tmp_deplibs= 75584642e01fSmrg for deplib in $deplibs; do 75594642e01fSmrg tmp_deplibs="$deplib $tmp_deplibs" 75604642e01fSmrg done 756135c4bbdfSmrg deplibs=$tmp_deplibs 75624642e01fSmrg fi 75634642e01fSmrg 756435c4bbdfSmrg if test lib,link = "$linkmode,$pass" || 756535c4bbdfSmrg test prog,scan = "$linkmode,$pass"; then 756635c4bbdfSmrg libs=$deplibs 75674642e01fSmrg deplibs= 75684642e01fSmrg fi 756935c4bbdfSmrg if test prog = "$linkmode"; then 75704642e01fSmrg case $pass in 757135c4bbdfSmrg dlopen) libs=$dlfiles ;; 757235c4bbdfSmrg dlpreopen) libs=$dlprefiles ;; 75736747b715Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 75744642e01fSmrg esac 75754642e01fSmrg fi 757635c4bbdfSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 75774642e01fSmrg # Collect and forward deplibs of preopened libtool libs 75784642e01fSmrg for lib in $dlprefiles; do 75794642e01fSmrg # Ignore non-libtool-libs 75804642e01fSmrg dependency_libs= 758135c4bbdfSmrg func_resolve_sysroot "$lib" 75824642e01fSmrg case $lib in 758335c4bbdfSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 75844642e01fSmrg esac 75854642e01fSmrg 75864642e01fSmrg # Collect preopened libtool deplibs, except any this library 75874642e01fSmrg # has declared as weak libs 75884642e01fSmrg for deplib in $dependency_libs; do 75896747b715Smrg func_basename "$deplib" 75906747b715Smrg deplib_base=$func_basename_result 75914642e01fSmrg case " $weak_libs " in 75924642e01fSmrg *" $deplib_base "*) ;; 759335c4bbdfSmrg *) func_append deplibs " $deplib" ;; 75944642e01fSmrg esac 75954642e01fSmrg done 75964642e01fSmrg done 759735c4bbdfSmrg libs=$dlprefiles 75984642e01fSmrg fi 759935c4bbdfSmrg if test dlopen = "$pass"; then 76004642e01fSmrg # Collect dlpreopened libraries 760135c4bbdfSmrg save_deplibs=$deplibs 76024642e01fSmrg deplibs= 76034642e01fSmrg fi 76044642e01fSmrg 76054642e01fSmrg for deplib in $libs; do 76064642e01fSmrg lib= 760735c4bbdfSmrg found=false 76084642e01fSmrg case $deplib in 760935c4bbdfSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 761035c4bbdfSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 761135c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 76124642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 76134642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 76144642e01fSmrg else 761535c4bbdfSmrg func_append compiler_flags " $deplib" 761635c4bbdfSmrg if test lib = "$linkmode"; then 76174642e01fSmrg case "$new_inherited_linker_flags " in 76184642e01fSmrg *" $deplib "*) ;; 761935c4bbdfSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 76204642e01fSmrg esac 76214642e01fSmrg fi 76224642e01fSmrg fi 76234642e01fSmrg continue 76244642e01fSmrg ;; 76254642e01fSmrg -l*) 762635c4bbdfSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 762735c4bbdfSmrg func_warning "'-l' is ignored for archives/objects" 76284642e01fSmrg continue 76294642e01fSmrg fi 76304642e01fSmrg func_stripname '-l' '' "$deplib" 76314642e01fSmrg name=$func_stripname_result 763235c4bbdfSmrg if test lib = "$linkmode"; then 76334642e01fSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 76344642e01fSmrg else 76354642e01fSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 76364642e01fSmrg fi 76374642e01fSmrg for searchdir in $searchdirs; do 76384642e01fSmrg for search_ext in .la $std_shrext .so .a; do 76394642e01fSmrg # Search the libtool library 764035c4bbdfSmrg lib=$searchdir/lib$name$search_ext 76414642e01fSmrg if test -f "$lib"; then 764235c4bbdfSmrg if test .la = "$search_ext"; then 764335c4bbdfSmrg found=: 76444642e01fSmrg else 764535c4bbdfSmrg found=false 76464642e01fSmrg fi 76474642e01fSmrg break 2 76484642e01fSmrg fi 76494642e01fSmrg done 76504642e01fSmrg done 765135c4bbdfSmrg if $found; then 765235c4bbdfSmrg # deplib is a libtool library 76534642e01fSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 76544642e01fSmrg # We need to do some special things here, and not later. 765535c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 76564642e01fSmrg case " $predeps $postdeps " in 76574642e01fSmrg *" $deplib "*) 76584642e01fSmrg if func_lalib_p "$lib"; then 76594642e01fSmrg library_names= 76604642e01fSmrg old_library= 76614642e01fSmrg func_source "$lib" 76624642e01fSmrg for l in $old_library $library_names; do 766335c4bbdfSmrg ll=$l 76644642e01fSmrg done 766535c4bbdfSmrg if test "X$ll" = "X$old_library"; then # only static version available 766635c4bbdfSmrg found=false 76674642e01fSmrg func_dirname "$lib" "" "." 766835c4bbdfSmrg ladir=$func_dirname_result 76694642e01fSmrg lib=$ladir/$old_library 767035c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 76714642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 76724642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 76734642e01fSmrg else 76744642e01fSmrg deplibs="$deplib $deplibs" 767535c4bbdfSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76764642e01fSmrg fi 76774642e01fSmrg continue 76784642e01fSmrg fi 76794642e01fSmrg fi 76804642e01fSmrg ;; 76814642e01fSmrg *) ;; 76824642e01fSmrg esac 76834642e01fSmrg fi 768435c4bbdfSmrg else 768535c4bbdfSmrg # deplib doesn't seem to be a libtool library 768635c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 768735c4bbdfSmrg compile_deplibs="$deplib $compile_deplibs" 768835c4bbdfSmrg finalize_deplibs="$deplib $finalize_deplibs" 768935c4bbdfSmrg else 769035c4bbdfSmrg deplibs="$deplib $deplibs" 769135c4bbdfSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769235c4bbdfSmrg fi 769335c4bbdfSmrg continue 76944642e01fSmrg fi 76954642e01fSmrg ;; # -l 76964642e01fSmrg *.ltframework) 769735c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 76984642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 76994642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 77004642e01fSmrg else 77014642e01fSmrg deplibs="$deplib $deplibs" 770235c4bbdfSmrg if test lib = "$linkmode"; then 77034642e01fSmrg case "$new_inherited_linker_flags " in 77044642e01fSmrg *" $deplib "*) ;; 770535c4bbdfSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 77064642e01fSmrg esac 77074642e01fSmrg fi 77084642e01fSmrg fi 77094642e01fSmrg continue 77104642e01fSmrg ;; 77114642e01fSmrg -L*) 77124642e01fSmrg case $linkmode in 77134642e01fSmrg lib) 77144642e01fSmrg deplibs="$deplib $deplibs" 771535c4bbdfSmrg test conv = "$pass" && continue 77164642e01fSmrg newdependency_libs="$deplib $newdependency_libs" 77174642e01fSmrg func_stripname '-L' '' "$deplib" 771835c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 771935c4bbdfSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 77204642e01fSmrg ;; 77214642e01fSmrg prog) 772235c4bbdfSmrg if test conv = "$pass"; then 77234642e01fSmrg deplibs="$deplib $deplibs" 77244642e01fSmrg continue 77254642e01fSmrg fi 772635c4bbdfSmrg if test scan = "$pass"; then 77274642e01fSmrg deplibs="$deplib $deplibs" 77284642e01fSmrg else 77294642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 77304642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 77314642e01fSmrg fi 77324642e01fSmrg func_stripname '-L' '' "$deplib" 773335c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 773435c4bbdfSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 77354642e01fSmrg ;; 77364642e01fSmrg *) 773735c4bbdfSmrg func_warning "'-L' is ignored for archives/objects" 77384642e01fSmrg ;; 77394642e01fSmrg esac # linkmode 77404642e01fSmrg continue 77414642e01fSmrg ;; # -L 77424642e01fSmrg -R*) 774335c4bbdfSmrg if test link = "$pass"; then 77444642e01fSmrg func_stripname '-R' '' "$deplib" 774535c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 774635c4bbdfSmrg dir=$func_resolve_sysroot_result 77474642e01fSmrg # Make sure the xrpath contains only unique directories. 77484642e01fSmrg case "$xrpath " in 77494642e01fSmrg *" $dir "*) ;; 775035c4bbdfSmrg *) func_append xrpath " $dir" ;; 77514642e01fSmrg esac 77524642e01fSmrg fi 77534642e01fSmrg deplibs="$deplib $deplibs" 77544642e01fSmrg continue 77554642e01fSmrg ;; 775635c4bbdfSmrg *.la) 775735c4bbdfSmrg func_resolve_sysroot "$deplib" 775835c4bbdfSmrg lib=$func_resolve_sysroot_result 775935c4bbdfSmrg ;; 77604642e01fSmrg *.$libext) 776135c4bbdfSmrg if test conv = "$pass"; then 77624642e01fSmrg deplibs="$deplib $deplibs" 77634642e01fSmrg continue 77644642e01fSmrg fi 77654642e01fSmrg case $linkmode in 77664642e01fSmrg lib) 77674642e01fSmrg # Linking convenience modules into shared libraries is allowed, 77684642e01fSmrg # but linking other static libraries is non-portable. 77694642e01fSmrg case " $dlpreconveniencelibs " in 77704642e01fSmrg *" $deplib "*) ;; 77714642e01fSmrg *) 777235c4bbdfSmrg valid_a_lib=false 77734642e01fSmrg case $deplibs_check_method in 77744642e01fSmrg match_pattern*) 77754642e01fSmrg set dummy $deplibs_check_method; shift 77764642e01fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77776747b715Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 77784642e01fSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 777935c4bbdfSmrg valid_a_lib=: 77804642e01fSmrg fi 77814642e01fSmrg ;; 77824642e01fSmrg pass_all) 778335c4bbdfSmrg valid_a_lib=: 77844642e01fSmrg ;; 77854642e01fSmrg esac 778635c4bbdfSmrg if $valid_a_lib; then 778735c4bbdfSmrg echo 778835c4bbdfSmrg $ECHO "*** Warning: Linking the shared library $output against the" 778935c4bbdfSmrg $ECHO "*** static library $deplib is not portable!" 779035c4bbdfSmrg deplibs="$deplib $deplibs" 779135c4bbdfSmrg else 77926747b715Smrg echo 77934642e01fSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 77946747b715Smrg echo "*** I have the capability to make that library automatically link in when" 77956747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 77966747b715Smrg echo "*** shared version of the library, which you do not appear to have" 77976747b715Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 77986747b715Smrg echo "*** that it is just a static archive that I should not use here." 77994642e01fSmrg fi 78004642e01fSmrg ;; 78014642e01fSmrg esac 78024642e01fSmrg continue 78034642e01fSmrg ;; 78044642e01fSmrg prog) 780535c4bbdfSmrg if test link != "$pass"; then 78064642e01fSmrg deplibs="$deplib $deplibs" 78074642e01fSmrg else 78084642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 78094642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 78104642e01fSmrg fi 78114642e01fSmrg continue 78124642e01fSmrg ;; 78134642e01fSmrg esac # linkmode 78144642e01fSmrg ;; # *.$libext 78154642e01fSmrg *.lo | *.$objext) 781635c4bbdfSmrg if test conv = "$pass"; then 78174642e01fSmrg deplibs="$deplib $deplibs" 781835c4bbdfSmrg elif test prog = "$linkmode"; then 781935c4bbdfSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 78204642e01fSmrg # If there is no dlopen support or we're linking statically, 78214642e01fSmrg # we need to preload. 782235c4bbdfSmrg func_append newdlprefiles " $deplib" 78234642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 78244642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 78254642e01fSmrg else 782635c4bbdfSmrg func_append newdlfiles " $deplib" 78274642e01fSmrg fi 78284642e01fSmrg fi 78294642e01fSmrg continue 78304642e01fSmrg ;; 78314642e01fSmrg %DEPLIBS%) 783235c4bbdfSmrg alldeplibs=: 78334642e01fSmrg continue 78344642e01fSmrg ;; 78354642e01fSmrg esac # case $deplib 78364642e01fSmrg 783735c4bbdfSmrg $found || test -f "$lib" \ 783835c4bbdfSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 78394642e01fSmrg 78404642e01fSmrg # Check to see that this really is a libtool archive. 78414642e01fSmrg func_lalib_unsafe_p "$lib" \ 784235c4bbdfSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 78434642e01fSmrg 78444642e01fSmrg func_dirname "$lib" "" "." 784535c4bbdfSmrg ladir=$func_dirname_result 78464642e01fSmrg 78474642e01fSmrg dlname= 78484642e01fSmrg dlopen= 78494642e01fSmrg dlpreopen= 78504642e01fSmrg libdir= 78514642e01fSmrg library_names= 78524642e01fSmrg old_library= 78534642e01fSmrg inherited_linker_flags= 78544642e01fSmrg # If the library was installed with an old release of libtool, 78554642e01fSmrg # it will not redefine variables installed, or shouldnotlink 78564642e01fSmrg installed=yes 78574642e01fSmrg shouldnotlink=no 78584642e01fSmrg avoidtemprpath= 78594642e01fSmrg 78604642e01fSmrg 78614642e01fSmrg # Read the .la file 78624642e01fSmrg func_source "$lib" 78634642e01fSmrg 78644642e01fSmrg # Convert "-framework foo" to "foo.ltframework" 78654642e01fSmrg if test -n "$inherited_linker_flags"; then 78666747b715Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 78674642e01fSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 78684642e01fSmrg case " $new_inherited_linker_flags " in 78694642e01fSmrg *" $tmp_inherited_linker_flag "*) ;; 787035c4bbdfSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 78714642e01fSmrg esac 78724642e01fSmrg done 78734642e01fSmrg fi 78746747b715Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787535c4bbdfSmrg if test lib,link = "$linkmode,$pass" || 787635c4bbdfSmrg test prog,scan = "$linkmode,$pass" || 787735c4bbdfSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 787835c4bbdfSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 787935c4bbdfSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 78804642e01fSmrg fi 78814642e01fSmrg 788235c4bbdfSmrg if test conv = "$pass"; then 78834642e01fSmrg # Only check for convenience libraries 78844642e01fSmrg deplibs="$lib $deplibs" 78854642e01fSmrg if test -z "$libdir"; then 78864642e01fSmrg if test -z "$old_library"; then 788735c4bbdfSmrg func_fatal_error "cannot find name of link library for '$lib'" 78884642e01fSmrg fi 78894642e01fSmrg # It is a libtool convenience library, so add in its objects. 789035c4bbdfSmrg func_append convenience " $ladir/$objdir/$old_library" 789135c4bbdfSmrg func_append old_convenience " $ladir/$objdir/$old_library" 789235c4bbdfSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 789335c4bbdfSmrg func_fatal_error "'$lib' is not a convenience library" 78944642e01fSmrg fi 78956747b715Smrg tmp_libs= 78966747b715Smrg for deplib in $dependency_libs; do 78976747b715Smrg deplibs="$deplib $deplibs" 789835c4bbdfSmrg if $opt_preserve_dup_deps; then 78996747b715Smrg case "$tmp_libs " in 790035c4bbdfSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 79016747b715Smrg esac 79026747b715Smrg fi 790335c4bbdfSmrg func_append tmp_libs " $deplib" 79046747b715Smrg done 79054642e01fSmrg continue 79064642e01fSmrg fi # $pass = conv 79074642e01fSmrg 79084642e01fSmrg 79094642e01fSmrg # Get the name of the library we link against. 79104642e01fSmrg linklib= 791135c4bbdfSmrg if test -n "$old_library" && 791235c4bbdfSmrg { test yes = "$prefer_static_libs" || 791335c4bbdfSmrg test built,no = "$prefer_static_libs,$installed"; }; then 791435c4bbdfSmrg linklib=$old_library 791535c4bbdfSmrg else 791635c4bbdfSmrg for l in $old_library $library_names; do 791735c4bbdfSmrg linklib=$l 791835c4bbdfSmrg done 791935c4bbdfSmrg fi 79204642e01fSmrg if test -z "$linklib"; then 792135c4bbdfSmrg func_fatal_error "cannot find name of link library for '$lib'" 79224642e01fSmrg fi 79234642e01fSmrg 79244642e01fSmrg # This library was specified with -dlopen. 792535c4bbdfSmrg if test dlopen = "$pass"; then 792635c4bbdfSmrg test -z "$libdir" \ 792735c4bbdfSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 79284642e01fSmrg if test -z "$dlname" || 792935c4bbdfSmrg test yes != "$dlopen_support" || 793035c4bbdfSmrg test no = "$build_libtool_libs" 793135c4bbdfSmrg then 79324642e01fSmrg # If there is no dlname, no dlopen support or we're linking 79334642e01fSmrg # statically, we need to preload. We also need to preload any 79344642e01fSmrg # dependent libraries so libltdl's deplib preloader doesn't 79354642e01fSmrg # bomb out in the load deplibs phase. 793635c4bbdfSmrg func_append dlprefiles " $lib $dependency_libs" 79374642e01fSmrg else 793835c4bbdfSmrg func_append newdlfiles " $lib" 79394642e01fSmrg fi 79404642e01fSmrg continue 79414642e01fSmrg fi # $pass = dlopen 79424642e01fSmrg 79434642e01fSmrg # We need an absolute path. 79444642e01fSmrg case $ladir in 794535c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 79464642e01fSmrg *) 79474642e01fSmrg abs_ladir=`cd "$ladir" && pwd` 79484642e01fSmrg if test -z "$abs_ladir"; then 794935c4bbdfSmrg func_warning "cannot determine absolute directory name of '$ladir'" 79504642e01fSmrg func_warning "passing it literally to the linker, although it might fail" 795135c4bbdfSmrg abs_ladir=$ladir 79524642e01fSmrg fi 79534642e01fSmrg ;; 79544642e01fSmrg esac 79554642e01fSmrg func_basename "$lib" 795635c4bbdfSmrg laname=$func_basename_result 79574642e01fSmrg 79584642e01fSmrg # Find the relevant object directory and library name. 795935c4bbdfSmrg if test yes = "$installed"; then 796035c4bbdfSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 796135c4bbdfSmrg func_warning "library '$lib' was moved." 796235c4bbdfSmrg dir=$ladir 796335c4bbdfSmrg absdir=$abs_ladir 796435c4bbdfSmrg libdir=$abs_ladir 79654642e01fSmrg else 796635c4bbdfSmrg dir=$lt_sysroot$libdir 796735c4bbdfSmrg absdir=$lt_sysroot$libdir 79684642e01fSmrg fi 796935c4bbdfSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 79704642e01fSmrg else 79714642e01fSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797235c4bbdfSmrg dir=$ladir 797335c4bbdfSmrg absdir=$abs_ladir 79744642e01fSmrg # Remove this search path later 797535c4bbdfSmrg func_append notinst_path " $abs_ladir" 79764642e01fSmrg else 797735c4bbdfSmrg dir=$ladir/$objdir 797835c4bbdfSmrg absdir=$abs_ladir/$objdir 79794642e01fSmrg # Remove this search path later 798035c4bbdfSmrg func_append notinst_path " $abs_ladir" 79814642e01fSmrg fi 79824642e01fSmrg fi # $installed = yes 79834642e01fSmrg func_stripname 'lib' '.la' "$laname" 79844642e01fSmrg name=$func_stripname_result 79854642e01fSmrg 79864642e01fSmrg # This library was specified with -dlpreopen. 798735c4bbdfSmrg if test dlpreopen = "$pass"; then 798835c4bbdfSmrg if test -z "$libdir" && test prog = "$linkmode"; then 798935c4bbdfSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7990475c125cSmrg fi 799135c4bbdfSmrg case $host in 799235c4bbdfSmrg # special handling for platforms with PE-DLLs. 799335c4bbdfSmrg *cygwin* | *mingw* | *cegcc* ) 799435c4bbdfSmrg # Linker will automatically link against shared library if both 799535c4bbdfSmrg # static and shared are present. Therefore, ensure we extract 799635c4bbdfSmrg # symbols from the import library if a shared library is present 799735c4bbdfSmrg # (otherwise, the dlopen module name will be incorrect). We do 799835c4bbdfSmrg # this by putting the import library name into $newdlprefiles. 799935c4bbdfSmrg # We recover the dlopen module name by 'saving' the la file 800035c4bbdfSmrg # name in a special purpose variable, and (later) extracting the 800135c4bbdfSmrg # dlname from the la file. 800235c4bbdfSmrg if test -n "$dlname"; then 800335c4bbdfSmrg func_tr_sh "$dir/$linklib" 800435c4bbdfSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800535c4bbdfSmrg func_append newdlprefiles " $dir/$linklib" 800635c4bbdfSmrg else 800735c4bbdfSmrg func_append newdlprefiles " $dir/$old_library" 800835c4bbdfSmrg # Keep a list of preopened convenience libraries to check 800935c4bbdfSmrg # that they are being used correctly in the link pass. 801035c4bbdfSmrg test -z "$libdir" && \ 801135c4bbdfSmrg func_append dlpreconveniencelibs " $dir/$old_library" 801235c4bbdfSmrg fi 801335c4bbdfSmrg ;; 801435c4bbdfSmrg * ) 801535c4bbdfSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 801635c4bbdfSmrg # are required to link). 801735c4bbdfSmrg if test -n "$old_library"; then 801835c4bbdfSmrg func_append newdlprefiles " $dir/$old_library" 801935c4bbdfSmrg # Keep a list of preopened convenience libraries to check 802035c4bbdfSmrg # that they are being used correctly in the link pass. 802135c4bbdfSmrg test -z "$libdir" && \ 802235c4bbdfSmrg func_append dlpreconveniencelibs " $dir/$old_library" 802335c4bbdfSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802435c4bbdfSmrg elif test -n "$dlname"; then 802535c4bbdfSmrg func_append newdlprefiles " $dir/$dlname" 802635c4bbdfSmrg else 802735c4bbdfSmrg func_append newdlprefiles " $dir/$linklib" 802835c4bbdfSmrg fi 802935c4bbdfSmrg ;; 803035c4bbdfSmrg esac 80314642e01fSmrg fi # $pass = dlpreopen 80324642e01fSmrg 80334642e01fSmrg if test -z "$libdir"; then 80344642e01fSmrg # Link the convenience library 803535c4bbdfSmrg if test lib = "$linkmode"; then 80364642e01fSmrg deplibs="$dir/$old_library $deplibs" 803735c4bbdfSmrg elif test prog,link = "$linkmode,$pass"; then 80384642e01fSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 80394642e01fSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 80404642e01fSmrg else 80414642e01fSmrg deplibs="$lib $deplibs" # used for prog,scan pass 80424642e01fSmrg fi 80434642e01fSmrg continue 80444642e01fSmrg fi 80454642e01fSmrg 80464642e01fSmrg 804735c4bbdfSmrg if test prog = "$linkmode" && test link != "$pass"; then 804835c4bbdfSmrg func_append newlib_search_path " $ladir" 80494642e01fSmrg deplibs="$lib $deplibs" 80504642e01fSmrg 805135c4bbdfSmrg linkalldeplibs=false 805235c4bbdfSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805335c4bbdfSmrg test no = "$build_libtool_libs"; then 805435c4bbdfSmrg linkalldeplibs=: 80554642e01fSmrg fi 80564642e01fSmrg 80574642e01fSmrg tmp_libs= 80584642e01fSmrg for deplib in $dependency_libs; do 80594642e01fSmrg case $deplib in 80604642e01fSmrg -L*) func_stripname '-L' '' "$deplib" 806135c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 806235c4bbdfSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80634642e01fSmrg ;; 80644642e01fSmrg esac 80654642e01fSmrg # Need to link against all dependency_libs? 806635c4bbdfSmrg if $linkalldeplibs; then 80674642e01fSmrg deplibs="$deplib $deplibs" 80684642e01fSmrg else 80694642e01fSmrg # Need to hardcode shared library paths 80704642e01fSmrg # or/and link against static libraries 80714642e01fSmrg newdependency_libs="$deplib $newdependency_libs" 80724642e01fSmrg fi 807335c4bbdfSmrg if $opt_preserve_dup_deps; then 80744642e01fSmrg case "$tmp_libs " in 807535c4bbdfSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 80764642e01fSmrg esac 80774642e01fSmrg fi 807835c4bbdfSmrg func_append tmp_libs " $deplib" 80794642e01fSmrg done # for deplib 80804642e01fSmrg continue 80814642e01fSmrg fi # $linkmode = prog... 80824642e01fSmrg 808335c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 80844642e01fSmrg if test -n "$library_names" && 808535c4bbdfSmrg { { test no = "$prefer_static_libs" || 808635c4bbdfSmrg test built,yes = "$prefer_static_libs,$installed"; } || 80874642e01fSmrg test -z "$old_library"; }; then 80884642e01fSmrg # We need to hardcode the library path 808935c4bbdfSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 80904642e01fSmrg # Make sure the rpath contains only unique directories. 809135c4bbdfSmrg case $temp_rpath: in 80924642e01fSmrg *"$absdir:"*) ;; 809335c4bbdfSmrg *) func_append temp_rpath "$absdir:" ;; 80944642e01fSmrg esac 80954642e01fSmrg fi 80964642e01fSmrg 80974642e01fSmrg # Hardcode the library path. 80984642e01fSmrg # Skip directories that are in the system default run-time 80994642e01fSmrg # search path. 81004642e01fSmrg case " $sys_lib_dlsearch_path " in 81014642e01fSmrg *" $absdir "*) ;; 81024642e01fSmrg *) 81034642e01fSmrg case "$compile_rpath " in 81044642e01fSmrg *" $absdir "*) ;; 810535c4bbdfSmrg *) func_append compile_rpath " $absdir" ;; 81064642e01fSmrg esac 81074642e01fSmrg ;; 81084642e01fSmrg esac 81094642e01fSmrg case " $sys_lib_dlsearch_path " in 81104642e01fSmrg *" $libdir "*) ;; 81114642e01fSmrg *) 81124642e01fSmrg case "$finalize_rpath " in 81134642e01fSmrg *" $libdir "*) ;; 811435c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 81154642e01fSmrg esac 81164642e01fSmrg ;; 81174642e01fSmrg esac 81184642e01fSmrg fi # $linkmode,$pass = prog,link... 81194642e01fSmrg 812035c4bbdfSmrg if $alldeplibs && 812135c4bbdfSmrg { test pass_all = "$deplibs_check_method" || 812235c4bbdfSmrg { test yes = "$build_libtool_libs" && 81234642e01fSmrg test -n "$library_names"; }; }; then 81244642e01fSmrg # We only need to search for static libraries 81254642e01fSmrg continue 81264642e01fSmrg fi 81274642e01fSmrg fi 81284642e01fSmrg 81294642e01fSmrg link_static=no # Whether the deplib will be linked statically 81304642e01fSmrg use_static_libs=$prefer_static_libs 813135c4bbdfSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 81324642e01fSmrg use_static_libs=no 81334642e01fSmrg fi 81344642e01fSmrg if test -n "$library_names" && 813535c4bbdfSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 81364642e01fSmrg case $host in 813735c4bbdfSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 81384642e01fSmrg # No point in relinking DLLs because paths are not encoded 813935c4bbdfSmrg func_append notinst_deplibs " $lib" 81404642e01fSmrg need_relink=no 81414642e01fSmrg ;; 81424642e01fSmrg *) 814335c4bbdfSmrg if test no = "$installed"; then 814435c4bbdfSmrg func_append notinst_deplibs " $lib" 81454642e01fSmrg need_relink=yes 81464642e01fSmrg fi 81474642e01fSmrg ;; 81484642e01fSmrg esac 81494642e01fSmrg # This is a shared library 81504642e01fSmrg 81514642e01fSmrg # Warn about portability, can't link against -module's on some 81524642e01fSmrg # systems (darwin). Don't bleat about dlopened modules though! 815335c4bbdfSmrg dlopenmodule= 81544642e01fSmrg for dlpremoduletest in $dlprefiles; do 81554642e01fSmrg if test "X$dlpremoduletest" = "X$lib"; then 815635c4bbdfSmrg dlopenmodule=$dlpremoduletest 81574642e01fSmrg break 81584642e01fSmrg fi 81594642e01fSmrg done 816035c4bbdfSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 81616747b715Smrg echo 816235c4bbdfSmrg if test prog = "$linkmode"; then 81634642e01fSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 81644642e01fSmrg else 81654642e01fSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 81664642e01fSmrg fi 81674642e01fSmrg $ECHO "*** $linklib is not portable!" 81684642e01fSmrg fi 816935c4bbdfSmrg if test lib = "$linkmode" && 817035c4bbdfSmrg test yes = "$hardcode_into_libs"; then 81714642e01fSmrg # Hardcode the library path. 81724642e01fSmrg # Skip directories that are in the system default run-time 81734642e01fSmrg # search path. 81744642e01fSmrg case " $sys_lib_dlsearch_path " in 81754642e01fSmrg *" $absdir "*) ;; 81764642e01fSmrg *) 81774642e01fSmrg case "$compile_rpath " in 81784642e01fSmrg *" $absdir "*) ;; 817935c4bbdfSmrg *) func_append compile_rpath " $absdir" ;; 81804642e01fSmrg esac 81814642e01fSmrg ;; 81824642e01fSmrg esac 81834642e01fSmrg case " $sys_lib_dlsearch_path " in 81844642e01fSmrg *" $libdir "*) ;; 81854642e01fSmrg *) 81864642e01fSmrg case "$finalize_rpath " in 81874642e01fSmrg *" $libdir "*) ;; 818835c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 81894642e01fSmrg esac 81904642e01fSmrg ;; 81914642e01fSmrg esac 81924642e01fSmrg fi 81934642e01fSmrg 81944642e01fSmrg if test -n "$old_archive_from_expsyms_cmds"; then 81954642e01fSmrg # figure out the soname 81964642e01fSmrg set dummy $library_names 81974642e01fSmrg shift 819835c4bbdfSmrg realname=$1 81994642e01fSmrg shift 82004642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 82014642e01fSmrg # use dlname if we got it. it's perfectly good, no? 82024642e01fSmrg if test -n "$dlname"; then 820335c4bbdfSmrg soname=$dlname 82044642e01fSmrg elif test -n "$soname_spec"; then 82054642e01fSmrg # bleh windows 82064642e01fSmrg case $host in 820735c4bbdfSmrg *cygwin* | mingw* | *cegcc* | *os2*) 82084642e01fSmrg func_arith $current - $age 82094642e01fSmrg major=$func_arith_result 821035c4bbdfSmrg versuffix=-$major 82114642e01fSmrg ;; 82124642e01fSmrg esac 82134642e01fSmrg eval soname=\"$soname_spec\" 82144642e01fSmrg else 821535c4bbdfSmrg soname=$realname 82164642e01fSmrg fi 82174642e01fSmrg 82184642e01fSmrg # Make a new name for the extract_expsyms_cmds to use 821935c4bbdfSmrg soroot=$soname 82204642e01fSmrg func_basename "$soroot" 822135c4bbdfSmrg soname=$func_basename_result 82224642e01fSmrg func_stripname 'lib' '.dll' "$soname" 82234642e01fSmrg newlib=libimp-$func_stripname_result.a 82244642e01fSmrg 82254642e01fSmrg # If the library has no export list, then create one now 82264642e01fSmrg if test -f "$output_objdir/$soname-def"; then : 82274642e01fSmrg else 822835c4bbdfSmrg func_verbose "extracting exported symbol list from '$soname'" 82294642e01fSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 82304642e01fSmrg fi 82314642e01fSmrg 82324642e01fSmrg # Create $newlib 82334642e01fSmrg if test -f "$output_objdir/$newlib"; then :; else 823435c4bbdfSmrg func_verbose "generating import library for '$soname'" 82354642e01fSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 82364642e01fSmrg fi 82374642e01fSmrg # make sure the library variables are pointing to the new library 82384642e01fSmrg dir=$output_objdir 82394642e01fSmrg linklib=$newlib 82404642e01fSmrg fi # test -n "$old_archive_from_expsyms_cmds" 82414642e01fSmrg 824235c4bbdfSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 82434642e01fSmrg add_shlibpath= 82444642e01fSmrg add_dir= 82454642e01fSmrg add= 82464642e01fSmrg lib_linked=yes 82474642e01fSmrg case $hardcode_action in 82484642e01fSmrg immediate | unsupported) 824935c4bbdfSmrg if test no = "$hardcode_direct"; then 825035c4bbdfSmrg add=$dir/$linklib 82514642e01fSmrg case $host in 825235c4bbdfSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825335c4bbdfSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 82544642e01fSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825535c4bbdfSmrg *-*-unixware7*) add_dir=-L$dir ;; 82564642e01fSmrg *-*-darwin* ) 825735c4bbdfSmrg # if the lib is a (non-dlopened) module then we cannot 82584642e01fSmrg # link against it, someone is ignoring the earlier warnings 82594642e01fSmrg if /usr/bin/file -L $add 2> /dev/null | 826035c4bbdfSmrg $GREP ": [^:]* bundle" >/dev/null; then 82614642e01fSmrg if test "X$dlopenmodule" != "X$lib"; then 82624642e01fSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826335c4bbdfSmrg if test -z "$old_library"; then 82646747b715Smrg echo 82656747b715Smrg echo "*** And there doesn't seem to be a static archive available" 82666747b715Smrg echo "*** The link will probably fail, sorry" 82674642e01fSmrg else 826835c4bbdfSmrg add=$dir/$old_library 82694642e01fSmrg fi 82704642e01fSmrg elif test -n "$old_library"; then 827135c4bbdfSmrg add=$dir/$old_library 82724642e01fSmrg fi 82734642e01fSmrg fi 82744642e01fSmrg esac 827535c4bbdfSmrg elif test no = "$hardcode_minus_L"; then 82764642e01fSmrg case $host in 827735c4bbdfSmrg *-*-sunos*) add_shlibpath=$dir ;; 82784642e01fSmrg esac 827935c4bbdfSmrg add_dir=-L$dir 828035c4bbdfSmrg add=-l$name 828135c4bbdfSmrg elif test no = "$hardcode_shlibpath_var"; then 828235c4bbdfSmrg add_shlibpath=$dir 828335c4bbdfSmrg add=-l$name 82844642e01fSmrg else 82854642e01fSmrg lib_linked=no 82864642e01fSmrg fi 82874642e01fSmrg ;; 82884642e01fSmrg relink) 828935c4bbdfSmrg if test yes = "$hardcode_direct" && 829035c4bbdfSmrg test no = "$hardcode_direct_absolute"; then 829135c4bbdfSmrg add=$dir/$linklib 829235c4bbdfSmrg elif test yes = "$hardcode_minus_L"; then 829335c4bbdfSmrg add_dir=-L$absdir 82944642e01fSmrg # Try looking first in the location we're being installed to. 82954642e01fSmrg if test -n "$inst_prefix_dir"; then 82964642e01fSmrg case $libdir in 82974642e01fSmrg [\\/]*) 829835c4bbdfSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 82994642e01fSmrg ;; 83004642e01fSmrg esac 83014642e01fSmrg fi 830235c4bbdfSmrg add=-l$name 830335c4bbdfSmrg elif test yes = "$hardcode_shlibpath_var"; then 830435c4bbdfSmrg add_shlibpath=$dir 830535c4bbdfSmrg add=-l$name 83064642e01fSmrg else 83074642e01fSmrg lib_linked=no 83084642e01fSmrg fi 83094642e01fSmrg ;; 83104642e01fSmrg *) lib_linked=no ;; 83114642e01fSmrg esac 83124642e01fSmrg 831335c4bbdfSmrg if test yes != "$lib_linked"; then 83144642e01fSmrg func_fatal_configuration "unsupported hardcode properties" 83154642e01fSmrg fi 83164642e01fSmrg 83174642e01fSmrg if test -n "$add_shlibpath"; then 83184642e01fSmrg case :$compile_shlibpath: in 83194642e01fSmrg *":$add_shlibpath:"*) ;; 832035c4bbdfSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 83214642e01fSmrg esac 83224642e01fSmrg fi 832335c4bbdfSmrg if test prog = "$linkmode"; then 83244642e01fSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 83254642e01fSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 83264642e01fSmrg else 83274642e01fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83284642e01fSmrg test -n "$add" && deplibs="$add $deplibs" 832935c4bbdfSmrg if test yes != "$hardcode_direct" && 833035c4bbdfSmrg test yes != "$hardcode_minus_L" && 833135c4bbdfSmrg test yes = "$hardcode_shlibpath_var"; then 83324642e01fSmrg case :$finalize_shlibpath: in 83334642e01fSmrg *":$libdir:"*) ;; 833435c4bbdfSmrg *) func_append finalize_shlibpath "$libdir:" ;; 83354642e01fSmrg esac 83364642e01fSmrg fi 83374642e01fSmrg fi 83384642e01fSmrg fi 83394642e01fSmrg 834035c4bbdfSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 83414642e01fSmrg add_shlibpath= 83424642e01fSmrg add_dir= 83434642e01fSmrg add= 83444642e01fSmrg # Finalize command for both is simple: just hardcode it. 834535c4bbdfSmrg if test yes = "$hardcode_direct" && 834635c4bbdfSmrg test no = "$hardcode_direct_absolute"; then 834735c4bbdfSmrg add=$libdir/$linklib 834835c4bbdfSmrg elif test yes = "$hardcode_minus_L"; then 834935c4bbdfSmrg add_dir=-L$libdir 835035c4bbdfSmrg add=-l$name 835135c4bbdfSmrg elif test yes = "$hardcode_shlibpath_var"; then 83524642e01fSmrg case :$finalize_shlibpath: in 83534642e01fSmrg *":$libdir:"*) ;; 835435c4bbdfSmrg *) func_append finalize_shlibpath "$libdir:" ;; 83554642e01fSmrg esac 835635c4bbdfSmrg add=-l$name 835735c4bbdfSmrg elif test yes = "$hardcode_automatic"; then 83584642e01fSmrg if test -n "$inst_prefix_dir" && 835935c4bbdfSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 836035c4bbdfSmrg add=$inst_prefix_dir$libdir/$linklib 83614642e01fSmrg else 836235c4bbdfSmrg add=$libdir/$linklib 83634642e01fSmrg fi 83644642e01fSmrg else 83654642e01fSmrg # We cannot seem to hardcode it, guess we'll fake it. 836635c4bbdfSmrg add_dir=-L$libdir 83674642e01fSmrg # Try looking first in the location we're being installed to. 83684642e01fSmrg if test -n "$inst_prefix_dir"; then 83694642e01fSmrg case $libdir in 83704642e01fSmrg [\\/]*) 837135c4bbdfSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 83724642e01fSmrg ;; 83734642e01fSmrg esac 83744642e01fSmrg fi 837535c4bbdfSmrg add=-l$name 83764642e01fSmrg fi 83774642e01fSmrg 837835c4bbdfSmrg if test prog = "$linkmode"; then 83794642e01fSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 83804642e01fSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 83814642e01fSmrg else 83824642e01fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83834642e01fSmrg test -n "$add" && deplibs="$add $deplibs" 83844642e01fSmrg fi 83854642e01fSmrg fi 838635c4bbdfSmrg elif test prog = "$linkmode"; then 83874642e01fSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 83884642e01fSmrg # is not unsupported. This is valid on all known static and 83894642e01fSmrg # shared platforms. 839035c4bbdfSmrg if test unsupported != "$hardcode_direct"; then 839135c4bbdfSmrg test -n "$old_library" && linklib=$old_library 83924642e01fSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 83934642e01fSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 83944642e01fSmrg else 83954642e01fSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 83964642e01fSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 83974642e01fSmrg fi 839835c4bbdfSmrg elif test yes = "$build_libtool_libs"; then 83994642e01fSmrg # Not a shared library 840035c4bbdfSmrg if test pass_all != "$deplibs_check_method"; then 84014642e01fSmrg # We're trying link a shared library against a static one 84024642e01fSmrg # but the system doesn't support it. 84034642e01fSmrg 84044642e01fSmrg # Just print a warning and add the library to dependency_libs so 84054642e01fSmrg # that the program can be linked against the static library. 84066747b715Smrg echo 840735c4bbdfSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 84086747b715Smrg echo "*** I have the capability to make that library automatically link in when" 84096747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 84106747b715Smrg echo "*** shared version of the library, which you do not appear to have." 841135c4bbdfSmrg if test yes = "$module"; then 84126747b715Smrg echo "*** But as you try to build a module library, libtool will still create " 84136747b715Smrg echo "*** a static module, that should work as long as the dlopening application" 84146747b715Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 84154642e01fSmrg if test -z "$global_symbol_pipe"; then 84166747b715Smrg echo 84176747b715Smrg echo "*** However, this would only work if libtool was able to extract symbol" 841835c4bbdfSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 84196747b715Smrg echo "*** not find such a program. So, this module is probably useless." 842035c4bbdfSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 84214642e01fSmrg fi 842235c4bbdfSmrg if test no = "$build_old_libs"; then 84234642e01fSmrg build_libtool_libs=module 84244642e01fSmrg build_old_libs=yes 84254642e01fSmrg else 84264642e01fSmrg build_libtool_libs=no 84274642e01fSmrg fi 84284642e01fSmrg fi 84294642e01fSmrg else 84304642e01fSmrg deplibs="$dir/$old_library $deplibs" 84314642e01fSmrg link_static=yes 84324642e01fSmrg fi 84334642e01fSmrg fi # link shared/static library? 84344642e01fSmrg 843535c4bbdfSmrg if test lib = "$linkmode"; then 84364642e01fSmrg if test -n "$dependency_libs" && 843735c4bbdfSmrg { test yes != "$hardcode_into_libs" || 843835c4bbdfSmrg test yes = "$build_old_libs" || 843935c4bbdfSmrg test yes = "$link_static"; }; then 84404642e01fSmrg # Extract -R from dependency_libs 84414642e01fSmrg temp_deplibs= 84424642e01fSmrg for libdir in $dependency_libs; do 84434642e01fSmrg case $libdir in 84444642e01fSmrg -R*) func_stripname '-R' '' "$libdir" 84454642e01fSmrg temp_xrpath=$func_stripname_result 84464642e01fSmrg case " $xrpath " in 84474642e01fSmrg *" $temp_xrpath "*) ;; 844835c4bbdfSmrg *) func_append xrpath " $temp_xrpath";; 84494642e01fSmrg esac;; 845035c4bbdfSmrg *) func_append temp_deplibs " $libdir";; 84514642e01fSmrg esac 84524642e01fSmrg done 845335c4bbdfSmrg dependency_libs=$temp_deplibs 84544642e01fSmrg fi 84554642e01fSmrg 845635c4bbdfSmrg func_append newlib_search_path " $absdir" 84574642e01fSmrg # Link against this library 845835c4bbdfSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 84594642e01fSmrg # ... and its dependency_libs 84604642e01fSmrg tmp_libs= 84614642e01fSmrg for deplib in $dependency_libs; do 84624642e01fSmrg newdependency_libs="$deplib $newdependency_libs" 846335c4bbdfSmrg case $deplib in 846435c4bbdfSmrg -L*) func_stripname '-L' '' "$deplib" 846535c4bbdfSmrg func_resolve_sysroot "$func_stripname_result";; 846635c4bbdfSmrg *) func_resolve_sysroot "$deplib" ;; 846735c4bbdfSmrg esac 846835c4bbdfSmrg if $opt_preserve_dup_deps; then 84694642e01fSmrg case "$tmp_libs " in 847035c4bbdfSmrg *" $func_resolve_sysroot_result "*) 847135c4bbdfSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 84724642e01fSmrg esac 84734642e01fSmrg fi 847435c4bbdfSmrg func_append tmp_libs " $func_resolve_sysroot_result" 84754642e01fSmrg done 84764642e01fSmrg 847735c4bbdfSmrg if test no != "$link_all_deplibs"; then 84784642e01fSmrg # Add the search paths of all dependency libraries 84794642e01fSmrg for deplib in $dependency_libs; do 84804642e01fSmrg path= 84814642e01fSmrg case $deplib in 848235c4bbdfSmrg -L*) path=$deplib ;; 84834642e01fSmrg *.la) 848435c4bbdfSmrg func_resolve_sysroot "$deplib" 848535c4bbdfSmrg deplib=$func_resolve_sysroot_result 84864642e01fSmrg func_dirname "$deplib" "" "." 848735c4bbdfSmrg dir=$func_dirname_result 84884642e01fSmrg # We need an absolute path. 84894642e01fSmrg case $dir in 849035c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 84914642e01fSmrg *) 84924642e01fSmrg absdir=`cd "$dir" && pwd` 84934642e01fSmrg if test -z "$absdir"; then 849435c4bbdfSmrg func_warning "cannot determine absolute directory name of '$dir'" 849535c4bbdfSmrg absdir=$dir 84964642e01fSmrg fi 84974642e01fSmrg ;; 84984642e01fSmrg esac 84994642e01fSmrg if $GREP "^installed=no" $deplib > /dev/null; then 85004642e01fSmrg case $host in 85014642e01fSmrg *-*-darwin*) 85024642e01fSmrg depdepl= 850335c4bbdfSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850435c4bbdfSmrg if test -n "$deplibrary_names"; then 850535c4bbdfSmrg for tmp in $deplibrary_names; do 85064642e01fSmrg depdepl=$tmp 85074642e01fSmrg done 850835c4bbdfSmrg if test -f "$absdir/$objdir/$depdepl"; then 850935c4bbdfSmrg depdepl=$absdir/$objdir/$depdepl 851035c4bbdfSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85114642e01fSmrg if test -z "$darwin_install_name"; then 851235c4bbdfSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85134642e01fSmrg fi 851435c4bbdfSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851535c4bbdfSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 85164642e01fSmrg path= 85174642e01fSmrg fi 85184642e01fSmrg fi 85194642e01fSmrg ;; 85204642e01fSmrg *) 852135c4bbdfSmrg path=-L$absdir/$objdir 85224642e01fSmrg ;; 85234642e01fSmrg esac 85244642e01fSmrg else 852535c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 85264642e01fSmrg test -z "$libdir" && \ 852735c4bbdfSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 85284642e01fSmrg test "$absdir" != "$libdir" && \ 852935c4bbdfSmrg func_warning "'$deplib' seems to be moved" 85304642e01fSmrg 853135c4bbdfSmrg path=-L$absdir 85324642e01fSmrg fi 85334642e01fSmrg ;; 85344642e01fSmrg esac 85354642e01fSmrg case " $deplibs " in 85364642e01fSmrg *" $path "*) ;; 85374642e01fSmrg *) deplibs="$path $deplibs" ;; 85384642e01fSmrg esac 85394642e01fSmrg done 85404642e01fSmrg fi # link_all_deplibs != no 85414642e01fSmrg fi # linkmode = lib 85424642e01fSmrg done # for deplib in $libs 854335c4bbdfSmrg if test link = "$pass"; then 854435c4bbdfSmrg if test prog = "$linkmode"; then 85454642e01fSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 85464642e01fSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 85474642e01fSmrg else 85486747b715Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 85494642e01fSmrg fi 85504642e01fSmrg fi 855135c4bbdfSmrg dependency_libs=$newdependency_libs 855235c4bbdfSmrg if test dlpreopen = "$pass"; then 85534642e01fSmrg # Link the dlpreopened libraries before other libraries 85544642e01fSmrg for deplib in $save_deplibs; do 85554642e01fSmrg deplibs="$deplib $deplibs" 85564642e01fSmrg done 85574642e01fSmrg fi 855835c4bbdfSmrg if test dlopen != "$pass"; then 855935c4bbdfSmrg test conv = "$pass" || { 85604642e01fSmrg # Make sure lib_search_path contains only unique directories. 85614642e01fSmrg lib_search_path= 85624642e01fSmrg for dir in $newlib_search_path; do 85634642e01fSmrg case "$lib_search_path " in 85644642e01fSmrg *" $dir "*) ;; 856535c4bbdfSmrg *) func_append lib_search_path " $dir" ;; 85664642e01fSmrg esac 85674642e01fSmrg done 85684642e01fSmrg newlib_search_path= 856935c4bbdfSmrg } 85704642e01fSmrg 857135c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 85724642e01fSmrg vars="compile_deplibs finalize_deplibs" 857335c4bbdfSmrg else 857435c4bbdfSmrg vars=deplibs 85754642e01fSmrg fi 85764642e01fSmrg for var in $vars dependency_libs; do 85774642e01fSmrg # Add libraries to $var in reverse order 85784642e01fSmrg eval tmp_libs=\"\$$var\" 85794642e01fSmrg new_libs= 85804642e01fSmrg for deplib in $tmp_libs; do 85814642e01fSmrg # FIXME: Pedantically, this is the right thing to do, so 85824642e01fSmrg # that some nasty dependency loop isn't accidentally 85834642e01fSmrg # broken: 85844642e01fSmrg #new_libs="$deplib $new_libs" 85854642e01fSmrg # Pragmatically, this seems to cause very few problems in 85864642e01fSmrg # practice: 85874642e01fSmrg case $deplib in 85884642e01fSmrg -L*) new_libs="$deplib $new_libs" ;; 85894642e01fSmrg -R*) ;; 85904642e01fSmrg *) 85914642e01fSmrg # And here is the reason: when a library appears more 85924642e01fSmrg # than once as an explicit dependence of a library, or 85934642e01fSmrg # is implicitly linked in more than once by the 85944642e01fSmrg # compiler, it is considered special, and multiple 85954642e01fSmrg # occurrences thereof are not removed. Compare this 85964642e01fSmrg # with having the same library being listed as a 85974642e01fSmrg # dependency of multiple other libraries: in this case, 85984642e01fSmrg # we know (pedantically, we assume) the library does not 85994642e01fSmrg # need to be listed more than once, so we keep only the 86004642e01fSmrg # last copy. This is not always right, but it is rare 86014642e01fSmrg # enough that we require users that really mean to play 86024642e01fSmrg # such unportable linking tricks to link the library 86034642e01fSmrg # using -Wl,-lname, so that libtool does not consider it 86044642e01fSmrg # for duplicate removal. 86054642e01fSmrg case " $specialdeplibs " in 86064642e01fSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 86074642e01fSmrg *) 86084642e01fSmrg case " $new_libs " in 86094642e01fSmrg *" $deplib "*) ;; 86104642e01fSmrg *) new_libs="$deplib $new_libs" ;; 86114642e01fSmrg esac 86124642e01fSmrg ;; 86134642e01fSmrg esac 86144642e01fSmrg ;; 86154642e01fSmrg esac 86164642e01fSmrg done 86174642e01fSmrg tmp_libs= 86184642e01fSmrg for deplib in $new_libs; do 86194642e01fSmrg case $deplib in 86204642e01fSmrg -L*) 86214642e01fSmrg case " $tmp_libs " in 86224642e01fSmrg *" $deplib "*) ;; 862335c4bbdfSmrg *) func_append tmp_libs " $deplib" ;; 86244642e01fSmrg esac 86254642e01fSmrg ;; 862635c4bbdfSmrg *) func_append tmp_libs " $deplib" ;; 86274642e01fSmrg esac 86284642e01fSmrg done 86294642e01fSmrg eval $var=\"$tmp_libs\" 86304642e01fSmrg done # for var 86314642e01fSmrg fi 863235c4bbdfSmrg 863335c4bbdfSmrg # Add Sun CC postdeps if required: 863435c4bbdfSmrg test CXX = "$tagname" && { 863535c4bbdfSmrg case $host_os in 863635c4bbdfSmrg linux*) 863735c4bbdfSmrg case `$CC -V 2>&1 | sed 5q` in 863835c4bbdfSmrg *Sun\ C*) # Sun C++ 5.9 863935c4bbdfSmrg func_suncc_cstd_abi 864035c4bbdfSmrg 864135c4bbdfSmrg if test no != "$suncc_use_cstd_abi"; then 864235c4bbdfSmrg func_append postdeps ' -library=Cstd -library=Crun' 864335c4bbdfSmrg fi 864435c4bbdfSmrg ;; 864535c4bbdfSmrg esac 864635c4bbdfSmrg ;; 864735c4bbdfSmrg 864835c4bbdfSmrg solaris*) 864935c4bbdfSmrg func_cc_basename "$CC" 865035c4bbdfSmrg case $func_cc_basename_result in 865135c4bbdfSmrg CC* | sunCC*) 865235c4bbdfSmrg func_suncc_cstd_abi 865335c4bbdfSmrg 865435c4bbdfSmrg if test no != "$suncc_use_cstd_abi"; then 865535c4bbdfSmrg func_append postdeps ' -library=Cstd -library=Crun' 865635c4bbdfSmrg fi 865735c4bbdfSmrg ;; 865835c4bbdfSmrg esac 865935c4bbdfSmrg ;; 866035c4bbdfSmrg esac 866135c4bbdfSmrg } 866235c4bbdfSmrg 86634642e01fSmrg # Last step: remove runtime libs from dependency_libs 86644642e01fSmrg # (they stay in deplibs) 86654642e01fSmrg tmp_libs= 866635c4bbdfSmrg for i in $dependency_libs; do 86674642e01fSmrg case " $predeps $postdeps $compiler_lib_search_path " in 86684642e01fSmrg *" $i "*) 866935c4bbdfSmrg i= 86704642e01fSmrg ;; 86714642e01fSmrg esac 867235c4bbdfSmrg if test -n "$i"; then 867335c4bbdfSmrg func_append tmp_libs " $i" 86744642e01fSmrg fi 86754642e01fSmrg done 86764642e01fSmrg dependency_libs=$tmp_libs 86774642e01fSmrg done # for pass 867835c4bbdfSmrg if test prog = "$linkmode"; then 867935c4bbdfSmrg dlfiles=$newdlfiles 86804642e01fSmrg fi 868135c4bbdfSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868235c4bbdfSmrg dlprefiles=$newdlprefiles 86834642e01fSmrg fi 86844642e01fSmrg 86854642e01fSmrg case $linkmode in 86864642e01fSmrg oldlib) 868735c4bbdfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 868835c4bbdfSmrg func_warning "'-dlopen' is ignored for archives" 86894642e01fSmrg fi 86904642e01fSmrg 86914642e01fSmrg case " $deplibs" in 86924642e01fSmrg *\ -l* | *\ -L*) 869335c4bbdfSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 86944642e01fSmrg esac 86954642e01fSmrg 86964642e01fSmrg test -n "$rpath" && \ 869735c4bbdfSmrg func_warning "'-rpath' is ignored for archives" 86984642e01fSmrg 86994642e01fSmrg test -n "$xrpath" && \ 870035c4bbdfSmrg func_warning "'-R' is ignored for archives" 87014642e01fSmrg 87024642e01fSmrg test -n "$vinfo" && \ 870335c4bbdfSmrg func_warning "'-version-info/-version-number' is ignored for archives" 87044642e01fSmrg 87054642e01fSmrg test -n "$release" && \ 870635c4bbdfSmrg func_warning "'-release' is ignored for archives" 87074642e01fSmrg 87084642e01fSmrg test -n "$export_symbols$export_symbols_regex" && \ 870935c4bbdfSmrg func_warning "'-export-symbols' is ignored for archives" 87104642e01fSmrg 87114642e01fSmrg # Now set the variables for building old libraries. 87124642e01fSmrg build_libtool_libs=no 871335c4bbdfSmrg oldlibs=$output 871435c4bbdfSmrg func_append objs "$old_deplibs" 87154642e01fSmrg ;; 87164642e01fSmrg 87174642e01fSmrg lib) 871835c4bbdfSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 87194642e01fSmrg case $outputname in 87204642e01fSmrg lib*) 87214642e01fSmrg func_stripname 'lib' '.la' "$outputname" 87224642e01fSmrg name=$func_stripname_result 87234642e01fSmrg eval shared_ext=\"$shrext_cmds\" 87244642e01fSmrg eval libname=\"$libname_spec\" 87254642e01fSmrg ;; 87264642e01fSmrg *) 872735c4bbdfSmrg test no = "$module" \ 872835c4bbdfSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 87294642e01fSmrg 873035c4bbdfSmrg if test no != "$need_lib_prefix"; then 87314642e01fSmrg # Add the "lib" prefix for modules if required 87324642e01fSmrg func_stripname '' '.la' "$outputname" 87334642e01fSmrg name=$func_stripname_result 87344642e01fSmrg eval shared_ext=\"$shrext_cmds\" 87354642e01fSmrg eval libname=\"$libname_spec\" 87364642e01fSmrg else 87374642e01fSmrg func_stripname '' '.la' "$outputname" 87384642e01fSmrg libname=$func_stripname_result 87394642e01fSmrg fi 87404642e01fSmrg ;; 87414642e01fSmrg esac 87424642e01fSmrg 87434642e01fSmrg if test -n "$objs"; then 874435c4bbdfSmrg if test pass_all != "$deplibs_check_method"; then 874535c4bbdfSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 87464642e01fSmrg else 87476747b715Smrg echo 87484642e01fSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 87494642e01fSmrg $ECHO "*** objects $objs is not portable!" 875035c4bbdfSmrg func_append libobjs " $objs" 87514642e01fSmrg fi 87524642e01fSmrg fi 87534642e01fSmrg 875435c4bbdfSmrg test no = "$dlself" \ 875535c4bbdfSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 87564642e01fSmrg 87574642e01fSmrg set dummy $rpath 87584642e01fSmrg shift 875935c4bbdfSmrg test 1 -lt "$#" \ 876035c4bbdfSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 87614642e01fSmrg 876235c4bbdfSmrg install_libdir=$1 87634642e01fSmrg 87644642e01fSmrg oldlibs= 87654642e01fSmrg if test -z "$rpath"; then 876635c4bbdfSmrg if test yes = "$build_libtool_libs"; then 87674642e01fSmrg # Building a libtool convenience library. 876835c4bbdfSmrg # Some compilers have problems with a '.al' extension so 87694642e01fSmrg # convenience libraries should have the same extension an 87704642e01fSmrg # archive normally would. 87714642e01fSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 87724642e01fSmrg build_libtool_libs=convenience 87734642e01fSmrg build_old_libs=yes 87744642e01fSmrg fi 87754642e01fSmrg 87764642e01fSmrg test -n "$vinfo" && \ 877735c4bbdfSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 87784642e01fSmrg 87794642e01fSmrg test -n "$release" && \ 878035c4bbdfSmrg func_warning "'-release' is ignored for convenience libraries" 87814642e01fSmrg else 87824642e01fSmrg 87834642e01fSmrg # Parse the version information argument. 878435c4bbdfSmrg save_ifs=$IFS; IFS=: 87854642e01fSmrg set dummy $vinfo 0 0 0 87864642e01fSmrg shift 878735c4bbdfSmrg IFS=$save_ifs 87884642e01fSmrg 87894642e01fSmrg test -n "$7" && \ 879035c4bbdfSmrg func_fatal_help "too many parameters to '-version-info'" 87914642e01fSmrg 87924642e01fSmrg # convert absolute version numbers to libtool ages 87934642e01fSmrg # this retains compatibility with .la files and attempts 87944642e01fSmrg # to make the code below a bit more comprehensible 87954642e01fSmrg 87964642e01fSmrg case $vinfo_number in 87974642e01fSmrg yes) 879835c4bbdfSmrg number_major=$1 879935c4bbdfSmrg number_minor=$2 880035c4bbdfSmrg number_revision=$3 88014642e01fSmrg # 88024642e01fSmrg # There are really only two kinds -- those that 88034642e01fSmrg # use the current revision as the major version 88044642e01fSmrg # and those that subtract age and use age as 88054642e01fSmrg # a minor version. But, then there is irix 880635c4bbdfSmrg # that has an extra 1 added just for fun 88074642e01fSmrg # 88084642e01fSmrg case $version_type in 880935c4bbdfSmrg # correct linux to gnu/linux during the next big refactor 881035c4bbdfSmrg darwin|freebsd-elf|linux|osf|windows|none) 88114642e01fSmrg func_arith $number_major + $number_minor 88124642e01fSmrg current=$func_arith_result 881335c4bbdfSmrg age=$number_minor 881435c4bbdfSmrg revision=$number_revision 88154642e01fSmrg ;; 881635c4bbdfSmrg freebsd-aout|qnx|sunos) 881735c4bbdfSmrg current=$number_major 881835c4bbdfSmrg revision=$number_minor 881935c4bbdfSmrg age=0 88204642e01fSmrg ;; 88214642e01fSmrg irix|nonstopux) 88224642e01fSmrg func_arith $number_major + $number_minor 88234642e01fSmrg current=$func_arith_result 882435c4bbdfSmrg age=$number_minor 882535c4bbdfSmrg revision=$number_minor 88264642e01fSmrg lt_irix_increment=no 88274642e01fSmrg ;; 88284642e01fSmrg esac 88294642e01fSmrg ;; 88304642e01fSmrg no) 883135c4bbdfSmrg current=$1 883235c4bbdfSmrg revision=$2 883335c4bbdfSmrg age=$3 88344642e01fSmrg ;; 88354642e01fSmrg esac 88364642e01fSmrg 88374642e01fSmrg # Check that each of the things are valid numbers. 88384642e01fSmrg case $current in 88394642e01fSmrg 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]) ;; 88404642e01fSmrg *) 884135c4bbdfSmrg func_error "CURRENT '$current' must be a nonnegative integer" 884235c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 88434642e01fSmrg ;; 88444642e01fSmrg esac 88454642e01fSmrg 88464642e01fSmrg case $revision in 88474642e01fSmrg 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]) ;; 88484642e01fSmrg *) 884935c4bbdfSmrg func_error "REVISION '$revision' must be a nonnegative integer" 885035c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 88514642e01fSmrg ;; 88524642e01fSmrg esac 88534642e01fSmrg 88544642e01fSmrg case $age in 88554642e01fSmrg 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]) ;; 88564642e01fSmrg *) 885735c4bbdfSmrg func_error "AGE '$age' must be a nonnegative integer" 885835c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 88594642e01fSmrg ;; 88604642e01fSmrg esac 88614642e01fSmrg 88624642e01fSmrg if test "$age" -gt "$current"; then 886335c4bbdfSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 886435c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 88654642e01fSmrg fi 88664642e01fSmrg 88674642e01fSmrg # Calculate the version variables. 88684642e01fSmrg major= 88694642e01fSmrg versuffix= 88704642e01fSmrg verstring= 88714642e01fSmrg case $version_type in 88724642e01fSmrg none) ;; 88734642e01fSmrg 88744642e01fSmrg darwin) 88754642e01fSmrg # Like Linux, but with the current version available in 88764642e01fSmrg # verstring for coding it into the library header 88774642e01fSmrg func_arith $current - $age 88784642e01fSmrg major=.$func_arith_result 887935c4bbdfSmrg versuffix=$major.$age.$revision 88804642e01fSmrg # Darwin ld doesn't like 0 for these options... 88814642e01fSmrg func_arith $current + 1 88824642e01fSmrg minor_current=$func_arith_result 888335c4bbdfSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88844642e01fSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 888535c4bbdfSmrg # On Darwin other compilers 888635c4bbdfSmrg case $CC in 888735c4bbdfSmrg nagfor*) 888835c4bbdfSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888935c4bbdfSmrg ;; 889035c4bbdfSmrg *) 889135c4bbdfSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889235c4bbdfSmrg ;; 889335c4bbdfSmrg esac 88944642e01fSmrg ;; 88954642e01fSmrg 88964642e01fSmrg freebsd-aout) 889735c4bbdfSmrg major=.$current 889835c4bbdfSmrg versuffix=.$current.$revision 88994642e01fSmrg ;; 89004642e01fSmrg 89014642e01fSmrg freebsd-elf) 890235c4bbdfSmrg func_arith $current - $age 890335c4bbdfSmrg major=.$func_arith_result 890435c4bbdfSmrg versuffix=$major.$age.$revision 89054642e01fSmrg ;; 89064642e01fSmrg 89074642e01fSmrg irix | nonstopux) 890835c4bbdfSmrg if test no = "$lt_irix_increment"; then 89094642e01fSmrg func_arith $current - $age 89104642e01fSmrg else 89114642e01fSmrg func_arith $current - $age + 1 89124642e01fSmrg fi 89134642e01fSmrg major=$func_arith_result 89144642e01fSmrg 89154642e01fSmrg case $version_type in 89164642e01fSmrg nonstopux) verstring_prefix=nonstopux ;; 89174642e01fSmrg *) verstring_prefix=sgi ;; 89184642e01fSmrg esac 891935c4bbdfSmrg verstring=$verstring_prefix$major.$revision 89204642e01fSmrg 89214642e01fSmrg # Add in all the interfaces that we are compatible with. 89224642e01fSmrg loop=$revision 892335c4bbdfSmrg while test 0 -ne "$loop"; do 89244642e01fSmrg func_arith $revision - $loop 89254642e01fSmrg iface=$func_arith_result 89264642e01fSmrg func_arith $loop - 1 89274642e01fSmrg loop=$func_arith_result 892835c4bbdfSmrg verstring=$verstring_prefix$major.$iface:$verstring 89294642e01fSmrg done 89304642e01fSmrg 893135c4bbdfSmrg # Before this point, $major must not contain '.'. 89324642e01fSmrg major=.$major 893335c4bbdfSmrg versuffix=$major.$revision 89344642e01fSmrg ;; 89354642e01fSmrg 893635c4bbdfSmrg linux) # correct to gnu/linux during the next big refactor 89374642e01fSmrg func_arith $current - $age 89384642e01fSmrg major=.$func_arith_result 893935c4bbdfSmrg versuffix=$major.$age.$revision 89404642e01fSmrg ;; 89414642e01fSmrg 89424642e01fSmrg osf) 89434642e01fSmrg func_arith $current - $age 89444642e01fSmrg major=.$func_arith_result 894535c4bbdfSmrg versuffix=.$current.$age.$revision 894635c4bbdfSmrg verstring=$current.$age.$revision 89474642e01fSmrg 89484642e01fSmrg # Add in all the interfaces that we are compatible with. 89494642e01fSmrg loop=$age 895035c4bbdfSmrg while test 0 -ne "$loop"; do 89514642e01fSmrg func_arith $current - $loop 89524642e01fSmrg iface=$func_arith_result 89534642e01fSmrg func_arith $loop - 1 89544642e01fSmrg loop=$func_arith_result 895535c4bbdfSmrg verstring=$verstring:$iface.0 89564642e01fSmrg done 89574642e01fSmrg 89584642e01fSmrg # Make executables depend on our current version. 895935c4bbdfSmrg func_append verstring ":$current.0" 89604642e01fSmrg ;; 89614642e01fSmrg 89624642e01fSmrg qnx) 896335c4bbdfSmrg major=.$current 896435c4bbdfSmrg versuffix=.$current 896535c4bbdfSmrg ;; 896635c4bbdfSmrg 896735c4bbdfSmrg sco) 896835c4bbdfSmrg major=.$current 896935c4bbdfSmrg versuffix=.$current 89704642e01fSmrg ;; 89714642e01fSmrg 89724642e01fSmrg sunos) 897335c4bbdfSmrg major=.$current 897435c4bbdfSmrg versuffix=.$current.$revision 89754642e01fSmrg ;; 89764642e01fSmrg 89774642e01fSmrg windows) 89784642e01fSmrg # Use '-' rather than '.', since we only want one 897935c4bbdfSmrg # extension on DOS 8.3 file systems. 89804642e01fSmrg func_arith $current - $age 89814642e01fSmrg major=$func_arith_result 898235c4bbdfSmrg versuffix=-$major 89834642e01fSmrg ;; 89844642e01fSmrg 89854642e01fSmrg *) 898635c4bbdfSmrg func_fatal_configuration "unknown library version type '$version_type'" 89874642e01fSmrg ;; 89884642e01fSmrg esac 89894642e01fSmrg 89904642e01fSmrg # Clear the version info if we defaulted, and they specified a release. 89914642e01fSmrg if test -z "$vinfo" && test -n "$release"; then 89924642e01fSmrg major= 89934642e01fSmrg case $version_type in 89944642e01fSmrg darwin) 89954642e01fSmrg # we can't check for "0.0" in archive_cmds due to quoting 89964642e01fSmrg # problems, so we reset it completely 89974642e01fSmrg verstring= 89984642e01fSmrg ;; 89994642e01fSmrg *) 900035c4bbdfSmrg verstring=0.0 90014642e01fSmrg ;; 90024642e01fSmrg esac 900335c4bbdfSmrg if test no = "$need_version"; then 90044642e01fSmrg versuffix= 90054642e01fSmrg else 900635c4bbdfSmrg versuffix=.0.0 90074642e01fSmrg fi 90084642e01fSmrg fi 90094642e01fSmrg 90104642e01fSmrg # Remove version info from name if versioning should be avoided 901135c4bbdfSmrg if test yes,no = "$avoid_version,$need_version"; then 90124642e01fSmrg major= 90134642e01fSmrg versuffix= 901435c4bbdfSmrg verstring= 90154642e01fSmrg fi 90164642e01fSmrg 90174642e01fSmrg # Check to see if the archive will have undefined symbols. 901835c4bbdfSmrg if test yes = "$allow_undefined"; then 901935c4bbdfSmrg if test unsupported = "$allow_undefined_flag"; then 902035c4bbdfSmrg if test yes = "$build_old_libs"; then 902135c4bbdfSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902235c4bbdfSmrg build_libtool_libs=no 902335c4bbdfSmrg else 902435c4bbdfSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 902535c4bbdfSmrg fi 90264642e01fSmrg fi 90274642e01fSmrg else 90284642e01fSmrg # Don't allow undefined symbols. 902935c4bbdfSmrg allow_undefined_flag=$no_undefined_flag 90304642e01fSmrg fi 90314642e01fSmrg 90324642e01fSmrg fi 90334642e01fSmrg 903435c4bbdfSmrg func_generate_dlsyms "$libname" "$libname" : 903535c4bbdfSmrg func_append libobjs " $symfileobj" 903635c4bbdfSmrg test " " = "$libobjs" && libobjs= 90374642e01fSmrg 903835c4bbdfSmrg if test relink != "$opt_mode"; then 90394642e01fSmrg # Remove our outputs, but don't remove object files since they 90404642e01fSmrg # may have been created when compiling PIC objects. 90414642e01fSmrg removelist= 90424642e01fSmrg tempremovelist=`$ECHO "$output_objdir/*"` 90434642e01fSmrg for p in $tempremovelist; do 90444642e01fSmrg case $p in 90454642e01fSmrg *.$objext | *.gcno) 90464642e01fSmrg ;; 904735c4bbdfSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 904835c4bbdfSmrg if test -n "$precious_files_regex"; then 90494642e01fSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 90504642e01fSmrg then 90514642e01fSmrg continue 90524642e01fSmrg fi 90534642e01fSmrg fi 905435c4bbdfSmrg func_append removelist " $p" 90554642e01fSmrg ;; 90564642e01fSmrg *) ;; 90574642e01fSmrg esac 90584642e01fSmrg done 90594642e01fSmrg test -n "$removelist" && \ 90604642e01fSmrg func_show_eval "${RM}r \$removelist" 90614642e01fSmrg fi 90624642e01fSmrg 90634642e01fSmrg # Now set the variables for building old libraries. 906435c4bbdfSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 906535c4bbdfSmrg func_append oldlibs " $output_objdir/$libname.$libext" 90664642e01fSmrg 90674642e01fSmrg # Transform .lo files to .o files. 906835c4bbdfSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 90694642e01fSmrg fi 90704642e01fSmrg 90714642e01fSmrg # Eliminate all temporary directories. 90724642e01fSmrg #for path in $notinst_path; do 90736747b715Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 90746747b715Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 90756747b715Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 90764642e01fSmrg #done 90774642e01fSmrg 90784642e01fSmrg if test -n "$xrpath"; then 90794642e01fSmrg # If the user specified any rpath flags, then add them. 90804642e01fSmrg temp_xrpath= 90814642e01fSmrg for libdir in $xrpath; do 908235c4bbdfSmrg func_replace_sysroot "$libdir" 908335c4bbdfSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 90844642e01fSmrg case "$finalize_rpath " in 90854642e01fSmrg *" $libdir "*) ;; 908635c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 90874642e01fSmrg esac 90884642e01fSmrg done 908935c4bbdfSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 90904642e01fSmrg dependency_libs="$temp_xrpath $dependency_libs" 90914642e01fSmrg fi 90924642e01fSmrg fi 90934642e01fSmrg 90944642e01fSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 909535c4bbdfSmrg old_dlfiles=$dlfiles 90964642e01fSmrg dlfiles= 90974642e01fSmrg for lib in $old_dlfiles; do 90984642e01fSmrg case " $dlprefiles $dlfiles " in 90994642e01fSmrg *" $lib "*) ;; 910035c4bbdfSmrg *) func_append dlfiles " $lib" ;; 91014642e01fSmrg esac 91024642e01fSmrg done 91034642e01fSmrg 91044642e01fSmrg # Make sure dlprefiles contains only unique files 910535c4bbdfSmrg old_dlprefiles=$dlprefiles 91064642e01fSmrg dlprefiles= 91074642e01fSmrg for lib in $old_dlprefiles; do 91084642e01fSmrg case "$dlprefiles " in 91094642e01fSmrg *" $lib "*) ;; 911035c4bbdfSmrg *) func_append dlprefiles " $lib" ;; 91114642e01fSmrg esac 91124642e01fSmrg done 91134642e01fSmrg 911435c4bbdfSmrg if test yes = "$build_libtool_libs"; then 91154642e01fSmrg if test -n "$rpath"; then 91164642e01fSmrg case $host in 91176747b715Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 91184642e01fSmrg # these systems don't actually have a c library (as such)! 91194642e01fSmrg ;; 91204642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 91214642e01fSmrg # Rhapsody C library is in the System framework 912235c4bbdfSmrg func_append deplibs " System.ltframework" 91234642e01fSmrg ;; 91244642e01fSmrg *-*-netbsd*) 91254642e01fSmrg # Don't link with libc until the a.out ld.so is fixed. 91264642e01fSmrg ;; 91274642e01fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 91284642e01fSmrg # Do not include libc due to us having libc/libc_r. 91294642e01fSmrg ;; 91304642e01fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 91314642e01fSmrg # Causes problems with __ctype 91324642e01fSmrg ;; 91334642e01fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 91344642e01fSmrg # Compiler inserts libc in the correct place for threads to work 91354642e01fSmrg ;; 91364642e01fSmrg *) 91374642e01fSmrg # Add libc to deplibs on all other systems if necessary. 913835c4bbdfSmrg if test yes = "$build_libtool_need_lc"; then 913935c4bbdfSmrg func_append deplibs " -lc" 91404642e01fSmrg fi 91414642e01fSmrg ;; 91424642e01fSmrg esac 91434642e01fSmrg fi 91444642e01fSmrg 91454642e01fSmrg # Transform deplibs into only deplibs that can be linked in shared. 91464642e01fSmrg name_save=$name 91474642e01fSmrg libname_save=$libname 91484642e01fSmrg release_save=$release 91494642e01fSmrg versuffix_save=$versuffix 91504642e01fSmrg major_save=$major 91514642e01fSmrg # I'm not sure if I'm treating the release correctly. I think 91524642e01fSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 91534642e01fSmrg # add it in twice. Is that correct? 915435c4bbdfSmrg release= 915535c4bbdfSmrg versuffix= 915635c4bbdfSmrg major= 91574642e01fSmrg newdeplibs= 91584642e01fSmrg droppeddeps=no 91594642e01fSmrg case $deplibs_check_method in 91604642e01fSmrg pass_all) 91614642e01fSmrg # Don't check for shared/static. Everything works. 91624642e01fSmrg # This might be a little naive. We might want to check 91634642e01fSmrg # whether the library exists or not. But this is on 91644642e01fSmrg # osf3 & osf4 and I'm not really sure... Just 91654642e01fSmrg # implementing what was already the behavior. 91664642e01fSmrg newdeplibs=$deplibs 91674642e01fSmrg ;; 91684642e01fSmrg test_compile) 91694642e01fSmrg # This code stresses the "libraries are programs" paradigm to its 91704642e01fSmrg # limits. Maybe even breaks it. We compile a program, linking it 91714642e01fSmrg # against the deplibs as a proxy for the library. Then we can check 91724642e01fSmrg # whether they linked in statically or dynamically with ldd. 91734642e01fSmrg $opt_dry_run || $RM conftest.c 91744642e01fSmrg cat > conftest.c <<EOF 91754642e01fSmrg int main() { return 0; } 91764642e01fSmrgEOF 91774642e01fSmrg $opt_dry_run || $RM conftest 91784642e01fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 91794642e01fSmrg ldd_output=`ldd conftest` 91804642e01fSmrg for i in $deplibs; do 91814642e01fSmrg case $i in 91824642e01fSmrg -l*) 91834642e01fSmrg func_stripname -l '' "$i" 91844642e01fSmrg name=$func_stripname_result 918535c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 91864642e01fSmrg case " $predeps $postdeps " in 91874642e01fSmrg *" $i "*) 918835c4bbdfSmrg func_append newdeplibs " $i" 918935c4bbdfSmrg i= 91904642e01fSmrg ;; 91914642e01fSmrg esac 91924642e01fSmrg fi 919335c4bbdfSmrg if test -n "$i"; then 91944642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 91954642e01fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 91964642e01fSmrg set dummy $deplib_matches; shift 91974642e01fSmrg deplib_match=$1 919835c4bbdfSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 919935c4bbdfSmrg func_append newdeplibs " $i" 92004642e01fSmrg else 92014642e01fSmrg droppeddeps=yes 92026747b715Smrg echo 92034642e01fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92046747b715Smrg echo "*** I have the capability to make that library automatically link in when" 92056747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 92066747b715Smrg echo "*** shared version of the library, which I believe you do not have" 92076747b715Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 92086747b715Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 92094642e01fSmrg fi 92104642e01fSmrg fi 92114642e01fSmrg ;; 92124642e01fSmrg *) 921335c4bbdfSmrg func_append newdeplibs " $i" 92144642e01fSmrg ;; 92154642e01fSmrg esac 92164642e01fSmrg done 92174642e01fSmrg else 92184642e01fSmrg # Error occurred in the first compile. Let's try to salvage 92194642e01fSmrg # the situation: Compile a separate program for each library. 92204642e01fSmrg for i in $deplibs; do 92214642e01fSmrg case $i in 92224642e01fSmrg -l*) 92234642e01fSmrg func_stripname -l '' "$i" 92244642e01fSmrg name=$func_stripname_result 92254642e01fSmrg $opt_dry_run || $RM conftest 92264642e01fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 92274642e01fSmrg ldd_output=`ldd conftest` 922835c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92294642e01fSmrg case " $predeps $postdeps " in 92304642e01fSmrg *" $i "*) 923135c4bbdfSmrg func_append newdeplibs " $i" 923235c4bbdfSmrg i= 92334642e01fSmrg ;; 92344642e01fSmrg esac 92354642e01fSmrg fi 923635c4bbdfSmrg if test -n "$i"; then 92374642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92384642e01fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92394642e01fSmrg set dummy $deplib_matches; shift 92404642e01fSmrg deplib_match=$1 924135c4bbdfSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924235c4bbdfSmrg func_append newdeplibs " $i" 92434642e01fSmrg else 92444642e01fSmrg droppeddeps=yes 92456747b715Smrg echo 92464642e01fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92476747b715Smrg echo "*** I have the capability to make that library automatically link in when" 92486747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 92496747b715Smrg echo "*** shared version of the library, which you do not appear to have" 92506747b715Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 92516747b715Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 92524642e01fSmrg fi 92534642e01fSmrg fi 92544642e01fSmrg else 92554642e01fSmrg droppeddeps=yes 92566747b715Smrg echo 92574642e01fSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 92586747b715Smrg echo "*** make it link in! You will probably need to install it or some" 92596747b715Smrg echo "*** library that it depends on before this library will be fully" 92606747b715Smrg echo "*** functional. Installing it before continuing would be even better." 92614642e01fSmrg fi 92624642e01fSmrg ;; 92634642e01fSmrg *) 926435c4bbdfSmrg func_append newdeplibs " $i" 92654642e01fSmrg ;; 92664642e01fSmrg esac 92674642e01fSmrg done 92684642e01fSmrg fi 92694642e01fSmrg ;; 92704642e01fSmrg file_magic*) 92714642e01fSmrg set dummy $deplibs_check_method; shift 92724642e01fSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 92734642e01fSmrg for a_deplib in $deplibs; do 92744642e01fSmrg case $a_deplib in 92754642e01fSmrg -l*) 92764642e01fSmrg func_stripname -l '' "$a_deplib" 92774642e01fSmrg name=$func_stripname_result 927835c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92794642e01fSmrg case " $predeps $postdeps " in 92804642e01fSmrg *" $a_deplib "*) 928135c4bbdfSmrg func_append newdeplibs " $a_deplib" 928235c4bbdfSmrg a_deplib= 92834642e01fSmrg ;; 92844642e01fSmrg esac 92854642e01fSmrg fi 928635c4bbdfSmrg if test -n "$a_deplib"; then 92874642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 928835c4bbdfSmrg if test -n "$file_magic_glob"; then 928935c4bbdfSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 929035c4bbdfSmrg else 929135c4bbdfSmrg libnameglob=$libname 929235c4bbdfSmrg fi 929335c4bbdfSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 92944642e01fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 929535c4bbdfSmrg if test yes = "$want_nocaseglob"; then 929635c4bbdfSmrg shopt -s nocaseglob 929735c4bbdfSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929835c4bbdfSmrg $nocaseglob 929935c4bbdfSmrg else 930035c4bbdfSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 930135c4bbdfSmrg fi 93024642e01fSmrg for potent_lib in $potential_libs; do 93034642e01fSmrg # Follow soft links. 93044642e01fSmrg if ls -lLd "$potent_lib" 2>/dev/null | 93054642e01fSmrg $GREP " -> " >/dev/null; then 93064642e01fSmrg continue 93074642e01fSmrg fi 93084642e01fSmrg # The statement above tries to avoid entering an 93094642e01fSmrg # endless loop below, in case of cyclic links. 93104642e01fSmrg # We might still enter an endless loop, since a link 93114642e01fSmrg # loop can be closed while we follow links, 93124642e01fSmrg # but so what? 931335c4bbdfSmrg potlib=$potent_lib 93144642e01fSmrg while test -h "$potlib" 2>/dev/null; do 931535c4bbdfSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 93164642e01fSmrg case $potliblink in 931735c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 931835c4bbdfSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 93194642e01fSmrg esac 93204642e01fSmrg done 93214642e01fSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 93224642e01fSmrg $SED -e 10q | 93234642e01fSmrg $EGREP "$file_magic_regex" > /dev/null; then 932435c4bbdfSmrg func_append newdeplibs " $a_deplib" 932535c4bbdfSmrg a_deplib= 93264642e01fSmrg break 2 93274642e01fSmrg fi 93284642e01fSmrg done 93294642e01fSmrg done 93304642e01fSmrg fi 933135c4bbdfSmrg if test -n "$a_deplib"; then 93324642e01fSmrg droppeddeps=yes 93336747b715Smrg echo 93344642e01fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93356747b715Smrg echo "*** I have the capability to make that library automatically link in when" 93366747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 93376747b715Smrg echo "*** shared version of the library, which you do not appear to have" 93386747b715Smrg echo "*** because I did check the linker path looking for a file starting" 933935c4bbdfSmrg if test -z "$potlib"; then 93404642e01fSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 93414642e01fSmrg else 93424642e01fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93434642e01fSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 93444642e01fSmrg fi 93454642e01fSmrg fi 93464642e01fSmrg ;; 93474642e01fSmrg *) 93484642e01fSmrg # Add a -L argument. 934935c4bbdfSmrg func_append newdeplibs " $a_deplib" 93504642e01fSmrg ;; 93514642e01fSmrg esac 93524642e01fSmrg done # Gone through all deplibs. 93534642e01fSmrg ;; 93544642e01fSmrg match_pattern*) 93554642e01fSmrg set dummy $deplibs_check_method; shift 93564642e01fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 93574642e01fSmrg for a_deplib in $deplibs; do 93584642e01fSmrg case $a_deplib in 93594642e01fSmrg -l*) 93604642e01fSmrg func_stripname -l '' "$a_deplib" 93614642e01fSmrg name=$func_stripname_result 936235c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 93634642e01fSmrg case " $predeps $postdeps " in 93644642e01fSmrg *" $a_deplib "*) 936535c4bbdfSmrg func_append newdeplibs " $a_deplib" 936635c4bbdfSmrg a_deplib= 93674642e01fSmrg ;; 93684642e01fSmrg esac 93694642e01fSmrg fi 937035c4bbdfSmrg if test -n "$a_deplib"; then 93714642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 93724642e01fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93734642e01fSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 93744642e01fSmrg for potent_lib in $potential_libs; do 937535c4bbdfSmrg potlib=$potent_lib # see symlink-check above in file_magic test 93766747b715Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 93774642e01fSmrg $EGREP "$match_pattern_regex" > /dev/null; then 937835c4bbdfSmrg func_append newdeplibs " $a_deplib" 937935c4bbdfSmrg a_deplib= 93804642e01fSmrg break 2 93814642e01fSmrg fi 93824642e01fSmrg done 93834642e01fSmrg done 93844642e01fSmrg fi 938535c4bbdfSmrg if test -n "$a_deplib"; then 93864642e01fSmrg droppeddeps=yes 93876747b715Smrg echo 93884642e01fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93896747b715Smrg echo "*** I have the capability to make that library automatically link in when" 93906747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 93916747b715Smrg echo "*** shared version of the library, which you do not appear to have" 93926747b715Smrg echo "*** because I did check the linker path looking for a file starting" 939335c4bbdfSmrg if test -z "$potlib"; then 93944642e01fSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 93954642e01fSmrg else 93964642e01fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93974642e01fSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 93984642e01fSmrg fi 93994642e01fSmrg fi 94004642e01fSmrg ;; 94014642e01fSmrg *) 94024642e01fSmrg # Add a -L argument. 940335c4bbdfSmrg func_append newdeplibs " $a_deplib" 94044642e01fSmrg ;; 94054642e01fSmrg esac 94064642e01fSmrg done # Gone through all deplibs. 94074642e01fSmrg ;; 94084642e01fSmrg none | unknown | *) 940935c4bbdfSmrg newdeplibs= 94106747b715Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 941135c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941235c4bbdfSmrg for i in $predeps $postdeps; do 94134642e01fSmrg # can't use Xsed below, because $i might contain '/' 941435c4bbdfSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 94154642e01fSmrg done 94164642e01fSmrg fi 94176747b715Smrg case $tmp_deplibs in 94186747b715Smrg *[!\ \ ]*) 94196747b715Smrg echo 942035c4bbdfSmrg if test none = "$deplibs_check_method"; then 94216747b715Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 94224642e01fSmrg else 94236747b715Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 94244642e01fSmrg fi 94256747b715Smrg echo "*** All declared inter-library dependencies are being dropped." 94264642e01fSmrg droppeddeps=yes 94276747b715Smrg ;; 94286747b715Smrg esac 94294642e01fSmrg ;; 94304642e01fSmrg esac 94314642e01fSmrg versuffix=$versuffix_save 94324642e01fSmrg major=$major_save 94334642e01fSmrg release=$release_save 94344642e01fSmrg libname=$libname_save 94354642e01fSmrg name=$name_save 94364642e01fSmrg 94374642e01fSmrg case $host in 94384642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 94394642e01fSmrg # On Rhapsody replace the C library with the System framework 94406747b715Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 94414642e01fSmrg ;; 94424642e01fSmrg esac 94434642e01fSmrg 944435c4bbdfSmrg if test yes = "$droppeddeps"; then 944535c4bbdfSmrg if test yes = "$module"; then 94466747b715Smrg echo 94476747b715Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 94484642e01fSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 94496747b715Smrg echo "*** a static module, that should work as long as the dlopening" 94506747b715Smrg echo "*** application is linked with the -dlopen flag." 94514642e01fSmrg if test -z "$global_symbol_pipe"; then 94526747b715Smrg echo 94536747b715Smrg echo "*** However, this would only work if libtool was able to extract symbol" 945435c4bbdfSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 94556747b715Smrg echo "*** not find such a program. So, this module is probably useless." 945635c4bbdfSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 94574642e01fSmrg fi 945835c4bbdfSmrg if test no = "$build_old_libs"; then 945935c4bbdfSmrg oldlibs=$output_objdir/$libname.$libext 94604642e01fSmrg build_libtool_libs=module 94614642e01fSmrg build_old_libs=yes 94624642e01fSmrg else 94634642e01fSmrg build_libtool_libs=no 94644642e01fSmrg fi 94654642e01fSmrg else 94666747b715Smrg echo "*** The inter-library dependencies that have been dropped here will be" 94676747b715Smrg echo "*** automatically added whenever a program is linked with this library" 94686747b715Smrg echo "*** or is declared to -dlopen it." 94694642e01fSmrg 947035c4bbdfSmrg if test no = "$allow_undefined"; then 94716747b715Smrg echo 94726747b715Smrg echo "*** Since this library must not contain undefined symbols," 94736747b715Smrg echo "*** because either the platform does not support them or" 94746747b715Smrg echo "*** it was explicitly requested with -no-undefined," 94756747b715Smrg echo "*** libtool will only create a static version of it." 947635c4bbdfSmrg if test no = "$build_old_libs"; then 947735c4bbdfSmrg oldlibs=$output_objdir/$libname.$libext 94784642e01fSmrg build_libtool_libs=module 94794642e01fSmrg build_old_libs=yes 94804642e01fSmrg else 94814642e01fSmrg build_libtool_libs=no 94824642e01fSmrg fi 94834642e01fSmrg fi 94844642e01fSmrg fi 94854642e01fSmrg fi 94864642e01fSmrg # Done checking deplibs! 94874642e01fSmrg deplibs=$newdeplibs 94884642e01fSmrg fi 94894642e01fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 94904642e01fSmrg case $host in 94914642e01fSmrg *-*-darwin*) 94926747b715Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94936747b715Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94946747b715Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94954642e01fSmrg ;; 94964642e01fSmrg esac 94974642e01fSmrg 94984642e01fSmrg # move library search paths that coincide with paths to not yet 94994642e01fSmrg # installed libraries to the beginning of the library search list 95004642e01fSmrg new_libs= 95014642e01fSmrg for path in $notinst_path; do 95024642e01fSmrg case " $new_libs " in 95034642e01fSmrg *" -L$path/$objdir "*) ;; 95044642e01fSmrg *) 95054642e01fSmrg case " $deplibs " in 95064642e01fSmrg *" -L$path/$objdir "*) 950735c4bbdfSmrg func_append new_libs " -L$path/$objdir" ;; 95084642e01fSmrg esac 95094642e01fSmrg ;; 95104642e01fSmrg esac 95114642e01fSmrg done 95124642e01fSmrg for deplib in $deplibs; do 95134642e01fSmrg case $deplib in 95144642e01fSmrg -L*) 95154642e01fSmrg case " $new_libs " in 95164642e01fSmrg *" $deplib "*) ;; 951735c4bbdfSmrg *) func_append new_libs " $deplib" ;; 95184642e01fSmrg esac 95194642e01fSmrg ;; 952035c4bbdfSmrg *) func_append new_libs " $deplib" ;; 95214642e01fSmrg esac 95224642e01fSmrg done 952335c4bbdfSmrg deplibs=$new_libs 95244642e01fSmrg 95254642e01fSmrg # All the library-specific variables (install_libdir is set above). 95264642e01fSmrg library_names= 95274642e01fSmrg old_library= 95284642e01fSmrg dlname= 95294642e01fSmrg 95304642e01fSmrg # Test again, we may have decided not to build it any more 953135c4bbdfSmrg if test yes = "$build_libtool_libs"; then 953235c4bbdfSmrg # Remove $wl instances when linking with ld. 953335c4bbdfSmrg # FIXME: should test the right _cmds variable. 953435c4bbdfSmrg case $archive_cmds in 953535c4bbdfSmrg *\$LD\ *) wl= ;; 953635c4bbdfSmrg esac 953735c4bbdfSmrg if test yes = "$hardcode_into_libs"; then 95384642e01fSmrg # Hardcode the library paths 95394642e01fSmrg hardcode_libdirs= 95404642e01fSmrg dep_rpath= 954135c4bbdfSmrg rpath=$finalize_rpath 954235c4bbdfSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 95434642e01fSmrg for libdir in $rpath; do 95444642e01fSmrg if test -n "$hardcode_libdir_flag_spec"; then 95454642e01fSmrg if test -n "$hardcode_libdir_separator"; then 954635c4bbdfSmrg func_replace_sysroot "$libdir" 954735c4bbdfSmrg libdir=$func_replace_sysroot_result 95484642e01fSmrg if test -z "$hardcode_libdirs"; then 954935c4bbdfSmrg hardcode_libdirs=$libdir 95504642e01fSmrg else 95514642e01fSmrg # Just accumulate the unique libdirs. 95524642e01fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 95534642e01fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 95544642e01fSmrg ;; 95554642e01fSmrg *) 955635c4bbdfSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 95574642e01fSmrg ;; 95584642e01fSmrg esac 95594642e01fSmrg fi 95604642e01fSmrg else 95614642e01fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 956235c4bbdfSmrg func_append dep_rpath " $flag" 95634642e01fSmrg fi 95644642e01fSmrg elif test -n "$runpath_var"; then 95654642e01fSmrg case "$perm_rpath " in 95664642e01fSmrg *" $libdir "*) ;; 956735c4bbdfSmrg *) func_append perm_rpath " $libdir" ;; 95684642e01fSmrg esac 95694642e01fSmrg fi 95704642e01fSmrg done 95714642e01fSmrg # Substitute the hardcoded libdirs into the rpath. 95724642e01fSmrg if test -n "$hardcode_libdir_separator" && 95734642e01fSmrg test -n "$hardcode_libdirs"; then 957435c4bbdfSmrg libdir=$hardcode_libdirs 957535c4bbdfSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 95764642e01fSmrg fi 95774642e01fSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 95784642e01fSmrg # We should set the runpath_var. 95794642e01fSmrg rpath= 95804642e01fSmrg for dir in $perm_rpath; do 958135c4bbdfSmrg func_append rpath "$dir:" 95824642e01fSmrg done 95834642e01fSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 95844642e01fSmrg fi 95854642e01fSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 95864642e01fSmrg fi 958705b261ecSmrg 958835c4bbdfSmrg shlibpath=$finalize_shlibpath 958935c4bbdfSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 95904642e01fSmrg if test -n "$shlibpath"; then 95914642e01fSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 95924642e01fSmrg fi 959305b261ecSmrg 95944642e01fSmrg # Get the real and link names of the library. 95954642e01fSmrg eval shared_ext=\"$shrext_cmds\" 95964642e01fSmrg eval library_names=\"$library_names_spec\" 95974642e01fSmrg set dummy $library_names 95984642e01fSmrg shift 959935c4bbdfSmrg realname=$1 96004642e01fSmrg shift 960105b261ecSmrg 96024642e01fSmrg if test -n "$soname_spec"; then 96034642e01fSmrg eval soname=\"$soname_spec\" 96044642e01fSmrg else 960535c4bbdfSmrg soname=$realname 96064642e01fSmrg fi 96074642e01fSmrg if test -z "$dlname"; then 96084642e01fSmrg dlname=$soname 96094642e01fSmrg fi 961005b261ecSmrg 961135c4bbdfSmrg lib=$output_objdir/$realname 96124642e01fSmrg linknames= 96134642e01fSmrg for link 96144642e01fSmrg do 961535c4bbdfSmrg func_append linknames " $link" 96164642e01fSmrg done 961705b261ecSmrg 96184642e01fSmrg # Use standard objects if they are pic 96196747b715Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 96204642e01fSmrg test "X$libobjs" = "X " && libobjs= 962105b261ecSmrg 96224642e01fSmrg delfiles= 96234642e01fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 96244642e01fSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 962535c4bbdfSmrg export_symbols=$output_objdir/$libname.uexp 962635c4bbdfSmrg func_append delfiles " $export_symbols" 96274642e01fSmrg fi 962805b261ecSmrg 96294642e01fSmrg orig_export_symbols= 96304642e01fSmrg case $host_os in 96314642e01fSmrg cygwin* | mingw* | cegcc*) 96324642e01fSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 96334642e01fSmrg # exporting using user supplied symfile 963435c4bbdfSmrg func_dll_def_p "$export_symbols" || { 96354642e01fSmrg # and it's NOT already a .def file. Must figure out 96364642e01fSmrg # which of the given symbols are data symbols and tag 96374642e01fSmrg # them as such. So, trigger use of export_symbols_cmds. 96384642e01fSmrg # export_symbols gets reassigned inside the "prepare 96394642e01fSmrg # the list of exported symbols" if statement, so the 96404642e01fSmrg # include_expsyms logic still works. 964135c4bbdfSmrg orig_export_symbols=$export_symbols 96424642e01fSmrg export_symbols= 96434642e01fSmrg always_export_symbols=yes 964435c4bbdfSmrg } 96454642e01fSmrg fi 96464642e01fSmrg ;; 96474642e01fSmrg esac 964805b261ecSmrg 96494642e01fSmrg # Prepare the list of exported symbols 96504642e01fSmrg if test -z "$export_symbols"; then 965135c4bbdfSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965235c4bbdfSmrg func_verbose "generating symbol list for '$libname.la'" 965335c4bbdfSmrg export_symbols=$output_objdir/$libname.exp 96544642e01fSmrg $opt_dry_run || $RM $export_symbols 96554642e01fSmrg cmds=$export_symbols_cmds 965635c4bbdfSmrg save_ifs=$IFS; IFS='~' 965735c4bbdfSmrg for cmd1 in $cmds; do 965835c4bbdfSmrg IFS=$save_ifs 965935c4bbdfSmrg # Take the normal branch if the nm_file_list_spec branch 966035c4bbdfSmrg # doesn't work or if tool conversion is not needed. 966135c4bbdfSmrg case $nm_file_list_spec~$to_tool_file_cmd in 966235c4bbdfSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 966335c4bbdfSmrg try_normal_branch=yes 966435c4bbdfSmrg eval cmd=\"$cmd1\" 966535c4bbdfSmrg func_len " $cmd" 966635c4bbdfSmrg len=$func_len_result 966735c4bbdfSmrg ;; 966835c4bbdfSmrg *) 966935c4bbdfSmrg try_normal_branch=no 967035c4bbdfSmrg ;; 967135c4bbdfSmrg esac 967235c4bbdfSmrg if test yes = "$try_normal_branch" \ 967335c4bbdfSmrg && { test "$len" -lt "$max_cmd_len" \ 967435c4bbdfSmrg || test "$max_cmd_len" -le -1; } 967535c4bbdfSmrg then 967635c4bbdfSmrg func_show_eval "$cmd" 'exit $?' 967735c4bbdfSmrg skipped_export=false 967835c4bbdfSmrg elif test -n "$nm_file_list_spec"; then 967935c4bbdfSmrg func_basename "$output" 968035c4bbdfSmrg output_la=$func_basename_result 968135c4bbdfSmrg save_libobjs=$libobjs 968235c4bbdfSmrg save_output=$output 968335c4bbdfSmrg output=$output_objdir/$output_la.nm 968435c4bbdfSmrg func_to_tool_file "$output" 968535c4bbdfSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 968635c4bbdfSmrg func_append delfiles " $output" 968735c4bbdfSmrg func_verbose "creating $NM input file list: $output" 968835c4bbdfSmrg for obj in $save_libobjs; do 968935c4bbdfSmrg func_to_tool_file "$obj" 969035c4bbdfSmrg $ECHO "$func_to_tool_file_result" 969135c4bbdfSmrg done > "$output" 969235c4bbdfSmrg eval cmd=\"$cmd1\" 96934642e01fSmrg func_show_eval "$cmd" 'exit $?' 969435c4bbdfSmrg output=$save_output 969535c4bbdfSmrg libobjs=$save_libobjs 96964642e01fSmrg skipped_export=false 96974642e01fSmrg else 96984642e01fSmrg # The command line is too long to execute in one step. 96994642e01fSmrg func_verbose "using reloadable object file for export list..." 97004642e01fSmrg skipped_export=: 97014642e01fSmrg # Break out early, otherwise skipped_export may be 97024642e01fSmrg # set to false by a later but shorter cmd. 97034642e01fSmrg break 97044642e01fSmrg fi 97054642e01fSmrg done 970635c4bbdfSmrg IFS=$save_ifs 970735c4bbdfSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 97084642e01fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 97094642e01fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 97104642e01fSmrg fi 97114642e01fSmrg fi 971205b261ecSmrg fi 971305b261ecSmrg 97144642e01fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 971535c4bbdfSmrg tmp_export_symbols=$export_symbols 971635c4bbdfSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 97176747b715Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 97184642e01fSmrg fi 971905b261ecSmrg 972035c4bbdfSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 97214642e01fSmrg # The given exports_symbols file has to be filtered, so filter it. 972235c4bbdfSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 97234642e01fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 972435c4bbdfSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 97254642e01fSmrg # though. Also, the filter scales superlinearly with the number of 97264642e01fSmrg # global variables. join(1) would be nice here, but unfortunately 97274642e01fSmrg # isn't a blessed tool. 97284642e01fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 972935c4bbdfSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 97304642e01fSmrg export_symbols=$output_objdir/$libname.def 97314642e01fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97324642e01fSmrg fi 973305b261ecSmrg 97344642e01fSmrg tmp_deplibs= 97354642e01fSmrg for test_deplib in $deplibs; do 97364642e01fSmrg case " $convenience " in 97374642e01fSmrg *" $test_deplib "*) ;; 97384642e01fSmrg *) 973935c4bbdfSmrg func_append tmp_deplibs " $test_deplib" 97404642e01fSmrg ;; 97414642e01fSmrg esac 97424642e01fSmrg done 974335c4bbdfSmrg deplibs=$tmp_deplibs 974405b261ecSmrg 97454642e01fSmrg if test -n "$convenience"; then 97464642e01fSmrg if test -n "$whole_archive_flag_spec" && 974735c4bbdfSmrg test yes = "$compiler_needs_object" && 97484642e01fSmrg test -z "$libobjs"; then 97494642e01fSmrg # extract the archives, so we have objects to list. 97504642e01fSmrg # TODO: could optimize this to just extract one archive. 97514642e01fSmrg whole_archive_flag_spec= 97524642e01fSmrg fi 97534642e01fSmrg if test -n "$whole_archive_flag_spec"; then 97544642e01fSmrg save_libobjs=$libobjs 97554642e01fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 97564642e01fSmrg test "X$libobjs" = "X " && libobjs= 97574642e01fSmrg else 975835c4bbdfSmrg gentop=$output_objdir/${outputname}x 975935c4bbdfSmrg func_append generated " $gentop" 976005b261ecSmrg 97614642e01fSmrg func_extract_archives $gentop $convenience 976235c4bbdfSmrg func_append libobjs " $func_extract_archives_result" 97634642e01fSmrg test "X$libobjs" = "X " && libobjs= 97644642e01fSmrg fi 976505b261ecSmrg fi 976605b261ecSmrg 976735c4bbdfSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 97684642e01fSmrg eval flag=\"$thread_safe_flag_spec\" 976935c4bbdfSmrg func_append linker_flags " $flag" 977005b261ecSmrg fi 977105b261ecSmrg 97724642e01fSmrg # Make a backup of the uninstalled library when relinking 977335c4bbdfSmrg if test relink = "$opt_mode"; then 97744642e01fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 97754642e01fSmrg fi 977605b261ecSmrg 97774642e01fSmrg # Do each of the archive commands. 977835c4bbdfSmrg if test yes = "$module" && test -n "$module_cmds"; then 97794642e01fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 97804642e01fSmrg eval test_cmds=\"$module_expsym_cmds\" 97814642e01fSmrg cmds=$module_expsym_cmds 97824642e01fSmrg else 97834642e01fSmrg eval test_cmds=\"$module_cmds\" 97844642e01fSmrg cmds=$module_cmds 97854642e01fSmrg fi 978605b261ecSmrg else 97874642e01fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 97884642e01fSmrg eval test_cmds=\"$archive_expsym_cmds\" 97894642e01fSmrg cmds=$archive_expsym_cmds 97904642e01fSmrg else 97914642e01fSmrg eval test_cmds=\"$archive_cmds\" 97924642e01fSmrg cmds=$archive_cmds 97934642e01fSmrg fi 979405b261ecSmrg fi 979505b261ecSmrg 979635c4bbdfSmrg if test : != "$skipped_export" && 97974642e01fSmrg func_len " $test_cmds" && 97984642e01fSmrg len=$func_len_result && 97994642e01fSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 98004642e01fSmrg : 98014642e01fSmrg else 98024642e01fSmrg # The command line is too long to link in one step, link piecewise 98034642e01fSmrg # or, if using GNU ld and skipped_export is not :, use a linker 98044642e01fSmrg # script. 980505b261ecSmrg 98064642e01fSmrg # Save the value of $output and $libobjs because we want to 98074642e01fSmrg # use them later. If we have whole_archive_flag_spec, we 98084642e01fSmrg # want to use save_libobjs as it was before 98094642e01fSmrg # whole_archive_flag_spec was expanded, because we can't 98104642e01fSmrg # assume the linker understands whole_archive_flag_spec. 98114642e01fSmrg # This may have to be revisited, in case too many 98124642e01fSmrg # convenience libraries get linked in and end up exceeding 98134642e01fSmrg # the spec. 98144642e01fSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 98154642e01fSmrg save_libobjs=$libobjs 98164642e01fSmrg fi 98174642e01fSmrg save_output=$output 98186747b715Smrg func_basename "$output" 98196747b715Smrg output_la=$func_basename_result 982005b261ecSmrg 98214642e01fSmrg # Clear the reloadable object creation command queue and 98224642e01fSmrg # initialize k to one. 98234642e01fSmrg test_cmds= 98244642e01fSmrg concat_cmds= 98254642e01fSmrg objlist= 98264642e01fSmrg last_robj= 98274642e01fSmrg k=1 98284642e01fSmrg 982935c4bbdfSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 983035c4bbdfSmrg output=$output_objdir/$output_la.lnkscript 98314642e01fSmrg func_verbose "creating GNU ld script: $output" 98326747b715Smrg echo 'INPUT (' > $output 98334642e01fSmrg for obj in $save_libobjs 983405b261ecSmrg do 983535c4bbdfSmrg func_to_tool_file "$obj" 983635c4bbdfSmrg $ECHO "$func_to_tool_file_result" >> $output 98374642e01fSmrg done 98386747b715Smrg echo ')' >> $output 983935c4bbdfSmrg func_append delfiles " $output" 984035c4bbdfSmrg func_to_tool_file "$output" 984135c4bbdfSmrg output=$func_to_tool_file_result 984235c4bbdfSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 984335c4bbdfSmrg output=$output_objdir/$output_la.lnk 98444642e01fSmrg func_verbose "creating linker input file list: $output" 98454642e01fSmrg : > $output 98464642e01fSmrg set x $save_libobjs 98474642e01fSmrg shift 98484642e01fSmrg firstobj= 984935c4bbdfSmrg if test yes = "$compiler_needs_object"; then 98504642e01fSmrg firstobj="$1 " 98514642e01fSmrg shift 98524642e01fSmrg fi 98534642e01fSmrg for obj 98544642e01fSmrg do 985535c4bbdfSmrg func_to_tool_file "$obj" 985635c4bbdfSmrg $ECHO "$func_to_tool_file_result" >> $output 98574642e01fSmrg done 985835c4bbdfSmrg func_append delfiles " $output" 985935c4bbdfSmrg func_to_tool_file "$output" 986035c4bbdfSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 98614642e01fSmrg else 98624642e01fSmrg if test -n "$save_libobjs"; then 98634642e01fSmrg func_verbose "creating reloadable object files..." 986435c4bbdfSmrg output=$output_objdir/$output_la-$k.$objext 98654642e01fSmrg eval test_cmds=\"$reload_cmds\" 98664642e01fSmrg func_len " $test_cmds" 98674642e01fSmrg len0=$func_len_result 98684642e01fSmrg len=$len0 98694642e01fSmrg 98704642e01fSmrg # Loop over the list of objects to be linked. 98714642e01fSmrg for obj in $save_libobjs 98724642e01fSmrg do 98734642e01fSmrg func_len " $obj" 98744642e01fSmrg func_arith $len + $func_len_result 98754642e01fSmrg len=$func_arith_result 987635c4bbdfSmrg if test -z "$objlist" || 98774642e01fSmrg test "$len" -lt "$max_cmd_len"; then 98784642e01fSmrg func_append objlist " $obj" 98794642e01fSmrg else 98804642e01fSmrg # The command $test_cmds is almost too long, add a 98814642e01fSmrg # command to the queue. 988235c4bbdfSmrg if test 1 -eq "$k"; then 98834642e01fSmrg # The first file doesn't have a previous command to add. 98846747b715Smrg reload_objs=$objlist 98856747b715Smrg eval concat_cmds=\"$reload_cmds\" 98864642e01fSmrg else 98874642e01fSmrg # All subsequent reloadable object files will link in 98884642e01fSmrg # the last one created. 98896747b715Smrg reload_objs="$objlist $last_robj" 98906747b715Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 98914642e01fSmrg fi 989235c4bbdfSmrg last_robj=$output_objdir/$output_la-$k.$objext 98934642e01fSmrg func_arith $k + 1 98944642e01fSmrg k=$func_arith_result 989535c4bbdfSmrg output=$output_objdir/$output_la-$k.$objext 98966747b715Smrg objlist=" $obj" 98974642e01fSmrg func_len " $last_robj" 98984642e01fSmrg func_arith $len0 + $func_len_result 98994642e01fSmrg len=$func_arith_result 99004642e01fSmrg fi 99014642e01fSmrg done 99024642e01fSmrg # Handle the remaining objects by creating one last 99034642e01fSmrg # reloadable object file. All subsequent reloadable object 99044642e01fSmrg # files will link in the last one created. 99054642e01fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99066747b715Smrg reload_objs="$objlist $last_robj" 990735c4bbdfSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 99084642e01fSmrg if test -n "$last_robj"; then 990935c4bbdfSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99104642e01fSmrg fi 991135c4bbdfSmrg func_append delfiles " $output" 991205b261ecSmrg 99134642e01fSmrg else 99144642e01fSmrg output= 99154642e01fSmrg fi 991605b261ecSmrg 991735c4bbdfSmrg ${skipped_export-false} && { 991835c4bbdfSmrg func_verbose "generating symbol list for '$libname.la'" 991935c4bbdfSmrg export_symbols=$output_objdir/$libname.exp 99204642e01fSmrg $opt_dry_run || $RM $export_symbols 99214642e01fSmrg libobjs=$output 99224642e01fSmrg # Append the command to create the export file. 99234642e01fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99244642e01fSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 99254642e01fSmrg if test -n "$last_robj"; then 99264642e01fSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99274642e01fSmrg fi 992835c4bbdfSmrg } 992905b261ecSmrg 99304642e01fSmrg test -n "$save_libobjs" && 99314642e01fSmrg func_verbose "creating a temporary reloadable object file: $output" 993205b261ecSmrg 99334642e01fSmrg # Loop through the commands generated above and execute them. 993435c4bbdfSmrg save_ifs=$IFS; IFS='~' 99354642e01fSmrg for cmd in $concat_cmds; do 993635c4bbdfSmrg IFS=$save_ifs 993735c4bbdfSmrg $opt_quiet || { 99384642e01fSmrg func_quote_for_expand "$cmd" 99394642e01fSmrg eval "func_echo $func_quote_for_expand_result" 99404642e01fSmrg } 99414642e01fSmrg $opt_dry_run || eval "$cmd" || { 99424642e01fSmrg lt_exit=$? 99434642e01fSmrg 99444642e01fSmrg # Restore the uninstalled library and exit 994535c4bbdfSmrg if test relink = "$opt_mode"; then 99464642e01fSmrg ( cd "$output_objdir" && \ 99474642e01fSmrg $RM "${realname}T" && \ 99484642e01fSmrg $MV "${realname}U" "$realname" ) 99494642e01fSmrg fi 995005b261ecSmrg 99514642e01fSmrg exit $lt_exit 99524642e01fSmrg } 99534642e01fSmrg done 995435c4bbdfSmrg IFS=$save_ifs 995505b261ecSmrg 99564642e01fSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 99574642e01fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99584642e01fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 995905b261ecSmrg fi 996005b261ecSmrg fi 996105b261ecSmrg 996235c4bbdfSmrg ${skipped_export-false} && { 99634642e01fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 996435c4bbdfSmrg tmp_export_symbols=$export_symbols 996535c4bbdfSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 99666747b715Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99674642e01fSmrg fi 996805b261ecSmrg 99694642e01fSmrg if test -n "$orig_export_symbols"; then 99704642e01fSmrg # The given exports_symbols file has to be filtered, so filter it. 997135c4bbdfSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 99724642e01fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 997335c4bbdfSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 99744642e01fSmrg # though. Also, the filter scales superlinearly with the number of 99754642e01fSmrg # global variables. join(1) would be nice here, but unfortunately 99764642e01fSmrg # isn't a blessed tool. 99774642e01fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 997835c4bbdfSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 99794642e01fSmrg export_symbols=$output_objdir/$libname.def 99804642e01fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 99814642e01fSmrg fi 998235c4bbdfSmrg } 998305b261ecSmrg 99844642e01fSmrg libobjs=$output 99854642e01fSmrg # Restore the value of output. 99864642e01fSmrg output=$save_output 998705b261ecSmrg 99884642e01fSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 99894642e01fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 99904642e01fSmrg test "X$libobjs" = "X " && libobjs= 99914642e01fSmrg fi 99924642e01fSmrg # Expand the library linking commands again to reset the 99934642e01fSmrg # value of $libobjs for piecewise linking. 999405b261ecSmrg 99954642e01fSmrg # Do each of the archive commands. 999635c4bbdfSmrg if test yes = "$module" && test -n "$module_cmds"; then 99974642e01fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 99984642e01fSmrg cmds=$module_expsym_cmds 99994642e01fSmrg else 100004642e01fSmrg cmds=$module_cmds 1000105b261ecSmrg fi 1000205b261ecSmrg else 100034642e01fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100044642e01fSmrg cmds=$archive_expsym_cmds 100054642e01fSmrg else 100064642e01fSmrg cmds=$archive_cmds 100074642e01fSmrg fi 1000805b261ecSmrg fi 100094642e01fSmrg fi 1001005b261ecSmrg 100114642e01fSmrg if test -n "$delfiles"; then 100124642e01fSmrg # Append the command to remove temporary files to $cmds. 100134642e01fSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 100144642e01fSmrg fi 1001505b261ecSmrg 100164642e01fSmrg # Add any objects from preloaded convenience libraries 100174642e01fSmrg if test -n "$dlprefiles"; then 1001835c4bbdfSmrg gentop=$output_objdir/${outputname}x 1001935c4bbdfSmrg func_append generated " $gentop" 1002005b261ecSmrg 100214642e01fSmrg func_extract_archives $gentop $dlprefiles 1002235c4bbdfSmrg func_append libobjs " $func_extract_archives_result" 100234642e01fSmrg test "X$libobjs" = "X " && libobjs= 100244642e01fSmrg fi 1002505b261ecSmrg 1002635c4bbdfSmrg save_ifs=$IFS; IFS='~' 100274642e01fSmrg for cmd in $cmds; do 1002835c4bbdfSmrg IFS=$sp$nl 100294642e01fSmrg eval cmd=\"$cmd\" 1003035c4bbdfSmrg IFS=$save_ifs 1003135c4bbdfSmrg $opt_quiet || { 100324642e01fSmrg func_quote_for_expand "$cmd" 100334642e01fSmrg eval "func_echo $func_quote_for_expand_result" 100344642e01fSmrg } 100354642e01fSmrg $opt_dry_run || eval "$cmd" || { 100364642e01fSmrg lt_exit=$? 1003705b261ecSmrg 100384642e01fSmrg # Restore the uninstalled library and exit 1003935c4bbdfSmrg if test relink = "$opt_mode"; then 100404642e01fSmrg ( cd "$output_objdir" && \ 100414642e01fSmrg $RM "${realname}T" && \ 100424642e01fSmrg $MV "${realname}U" "$realname" ) 100434642e01fSmrg fi 1004405b261ecSmrg 100454642e01fSmrg exit $lt_exit 100464642e01fSmrg } 100474642e01fSmrg done 1004835c4bbdfSmrg IFS=$save_ifs 1004905b261ecSmrg 100504642e01fSmrg # Restore the uninstalled library and exit 1005135c4bbdfSmrg if test relink = "$opt_mode"; then 100524642e01fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1005305b261ecSmrg 100544642e01fSmrg if test -n "$convenience"; then 100554642e01fSmrg if test -z "$whole_archive_flag_spec"; then 100564642e01fSmrg func_show_eval '${RM}r "$gentop"' 100574642e01fSmrg fi 100584642e01fSmrg fi 1005905b261ecSmrg 100604642e01fSmrg exit $EXIT_SUCCESS 100614642e01fSmrg fi 100624642e01fSmrg 100634642e01fSmrg # Create links to the real library. 100644642e01fSmrg for linkname in $linknames; do 100654642e01fSmrg if test "$realname" != "$linkname"; then 100664642e01fSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1006705b261ecSmrg fi 1006805b261ecSmrg done 1006905b261ecSmrg 100704642e01fSmrg # If -module or -export-dynamic was specified, set the dlname. 1007135c4bbdfSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 100724642e01fSmrg # On all known operating systems, these are identical. 1007335c4bbdfSmrg dlname=$soname 100744642e01fSmrg fi 100754642e01fSmrg fi 1007605b261ecSmrg ;; 1007705b261ecSmrg 100784642e01fSmrg obj) 1007935c4bbdfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1008035c4bbdfSmrg func_warning "'-dlopen' is ignored for objects" 100814642e01fSmrg fi 1008205b261ecSmrg 100834642e01fSmrg case " $deplibs" in 100844642e01fSmrg *\ -l* | *\ -L*) 1008535c4bbdfSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 1008605b261ecSmrg esac 1008705b261ecSmrg 100884642e01fSmrg test -n "$rpath" && \ 1008935c4bbdfSmrg func_warning "'-rpath' is ignored for objects" 100904642e01fSmrg 100914642e01fSmrg test -n "$xrpath" && \ 1009235c4bbdfSmrg func_warning "'-R' is ignored for objects" 1009305b261ecSmrg 100944642e01fSmrg test -n "$vinfo" && \ 1009535c4bbdfSmrg func_warning "'-version-info' is ignored for objects" 1009605b261ecSmrg 100974642e01fSmrg test -n "$release" && \ 1009835c4bbdfSmrg func_warning "'-release' is ignored for objects" 100994642e01fSmrg 101004642e01fSmrg case $output in 101014642e01fSmrg *.lo) 101024642e01fSmrg test -n "$objs$old_deplibs" && \ 1010335c4bbdfSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 101044642e01fSmrg 101054642e01fSmrg libobj=$output 101064642e01fSmrg func_lo2o "$libobj" 101074642e01fSmrg obj=$func_lo2o_result 1010805b261ecSmrg ;; 1010905b261ecSmrg *) 101104642e01fSmrg libobj= 1011135c4bbdfSmrg obj=$output 1011205b261ecSmrg ;; 1011305b261ecSmrg esac 1011405b261ecSmrg 101154642e01fSmrg # Delete the old objects. 101164642e01fSmrg $opt_dry_run || $RM $obj $libobj 1011705b261ecSmrg 101184642e01fSmrg # Objects from convenience libraries. This assumes 101194642e01fSmrg # single-version convenience libraries. Whenever we create 101204642e01fSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 101214642e01fSmrg # the extraction. 101224642e01fSmrg reload_conv_objs= 101234642e01fSmrg gentop= 1012435c4bbdfSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1012535c4bbdfSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1012635c4bbdfSmrg # into space. 1012735c4bbdfSmrg case $reload_cmds in 1012835c4bbdfSmrg *\$LD[\ \$]*) wl= ;; 1012935c4bbdfSmrg esac 101304642e01fSmrg if test -n "$convenience"; then 101314642e01fSmrg if test -n "$whole_archive_flag_spec"; then 101324642e01fSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1013335c4bbdfSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1013435c4bbdfSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 101354642e01fSmrg else 1013635c4bbdfSmrg gentop=$output_objdir/${obj}x 1013735c4bbdfSmrg func_append generated " $gentop" 1013805b261ecSmrg 101394642e01fSmrg func_extract_archives $gentop $convenience 101404642e01fSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 101414642e01fSmrg fi 1014205b261ecSmrg fi 1014305b261ecSmrg 1014435c4bbdfSmrg # If we're not building shared, we need to use non_pic_objs 1014535c4bbdfSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1014635c4bbdfSmrg 101474642e01fSmrg # Create the old-style object. 1014835c4bbdfSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 1014905b261ecSmrg 1015035c4bbdfSmrg output=$obj 101514642e01fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1015205b261ecSmrg 101534642e01fSmrg # Exit if we aren't doing a library object file. 101544642e01fSmrg if test -z "$libobj"; then 101554642e01fSmrg if test -n "$gentop"; then 101564642e01fSmrg func_show_eval '${RM}r "$gentop"' 101574642e01fSmrg fi 101584642e01fSmrg 101594642e01fSmrg exit $EXIT_SUCCESS 1016005b261ecSmrg fi 101614642e01fSmrg 1016235c4bbdfSmrg test yes = "$build_libtool_libs" || { 101634642e01fSmrg if test -n "$gentop"; then 101644642e01fSmrg func_show_eval '${RM}r "$gentop"' 101654642e01fSmrg fi 101664642e01fSmrg 101674642e01fSmrg # Create an invalid libtool object if no PIC, so that we don't 101684642e01fSmrg # accidentally link it into a program. 101694642e01fSmrg # $show "echo timestamp > $libobj" 101704642e01fSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 101714642e01fSmrg exit $EXIT_SUCCESS 1017235c4bbdfSmrg } 101734642e01fSmrg 1017435c4bbdfSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 101754642e01fSmrg # Only do commands if we really have different PIC objects. 101764642e01fSmrg reload_objs="$libobjs $reload_conv_objs" 1017735c4bbdfSmrg output=$libobj 101784642e01fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 101794642e01fSmrg fi 101804642e01fSmrg 101814642e01fSmrg if test -n "$gentop"; then 101824642e01fSmrg func_show_eval '${RM}r "$gentop"' 101834642e01fSmrg fi 101844642e01fSmrg 101854642e01fSmrg exit $EXIT_SUCCESS 1018605b261ecSmrg ;; 1018705b261ecSmrg 101884642e01fSmrg prog) 101894642e01fSmrg case $host in 101904642e01fSmrg *cygwin*) func_stripname '' '.exe' "$output" 101914642e01fSmrg output=$func_stripname_result.exe;; 101924642e01fSmrg esac 101934642e01fSmrg test -n "$vinfo" && \ 1019435c4bbdfSmrg func_warning "'-version-info' is ignored for programs" 1019505b261ecSmrg 101964642e01fSmrg test -n "$release" && \ 1019735c4bbdfSmrg func_warning "'-release' is ignored for programs" 1019805b261ecSmrg 1019935c4bbdfSmrg $preload \ 1020035c4bbdfSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1020135c4bbdfSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102024642e01fSmrg 102034642e01fSmrg case $host in 102044642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 102054642e01fSmrg # On Rhapsody replace the C library is the System framework 102066747b715Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 102076747b715Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020805b261ecSmrg ;; 102094642e01fSmrg esac 1021005b261ecSmrg 102114642e01fSmrg case $host in 102124642e01fSmrg *-*-darwin*) 102134642e01fSmrg # Don't allow lazy linking, it breaks C++ global constructors 102144642e01fSmrg # But is supposedly fixed on 10.4 or later (yay!). 1021535c4bbdfSmrg if test CXX = "$tagname"; then 102164642e01fSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 102174642e01fSmrg 10.[0123]) 1021835c4bbdfSmrg func_append compile_command " $wl-bind_at_load" 1021935c4bbdfSmrg func_append finalize_command " $wl-bind_at_load" 102204642e01fSmrg ;; 102214642e01fSmrg esac 1022205b261ecSmrg fi 102234642e01fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 102246747b715Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102256747b715Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102264642e01fSmrg ;; 102274642e01fSmrg esac 1022805b261ecSmrg 1022905b261ecSmrg 102304642e01fSmrg # move library search paths that coincide with paths to not yet 102314642e01fSmrg # installed libraries to the beginning of the library search list 102324642e01fSmrg new_libs= 102334642e01fSmrg for path in $notinst_path; do 102344642e01fSmrg case " $new_libs " in 102354642e01fSmrg *" -L$path/$objdir "*) ;; 102364642e01fSmrg *) 102374642e01fSmrg case " $compile_deplibs " in 102384642e01fSmrg *" -L$path/$objdir "*) 1023935c4bbdfSmrg func_append new_libs " -L$path/$objdir" ;; 1024005b261ecSmrg esac 102414642e01fSmrg ;; 102424642e01fSmrg esac 102434642e01fSmrg done 102444642e01fSmrg for deplib in $compile_deplibs; do 102454642e01fSmrg case $deplib in 102464642e01fSmrg -L*) 102474642e01fSmrg case " $new_libs " in 102484642e01fSmrg *" $deplib "*) ;; 1024935c4bbdfSmrg *) func_append new_libs " $deplib" ;; 1025005b261ecSmrg esac 102514642e01fSmrg ;; 1025235c4bbdfSmrg *) func_append new_libs " $deplib" ;; 102534642e01fSmrg esac 102544642e01fSmrg done 1025535c4bbdfSmrg compile_deplibs=$new_libs 1025605b261ecSmrg 1025705b261ecSmrg 1025835c4bbdfSmrg func_append compile_command " $compile_deplibs" 1025935c4bbdfSmrg func_append finalize_command " $finalize_deplibs" 1026005b261ecSmrg 102614642e01fSmrg if test -n "$rpath$xrpath"; then 102624642e01fSmrg # If the user specified any rpath flags, then add them. 102634642e01fSmrg for libdir in $rpath $xrpath; do 102644642e01fSmrg # This is the magic to use -rpath. 102654642e01fSmrg case "$finalize_rpath " in 102664642e01fSmrg *" $libdir "*) ;; 1026735c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 102684642e01fSmrg esac 102694642e01fSmrg done 102704642e01fSmrg fi 1027105b261ecSmrg 102724642e01fSmrg # Now hardcode the library paths 102734642e01fSmrg rpath= 102744642e01fSmrg hardcode_libdirs= 102754642e01fSmrg for libdir in $compile_rpath $finalize_rpath; do 102764642e01fSmrg if test -n "$hardcode_libdir_flag_spec"; then 102774642e01fSmrg if test -n "$hardcode_libdir_separator"; then 102784642e01fSmrg if test -z "$hardcode_libdirs"; then 1027935c4bbdfSmrg hardcode_libdirs=$libdir 102804642e01fSmrg else 102814642e01fSmrg # Just accumulate the unique libdirs. 102824642e01fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 102834642e01fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 102844642e01fSmrg ;; 102854642e01fSmrg *) 1028635c4bbdfSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 102874642e01fSmrg ;; 102884642e01fSmrg esac 102894642e01fSmrg fi 1029005b261ecSmrg else 102914642e01fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1029235c4bbdfSmrg func_append rpath " $flag" 1029305b261ecSmrg fi 102944642e01fSmrg elif test -n "$runpath_var"; then 102954642e01fSmrg case "$perm_rpath " in 102964642e01fSmrg *" $libdir "*) ;; 1029735c4bbdfSmrg *) func_append perm_rpath " $libdir" ;; 102984642e01fSmrg esac 102994642e01fSmrg fi 103004642e01fSmrg case $host in 103014642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030235c4bbdfSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 103034642e01fSmrg case :$dllsearchpath: in 103044642e01fSmrg *":$libdir:"*) ;; 103054642e01fSmrg ::) dllsearchpath=$libdir;; 1030635c4bbdfSmrg *) func_append dllsearchpath ":$libdir";; 103074642e01fSmrg esac 103084642e01fSmrg case :$dllsearchpath: in 103094642e01fSmrg *":$testbindir:"*) ;; 103104642e01fSmrg ::) dllsearchpath=$testbindir;; 1031135c4bbdfSmrg *) func_append dllsearchpath ":$testbindir";; 103124642e01fSmrg esac 103134642e01fSmrg ;; 103144642e01fSmrg esac 103154642e01fSmrg done 103164642e01fSmrg # Substitute the hardcoded libdirs into the rpath. 103174642e01fSmrg if test -n "$hardcode_libdir_separator" && 103184642e01fSmrg test -n "$hardcode_libdirs"; then 1031935c4bbdfSmrg libdir=$hardcode_libdirs 103204642e01fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103214642e01fSmrg fi 1032235c4bbdfSmrg compile_rpath=$rpath 1032305b261ecSmrg 103244642e01fSmrg rpath= 103254642e01fSmrg hardcode_libdirs= 103264642e01fSmrg for libdir in $finalize_rpath; do 103274642e01fSmrg if test -n "$hardcode_libdir_flag_spec"; then 103284642e01fSmrg if test -n "$hardcode_libdir_separator"; then 103294642e01fSmrg if test -z "$hardcode_libdirs"; then 1033035c4bbdfSmrg hardcode_libdirs=$libdir 103314642e01fSmrg else 103324642e01fSmrg # Just accumulate the unique libdirs. 103334642e01fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 103344642e01fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 103354642e01fSmrg ;; 103364642e01fSmrg *) 1033735c4bbdfSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 103384642e01fSmrg ;; 103394642e01fSmrg esac 103404642e01fSmrg fi 1034105b261ecSmrg else 103424642e01fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1034335c4bbdfSmrg func_append rpath " $flag" 1034405b261ecSmrg fi 103454642e01fSmrg elif test -n "$runpath_var"; then 103464642e01fSmrg case "$finalize_perm_rpath " in 103474642e01fSmrg *" $libdir "*) ;; 1034835c4bbdfSmrg *) func_append finalize_perm_rpath " $libdir" ;; 103494642e01fSmrg esac 1035005b261ecSmrg fi 103514642e01fSmrg done 103524642e01fSmrg # Substitute the hardcoded libdirs into the rpath. 103534642e01fSmrg if test -n "$hardcode_libdir_separator" && 103544642e01fSmrg test -n "$hardcode_libdirs"; then 1035535c4bbdfSmrg libdir=$hardcode_libdirs 103564642e01fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103574642e01fSmrg fi 1035835c4bbdfSmrg finalize_rpath=$rpath 1035905b261ecSmrg 1036035c4bbdfSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 103614642e01fSmrg # Transform all the library objects into standard objects. 103626747b715Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103636747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103644642e01fSmrg fi 1036505b261ecSmrg 1036635c4bbdfSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1036705b261ecSmrg 103684642e01fSmrg # template prelinking step 103694642e01fSmrg if test -n "$prelink_cmds"; then 103704642e01fSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 103714642e01fSmrg fi 1037205b261ecSmrg 1037335c4bbdfSmrg wrappers_required=: 103744642e01fSmrg case $host in 103756747b715Smrg *cegcc* | *mingw32ce*) 103766747b715Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1037735c4bbdfSmrg wrappers_required=false 103786747b715Smrg ;; 103794642e01fSmrg *cygwin* | *mingw* ) 1038035c4bbdfSmrg test yes = "$build_libtool_libs" || wrappers_required=false 103814642e01fSmrg ;; 103824642e01fSmrg *) 1038335c4bbdfSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1038435c4bbdfSmrg wrappers_required=false 103854642e01fSmrg fi 103864642e01fSmrg ;; 103874642e01fSmrg esac 1038835c4bbdfSmrg $wrappers_required || { 103894642e01fSmrg # Replace the output file specification. 103906747b715Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1039135c4bbdfSmrg link_command=$compile_command$compile_rpath 1039205b261ecSmrg 103934642e01fSmrg # We have no uninstalled library dependencies, so finalize right now. 103944642e01fSmrg exit_status=0 103954642e01fSmrg func_show_eval "$link_command" 'exit_status=$?' 1039605b261ecSmrg 1039735c4bbdfSmrg if test -n "$postlink_cmds"; then 1039835c4bbdfSmrg func_to_tool_file "$output" 1039935c4bbdfSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1040035c4bbdfSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 1040135c4bbdfSmrg fi 1040235c4bbdfSmrg 104034642e01fSmrg # Delete the generated files. 1040435c4bbdfSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1040535c4bbdfSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1040605b261ecSmrg fi 1040705b261ecSmrg 104084642e01fSmrg exit $exit_status 1040935c4bbdfSmrg } 1041005b261ecSmrg 104114642e01fSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 104124642e01fSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 104134642e01fSmrg fi 104144642e01fSmrg if test -n "$finalize_shlibpath"; then 104154642e01fSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 104164642e01fSmrg fi 1041705b261ecSmrg 104184642e01fSmrg compile_var= 104194642e01fSmrg finalize_var= 104204642e01fSmrg if test -n "$runpath_var"; then 104214642e01fSmrg if test -n "$perm_rpath"; then 104224642e01fSmrg # We should set the runpath_var. 104234642e01fSmrg rpath= 104244642e01fSmrg for dir in $perm_rpath; do 1042535c4bbdfSmrg func_append rpath "$dir:" 104264642e01fSmrg done 104274642e01fSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1042805b261ecSmrg fi 104294642e01fSmrg if test -n "$finalize_perm_rpath"; then 104304642e01fSmrg # We should set the runpath_var. 104314642e01fSmrg rpath= 104324642e01fSmrg for dir in $finalize_perm_rpath; do 1043335c4bbdfSmrg func_append rpath "$dir:" 104344642e01fSmrg done 104354642e01fSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043605b261ecSmrg fi 104374642e01fSmrg fi 1043805b261ecSmrg 1043935c4bbdfSmrg if test yes = "$no_install"; then 104404642e01fSmrg # We don't need to create a wrapper script. 1044135c4bbdfSmrg link_command=$compile_var$compile_command$compile_rpath 104424642e01fSmrg # Replace the output file specification. 104436747b715Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104444642e01fSmrg # Delete the old output file. 104454642e01fSmrg $opt_dry_run || $RM $output 104464642e01fSmrg # Link the executable and exit 104474642e01fSmrg func_show_eval "$link_command" 'exit $?' 1044835c4bbdfSmrg 1044935c4bbdfSmrg if test -n "$postlink_cmds"; then 1045035c4bbdfSmrg func_to_tool_file "$output" 1045135c4bbdfSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045235c4bbdfSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 1045335c4bbdfSmrg fi 1045435c4bbdfSmrg 1045505b261ecSmrg exit $EXIT_SUCCESS 104564642e01fSmrg fi 1045705b261ecSmrg 1045835c4bbdfSmrg case $hardcode_action,$fast_install in 1045935c4bbdfSmrg relink,*) 1046035c4bbdfSmrg # Fast installation is not supported 1046135c4bbdfSmrg link_command=$compile_var$compile_command$compile_rpath 1046235c4bbdfSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 104634642e01fSmrg 1046435c4bbdfSmrg func_warning "this platform does not like uninstalled shared libraries" 1046535c4bbdfSmrg func_warning "'$output' will be relinked during installation" 1046635c4bbdfSmrg ;; 1046735c4bbdfSmrg *,yes) 1046835c4bbdfSmrg link_command=$finalize_var$compile_command$finalize_rpath 1046935c4bbdfSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1047035c4bbdfSmrg ;; 1047135c4bbdfSmrg *,no) 1047235c4bbdfSmrg link_command=$compile_var$compile_command$compile_rpath 1047335c4bbdfSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1047435c4bbdfSmrg ;; 1047535c4bbdfSmrg *,needless) 1047635c4bbdfSmrg link_command=$finalize_var$compile_command$finalize_rpath 1047735c4bbdfSmrg relink_command= 1047835c4bbdfSmrg ;; 1047935c4bbdfSmrg esac 1048005b261ecSmrg 104814642e01fSmrg # Replace the output file specification. 104826747b715Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1048305b261ecSmrg 104844642e01fSmrg # Delete the old output files. 104854642e01fSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1048605b261ecSmrg 104874642e01fSmrg func_show_eval "$link_command" 'exit $?' 1048805b261ecSmrg 1048935c4bbdfSmrg if test -n "$postlink_cmds"; then 1049035c4bbdfSmrg func_to_tool_file "$output_objdir/$outputname" 1049135c4bbdfSmrg 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'` 1049235c4bbdfSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 1049335c4bbdfSmrg fi 1049435c4bbdfSmrg 104954642e01fSmrg # Now create the wrapper script. 104964642e01fSmrg func_verbose "creating $output" 1049705b261ecSmrg 104984642e01fSmrg # Quote the relink command for shipping. 104994642e01fSmrg if test -n "$relink_command"; then 105004642e01fSmrg # Preserve any variables that may affect compiler behavior 105014642e01fSmrg for var in $variables_saved_for_relink; do 105024642e01fSmrg if eval test -z \"\${$var+set}\"; then 105034642e01fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 105044642e01fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 105054642e01fSmrg relink_command="$var=; export $var; $relink_command" 1050605b261ecSmrg else 105074642e01fSmrg func_quote_for_eval "$var_value" 105084642e01fSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1050905b261ecSmrg fi 105104642e01fSmrg done 105114642e01fSmrg relink_command="(cd `pwd`; $relink_command)" 105126747b715Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 105134642e01fSmrg fi 105144642e01fSmrg 105154642e01fSmrg # Only actually do things if not in dry run mode. 105164642e01fSmrg $opt_dry_run || { 105174642e01fSmrg # win32 will think the script is a binary if it has 105184642e01fSmrg # a .exe suffix, so we strip it off here. 105194642e01fSmrg case $output in 105204642e01fSmrg *.exe) func_stripname '' '.exe' "$output" 105214642e01fSmrg output=$func_stripname_result ;; 105224642e01fSmrg esac 105234642e01fSmrg # test for cygwin because mv fails w/o .exe extensions 105244642e01fSmrg case $host in 105254642e01fSmrg *cygwin*) 105264642e01fSmrg exeext=.exe 105274642e01fSmrg func_stripname '' '.exe' "$outputname" 105284642e01fSmrg outputname=$func_stripname_result ;; 105294642e01fSmrg *) exeext= ;; 1053005b261ecSmrg esac 105314642e01fSmrg case $host in 105324642e01fSmrg *cygwin* | *mingw* ) 105334642e01fSmrg func_dirname_and_basename "$output" "" "." 105344642e01fSmrg output_name=$func_basename_result 105354642e01fSmrg output_path=$func_dirname_result 1053635c4bbdfSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1053735c4bbdfSmrg cwrapper=$output_path/$output_name.exe 105384642e01fSmrg $RM $cwrappersource $cwrapper 105394642e01fSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 105404642e01fSmrg 105414642e01fSmrg func_emit_cwrapperexe_src > $cwrappersource 105424642e01fSmrg 105434642e01fSmrg # The wrapper executable is built using the $host compiler, 105444642e01fSmrg # because it contains $host paths and files. If cross- 105454642e01fSmrg # compiling, it, like the target executable, must be 105464642e01fSmrg # executed on the $host or under an emulation environment. 105474642e01fSmrg $opt_dry_run || { 105484642e01fSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 105494642e01fSmrg $STRIP $cwrapper 105504642e01fSmrg } 1055105b261ecSmrg 105524642e01fSmrg # Now, create the wrapper script for func_source use: 105534642e01fSmrg func_ltwrapper_scriptname $cwrapper 105544642e01fSmrg $RM $func_ltwrapper_scriptname_result 105554642e01fSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 105564642e01fSmrg $opt_dry_run || { 105574642e01fSmrg # note: this script will not be executed, so do not chmod. 1055835c4bbdfSmrg if test "x$build" = "x$host"; then 105594642e01fSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105604642e01fSmrg else 105614642e01fSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105624642e01fSmrg fi 105634642e01fSmrg } 105644642e01fSmrg ;; 105654642e01fSmrg * ) 105664642e01fSmrg $RM $output 105674642e01fSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1056805b261ecSmrg 105694642e01fSmrg func_emit_wrapper no > $output 105704642e01fSmrg chmod +x $output 105714642e01fSmrg ;; 105724642e01fSmrg esac 105734642e01fSmrg } 105744642e01fSmrg exit $EXIT_SUCCESS 105754642e01fSmrg ;; 105764642e01fSmrg esac 1057705b261ecSmrg 105784642e01fSmrg # See if we need to build an old-fashioned archive. 105794642e01fSmrg for oldlib in $oldlibs; do 1058005b261ecSmrg 1058135c4bbdfSmrg case $build_libtool_libs in 1058235c4bbdfSmrg convenience) 1058335c4bbdfSmrg oldobjs="$libobjs_save $symfileobj" 1058435c4bbdfSmrg addlibs=$convenience 105854642e01fSmrg build_libtool_libs=no 1058635c4bbdfSmrg ;; 1058735c4bbdfSmrg module) 1058835c4bbdfSmrg oldobjs=$libobjs_save 1058935c4bbdfSmrg addlibs=$old_convenience 1059035c4bbdfSmrg build_libtool_libs=no 1059135c4bbdfSmrg ;; 1059235c4bbdfSmrg *) 105934642e01fSmrg oldobjs="$old_deplibs $non_pic_objects" 1059435c4bbdfSmrg $preload && test -f "$symfileobj" \ 1059535c4bbdfSmrg && func_append oldobjs " $symfileobj" 1059635c4bbdfSmrg addlibs=$old_convenience 1059735c4bbdfSmrg ;; 1059835c4bbdfSmrg esac 1059905b261ecSmrg 106004642e01fSmrg if test -n "$addlibs"; then 1060135c4bbdfSmrg gentop=$output_objdir/${outputname}x 1060235c4bbdfSmrg func_append generated " $gentop" 1060305b261ecSmrg 106044642e01fSmrg func_extract_archives $gentop $addlibs 1060535c4bbdfSmrg func_append oldobjs " $func_extract_archives_result" 106064642e01fSmrg fi 1060705b261ecSmrg 106084642e01fSmrg # Do each command in the archive commands. 1060935c4bbdfSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 106104642e01fSmrg cmds=$old_archive_from_new_cmds 106114642e01fSmrg else 1061205b261ecSmrg 106134642e01fSmrg # Add any objects from preloaded convenience libraries 106144642e01fSmrg if test -n "$dlprefiles"; then 1061535c4bbdfSmrg gentop=$output_objdir/${outputname}x 1061635c4bbdfSmrg func_append generated " $gentop" 1061705b261ecSmrg 106184642e01fSmrg func_extract_archives $gentop $dlprefiles 1061935c4bbdfSmrg func_append oldobjs " $func_extract_archives_result" 106204642e01fSmrg fi 1062105b261ecSmrg 106224642e01fSmrg # POSIX demands no paths to be encoded in archives. We have 106234642e01fSmrg # to avoid creating archives with duplicate basenames if we 106244642e01fSmrg # might have to extract them afterwards, e.g., when creating a 106254642e01fSmrg # static archive out of a convenience library, or when linking 106264642e01fSmrg # the entirety of a libtool archive into another (currently 106274642e01fSmrg # not supported by libtool). 106284642e01fSmrg if (for obj in $oldobjs 106294642e01fSmrg do 106304642e01fSmrg func_basename "$obj" 106314642e01fSmrg $ECHO "$func_basename_result" 106324642e01fSmrg done | sort | sort -uc >/dev/null 2>&1); then 106334642e01fSmrg : 106344642e01fSmrg else 106356747b715Smrg echo "copying selected object files to avoid basename conflicts..." 1063635c4bbdfSmrg gentop=$output_objdir/${outputname}x 1063735c4bbdfSmrg func_append generated " $gentop" 106384642e01fSmrg func_mkdir_p "$gentop" 106394642e01fSmrg save_oldobjs=$oldobjs 106404642e01fSmrg oldobjs= 106414642e01fSmrg counter=1 106424642e01fSmrg for obj in $save_oldobjs 106434642e01fSmrg do 106444642e01fSmrg func_basename "$obj" 1064535c4bbdfSmrg objbase=$func_basename_result 106464642e01fSmrg case " $oldobjs " in 106474642e01fSmrg " ") oldobjs=$obj ;; 106484642e01fSmrg *[\ /]"$objbase "*) 106494642e01fSmrg while :; do 106504642e01fSmrg # Make sure we don't pick an alternate name that also 106514642e01fSmrg # overlaps. 106524642e01fSmrg newobj=lt$counter-$objbase 106534642e01fSmrg func_arith $counter + 1 106544642e01fSmrg counter=$func_arith_result 106554642e01fSmrg case " $oldobjs " in 106564642e01fSmrg *[\ /]"$newobj "*) ;; 106574642e01fSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 106584642e01fSmrg esac 106594642e01fSmrg done 106604642e01fSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1066135c4bbdfSmrg func_append oldobjs " $gentop/$newobj" 106624642e01fSmrg ;; 1066335c4bbdfSmrg *) func_append oldobjs " $obj" ;; 106644642e01fSmrg esac 1066505b261ecSmrg done 1066605b261ecSmrg fi 1066735c4bbdfSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1066835c4bbdfSmrg tool_oldlib=$func_to_tool_file_result 106694642e01fSmrg eval cmds=\"$old_archive_cmds\" 1067005b261ecSmrg 106714642e01fSmrg func_len " $cmds" 106724642e01fSmrg len=$func_len_result 106734642e01fSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 106744642e01fSmrg cmds=$old_archive_cmds 1067535c4bbdfSmrg elif test -n "$archiver_list_spec"; then 1067635c4bbdfSmrg func_verbose "using command file archive linking..." 1067735c4bbdfSmrg for obj in $oldobjs 1067835c4bbdfSmrg do 1067935c4bbdfSmrg func_to_tool_file "$obj" 1068035c4bbdfSmrg $ECHO "$func_to_tool_file_result" 1068135c4bbdfSmrg done > $output_objdir/$libname.libcmd 1068235c4bbdfSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 1068335c4bbdfSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1068435c4bbdfSmrg cmds=$old_archive_cmds 106854642e01fSmrg else 106864642e01fSmrg # the command line is too long to link in one step, link in parts 106874642e01fSmrg func_verbose "using piecewise archive linking..." 106884642e01fSmrg save_RANLIB=$RANLIB 106894642e01fSmrg RANLIB=: 106904642e01fSmrg objlist= 106914642e01fSmrg concat_cmds= 106924642e01fSmrg save_oldobjs=$oldobjs 106934642e01fSmrg oldobjs= 106944642e01fSmrg # Is there a better way of finding the last object in the list? 106954642e01fSmrg for obj in $save_oldobjs 106964642e01fSmrg do 106974642e01fSmrg last_oldobj=$obj 106984642e01fSmrg done 106994642e01fSmrg eval test_cmds=\"$old_archive_cmds\" 107004642e01fSmrg func_len " $test_cmds" 107014642e01fSmrg len0=$func_len_result 107024642e01fSmrg len=$len0 107034642e01fSmrg for obj in $save_oldobjs 107044642e01fSmrg do 107054642e01fSmrg func_len " $obj" 107064642e01fSmrg func_arith $len + $func_len_result 107074642e01fSmrg len=$func_arith_result 107084642e01fSmrg func_append objlist " $obj" 107094642e01fSmrg if test "$len" -lt "$max_cmd_len"; then 107104642e01fSmrg : 107114642e01fSmrg else 107124642e01fSmrg # the above command should be used before it gets too long 107134642e01fSmrg oldobjs=$objlist 1071435c4bbdfSmrg if test "$obj" = "$last_oldobj"; then 107154642e01fSmrg RANLIB=$save_RANLIB 107164642e01fSmrg fi 107174642e01fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1071835c4bbdfSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 107194642e01fSmrg objlist= 107204642e01fSmrg len=$len0 107214642e01fSmrg fi 107224642e01fSmrg done 107234642e01fSmrg RANLIB=$save_RANLIB 107244642e01fSmrg oldobjs=$objlist 1072535c4bbdfSmrg if test -z "$oldobjs"; then 107264642e01fSmrg eval cmds=\"\$concat_cmds\" 107274642e01fSmrg else 107284642e01fSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 107294642e01fSmrg fi 107304642e01fSmrg fi 107314642e01fSmrg fi 107324642e01fSmrg func_execute_cmds "$cmds" 'exit $?' 1073305b261ecSmrg done 1073405b261ecSmrg 107354642e01fSmrg test -n "$generated" && \ 107364642e01fSmrg func_show_eval "${RM}r$generated" 1073705b261ecSmrg 107384642e01fSmrg # Now create the libtool archive. 107394642e01fSmrg case $output in 107404642e01fSmrg *.la) 107414642e01fSmrg old_library= 1074235c4bbdfSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 107434642e01fSmrg func_verbose "creating $output" 1074405b261ecSmrg 107454642e01fSmrg # Preserve any variables that may affect compiler behavior 107464642e01fSmrg for var in $variables_saved_for_relink; do 107474642e01fSmrg if eval test -z \"\${$var+set}\"; then 107484642e01fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107494642e01fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 107504642e01fSmrg relink_command="$var=; export $var; $relink_command" 1075105b261ecSmrg else 107524642e01fSmrg func_quote_for_eval "$var_value" 107534642e01fSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1075405b261ecSmrg fi 107554642e01fSmrg done 107564642e01fSmrg # Quote the link command for shipping. 1075735c4bbdfSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 107586747b715Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1075935c4bbdfSmrg if test yes = "$hardcode_automatic"; then 107604642e01fSmrg relink_command= 107614642e01fSmrg fi 1076205b261ecSmrg 107634642e01fSmrg # Only create the output if not a dry run. 107644642e01fSmrg $opt_dry_run || { 107654642e01fSmrg for installed in no yes; do 1076635c4bbdfSmrg if test yes = "$installed"; then 107674642e01fSmrg if test -z "$install_libdir"; then 107684642e01fSmrg break 107694642e01fSmrg fi 1077035c4bbdfSmrg output=$output_objdir/${outputname}i 107714642e01fSmrg # Replace all uninstalled libtool libraries with the installed ones 107724642e01fSmrg newdependency_libs= 107734642e01fSmrg for deplib in $dependency_libs; do 107744642e01fSmrg case $deplib in 107754642e01fSmrg *.la) 107764642e01fSmrg func_basename "$deplib" 1077735c4bbdfSmrg name=$func_basename_result 1077835c4bbdfSmrg func_resolve_sysroot "$deplib" 1077935c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 107804642e01fSmrg test -z "$libdir" && \ 1078135c4bbdfSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078235c4bbdfSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1078335c4bbdfSmrg ;; 1078435c4bbdfSmrg -L*) 1078535c4bbdfSmrg func_stripname -L '' "$deplib" 1078635c4bbdfSmrg func_replace_sysroot "$func_stripname_result" 1078735c4bbdfSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 107886747b715Smrg ;; 1078935c4bbdfSmrg -R*) 1079035c4bbdfSmrg func_stripname -R '' "$deplib" 1079135c4bbdfSmrg func_replace_sysroot "$func_stripname_result" 1079235c4bbdfSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1079335c4bbdfSmrg ;; 1079435c4bbdfSmrg *) func_append newdependency_libs " $deplib" ;; 107954642e01fSmrg esac 107964642e01fSmrg done 1079735c4bbdfSmrg dependency_libs=$newdependency_libs 107984642e01fSmrg newdlfiles= 107994642e01fSmrg 108004642e01fSmrg for lib in $dlfiles; do 108014642e01fSmrg case $lib in 108024642e01fSmrg *.la) 108034642e01fSmrg func_basename "$lib" 1080435c4bbdfSmrg name=$func_basename_result 1080535c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108064642e01fSmrg test -z "$libdir" && \ 1080735c4bbdfSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1080835c4bbdfSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 108094642e01fSmrg ;; 1081035c4bbdfSmrg *) func_append newdlfiles " $lib" ;; 108114642e01fSmrg esac 108124642e01fSmrg done 1081335c4bbdfSmrg dlfiles=$newdlfiles 108144642e01fSmrg newdlprefiles= 108154642e01fSmrg for lib in $dlprefiles; do 108164642e01fSmrg case $lib in 108174642e01fSmrg *.la) 108184642e01fSmrg # Only pass preopened files to the pseudo-archive (for 108194642e01fSmrg # eventual linking with the app. that links it) if we 108204642e01fSmrg # didn't already link the preopened objects directly into 108214642e01fSmrg # the library: 108224642e01fSmrg func_basename "$lib" 1082335c4bbdfSmrg name=$func_basename_result 1082435c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108254642e01fSmrg test -z "$libdir" && \ 1082635c4bbdfSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1082735c4bbdfSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 108284642e01fSmrg ;; 108294642e01fSmrg esac 108304642e01fSmrg done 1083135c4bbdfSmrg dlprefiles=$newdlprefiles 108324642e01fSmrg else 108334642e01fSmrg newdlfiles= 108344642e01fSmrg for lib in $dlfiles; do 108354642e01fSmrg case $lib in 1083635c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108374642e01fSmrg *) abs=`pwd`"/$lib" ;; 108384642e01fSmrg esac 1083935c4bbdfSmrg func_append newdlfiles " $abs" 108404642e01fSmrg done 1084135c4bbdfSmrg dlfiles=$newdlfiles 108424642e01fSmrg newdlprefiles= 108434642e01fSmrg for lib in $dlprefiles; do 108444642e01fSmrg case $lib in 1084535c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108464642e01fSmrg *) abs=`pwd`"/$lib" ;; 108474642e01fSmrg esac 1084835c4bbdfSmrg func_append newdlprefiles " $abs" 108494642e01fSmrg done 1085035c4bbdfSmrg dlprefiles=$newdlprefiles 108514642e01fSmrg fi 108524642e01fSmrg $RM $output 108534642e01fSmrg # place dlname in correct position for cygwin 108546747b715Smrg # In fact, it would be nice if we could use this code for all target 108556747b715Smrg # systems that can't hard-code library paths into their executables 108566747b715Smrg # and that have no shared library path variable independent of PATH, 108576747b715Smrg # but it turns out we can't easily determine that from inspecting 108586747b715Smrg # libtool variables, so we have to hard-code the OSs to which it 108596747b715Smrg # applies here; at the moment, that means platforms that use the PE 108606747b715Smrg # object format with DLL files. See the long comment at the top of 108616747b715Smrg # tests/bindir.at for full details. 108624642e01fSmrg tdlname=$dlname 108634642e01fSmrg case $host,$output,$installed,$module,$dlname in 108646747b715Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 108656747b715Smrg # If a -bindir argument was supplied, place the dll there. 1086635c4bbdfSmrg if test -n "$bindir"; then 108676747b715Smrg func_relative_path "$install_libdir" "$bindir" 1086835c4bbdfSmrg tdlname=$func_relative_path_result/$dlname 108696747b715Smrg else 108706747b715Smrg # Otherwise fall back on heuristic. 108716747b715Smrg tdlname=../bin/$dlname 108726747b715Smrg fi 108736747b715Smrg ;; 108744642e01fSmrg esac 108754642e01fSmrg $ECHO > $output "\ 108764642e01fSmrg# $outputname - a libtool library file 1087735c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 108784642e01fSmrg# 108794642e01fSmrg# Please DO NOT delete this file! 108804642e01fSmrg# It is necessary for linking the library. 1088105b261ecSmrg 108824642e01fSmrg# The name that we can dlopen(3). 108834642e01fSmrgdlname='$tdlname' 1088405b261ecSmrg 108854642e01fSmrg# Names of this library. 108864642e01fSmrglibrary_names='$library_names' 1088705b261ecSmrg 108884642e01fSmrg# The name of the static archive. 108894642e01fSmrgold_library='$old_library' 1089005b261ecSmrg 1089135c4bbdfSmrg# Linker flags that cannot go in dependency_libs. 108924642e01fSmrginherited_linker_flags='$new_inherited_linker_flags' 1089305b261ecSmrg 108944642e01fSmrg# Libraries that this one depends upon. 108954642e01fSmrgdependency_libs='$dependency_libs' 1089605b261ecSmrg 108974642e01fSmrg# Names of additional weak libraries provided by this library 108984642e01fSmrgweak_library_names='$weak_libs' 1089905b261ecSmrg 109004642e01fSmrg# Version information for $libname. 109014642e01fSmrgcurrent=$current 109024642e01fSmrgage=$age 109034642e01fSmrgrevision=$revision 1090405b261ecSmrg 109054642e01fSmrg# Is this an already installed library? 109064642e01fSmrginstalled=$installed 1090705b261ecSmrg 109084642e01fSmrg# Should we warn about portability when linking against -modules? 109094642e01fSmrgshouldnotlink=$module 1091005b261ecSmrg 109114642e01fSmrg# Files to dlopen/dlpreopen 109124642e01fSmrgdlopen='$dlfiles' 109134642e01fSmrgdlpreopen='$dlprefiles' 1091405b261ecSmrg 109154642e01fSmrg# Directory that this library needs to be installed in: 109164642e01fSmrglibdir='$install_libdir'" 1091735c4bbdfSmrg if test no,yes = "$installed,$need_relink"; then 109184642e01fSmrg $ECHO >> $output "\ 109194642e01fSmrgrelink_command=\"$relink_command\"" 109204642e01fSmrg fi 109214642e01fSmrg done 109224642e01fSmrg } 1092305b261ecSmrg 109244642e01fSmrg # Do a symbolic link so that the libtool archive can be found in 109254642e01fSmrg # LD_LIBRARY_PATH before the program is installed. 109264642e01fSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 109274642e01fSmrg ;; 109284642e01fSmrg esac 109294642e01fSmrg exit $EXIT_SUCCESS 109304642e01fSmrg} 1093105b261ecSmrg 1093235c4bbdfSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1093335c4bbdfSmrg func_mode_link ${1+"$@"} 1093435c4bbdfSmrgfi 1093505b261ecSmrg 1093605b261ecSmrg 109374642e01fSmrg# func_mode_uninstall arg... 109384642e01fSmrgfunc_mode_uninstall () 109394642e01fSmrg{ 1094035c4bbdfSmrg $debug_cmd 1094135c4bbdfSmrg 1094235c4bbdfSmrg RM=$nonopt 1094305b261ecSmrg files= 1094435c4bbdfSmrg rmforce=false 1094505b261ecSmrg exit_status=0 1094605b261ecSmrg 1094705b261ecSmrg # This variable tells wrapper scripts just to set variables rather 1094805b261ecSmrg # than running their programs. 1094935c4bbdfSmrg libtool_install_magic=$magic 1095005b261ecSmrg 1095105b261ecSmrg for arg 1095205b261ecSmrg do 1095305b261ecSmrg case $arg in 1095435c4bbdfSmrg -f) func_append RM " $arg"; rmforce=: ;; 1095535c4bbdfSmrg -*) func_append RM " $arg" ;; 1095635c4bbdfSmrg *) func_append files " $arg" ;; 1095705b261ecSmrg esac 1095805b261ecSmrg done 1095905b261ecSmrg 109604642e01fSmrg test -z "$RM" && \ 109614642e01fSmrg func_fatal_help "you must specify an RM program" 1096205b261ecSmrg 1096305b261ecSmrg rmdirs= 1096405b261ecSmrg 1096505b261ecSmrg for file in $files; do 109664642e01fSmrg func_dirname "$file" "" "." 1096735c4bbdfSmrg dir=$func_dirname_result 1096835c4bbdfSmrg if test . = "$dir"; then 1096935c4bbdfSmrg odir=$objdir 1097005b261ecSmrg else 1097135c4bbdfSmrg odir=$dir/$objdir 1097205b261ecSmrg fi 109734642e01fSmrg func_basename "$file" 1097435c4bbdfSmrg name=$func_basename_result 1097535c4bbdfSmrg test uninstall = "$opt_mode" && odir=$dir 1097605b261ecSmrg 1097735c4bbdfSmrg # Remember odir for removal later, being careful to avoid duplicates 1097835c4bbdfSmrg if test clean = "$opt_mode"; then 1097905b261ecSmrg case " $rmdirs " in 1098035c4bbdfSmrg *" $odir "*) ;; 1098135c4bbdfSmrg *) func_append rmdirs " $odir" ;; 1098205b261ecSmrg esac 1098305b261ecSmrg fi 1098405b261ecSmrg 1098505b261ecSmrg # Don't error if the file doesn't exist and rm -f was used. 109864642e01fSmrg if { test -L "$file"; } >/dev/null 2>&1 || 109874642e01fSmrg { test -h "$file"; } >/dev/null 2>&1 || 109884642e01fSmrg test -f "$file"; then 1098905b261ecSmrg : 1099005b261ecSmrg elif test -d "$file"; then 1099105b261ecSmrg exit_status=1 1099205b261ecSmrg continue 1099335c4bbdfSmrg elif $rmforce; then 1099405b261ecSmrg continue 1099505b261ecSmrg fi 1099605b261ecSmrg 1099735c4bbdfSmrg rmfiles=$file 1099805b261ecSmrg 1099905b261ecSmrg case $name in 1100005b261ecSmrg *.la) 1100105b261ecSmrg # Possibly a libtool archive, so verify it. 110024642e01fSmrg if func_lalib_p "$file"; then 110034642e01fSmrg func_source $dir/$name 1100405b261ecSmrg 1100505b261ecSmrg # Delete the libtool libraries and symlinks. 1100605b261ecSmrg for n in $library_names; do 1100735c4bbdfSmrg func_append rmfiles " $odir/$n" 1100805b261ecSmrg done 1100935c4bbdfSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1101005b261ecSmrg 1101135c4bbdfSmrg case $opt_mode in 1101205b261ecSmrg clean) 1101335c4bbdfSmrg case " $library_names " in 1101405b261ecSmrg *" $dlname "*) ;; 1101535c4bbdfSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1101605b261ecSmrg esac 1101735c4bbdfSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1101805b261ecSmrg ;; 1101905b261ecSmrg uninstall) 1102005b261ecSmrg if test -n "$library_names"; then 1102105b261ecSmrg # Do each command in the postuninstall commands. 1102235c4bbdfSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1102305b261ecSmrg fi 1102405b261ecSmrg 1102505b261ecSmrg if test -n "$old_library"; then 1102605b261ecSmrg # Do each command in the old_postuninstall commands. 1102735c4bbdfSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1102805b261ecSmrg fi 1102905b261ecSmrg # FIXME: should reinstall the best remaining shared library. 1103005b261ecSmrg ;; 1103105b261ecSmrg esac 1103205b261ecSmrg fi 1103305b261ecSmrg ;; 1103405b261ecSmrg 1103505b261ecSmrg *.lo) 1103605b261ecSmrg # Possibly a libtool object, so verify it. 110374642e01fSmrg if func_lalib_p "$file"; then 1103805b261ecSmrg 1103905b261ecSmrg # Read the .lo file 110404642e01fSmrg func_source $dir/$name 1104105b261ecSmrg 1104205b261ecSmrg # Add PIC object to the list of files to remove. 1104335c4bbdfSmrg if test -n "$pic_object" && test none != "$pic_object"; then 1104435c4bbdfSmrg func_append rmfiles " $dir/$pic_object" 1104505b261ecSmrg fi 1104605b261ecSmrg 1104705b261ecSmrg # Add non-PIC object to the list of files to remove. 1104835c4bbdfSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1104935c4bbdfSmrg func_append rmfiles " $dir/$non_pic_object" 1105005b261ecSmrg fi 1105105b261ecSmrg fi 1105205b261ecSmrg ;; 1105305b261ecSmrg 1105405b261ecSmrg *) 1105535c4bbdfSmrg if test clean = "$opt_mode"; then 1105605b261ecSmrg noexename=$name 1105705b261ecSmrg case $file in 1105805b261ecSmrg *.exe) 110594642e01fSmrg func_stripname '' '.exe' "$file" 110604642e01fSmrg file=$func_stripname_result 110614642e01fSmrg func_stripname '' '.exe' "$name" 110624642e01fSmrg noexename=$func_stripname_result 1106305b261ecSmrg # $file with .exe has already been added to rmfiles, 1106405b261ecSmrg # add $file without .exe 1106535c4bbdfSmrg func_append rmfiles " $file" 1106605b261ecSmrg ;; 1106705b261ecSmrg esac 1106805b261ecSmrg # Do a test to see if this is a libtool program. 110694642e01fSmrg if func_ltwrapper_p "$file"; then 110704642e01fSmrg if func_ltwrapper_executable_p "$file"; then 110714642e01fSmrg func_ltwrapper_scriptname "$file" 110724642e01fSmrg relink_command= 110734642e01fSmrg func_source $func_ltwrapper_scriptname_result 1107435c4bbdfSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 110754642e01fSmrg else 110764642e01fSmrg relink_command= 110774642e01fSmrg func_source $dir/$noexename 110784642e01fSmrg fi 1107905b261ecSmrg 1108005b261ecSmrg # note $name still contains .exe if it was in $file originally 1108105b261ecSmrg # as does the version of $file that was added into $rmfiles 1108235c4bbdfSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1108335c4bbdfSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 1108435c4bbdfSmrg func_append rmfiles " $odir/lt-$name" 1108505b261ecSmrg fi 1108635c4bbdfSmrg if test "X$noexename" != "X$name"; then 1108735c4bbdfSmrg func_append rmfiles " $odir/lt-$noexename.c" 1108805b261ecSmrg fi 1108905b261ecSmrg fi 1109005b261ecSmrg fi 1109105b261ecSmrg ;; 1109205b261ecSmrg esac 110934642e01fSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1109405b261ecSmrg done 1109505b261ecSmrg 1109635c4bbdfSmrg # Try to remove the $objdir's in the directories where we deleted files 1109705b261ecSmrg for dir in $rmdirs; do 1109805b261ecSmrg if test -d "$dir"; then 110994642e01fSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1110005b261ecSmrg fi 1110105b261ecSmrg done 1110205b261ecSmrg 1110305b261ecSmrg exit $exit_status 111044642e01fSmrg} 1110505b261ecSmrg 1110635c4bbdfSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1110735c4bbdfSmrg func_mode_uninstall ${1+"$@"} 1110835c4bbdfSmrgfi 1110905b261ecSmrg 1111035c4bbdfSmrgtest -z "$opt_mode" && { 1111135c4bbdfSmrg help=$generic_help 111124642e01fSmrg func_fatal_help "you must specify a MODE" 111134642e01fSmrg} 111144642e01fSmrg 111154642e01fSmrgtest -z "$exec_cmd" && \ 1111635c4bbdfSmrg func_fatal_help "invalid operation mode '$opt_mode'" 1111705b261ecSmrg 1111805b261ecSmrgif test -n "$exec_cmd"; then 111194642e01fSmrg eval exec "$exec_cmd" 1112005b261ecSmrg exit $EXIT_FAILURE 1112105b261ecSmrgfi 1112205b261ecSmrg 111234642e01fSmrgexit $exit_status 1112405b261ecSmrg 1112505b261ecSmrg 1112605b261ecSmrg# The TAGs below are defined such that we never get into a situation 1112735c4bbdfSmrg# where we disable both kinds of libraries. Given conflicting 1112805b261ecSmrg# choices, we go for a static library, that is the most portable, 1112905b261ecSmrg# since we can't tell whether shared libraries were disabled because 1113005b261ecSmrg# the user asked for that or because the platform doesn't support 1113105b261ecSmrg# them. This is particularly important on AIX, because we don't 1113205b261ecSmrg# support having both static and shared libraries enabled at the same 1113305b261ecSmrg# time on that platform, so we default to a shared-only configuration. 1113405b261ecSmrg# If a disable-shared tag is given, we'll fallback to a static-only 1113505b261ecSmrg# configuration. But we'll never go from static-only to shared-only. 1113605b261ecSmrg 1113705b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 111384642e01fSmrgbuild_libtool_libs=no 111394642e01fSmrgbuild_old_libs=yes 1114005b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 1114105b261ecSmrg 1114205b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 111434642e01fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1114405b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-static 1114505b261ecSmrg 1114605b261ecSmrg# Local Variables: 1114705b261ecSmrg# mode:shell-script 1114805b261ecSmrg# sh-indentation:2 1114905b261ecSmrg# End: 11150