16b526288Smrg#! /bin/sh 26b526288Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 36b526288Smrg## by inline-source v2014-01-03.01 411a29bacSmrg 56b526288Smrg# libtool (GNU libtool) 2.4.6 66b526288Smrg# Provide generalized library-building support services. 711a29bacSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 811a29bacSmrg 96b526288Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 1011a29bacSmrg# This is free software; see the source for copying conditions. There is NO 1111a29bacSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1211a29bacSmrg 1311a29bacSmrg# GNU Libtool is free software; you can redistribute it and/or modify 1441b2f0bdSmrg# it under the terms of the GNU General Public License as published by 1541b2f0bdSmrg# the Free Software Foundation; either version 2 of the License, or 1641b2f0bdSmrg# (at your option) any later version. 1741b2f0bdSmrg# 1811a29bacSmrg# As a special exception to the GNU General Public License, 1911a29bacSmrg# if you distribute this file as part of a program or library that 2011a29bacSmrg# is built using GNU Libtool, you may include this file under the 2111a29bacSmrg# same distribution terms that you use for the rest of that program. 2211a29bacSmrg# 2311a29bacSmrg# GNU Libtool is distributed in the hope that it will be useful, but 2441b2f0bdSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2541b2f0bdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2641b2f0bdSmrg# General Public License for more details. 2741b2f0bdSmrg# 2841b2f0bdSmrg# You should have received a copy of the GNU General Public License 296b526288Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3041b2f0bdSmrg 3141b2f0bdSmrg 3211a29bacSmrgPROGRAM=libtool 3341b2f0bdSmrgPACKAGE=libtool 346b526288SmrgVERSION=2.4.6 356b526288Smrgpackage_revision=2.4.6 3611245024Smrg 376b526288Smrg 386b526288Smrg## ------ ## 396b526288Smrg## Usage. ## 406b526288Smrg## ------ ## 416b526288Smrg 426b526288Smrg# Run './libtool --help' for help with using this script from the 436b526288Smrg# command line. 446b526288Smrg 456b526288Smrg 466b526288Smrg## ------------------------------- ## 476b526288Smrg## User overridable command paths. ## 486b526288Smrg## ------------------------------- ## 496b526288Smrg 506b526288Smrg# After configure completes, it has a better idea of some of the 516b526288Smrg# shell tools we need than the defaults used by the functions shared 526b526288Smrg# with bootstrap, so set those here where they can still be over- 536b526288Smrg# ridden by the user, but otherwise take precedence. 546b526288Smrg 556b526288Smrg: ${AUTOCONF="autoconf"} 566b526288Smrg: ${AUTOMAKE="automake"} 576b526288Smrg 586b526288Smrg 596b526288Smrg## -------------------------- ## 606b526288Smrg## Source external libraries. ## 616b526288Smrg## -------------------------- ## 626b526288Smrg 636b526288Smrg# Much of our low-level functionality needs to be sourced from external 646b526288Smrg# libraries, which are installed to $pkgauxdir. 656b526288Smrg 666b526288Smrg# Set a version string for this script. 676b526288Smrgscriptversion=2015-01-20.17; # UTC 686b526288Smrg 696b526288Smrg# General shell script boiler plate, and helper functions. 706b526288Smrg# Written by Gary V. Vaughan, 2004 716b526288Smrg 726b526288Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 736b526288Smrg# This is free software; see the source for copying conditions. There is NO 746b526288Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 756b526288Smrg 766b526288Smrg# This program is free software; you can redistribute it and/or modify 776b526288Smrg# it under the terms of the GNU General Public License as published by 786b526288Smrg# the Free Software Foundation; either version 3 of the License, or 796b526288Smrg# (at your option) any later version. 806b526288Smrg 816b526288Smrg# As a special exception to the GNU General Public License, if you distribute 826b526288Smrg# this file as part of a program or library that is built using GNU Libtool, 836b526288Smrg# you may include this file under the same distribution terms that you use 846b526288Smrg# for the rest of that program. 856b526288Smrg 866b526288Smrg# This program is distributed in the hope that it will be useful, 876b526288Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 886b526288Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 896b526288Smrg# General Public License for more details. 906b526288Smrg 916b526288Smrg# You should have received a copy of the GNU General Public License 926b526288Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 936b526288Smrg 946b526288Smrg# Please report bugs or propose patches to gary@gnu.org. 956b526288Smrg 966b526288Smrg 976b526288Smrg## ------ ## 986b526288Smrg## Usage. ## 996b526288Smrg## ------ ## 1006b526288Smrg 1016b526288Smrg# Evaluate this file near the top of your script to gain access to 1026b526288Smrg# the functions and variables defined here: 1036b526288Smrg# 1046b526288Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 1056b526288Smrg# 1066b526288Smrg# If you need to override any of the default environment variable 1076b526288Smrg# settings, do that before evaluating this file. 1086b526288Smrg 1096b526288Smrg 1106b526288Smrg## -------------------- ## 1116b526288Smrg## Shell normalisation. ## 1126b526288Smrg## -------------------- ## 1136b526288Smrg 1146b526288Smrg# Some shells need a little help to be as Bourne compatible as possible. 1156b526288Smrg# Before doing anything else, make sure all that help has been provided! 1166b526288Smrg 1176b526288SmrgDUALCASE=1; export DUALCASE # for MKS sh 1186b526288Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11911245024Smrg emulate sh 12011245024Smrg NULLCMD=: 1216b526288Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 12211245024Smrg # is contrary to our usage. Disable this feature. 12311245024Smrg alias -g '${1+"$@"}'='"$@"' 12441b2f0bdSmrg setopt NO_GLOB_SUBST 12511245024Smrgelse 1266b526288Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12741b2f0bdSmrgfi 12841b2f0bdSmrg 1296b526288Smrg# NLS nuisances: We save the old values in case they are required later. 1306b526288Smrg_G_user_locale= 1316b526288Smrg_G_safe_locale= 1326b526288Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 13311245024Smrgdo 1346b526288Smrg eval "if test set = \"\${$_G_var+set}\"; then 1356b526288Smrg save_$_G_var=\$$_G_var 1366b526288Smrg $_G_var=C 1376b526288Smrg export $_G_var 1386b526288Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1396b526288Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 14011245024Smrg fi" 14111245024Smrgdone 14211245024Smrg 1436b526288Smrg# CDPATH. 1446b526288Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 14511a29bacSmrg 1466b526288Smrg# Make sure IFS has a sensible default 1476b526288Smrgsp=' ' 1486b526288Smrgnl=' 1496b526288Smrg' 1506b526288SmrgIFS="$sp $nl" 1516b526288Smrg 1526b526288Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 1536b526288Smrgif test "${PATH_SEPARATOR+set}" != set; then 1546b526288Smrg PATH_SEPARATOR=: 1556b526288Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1566b526288Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1576b526288Smrg PATH_SEPARATOR=';' 1586b526288Smrg } 1596b526288Smrgfi 16011a29bacSmrg 16111a29bacSmrg 16211a29bacSmrg 1636b526288Smrg## ------------------------- ## 1646b526288Smrg## Locate command utilities. ## 1656b526288Smrg## ------------------------- ## 1666b526288Smrg 1676b526288Smrg 1686b526288Smrg# func_executable_p FILE 1696b526288Smrg# ---------------------- 1706b526288Smrg# Check that FILE is an executable regular file. 1716b526288Smrgfunc_executable_p () 1726b526288Smrg{ 1736b526288Smrg test -f "$1" && test -x "$1" 1746b526288Smrg} 1756b526288Smrg 1766b526288Smrg 1776b526288Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1786b526288Smrg# -------------------------------------------- 1796b526288Smrg# Search for either a program that responds to --version with output 1806b526288Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1816b526288Smrg# trying all the directories in PATH with each of the elements of 1826b526288Smrg# PROGS_LIST. 1836b526288Smrg# 1846b526288Smrg# CHECK_FUNC should accept the path to a candidate program, and 1856b526288Smrg# set $func_check_prog_result if it truncates its output less than 1866b526288Smrg# $_G_path_prog_max characters. 1876b526288Smrgfunc_path_progs () 1886b526288Smrg{ 1896b526288Smrg _G_progs_list=$1 1906b526288Smrg _G_check_func=$2 1916b526288Smrg _G_PATH=${3-"$PATH"} 1926b526288Smrg 1936b526288Smrg _G_path_prog_max=0 1946b526288Smrg _G_path_prog_found=false 1956b526288Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 1966b526288Smrg for _G_dir in $_G_PATH; do 1976b526288Smrg IFS=$_G_save_IFS 1986b526288Smrg test -z "$_G_dir" && _G_dir=. 1996b526288Smrg for _G_prog_name in $_G_progs_list; do 2006b526288Smrg for _exeext in '' .EXE; do 2016b526288Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2026b526288Smrg func_executable_p "$_G_path_prog" || continue 2036b526288Smrg case `"$_G_path_prog" --version 2>&1` in 2046b526288Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2056b526288Smrg *) $_G_check_func $_G_path_prog 2066b526288Smrg func_path_progs_result=$func_check_prog_result 2076b526288Smrg ;; 2086b526288Smrg esac 2096b526288Smrg $_G_path_prog_found && break 3 2106b526288Smrg done 2116b526288Smrg done 2126b526288Smrg done 2136b526288Smrg IFS=$_G_save_IFS 2146b526288Smrg test -z "$func_path_progs_result" && { 2156b526288Smrg echo "no acceptable sed could be found in \$PATH" >&2 2166b526288Smrg exit 1 2176b526288Smrg } 2186b526288Smrg} 2196b526288Smrg 2206b526288Smrg 2216b526288Smrg# We want to be able to use the functions in this file before configure 2226b526288Smrg# has figured out where the best binaries are kept, which means we have 2236b526288Smrg# to search for them ourselves - except when the results are already set 2246b526288Smrg# where we skip the searches. 2256b526288Smrg 2266b526288Smrg# Unless the user overrides by setting SED, search the path for either GNU 2276b526288Smrg# sed, or the sed that truncates its output the least. 2286b526288Smrgtest -z "$SED" && { 2296b526288Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2306b526288Smrg for _G_i in 1 2 3 4 5 6 7; do 2316b526288Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2326b526288Smrg done 2336b526288Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2346b526288Smrg _G_sed_script= 2356b526288Smrg 2366b526288Smrg func_check_prog_sed () 2376b526288Smrg { 2386b526288Smrg _G_path_prog=$1 2396b526288Smrg 2406b526288Smrg _G_count=0 2416b526288Smrg printf 0123456789 >conftest.in 2426b526288Smrg while : 2436b526288Smrg do 2446b526288Smrg cat conftest.in conftest.in >conftest.tmp 2456b526288Smrg mv conftest.tmp conftest.in 2466b526288Smrg cp conftest.in conftest.nl 2476b526288Smrg echo '' >> conftest.nl 2486b526288Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2496b526288Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2506b526288Smrg _G_count=`expr $_G_count + 1` 2516b526288Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2526b526288Smrg # Best one so far, save it but keep looking for a better one 2536b526288Smrg func_check_prog_result=$_G_path_prog 2546b526288Smrg _G_path_prog_max=$_G_count 2556b526288Smrg fi 2566b526288Smrg # 10*(2^10) chars as input seems more than enough 2576b526288Smrg test 10 -lt "$_G_count" && break 2586b526288Smrg done 2596b526288Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2606b526288Smrg } 2616b526288Smrg 2626b526288Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 2636b526288Smrg rm -f conftest.sed 2646b526288Smrg SED=$func_path_progs_result 2656b526288Smrg} 2666b526288Smrg 2676b526288Smrg 2686b526288Smrg# Unless the user overrides by setting GREP, search the path for either GNU 2696b526288Smrg# grep, or the grep that truncates its output the least. 2706b526288Smrgtest -z "$GREP" && { 2716b526288Smrg func_check_prog_grep () 2726b526288Smrg { 2736b526288Smrg _G_path_prog=$1 2746b526288Smrg 2756b526288Smrg _G_count=0 2766b526288Smrg _G_path_prog_max=0 2776b526288Smrg printf 0123456789 >conftest.in 2786b526288Smrg while : 2796b526288Smrg do 2806b526288Smrg cat conftest.in conftest.in >conftest.tmp 2816b526288Smrg mv conftest.tmp conftest.in 2826b526288Smrg cp conftest.in conftest.nl 2836b526288Smrg echo 'GREP' >> conftest.nl 2846b526288Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2856b526288Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2866b526288Smrg _G_count=`expr $_G_count + 1` 2876b526288Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2886b526288Smrg # Best one so far, save it but keep looking for a better one 2896b526288Smrg func_check_prog_result=$_G_path_prog 2906b526288Smrg _G_path_prog_max=$_G_count 2916b526288Smrg fi 2926b526288Smrg # 10*(2^10) chars as input seems more than enough 2936b526288Smrg test 10 -lt "$_G_count" && break 2946b526288Smrg done 2956b526288Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2966b526288Smrg } 2976b526288Smrg 2986b526288Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 2996b526288Smrg GREP=$func_path_progs_result 3006b526288Smrg} 3016b526288Smrg 3026b526288Smrg 3036b526288Smrg## ------------------------------- ## 3046b526288Smrg## User overridable command paths. ## 3056b526288Smrg## ------------------------------- ## 3066b526288Smrg 3076b526288Smrg# All uppercase variable names are used for environment variables. These 3086b526288Smrg# variables can be overridden by the user before calling a script that 3096b526288Smrg# uses them if a suitable command of that name is not already available 3106b526288Smrg# in the command search PATH. 31111a29bacSmrg 31211a29bacSmrg: ${CP="cp -f"} 3136b526288Smrg: ${ECHO="printf %s\n"} 3146b526288Smrg: ${EGREP="$GREP -E"} 3156b526288Smrg: ${FGREP="$GREP -F"} 31611a29bacSmrg: ${LN_S="ln -s"} 31711a29bacSmrg: ${MAKE="make"} 31811a29bacSmrg: ${MKDIR="mkdir"} 31911a29bacSmrg: ${MV="mv -f"} 32011a29bacSmrg: ${RM="rm -f"} 32111a29bacSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 32211a29bacSmrg 32311a29bacSmrg 3246b526288Smrg## -------------------- ## 3256b526288Smrg## Useful sed snippets. ## 3266b526288Smrg## -------------------- ## 32741b2f0bdSmrg 3286b526288Smrgsed_dirname='s|/[^/]*$||' 3296b526288Smrgsed_basename='s|^.*/||' 33041b2f0bdSmrg 3316b526288Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3326b526288Smrg# metacharacters that are still active within double-quoted strings. 3336b526288Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33411a29bacSmrg 3356b526288Smrg# Same as above, but do not quote variable references. 3366b526288Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3376b526288Smrg 3386b526288Smrg# Sed substitution that turns a string into a regex matching for the 3396b526288Smrg# string literally. 3406b526288Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3416b526288Smrg 3426b526288Smrg# Sed substitution that converts a w32 file name or path 3436b526288Smrg# that contains forward slashes, into one that contains 3446b526288Smrg# (escaped) backslashes. A very naive implementation. 3456b526288Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3466b526288Smrg 3476b526288Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3486b526288Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3496b526288Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3506b526288Smrg# expansion. Since each input '\' is now two '\'s, look for any number 3516b526288Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3526b526288Smrg_G_bs='\\' 3536b526288Smrg_G_bs2='\\\\' 3546b526288Smrg_G_bs4='\\\\\\\\' 3556b526288Smrg_G_dollar='\$' 3566b526288Smrgsed_double_backslash="\ 3576b526288Smrg s/$_G_bs4/&\\ 3586b526288Smrg/g 3596b526288Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3606b526288Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3616b526288Smrg s/\n//g" 36241b2f0bdSmrg 36311a29bacSmrg 3646b526288Smrg## ----------------- ## 3656b526288Smrg## Global variables. ## 3666b526288Smrg## ----------------- ## 36711a29bacSmrg 3686b526288Smrg# Except for the global variables explicitly listed below, the following 3696b526288Smrg# functions in the '^func_' namespace, and the '^require_' namespace 3706b526288Smrg# variables initialised in the 'Resource management' section, sourcing 3716b526288Smrg# this file will not pollute your global namespace with anything 3726b526288Smrg# else. There's no portable way to scope variables in Bourne shell 3736b526288Smrg# though, so actually running these functions will sometimes place 3746b526288Smrg# results into a variable named after the function, and often use 3756b526288Smrg# temporary variables in the '^_G_' namespace. If you are careful to 3766b526288Smrg# avoid using those namespaces casually in your sourcing script, things 3776b526288Smrg# should continue to work as you expect. And, of course, you can freely 3786b526288Smrg# overwrite any of the functions or variables defined here before 3796b526288Smrg# calling anything to customize them. 38011a29bacSmrg 3816b526288SmrgEXIT_SUCCESS=0 3826b526288SmrgEXIT_FAILURE=1 3836b526288SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 3846b526288SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38511a29bacSmrg 3866b526288Smrg# Allow overriding, eg assuming that you follow the convention of 3876b526288Smrg# putting '$debug_cmd' at the start of all your functions, you can get 3886b526288Smrg# bash to show function call trace with: 3896b526288Smrg# 3906b526288Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 3916b526288Smrgdebug_cmd=${debug_cmd-":"} 3926b526288Smrgexit_cmd=: 39311a29bacSmrg 3946b526288Smrg# By convention, finish your script with: 3956b526288Smrg# 3966b526288Smrg# exit $exit_status 3976b526288Smrg# 3986b526288Smrg# so that you can set exit_status to non-zero if you want to indicate 3996b526288Smrg# something went wrong during execution without actually bailing out at 4006b526288Smrg# the point of failure. 4016b526288Smrgexit_status=$EXIT_SUCCESS 4026b526288Smrg 4036b526288Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4046b526288Smrg# is ksh but when the shell is invoked as "sh" and the current value of 4056b526288Smrg# the _XPG environment variable is not equal to 1 (one), the special 4066b526288Smrg# positional parameter $0, within a function call, is the name of the 4076b526288Smrg# function. 4086b526288Smrgprogpath=$0 40911a29bacSmrg 4106b526288Smrg# The name of this program. 4116b526288Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 41211a29bacSmrg 4136b526288Smrg# Make sure we have an absolute progpath for reexecution: 41411a29bacSmrgcase $progpath in 41511a29bacSmrg [\\/]*|[A-Za-z]:\\*) ;; 41611a29bacSmrg *[\\/]*) 4176b526288Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 41811a29bacSmrg progdir=`cd "$progdir" && pwd` 4196b526288Smrg progpath=$progdir/$progname 42011a29bacSmrg ;; 42111a29bacSmrg *) 4226b526288Smrg _G_IFS=$IFS 4236b526288Smrg IFS=${PATH_SEPARATOR-:} 42411a29bacSmrg for progdir in $PATH; do 4256b526288Smrg IFS=$_G_IFS 42611a29bacSmrg test -x "$progdir/$progname" && break 42711a29bacSmrg done 4286b526288Smrg IFS=$_G_IFS 42911a29bacSmrg test -n "$progdir" || progdir=`pwd` 4306b526288Smrg progpath=$progdir/$progname 43111a29bacSmrg ;; 43211a29bacSmrgesac 43311a29bacSmrg 43411a29bacSmrg 4356b526288Smrg## ----------------- ## 4366b526288Smrg## Standard options. ## 4376b526288Smrg## ----------------- ## 4386b526288Smrg 4396b526288Smrg# The following options affect the operation of the functions defined 4406b526288Smrg# below, and should be set appropriately depending on run-time para- 4416b526288Smrg# meters passed on the command line. 44211a29bacSmrg 44311a29bacSmrgopt_dry_run=false 44411a29bacSmrgopt_quiet=false 44511a29bacSmrgopt_verbose=false 44611a29bacSmrg 4476b526288Smrg# Categories 'all' and 'none' are always available. Append any others 4486b526288Smrg# you will pass as the first argument to func_warning from your own 4496b526288Smrg# code. 4506b526288Smrgwarning_categories= 45111a29bacSmrg 4526b526288Smrg# By default, display warnings according to 'opt_warning_types'. Set 4536b526288Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4546b526288Smrg# treat the next displayed warning as a fatal error. 4556b526288Smrgwarning_func=func_warn_and_continue 45611a29bacSmrg 4576b526288Smrg# Set to 'all' to display all warnings, 'none' to suppress all 4586b526288Smrg# warnings, or a space delimited list of some subset of 4596b526288Smrg# 'warning_categories' to display only the listed warnings. 4606b526288Smrgopt_warning_types=all 46111a29bacSmrg 46211a29bacSmrg 4636b526288Smrg## -------------------- ## 4646b526288Smrg## Resource management. ## 4656b526288Smrg## -------------------- ## 46611a29bacSmrg 4676b526288Smrg# This section contains definitions for functions that each ensure a 4686b526288Smrg# particular resource (a file, or a non-empty configuration variable for 4696b526288Smrg# example) is available, and if appropriate to extract default values 4706b526288Smrg# from pertinent package files. Call them using their associated 4716b526288Smrg# 'require_*' variable to ensure that they are executed, at most, once. 4726b526288Smrg# 4736b526288Smrg# It's entirely deliberate that calling these functions can set 4746b526288Smrg# variables that don't obey the namespace limitations obeyed by the rest 4756b526288Smrg# of this file, in order that that they be as useful as possible to 4766b526288Smrg# callers. 47711a29bacSmrg 47811a29bacSmrg 4796b526288Smrg# require_term_colors 4806b526288Smrg# ------------------- 4816b526288Smrg# Allow display of bold text on terminals that support it. 4826b526288Smrgrequire_term_colors=func_require_term_colors 4836b526288Smrgfunc_require_term_colors () 48411a29bacSmrg{ 4856b526288Smrg $debug_cmd 4866b526288Smrg 4876b526288Smrg test -t 1 && { 4886b526288Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 4896b526288Smrg # precedence, because most terminfo databases neglect to describe 4906b526288Smrg # whether color sequences are supported. 4916b526288Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 4926b526288Smrg 4936b526288Smrg if test 1 = "$USE_ANSI_COLORS"; then 4946b526288Smrg # Standard ANSI escape sequences 4956b526288Smrg tc_reset='[0m' 4966b526288Smrg tc_bold='[1m'; tc_standout='[7m' 4976b526288Smrg tc_red='[31m'; tc_green='[32m' 4986b526288Smrg tc_blue='[34m'; tc_cyan='[36m' 4996b526288Smrg else 5006b526288Smrg # Otherwise trust the terminfo database after all. 5016b526288Smrg test -n "`tput sgr0 2>/dev/null`" && { 5026b526288Smrg tc_reset=`tput sgr0` 5036b526288Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5046b526288Smrg tc_standout=$tc_bold 5056b526288Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5066b526288Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5076b526288Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5086b526288Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5096b526288Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5106b526288Smrg } 5116b526288Smrg fi 5126b526288Smrg } 51311a29bacSmrg 5146b526288Smrg require_term_colors=: 51511a29bacSmrg} 51611a29bacSmrg 51711a29bacSmrg 5186b526288Smrg## ----------------- ## 5196b526288Smrg## Function library. ## 5206b526288Smrg## ----------------- ## 52111a29bacSmrg 5226b526288Smrg# This section contains a variety of useful functions to call in your 5236b526288Smrg# scripts. Take note of the portable wrappers for features provided by 5246b526288Smrg# some modern shells, which will fall back to slower equivalents on 5256b526288Smrg# less featureful shells. 52611a29bacSmrg 52711a29bacSmrg 5286b526288Smrg# func_append VAR VALUE 5296b526288Smrg# --------------------- 5306b526288Smrg# Append VALUE onto the existing contents of VAR. 53111a29bacSmrg 5326b526288Smrg # We should try to minimise forks, especially on Windows where they are 5336b526288Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 5346b526288Smrg # being used: 5356b526288Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5366b526288Smrg : ${_G_HAVE_ARITH_OP="yes"} 5376b526288Smrg : ${_G_HAVE_XSI_OPS="yes"} 5386b526288Smrg # The += operator was introduced in bash 3.1 5396b526288Smrg case $BASH_VERSION in 5406b526288Smrg [12].* | 3.0 | 3.0*) ;; 5416b526288Smrg *) 5426b526288Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5436b526288Smrg ;; 5446b526288Smrg esac 5456b526288Smrg fi 54611a29bacSmrg 5476b526288Smrg # _G_HAVE_PLUSEQ_OP 5486b526288Smrg # Can be empty, in which case the shell is probed, "yes" if += is 5496b526288Smrg # useable or anything else if it does not work. 5506b526288Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5516b526288Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5526b526288Smrg && _G_HAVE_PLUSEQ_OP=yes 5536b526288Smrg 5546b526288Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5556b526288Smrgthen 5566b526288Smrg # This is an XSI compatible shell, allowing a faster implementation... 5576b526288Smrg eval 'func_append () 5586b526288Smrg { 5596b526288Smrg $debug_cmd 56011a29bacSmrg 5616b526288Smrg eval "$1+=\$2" 5626b526288Smrg }' 5636b526288Smrgelse 5646b526288Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 5656b526288Smrg func_append () 5666b526288Smrg { 5676b526288Smrg $debug_cmd 56811a29bacSmrg 5696b526288Smrg eval "$1=\$$1\$2" 5706b526288Smrg } 5716b526288Smrgfi 5726b526288Smrg 5736b526288Smrg 5746b526288Smrg# func_append_quoted VAR VALUE 5756b526288Smrg# ---------------------------- 5766b526288Smrg# Quote VALUE and append to the end of shell variable VAR, separated 5776b526288Smrg# by a space. 5786b526288Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 5796b526288Smrg eval 'func_append_quoted () 5806b526288Smrg { 5816b526288Smrg $debug_cmd 5826b526288Smrg 5836b526288Smrg func_quote_for_eval "$2" 5846b526288Smrg eval "$1+=\\ \$func_quote_for_eval_result" 5856b526288Smrg }' 5866b526288Smrgelse 5876b526288Smrg func_append_quoted () 5886b526288Smrg { 5896b526288Smrg $debug_cmd 5906b526288Smrg 5916b526288Smrg func_quote_for_eval "$2" 5926b526288Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 5936b526288Smrg } 5946b526288Smrgfi 5956b526288Smrg 5966b526288Smrg 5976b526288Smrg# func_append_uniq VAR VALUE 5986b526288Smrg# -------------------------- 5996b526288Smrg# Append unique VALUE onto the existing contents of VAR, assuming 6006b526288Smrg# entries are delimited by the first character of VALUE. For example: 6016b526288Smrg# 6026b526288Smrg# func_append_uniq options " --another-option option-argument" 6036b526288Smrg# 6046b526288Smrg# will only append to $options if " --another-option option-argument " 6056b526288Smrg# is not already present somewhere in $options already (note spaces at 6066b526288Smrg# each end implied by leading space in second argument). 6076b526288Smrgfunc_append_uniq () 6086b526288Smrg{ 6096b526288Smrg $debug_cmd 6106b526288Smrg 6116b526288Smrg eval _G_current_value='`$ECHO $'$1'`' 6126b526288Smrg _G_delim=`expr "$2" : '\(.\)'` 6136b526288Smrg 6146b526288Smrg case $_G_delim$_G_current_value$_G_delim in 6156b526288Smrg *"$2$_G_delim"*) ;; 6166b526288Smrg *) func_append "$@" ;; 6176b526288Smrg esac 6186b526288Smrg} 6196b526288Smrg 6206b526288Smrg 6216b526288Smrg# func_arith TERM... 6226b526288Smrg# ------------------ 6236b526288Smrg# Set func_arith_result to the result of evaluating TERMs. 6246b526288Smrg test -z "$_G_HAVE_ARITH_OP" \ 6256b526288Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6266b526288Smrg && _G_HAVE_ARITH_OP=yes 6276b526288Smrg 6286b526288Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 6296b526288Smrg eval 'func_arith () 6306b526288Smrg { 6316b526288Smrg $debug_cmd 6326b526288Smrg 6336b526288Smrg func_arith_result=$(( $* )) 6346b526288Smrg }' 6356b526288Smrgelse 6366b526288Smrg func_arith () 6376b526288Smrg { 6386b526288Smrg $debug_cmd 6396b526288Smrg 6406b526288Smrg func_arith_result=`expr "$@"` 6416b526288Smrg } 6426b526288Smrgfi 6436b526288Smrg 6446b526288Smrg 6456b526288Smrg# func_basename FILE 6466b526288Smrg# ------------------ 6476b526288Smrg# Set func_basename_result to FILE with everything up to and including 6486b526288Smrg# the last / stripped. 6496b526288Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 6506b526288Smrg # If this shell supports suffix pattern removal, then use it to avoid 6516b526288Smrg # forking. Hide the definitions single quotes in case the shell chokes 6526b526288Smrg # on unsupported syntax... 6536b526288Smrg _b='func_basename_result=${1##*/}' 6546b526288Smrg _d='case $1 in 6556b526288Smrg */*) func_dirname_result=${1%/*}$2 ;; 6566b526288Smrg * ) func_dirname_result=$3 ;; 6576b526288Smrg esac' 6586b526288Smrg 6596b526288Smrgelse 6606b526288Smrg # ...otherwise fall back to using sed. 6616b526288Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 6626b526288Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 6636b526288Smrg if test "X$func_dirname_result" = "X$1"; then 6646b526288Smrg func_dirname_result=$3 6656b526288Smrg else 6666b526288Smrg func_append func_dirname_result "$2" 6676b526288Smrg fi' 6686b526288Smrgfi 6696b526288Smrg 6706b526288Smrgeval 'func_basename () 6716b526288Smrg{ 6726b526288Smrg $debug_cmd 6736b526288Smrg 6746b526288Smrg '"$_b"' 6756b526288Smrg}' 6766b526288Smrg 6776b526288Smrg 6786b526288Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 6796b526288Smrg# ------------------------------------------- 6806b526288Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 6816b526288Smrg# otherwise set result to NONDIR_REPLACEMENT. 6826b526288Smrgeval 'func_dirname () 6836b526288Smrg{ 6846b526288Smrg $debug_cmd 6856b526288Smrg 6866b526288Smrg '"$_d"' 6876b526288Smrg}' 6886b526288Smrg 6896b526288Smrg 6906b526288Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 6916b526288Smrg# -------------------------------------------------------- 6926b526288Smrg# Perform func_basename and func_dirname in a single function 6936b526288Smrg# call: 6946b526288Smrg# dirname: Compute the dirname of FILE. If nonempty, 6956b526288Smrg# add APPEND to the result, otherwise set result 6966b526288Smrg# to NONDIR_REPLACEMENT. 6976b526288Smrg# value returned in "$func_dirname_result" 6986b526288Smrg# basename: Compute filename of FILE. 6996b526288Smrg# value retuned in "$func_basename_result" 7006b526288Smrg# For efficiency, we do not delegate to the functions above but instead 7016b526288Smrg# duplicate the functionality here. 7026b526288Smrgeval 'func_dirname_and_basename () 7036b526288Smrg{ 7046b526288Smrg $debug_cmd 7056b526288Smrg 7066b526288Smrg '"$_b"' 7076b526288Smrg '"$_d"' 7086b526288Smrg}' 7096b526288Smrg 7106b526288Smrg 7116b526288Smrg# func_echo ARG... 7126b526288Smrg# ---------------- 7136b526288Smrg# Echo program name prefixed message. 7146b526288Smrgfunc_echo () 7156b526288Smrg{ 7166b526288Smrg $debug_cmd 7176b526288Smrg 7186b526288Smrg _G_message=$* 7196b526288Smrg 7206b526288Smrg func_echo_IFS=$IFS 7216b526288Smrg IFS=$nl 7226b526288Smrg for _G_line in $_G_message; do 7236b526288Smrg IFS=$func_echo_IFS 7246b526288Smrg $ECHO "$progname: $_G_line" 7256b526288Smrg done 7266b526288Smrg IFS=$func_echo_IFS 7276b526288Smrg} 7286b526288Smrg 7296b526288Smrg 7306b526288Smrg# func_echo_all ARG... 7316b526288Smrg# -------------------- 7326b526288Smrg# Invoke $ECHO with all args, space-separated. 7336b526288Smrgfunc_echo_all () 7346b526288Smrg{ 7356b526288Smrg $ECHO "$*" 7366b526288Smrg} 7376b526288Smrg 7386b526288Smrg 7396b526288Smrg# func_echo_infix_1 INFIX ARG... 7406b526288Smrg# ------------------------------ 7416b526288Smrg# Echo program name, followed by INFIX on the first line, with any 7426b526288Smrg# additional lines not showing INFIX. 7436b526288Smrgfunc_echo_infix_1 () 7446b526288Smrg{ 7456b526288Smrg $debug_cmd 7466b526288Smrg 7476b526288Smrg $require_term_colors 7486b526288Smrg 7496b526288Smrg _G_infix=$1; shift 7506b526288Smrg _G_indent=$_G_infix 7516b526288Smrg _G_prefix="$progname: $_G_infix: " 7526b526288Smrg _G_message=$* 7536b526288Smrg 7546b526288Smrg # Strip color escape sequences before counting printable length 7556b526288Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7566b526288Smrg do 7576b526288Smrg test -n "$_G_tc" && { 7586b526288Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 7596b526288Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 7606b526288Smrg } 7616b526288Smrg done 7626b526288Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 7636b526288Smrg 7646b526288Smrg func_echo_infix_1_IFS=$IFS 7656b526288Smrg IFS=$nl 7666b526288Smrg for _G_line in $_G_message; do 7676b526288Smrg IFS=$func_echo_infix_1_IFS 7686b526288Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 7696b526288Smrg _G_prefix=$_G_indent 7706b526288Smrg done 7716b526288Smrg IFS=$func_echo_infix_1_IFS 7726b526288Smrg} 7736b526288Smrg 7746b526288Smrg 7756b526288Smrg# func_error ARG... 7766b526288Smrg# ----------------- 7776b526288Smrg# Echo program name prefixed message to standard error. 7786b526288Smrgfunc_error () 7796b526288Smrg{ 7806b526288Smrg $debug_cmd 7816b526288Smrg 7826b526288Smrg $require_term_colors 7836b526288Smrg 7846b526288Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 7856b526288Smrg} 7866b526288Smrg 7876b526288Smrg 7886b526288Smrg# func_fatal_error ARG... 7896b526288Smrg# ----------------------- 7906b526288Smrg# Echo program name prefixed message to standard error, and exit. 7916b526288Smrgfunc_fatal_error () 7926b526288Smrg{ 7936b526288Smrg $debug_cmd 7946b526288Smrg 7956b526288Smrg func_error "$*" 7966b526288Smrg exit $EXIT_FAILURE 7976b526288Smrg} 7986b526288Smrg 7996b526288Smrg 8006b526288Smrg# func_grep EXPRESSION FILENAME 8016b526288Smrg# ----------------------------- 8026b526288Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8036b526288Smrgfunc_grep () 8046b526288Smrg{ 8056b526288Smrg $debug_cmd 8066b526288Smrg 8076b526288Smrg $GREP "$1" "$2" >/dev/null 2>&1 8086b526288Smrg} 8096b526288Smrg 8106b526288Smrg 8116b526288Smrg# func_len STRING 8126b526288Smrg# --------------- 8136b526288Smrg# Set func_len_result to the length of STRING. STRING may not 8146b526288Smrg# start with a hyphen. 8156b526288Smrg test -z "$_G_HAVE_XSI_OPS" \ 8166b526288Smrg && (eval 'x=a/b/c; 8176b526288Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8186b526288Smrg && _G_HAVE_XSI_OPS=yes 8196b526288Smrg 8206b526288Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 8216b526288Smrg eval 'func_len () 8226b526288Smrg { 8236b526288Smrg $debug_cmd 8246b526288Smrg 8256b526288Smrg func_len_result=${#1} 8266b526288Smrg }' 8276b526288Smrgelse 8286b526288Smrg func_len () 8296b526288Smrg { 8306b526288Smrg $debug_cmd 8316b526288Smrg 8326b526288Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8336b526288Smrg } 8346b526288Smrgfi 8356b526288Smrg 8366b526288Smrg 8376b526288Smrg# func_mkdir_p DIRECTORY-PATH 8386b526288Smrg# --------------------------- 8396b526288Smrg# Make sure the entire path to DIRECTORY-PATH is available. 8406b526288Smrgfunc_mkdir_p () 8416b526288Smrg{ 8426b526288Smrg $debug_cmd 8436b526288Smrg 8446b526288Smrg _G_directory_path=$1 8456b526288Smrg _G_dir_list= 8466b526288Smrg 8476b526288Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8486b526288Smrg 8496b526288Smrg # Protect directory names starting with '-' 8506b526288Smrg case $_G_directory_path in 8516b526288Smrg -*) _G_directory_path=./$_G_directory_path ;; 8526b526288Smrg esac 8536b526288Smrg 8546b526288Smrg # While some portion of DIR does not yet exist... 8556b526288Smrg while test ! -d "$_G_directory_path"; do 8566b526288Smrg # ...make a list in topmost first order. Use a colon delimited 8576b526288Smrg # list incase some portion of path contains whitespace. 8586b526288Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 8596b526288Smrg 8606b526288Smrg # If the last portion added has no slash in it, the list is done 8616b526288Smrg case $_G_directory_path in */*) ;; *) break ;; esac 8626b526288Smrg 8636b526288Smrg # ...otherwise throw away the child directory and loop 8646b526288Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 8656b526288Smrg done 8666b526288Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 86711a29bacSmrg 8686b526288Smrg func_mkdir_p_IFS=$IFS; IFS=: 8696b526288Smrg for _G_dir in $_G_dir_list; do 8706b526288Smrg IFS=$func_mkdir_p_IFS 8716b526288Smrg # mkdir can fail with a 'File exist' error if two processes 87211a29bacSmrg # try to create one of the directories concurrently. Don't 87311a29bacSmrg # stop in that case! 8746b526288Smrg $MKDIR "$_G_dir" 2>/dev/null || : 87511a29bacSmrg done 8766b526288Smrg IFS=$func_mkdir_p_IFS 87711a29bacSmrg 87811a29bacSmrg # Bail out if we (or some other process) failed to create a directory. 8796b526288Smrg test -d "$_G_directory_path" || \ 8806b526288Smrg func_fatal_error "Failed to create '$1'" 88111a29bacSmrg fi 88211a29bacSmrg} 88341b2f0bdSmrg 88441b2f0bdSmrg 8856b526288Smrg# func_mktempdir [BASENAME] 8866b526288Smrg# ------------------------- 88741b2f0bdSmrg# Make a temporary directory that won't clash with other running 88841b2f0bdSmrg# libtool processes, and avoids race conditions if possible. If 8896b526288Smrg# given, BASENAME is the basename for that directory. 89041b2f0bdSmrgfunc_mktempdir () 89141b2f0bdSmrg{ 8926b526288Smrg $debug_cmd 89341b2f0bdSmrg 8946b526288Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 8956b526288Smrg 8966b526288Smrg if test : = "$opt_dry_run"; then 89741b2f0bdSmrg # Return a directory name, but don't create it in dry-run mode 8986b526288Smrg _G_tmpdir=$_G_template-$$ 89941b2f0bdSmrg else 90041b2f0bdSmrg 90141b2f0bdSmrg # If mktemp works, use that first and foremost 9026b526288Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 90341b2f0bdSmrg 9046b526288Smrg if test ! -d "$_G_tmpdir"; then 90511a29bacSmrg # Failing that, at least try and use $RANDOM to avoid a race 9066b526288Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 90741b2f0bdSmrg 9086b526288Smrg func_mktempdir_umask=`umask` 90911a29bacSmrg umask 0077 9106b526288Smrg $MKDIR "$_G_tmpdir" 9116b526288Smrg umask $func_mktempdir_umask 91241b2f0bdSmrg fi 91341b2f0bdSmrg 91441b2f0bdSmrg # If we're not in dry-run mode, bomb out on failure 9156b526288Smrg test -d "$_G_tmpdir" || \ 9166b526288Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91741b2f0bdSmrg fi 91841b2f0bdSmrg 9196b526288Smrg $ECHO "$_G_tmpdir" 92041b2f0bdSmrg} 92141b2f0bdSmrg 92241b2f0bdSmrg 9236b526288Smrg# func_normal_abspath PATH 9246b526288Smrg# ------------------------ 9256b526288Smrg# Remove doubled-up and trailing slashes, "." path components, 9266b526288Smrg# and cancel out any ".." path components in PATH after making 9276b526288Smrg# it an absolute path. 9286b526288Smrgfunc_normal_abspath () 92941b2f0bdSmrg{ 9306b526288Smrg $debug_cmd 93111a29bacSmrg 9326b526288Smrg # These SED scripts presuppose an absolute path with a trailing slash. 9336b526288Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9346b526288Smrg _G_pathcdr='s|^/[^/]*||' 9356b526288Smrg _G_removedotparts=':dotsl 9366b526288Smrg s|/\./|/|g 9376b526288Smrg t dotsl 9386b526288Smrg s|/\.$|/|' 9396b526288Smrg _G_collapseslashes='s|/\{1,\}|/|g' 9406b526288Smrg _G_finalslash='s|/*$|/|' 9416b526288Smrg 9426b526288Smrg # Start from root dir and reassemble the path. 9436b526288Smrg func_normal_abspath_result= 9446b526288Smrg func_normal_abspath_tpath=$1 9456b526288Smrg func_normal_abspath_altnamespace= 9466b526288Smrg case $func_normal_abspath_tpath in 9476b526288Smrg "") 9486b526288Smrg # Empty path, that just means $cwd. 9496b526288Smrg func_stripname '' '/' "`pwd`" 9506b526288Smrg func_normal_abspath_result=$func_stripname_result 9516b526288Smrg return 9526b526288Smrg ;; 9536b526288Smrg # The next three entries are used to spot a run of precisely 9546b526288Smrg # two leading slashes without using negated character classes; 9556b526288Smrg # we take advantage of case's first-match behaviour. 9566b526288Smrg ///*) 9576b526288Smrg # Unusual form of absolute path, do nothing. 9586b526288Smrg ;; 9596b526288Smrg //*) 9606b526288Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 9616b526288Smrg # and for example Cygwin uses it to access remote file shares 9626b526288Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 9636b526288Smrg func_normal_abspath_altnamespace=/ 9646b526288Smrg ;; 9656b526288Smrg /*) 9666b526288Smrg # Absolute path, do nothing. 96711a29bacSmrg ;; 96811a29bacSmrg *) 9696b526288Smrg # Relative path, prepend $cwd. 9706b526288Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 9716b526288Smrg ;; 97241b2f0bdSmrg esac 9736b526288Smrg 9746b526288Smrg # Cancel out all the simple stuff to save iterations. We also want 9756b526288Smrg # the path to end with a slash for ease of parsing, so make sure 9766b526288Smrg # there is one (and only one) here. 9776b526288Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9786b526288Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 9796b526288Smrg while :; do 9806b526288Smrg # Processed it all yet? 9816b526288Smrg if test / = "$func_normal_abspath_tpath"; then 9826b526288Smrg # If we ascended to the root using ".." the result may be empty now. 9836b526288Smrg if test -z "$func_normal_abspath_result"; then 9846b526288Smrg func_normal_abspath_result=/ 9856b526288Smrg fi 9866b526288Smrg break 9876b526288Smrg fi 9886b526288Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9896b526288Smrg -e "$_G_pathcar"` 9906b526288Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9916b526288Smrg -e "$_G_pathcdr"` 9926b526288Smrg # Figure out what to do with it 9936b526288Smrg case $func_normal_abspath_tcomponent in 9946b526288Smrg "") 9956b526288Smrg # Trailing empty path component, ignore it. 9966b526288Smrg ;; 9976b526288Smrg ..) 9986b526288Smrg # Parent dir; strip last assembled component from result. 9996b526288Smrg func_dirname "$func_normal_abspath_result" 10006b526288Smrg func_normal_abspath_result=$func_dirname_result 10016b526288Smrg ;; 10026b526288Smrg *) 10036b526288Smrg # Actual path component, append it. 10046b526288Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10056b526288Smrg ;; 10066b526288Smrg esac 10076b526288Smrg done 10086b526288Smrg # Restore leading double-slash if one was found on entry. 10096b526288Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10106b526288Smrg} 10116b526288Smrg 10126b526288Smrg 10136b526288Smrg# func_notquiet ARG... 10146b526288Smrg# -------------------- 10156b526288Smrg# Echo program name prefixed message only when not in quiet mode. 10166b526288Smrgfunc_notquiet () 10176b526288Smrg{ 10186b526288Smrg $debug_cmd 10196b526288Smrg 10206b526288Smrg $opt_quiet || func_echo ${1+"$@"} 10216b526288Smrg 10226b526288Smrg # A bug in bash halts the script if the last line of a function 10236b526288Smrg # fails when set -e is in force, so we need another command to 10246b526288Smrg # work around that: 10256b526288Smrg : 10266b526288Smrg} 10276b526288Smrg 10286b526288Smrg 10296b526288Smrg# func_relative_path SRCDIR DSTDIR 10306b526288Smrg# -------------------------------- 10316b526288Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10326b526288Smrgfunc_relative_path () 10336b526288Smrg{ 10346b526288Smrg $debug_cmd 10356b526288Smrg 10366b526288Smrg func_relative_path_result= 10376b526288Smrg func_normal_abspath "$1" 10386b526288Smrg func_relative_path_tlibdir=$func_normal_abspath_result 10396b526288Smrg func_normal_abspath "$2" 10406b526288Smrg func_relative_path_tbindir=$func_normal_abspath_result 10416b526288Smrg 10426b526288Smrg # Ascend the tree starting from libdir 10436b526288Smrg while :; do 10446b526288Smrg # check if we have found a prefix of bindir 10456b526288Smrg case $func_relative_path_tbindir in 10466b526288Smrg $func_relative_path_tlibdir) 10476b526288Smrg # found an exact match 10486b526288Smrg func_relative_path_tcancelled= 10496b526288Smrg break 10506b526288Smrg ;; 10516b526288Smrg $func_relative_path_tlibdir*) 10526b526288Smrg # found a matching prefix 10536b526288Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10546b526288Smrg func_relative_path_tcancelled=$func_stripname_result 10556b526288Smrg if test -z "$func_relative_path_result"; then 10566b526288Smrg func_relative_path_result=. 10576b526288Smrg fi 10586b526288Smrg break 10596b526288Smrg ;; 10606b526288Smrg *) 10616b526288Smrg func_dirname $func_relative_path_tlibdir 10626b526288Smrg func_relative_path_tlibdir=$func_dirname_result 10636b526288Smrg if test -z "$func_relative_path_tlibdir"; then 10646b526288Smrg # Have to descend all the way to the root! 10656b526288Smrg func_relative_path_result=../$func_relative_path_result 10666b526288Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 10676b526288Smrg break 10686b526288Smrg fi 10696b526288Smrg func_relative_path_result=../$func_relative_path_result 10706b526288Smrg ;; 10716b526288Smrg esac 10726b526288Smrg done 10736b526288Smrg 10746b526288Smrg # Now calculate path; take care to avoid doubling-up slashes. 10756b526288Smrg func_stripname '' '/' "$func_relative_path_result" 10766b526288Smrg func_relative_path_result=$func_stripname_result 10776b526288Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 10786b526288Smrg if test -n "$func_stripname_result"; then 10796b526288Smrg func_append func_relative_path_result "/$func_stripname_result" 10806b526288Smrg fi 10816b526288Smrg 10826b526288Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 10836b526288Smrg if test -n "$func_relative_path_result"; then 10846b526288Smrg func_stripname './' '' "$func_relative_path_result" 10856b526288Smrg func_relative_path_result=$func_stripname_result 10866b526288Smrg fi 10876b526288Smrg 10886b526288Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 10896b526288Smrg 10906b526288Smrg : 10916b526288Smrg} 10926b526288Smrg 10936b526288Smrg 10946b526288Smrg# func_quote_for_eval ARG... 10956b526288Smrg# -------------------------- 10966b526288Smrg# Aesthetically quote ARGs to be evaled later. 10976b526288Smrg# This function returns two values: 10986b526288Smrg# i) func_quote_for_eval_result 10996b526288Smrg# double-quoted, suitable for a subsequent eval 11006b526288Smrg# ii) func_quote_for_eval_unquoted_result 11016b526288Smrg# has all characters that are still active within double 11026b526288Smrg# quotes backslashified. 11036b526288Smrgfunc_quote_for_eval () 11046b526288Smrg{ 11056b526288Smrg $debug_cmd 11066b526288Smrg 11076b526288Smrg func_quote_for_eval_unquoted_result= 11086b526288Smrg func_quote_for_eval_result= 11096b526288Smrg while test 0 -lt $#; do 11106b526288Smrg case $1 in 11116b526288Smrg *[\\\`\"\$]*) 11126b526288Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 11136b526288Smrg *) 11146b526288Smrg _G_unquoted_arg=$1 ;; 11156b526288Smrg esac 11166b526288Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 11176b526288Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 11186b526288Smrg else 11196b526288Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 11206b526288Smrg fi 11216b526288Smrg 11226b526288Smrg case $_G_unquoted_arg in 11236b526288Smrg # Double-quote args containing shell metacharacters to delay 11246b526288Smrg # word splitting, command substitution and variable expansion 11256b526288Smrg # for a subsequent eval. 11266b526288Smrg # Many Bourne shells cannot handle close brackets correctly 11276b526288Smrg # in scan sets, so we specify it separately. 11286b526288Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11296b526288Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 11306b526288Smrg ;; 11316b526288Smrg *) 11326b526288Smrg _G_quoted_arg=$_G_unquoted_arg 11336b526288Smrg ;; 11346b526288Smrg esac 11356b526288Smrg 11366b526288Smrg if test -n "$func_quote_for_eval_result"; then 11376b526288Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 11386b526288Smrg else 11396b526288Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 11406b526288Smrg fi 11416b526288Smrg shift 11426b526288Smrg done 114341b2f0bdSmrg} 114441b2f0bdSmrg 114541b2f0bdSmrg 11466b526288Smrg# func_quote_for_expand ARG 11476b526288Smrg# ------------------------- 114811a29bacSmrg# Aesthetically quote ARG to be evaled later; same as above, 114911a29bacSmrg# but do not quote variable references. 115011a29bacSmrgfunc_quote_for_expand () 115141b2f0bdSmrg{ 11526b526288Smrg $debug_cmd 11536b526288Smrg 115411a29bacSmrg case $1 in 115511a29bacSmrg *[\\\`\"]*) 11566b526288Smrg _G_arg=`$ECHO "$1" | $SED \ 11576b526288Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115841b2f0bdSmrg *) 11596b526288Smrg _G_arg=$1 ;; 116011a29bacSmrg esac 116111a29bacSmrg 11626b526288Smrg case $_G_arg in 116311a29bacSmrg # Double-quote args containing shell metacharacters to delay 116411a29bacSmrg # word splitting and command substitution for a subsequent eval. 116511a29bacSmrg # Many Bourne shells cannot handle close brackets correctly 116611a29bacSmrg # in scan sets, so we specify it separately. 116711a29bacSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11686b526288Smrg _G_arg=\"$_G_arg\" 116911a29bacSmrg ;; 117011a29bacSmrg esac 117111a29bacSmrg 11726b526288Smrg func_quote_for_expand_result=$_G_arg 117341b2f0bdSmrg} 117441b2f0bdSmrg 117541b2f0bdSmrg 11766b526288Smrg# func_stripname PREFIX SUFFIX NAME 11776b526288Smrg# --------------------------------- 11786b526288Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 11796b526288Smrg# PREFIX and SUFFIX must not contain globbing or regex special 11806b526288Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 11816b526288Smrg# dot (in which case that matches only a dot). 11826b526288Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 11836b526288Smrg eval 'func_stripname () 11846b526288Smrg { 11856b526288Smrg $debug_cmd 11866b526288Smrg 11876b526288Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 11886b526288Smrg # positional parameters, so assign one to ordinary variable first. 11896b526288Smrg func_stripname_result=$3 11906b526288Smrg func_stripname_result=${func_stripname_result#"$1"} 11916b526288Smrg func_stripname_result=${func_stripname_result%"$2"} 11926b526288Smrg }' 11936b526288Smrgelse 11946b526288Smrg func_stripname () 11956b526288Smrg { 11966b526288Smrg $debug_cmd 11976b526288Smrg 11986b526288Smrg case $2 in 11996b526288Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 12006b526288Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 12016b526288Smrg esac 12026b526288Smrg } 12036b526288Smrgfi 12046b526288Smrg 12056b526288Smrg 12066b526288Smrg# func_show_eval CMD [FAIL_EXP] 12076b526288Smrg# ----------------------------- 12086b526288Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120911a29bacSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121011a29bacSmrg# is given, then evaluate it. 121111a29bacSmrgfunc_show_eval () 121241b2f0bdSmrg{ 12136b526288Smrg $debug_cmd 121441b2f0bdSmrg 12156b526288Smrg _G_cmd=$1 12166b526288Smrg _G_fail_exp=${2-':'} 121711a29bacSmrg 12186b526288Smrg func_quote_for_expand "$_G_cmd" 12196b526288Smrg eval "func_notquiet $func_quote_for_expand_result" 12206b526288Smrg 12216b526288Smrg $opt_dry_run || { 12226b526288Smrg eval "$_G_cmd" 12236b526288Smrg _G_status=$? 12246b526288Smrg if test 0 -ne "$_G_status"; then 12256b526288Smrg eval "(exit $_G_status); $_G_fail_exp" 122611a29bacSmrg fi 12276b526288Smrg } 122841b2f0bdSmrg} 122941b2f0bdSmrg 123011a29bacSmrg 12316b526288Smrg# func_show_eval_locale CMD [FAIL_EXP] 12326b526288Smrg# ------------------------------------ 12336b526288Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123411a29bacSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123511a29bacSmrg# is given, then evaluate it. Use the saved locale for evaluation. 123611a29bacSmrgfunc_show_eval_locale () 123741b2f0bdSmrg{ 12386b526288Smrg $debug_cmd 123941b2f0bdSmrg 12406b526288Smrg _G_cmd=$1 12416b526288Smrg _G_fail_exp=${2-':'} 12426b526288Smrg 12436b526288Smrg $opt_quiet || { 12446b526288Smrg func_quote_for_expand "$_G_cmd" 124511a29bacSmrg eval "func_echo $func_quote_for_expand_result" 124611a29bacSmrg } 124741b2f0bdSmrg 12486b526288Smrg $opt_dry_run || { 12496b526288Smrg eval "$_G_user_locale 12506b526288Smrg $_G_cmd" 12516b526288Smrg _G_status=$? 12526b526288Smrg eval "$_G_safe_locale" 12536b526288Smrg if test 0 -ne "$_G_status"; then 12546b526288Smrg eval "(exit $_G_status); $_G_fail_exp" 125541b2f0bdSmrg fi 12566b526288Smrg } 125741b2f0bdSmrg} 125841b2f0bdSmrg 125941b2f0bdSmrg 12606b526288Smrg# func_tr_sh 12616b526288Smrg# ---------- 12626b526288Smrg# Turn $1 into a string suitable for a shell variable name. 12636b526288Smrg# Result is stored in $func_tr_sh_result. All characters 12646b526288Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 12656b526288Smrg# if $1 begins with a digit, a '_' is prepended as well. 12666b526288Smrgfunc_tr_sh () 126711a29bacSmrg{ 12686b526288Smrg $debug_cmd 126941b2f0bdSmrg 12706b526288Smrg case $1 in 12716b526288Smrg [0-9]* | *[!a-zA-Z0-9_]*) 12726b526288Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 12736b526288Smrg ;; 12746b526288Smrg * ) 12756b526288Smrg func_tr_sh_result=$1 12766b526288Smrg ;; 12776b526288Smrg esac 127811a29bacSmrg} 127941b2f0bdSmrg 128041b2f0bdSmrg 12816b526288Smrg# func_verbose ARG... 12826b526288Smrg# ------------------- 12836b526288Smrg# Echo program name prefixed message in verbose mode only. 12846b526288Smrgfunc_verbose () 128511a29bacSmrg{ 12866b526288Smrg $debug_cmd 128741b2f0bdSmrg 12886b526288Smrg $opt_verbose && func_echo "$*" 128941b2f0bdSmrg 12906b526288Smrg : 12916b526288Smrg} 129241b2f0bdSmrg 129341b2f0bdSmrg 12946b526288Smrg# func_warn_and_continue ARG... 12956b526288Smrg# ----------------------------- 12966b526288Smrg# Echo program name prefixed warning message to standard error. 12976b526288Smrgfunc_warn_and_continue () 12986b526288Smrg{ 12996b526288Smrg $debug_cmd 130011245024Smrg 13016b526288Smrg $require_term_colors 130241b2f0bdSmrg 13036b526288Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 13046b526288Smrg} 130511a29bacSmrg 13066b526288Smrg 13076b526288Smrg# func_warning CATEGORY ARG... 13086b526288Smrg# ---------------------------- 13096b526288Smrg# Echo program name prefixed warning message to standard error. Warning 13106b526288Smrg# messages can be filtered according to CATEGORY, where this function 13116b526288Smrg# elides messages where CATEGORY is not listed in the global variable 13126b526288Smrg# 'opt_warning_types'. 13136b526288Smrgfunc_warning () 13146b526288Smrg{ 13156b526288Smrg $debug_cmd 13166b526288Smrg 13176b526288Smrg # CATEGORY must be in the warning_categories list! 13186b526288Smrg case " $warning_categories " in 13196b526288Smrg *" $1 "*) ;; 13206b526288Smrg *) func_internal_error "invalid warning category '$1'" ;; 13216b526288Smrg esac 13226b526288Smrg 13236b526288Smrg _G_category=$1 13246b526288Smrg shift 13256b526288Smrg 13266b526288Smrg case " $opt_warning_types " in 13276b526288Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 13286b526288Smrg esac 13296b526288Smrg} 13306b526288Smrg 13316b526288Smrg 13326b526288Smrg# func_sort_ver VER1 VER2 13336b526288Smrg# ----------------------- 13346b526288Smrg# 'sort -V' is not generally available. 13356b526288Smrg# Note this deviates from the version comparison in automake 13366b526288Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 13376b526288Smrg# but this should suffice as we won't be specifying old 13386b526288Smrg# version formats or redundant trailing .0 in bootstrap.conf. 13396b526288Smrg# If we did want full compatibility then we should probably 13406b526288Smrg# use m4_version_compare from autoconf. 13416b526288Smrgfunc_sort_ver () 13426b526288Smrg{ 13436b526288Smrg $debug_cmd 13446b526288Smrg 13456b526288Smrg printf '%s\n%s\n' "$1" "$2" \ 13466b526288Smrg | 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 13476b526288Smrg} 13486b526288Smrg 13496b526288Smrg# func_lt_ver PREV CURR 13506b526288Smrg# --------------------- 13516b526288Smrg# Return true if PREV and CURR are in the correct order according to 13526b526288Smrg# func_sort_ver, otherwise false. Use it like this: 13536b526288Smrg# 13546b526288Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 13556b526288Smrgfunc_lt_ver () 13566b526288Smrg{ 13576b526288Smrg $debug_cmd 13586b526288Smrg 13596b526288Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 13606b526288Smrg} 13616b526288Smrg 13626b526288Smrg 13636b526288Smrg# Local variables: 13646b526288Smrg# mode: shell-script 13656b526288Smrg# sh-indentation: 2 13666b526288Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 13676b526288Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 13686b526288Smrg# time-stamp-time-zone: "UTC" 13696b526288Smrg# End: 13706b526288Smrg#! /bin/sh 13716b526288Smrg 13726b526288Smrg# Set a version string for this script. 13736b526288Smrgscriptversion=2014-01-07.03; # UTC 13746b526288Smrg 13756b526288Smrg# A portable, pluggable option parser for Bourne shell. 13766b526288Smrg# Written by Gary V. Vaughan, 2010 13776b526288Smrg 13786b526288Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 13796b526288Smrg# This is free software; see the source for copying conditions. There is NO 13806b526288Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13816b526288Smrg 13826b526288Smrg# This program is free software: you can redistribute it and/or modify 13836b526288Smrg# it under the terms of the GNU General Public License as published by 13846b526288Smrg# the Free Software Foundation, either version 3 of the License, or 13856b526288Smrg# (at your option) any later version. 13866b526288Smrg 13876b526288Smrg# This program is distributed in the hope that it will be useful, 13886b526288Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 13896b526288Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13906b526288Smrg# GNU General Public License for more details. 13916b526288Smrg 13926b526288Smrg# You should have received a copy of the GNU General Public License 13936b526288Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 13946b526288Smrg 13956b526288Smrg# Please report bugs or propose patches to gary@gnu.org. 13966b526288Smrg 13976b526288Smrg 13986b526288Smrg## ------ ## 13996b526288Smrg## Usage. ## 14006b526288Smrg## ------ ## 14016b526288Smrg 14026b526288Smrg# This file is a library for parsing options in your shell scripts along 14036b526288Smrg# with assorted other useful supporting features that you can make use 14046b526288Smrg# of too. 14056b526288Smrg# 14066b526288Smrg# For the simplest scripts you might need only: 14076b526288Smrg# 14086b526288Smrg# #!/bin/sh 14096b526288Smrg# . relative/path/to/funclib.sh 14106b526288Smrg# . relative/path/to/options-parser 14116b526288Smrg# scriptversion=1.0 14126b526288Smrg# func_options ${1+"$@"} 14136b526288Smrg# eval set dummy "$func_options_result"; shift 14146b526288Smrg# ...rest of your script... 14156b526288Smrg# 14166b526288Smrg# In order for the '--version' option to work, you will need to have a 14176b526288Smrg# suitably formatted comment like the one at the top of this file 14186b526288Smrg# starting with '# Written by ' and ending with '# warranty; '. 14196b526288Smrg# 14206b526288Smrg# For '-h' and '--help' to work, you will also need a one line 14216b526288Smrg# description of your script's purpose in a comment directly above the 14226b526288Smrg# '# Written by ' line, like the one at the top of this file. 14236b526288Smrg# 14246b526288Smrg# The default options also support '--debug', which will turn on shell 14256b526288Smrg# execution tracing (see the comment above debug_cmd below for another 14266b526288Smrg# use), and '--verbose' and the func_verbose function to allow your script 14276b526288Smrg# to display verbose messages only when your user has specified 14286b526288Smrg# '--verbose'. 14296b526288Smrg# 14306b526288Smrg# After sourcing this file, you can plug processing for additional 14316b526288Smrg# options by amending the variables from the 'Configuration' section 14326b526288Smrg# below, and following the instructions in the 'Option parsing' 14336b526288Smrg# section further down. 14346b526288Smrg 14356b526288Smrg## -------------- ## 14366b526288Smrg## Configuration. ## 14376b526288Smrg## -------------- ## 14386b526288Smrg 14396b526288Smrg# You should override these variables in your script after sourcing this 14406b526288Smrg# file so that they reflect the customisations you have added to the 14416b526288Smrg# option parser. 14426b526288Smrg 14436b526288Smrg# The usage line for option parsing errors and the start of '-h' and 14446b526288Smrg# '--help' output messages. You can embed shell variables for delayed 14456b526288Smrg# expansion at the time the message is displayed, but you will need to 14466b526288Smrg# quote other shell meta-characters carefully to prevent them being 14476b526288Smrg# expanded when the contents are evaled. 14486b526288Smrgusage='$progpath [OPTION]...' 14496b526288Smrg 14506b526288Smrg# Short help message in response to '-h' and '--help'. Add to this or 14516b526288Smrg# override it after sourcing this library to reflect the full set of 14526b526288Smrg# options your script accepts. 14536b526288Smrgusage_message="\ 14546b526288Smrg --debug enable verbose shell tracing 14556b526288Smrg -W, --warnings=CATEGORY 14566b526288Smrg report the warnings falling in CATEGORY [all] 14576b526288Smrg -v, --verbose verbosely report processing 14586b526288Smrg --version print version information and exit 14596b526288Smrg -h, --help print short or long help message and exit 14606b526288Smrg" 14616b526288Smrg 14626b526288Smrg# Additional text appended to 'usage_message' in response to '--help'. 14636b526288Smrglong_help_message=" 14646b526288SmrgWarning categories include: 14656b526288Smrg 'all' show all warnings 14666b526288Smrg 'none' turn off all the warnings 14676b526288Smrg 'error' warnings are treated as fatal errors" 14686b526288Smrg 14696b526288Smrg# Help message printed before fatal option parsing errors. 14706b526288Smrgfatal_help="Try '\$progname --help' for more information." 14716b526288Smrg 14726b526288Smrg 14736b526288Smrg 14746b526288Smrg## ------------------------- ## 14756b526288Smrg## Hook function management. ## 14766b526288Smrg## ------------------------- ## 14776b526288Smrg 14786b526288Smrg# This section contains functions for adding, removing, and running hooks 14796b526288Smrg# to the main code. A hook is just a named list of of function, that can 14806b526288Smrg# be run in order later on. 14816b526288Smrg 14826b526288Smrg# func_hookable FUNC_NAME 14836b526288Smrg# ----------------------- 14846b526288Smrg# Declare that FUNC_NAME will run hooks added with 14856b526288Smrg# 'func_add_hook FUNC_NAME ...'. 14866b526288Smrgfunc_hookable () 14876b526288Smrg{ 14886b526288Smrg $debug_cmd 14896b526288Smrg 14906b526288Smrg func_append hookable_fns " $1" 14916b526288Smrg} 14926b526288Smrg 14936b526288Smrg 14946b526288Smrg# func_add_hook FUNC_NAME HOOK_FUNC 14956b526288Smrg# --------------------------------- 14966b526288Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 14976b526288Smrg# first have been declared "hookable" by a call to 'func_hookable'. 14986b526288Smrgfunc_add_hook () 14996b526288Smrg{ 15006b526288Smrg $debug_cmd 15016b526288Smrg 15026b526288Smrg case " $hookable_fns " in 15036b526288Smrg *" $1 "*) ;; 15046b526288Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 15056b526288Smrg esac 15066b526288Smrg 15076b526288Smrg eval func_append ${1}_hooks '" $2"' 15086b526288Smrg} 15096b526288Smrg 15106b526288Smrg 15116b526288Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 15126b526288Smrg# ------------------------------------ 15136b526288Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 15146b526288Smrgfunc_remove_hook () 15156b526288Smrg{ 15166b526288Smrg $debug_cmd 15176b526288Smrg 15186b526288Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 15196b526288Smrg} 15206b526288Smrg 15216b526288Smrg 15226b526288Smrg# func_run_hooks FUNC_NAME [ARG]... 15236b526288Smrg# --------------------------------- 15246b526288Smrg# Run all hook functions registered to FUNC_NAME. 15256b526288Smrg# It is assumed that the list of hook functions contains nothing more 15266b526288Smrg# than a whitespace-delimited list of legal shell function names, and 15276b526288Smrg# no effort is wasted trying to catch shell meta-characters or preserve 15286b526288Smrg# whitespace. 15296b526288Smrgfunc_run_hooks () 15306b526288Smrg{ 15316b526288Smrg $debug_cmd 15326b526288Smrg 15336b526288Smrg case " $hookable_fns " in 15346b526288Smrg *" $1 "*) ;; 15356b526288Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 15366b526288Smrg esac 15376b526288Smrg 15386b526288Smrg eval _G_hook_fns=\$$1_hooks; shift 15396b526288Smrg 15406b526288Smrg for _G_hook in $_G_hook_fns; do 15416b526288Smrg eval $_G_hook '"$@"' 15426b526288Smrg 15436b526288Smrg # store returned options list back into positional 15446b526288Smrg # parameters for next 'cmd' execution. 15456b526288Smrg eval _G_hook_result=\$${_G_hook}_result 15466b526288Smrg eval set dummy "$_G_hook_result"; shift 15476b526288Smrg done 15486b526288Smrg 15496b526288Smrg func_quote_for_eval ${1+"$@"} 15506b526288Smrg func_run_hooks_result=$func_quote_for_eval_result 15516b526288Smrg} 15526b526288Smrg 15536b526288Smrg 15546b526288Smrg 15556b526288Smrg## --------------- ## 15566b526288Smrg## Option parsing. ## 15576b526288Smrg## --------------- ## 15586b526288Smrg 15596b526288Smrg# In order to add your own option parsing hooks, you must accept the 15606b526288Smrg# full positional parameter list in your hook function, remove any 15616b526288Smrg# options that you action, and then pass back the remaining unprocessed 15626b526288Smrg# options in '<hooked_function_name>_result', escaped suitably for 15636b526288Smrg# 'eval'. Like this: 15646b526288Smrg# 15656b526288Smrg# my_options_prep () 15666b526288Smrg# { 15676b526288Smrg# $debug_cmd 15686b526288Smrg# 15696b526288Smrg# # Extend the existing usage message. 15706b526288Smrg# usage_message=$usage_message' 15716b526288Smrg# -s, --silent don'\''t print informational messages 15726b526288Smrg# ' 15736b526288Smrg# 15746b526288Smrg# func_quote_for_eval ${1+"$@"} 15756b526288Smrg# my_options_prep_result=$func_quote_for_eval_result 15766b526288Smrg# } 15776b526288Smrg# func_add_hook func_options_prep my_options_prep 15786b526288Smrg# 15796b526288Smrg# 15806b526288Smrg# my_silent_option () 15816b526288Smrg# { 15826b526288Smrg# $debug_cmd 15836b526288Smrg# 15846b526288Smrg# # Note that for efficiency, we parse as many options as we can 15856b526288Smrg# # recognise in a loop before passing the remainder back to the 15866b526288Smrg# # caller on the first unrecognised argument we encounter. 15876b526288Smrg# while test $# -gt 0; do 15886b526288Smrg# opt=$1; shift 15896b526288Smrg# case $opt in 15906b526288Smrg# --silent|-s) opt_silent=: ;; 15916b526288Smrg# # Separate non-argument short options: 15926b526288Smrg# -s*) func_split_short_opt "$_G_opt" 15936b526288Smrg# set dummy "$func_split_short_opt_name" \ 15946b526288Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 15956b526288Smrg# shift 15966b526288Smrg# ;; 15976b526288Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 15986b526288Smrg# esac 15996b526288Smrg# done 16006b526288Smrg# 16016b526288Smrg# func_quote_for_eval ${1+"$@"} 16026b526288Smrg# my_silent_option_result=$func_quote_for_eval_result 16036b526288Smrg# } 16046b526288Smrg# func_add_hook func_parse_options my_silent_option 16056b526288Smrg# 16066b526288Smrg# 16076b526288Smrg# my_option_validation () 16086b526288Smrg# { 16096b526288Smrg# $debug_cmd 16106b526288Smrg# 16116b526288Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 16126b526288Smrg# '--silent' and '--verbose' options are mutually exclusive." 16136b526288Smrg# 16146b526288Smrg# func_quote_for_eval ${1+"$@"} 16156b526288Smrg# my_option_validation_result=$func_quote_for_eval_result 16166b526288Smrg# } 16176b526288Smrg# func_add_hook func_validate_options my_option_validation 16186b526288Smrg# 16196b526288Smrg# You'll alse need to manually amend $usage_message to reflect the extra 16206b526288Smrg# options you parse. It's preferable to append if you can, so that 16216b526288Smrg# multiple option parsing hooks can be added safely. 16226b526288Smrg 16236b526288Smrg 16246b526288Smrg# func_options [ARG]... 16256b526288Smrg# --------------------- 16266b526288Smrg# All the functions called inside func_options are hookable. See the 16276b526288Smrg# individual implementations for details. 16286b526288Smrgfunc_hookable func_options 16296b526288Smrgfunc_options () 16306b526288Smrg{ 16316b526288Smrg $debug_cmd 16326b526288Smrg 16336b526288Smrg func_options_prep ${1+"$@"} 16346b526288Smrg eval func_parse_options \ 16356b526288Smrg ${func_options_prep_result+"$func_options_prep_result"} 16366b526288Smrg eval func_validate_options \ 16376b526288Smrg ${func_parse_options_result+"$func_parse_options_result"} 16386b526288Smrg 16396b526288Smrg eval func_run_hooks func_options \ 16406b526288Smrg ${func_validate_options_result+"$func_validate_options_result"} 16416b526288Smrg 16426b526288Smrg # save modified positional parameters for caller 16436b526288Smrg func_options_result=$func_run_hooks_result 16446b526288Smrg} 16456b526288Smrg 16466b526288Smrg 16476b526288Smrg# func_options_prep [ARG]... 16486b526288Smrg# -------------------------- 16496b526288Smrg# All initialisations required before starting the option parse loop. 16506b526288Smrg# Note that when calling hook functions, we pass through the list of 16516b526288Smrg# positional parameters. If a hook function modifies that list, and 16526b526288Smrg# needs to propogate that back to rest of this script, then the complete 16536b526288Smrg# modified list must be put in 'func_run_hooks_result' before 16546b526288Smrg# returning. 16556b526288Smrgfunc_hookable func_options_prep 16566b526288Smrgfunc_options_prep () 16576b526288Smrg{ 16586b526288Smrg $debug_cmd 16596b526288Smrg 16606b526288Smrg # Option defaults: 16616b526288Smrg opt_verbose=false 16626b526288Smrg opt_warning_types= 16636b526288Smrg 16646b526288Smrg func_run_hooks func_options_prep ${1+"$@"} 16656b526288Smrg 16666b526288Smrg # save modified positional parameters for caller 16676b526288Smrg func_options_prep_result=$func_run_hooks_result 16686b526288Smrg} 16696b526288Smrg 16706b526288Smrg 16716b526288Smrg# func_parse_options [ARG]... 16726b526288Smrg# --------------------------- 16736b526288Smrg# The main option parsing loop. 16746b526288Smrgfunc_hookable func_parse_options 16756b526288Smrgfunc_parse_options () 16766b526288Smrg{ 16776b526288Smrg $debug_cmd 16786b526288Smrg 16796b526288Smrg func_parse_options_result= 16806b526288Smrg 16816b526288Smrg # this just eases exit handling 16826b526288Smrg while test $# -gt 0; do 16836b526288Smrg # Defer to hook functions for initial option parsing, so they 16846b526288Smrg # get priority in the event of reusing an option name. 16856b526288Smrg func_run_hooks func_parse_options ${1+"$@"} 16866b526288Smrg 16876b526288Smrg # Adjust func_parse_options positional parameters to match 16886b526288Smrg eval set dummy "$func_run_hooks_result"; shift 16896b526288Smrg 16906b526288Smrg # Break out of the loop if we already parsed every option. 16916b526288Smrg test $# -gt 0 || break 16926b526288Smrg 16936b526288Smrg _G_opt=$1 16946b526288Smrg shift 16956b526288Smrg case $_G_opt in 16966b526288Smrg --debug|-x) debug_cmd='set -x' 16976b526288Smrg func_echo "enabling shell trace mode" 16986b526288Smrg $debug_cmd 16996b526288Smrg ;; 17006b526288Smrg 17016b526288Smrg --no-warnings|--no-warning|--no-warn) 17026b526288Smrg set dummy --warnings none ${1+"$@"} 17036b526288Smrg shift 17046b526288Smrg ;; 17056b526288Smrg 17066b526288Smrg --warnings|--warning|-W) 17076b526288Smrg test $# = 0 && func_missing_arg $_G_opt && break 17086b526288Smrg case " $warning_categories $1" in 17096b526288Smrg *" $1 "*) 17106b526288Smrg # trailing space prevents matching last $1 above 17116b526288Smrg func_append_uniq opt_warning_types " $1" 17126b526288Smrg ;; 17136b526288Smrg *all) 17146b526288Smrg opt_warning_types=$warning_categories 17156b526288Smrg ;; 17166b526288Smrg *none) 17176b526288Smrg opt_warning_types=none 17186b526288Smrg warning_func=: 17196b526288Smrg ;; 17206b526288Smrg *error) 17216b526288Smrg opt_warning_types=$warning_categories 17226b526288Smrg warning_func=func_fatal_error 17236b526288Smrg ;; 17246b526288Smrg *) 17256b526288Smrg func_fatal_error \ 17266b526288Smrg "unsupported warning category: '$1'" 17276b526288Smrg ;; 17286b526288Smrg esac 17296b526288Smrg shift 17306b526288Smrg ;; 17316b526288Smrg 17326b526288Smrg --verbose|-v) opt_verbose=: ;; 17336b526288Smrg --version) func_version ;; 17346b526288Smrg -\?|-h) func_usage ;; 17356b526288Smrg --help) func_help ;; 17366b526288Smrg 17376b526288Smrg # Separate optargs to long options (plugins may need this): 17386b526288Smrg --*=*) func_split_equals "$_G_opt" 17396b526288Smrg set dummy "$func_split_equals_lhs" \ 17406b526288Smrg "$func_split_equals_rhs" ${1+"$@"} 17416b526288Smrg shift 17426b526288Smrg ;; 17436b526288Smrg 17446b526288Smrg # Separate optargs to short options: 17456b526288Smrg -W*) 17466b526288Smrg func_split_short_opt "$_G_opt" 17476b526288Smrg set dummy "$func_split_short_opt_name" \ 17486b526288Smrg "$func_split_short_opt_arg" ${1+"$@"} 17496b526288Smrg shift 17506b526288Smrg ;; 17516b526288Smrg 17526b526288Smrg # Separate non-argument short options: 17536b526288Smrg -\?*|-h*|-v*|-x*) 17546b526288Smrg func_split_short_opt "$_G_opt" 17556b526288Smrg set dummy "$func_split_short_opt_name" \ 17566b526288Smrg "-$func_split_short_opt_arg" ${1+"$@"} 17576b526288Smrg shift 17586b526288Smrg ;; 17596b526288Smrg 17606b526288Smrg --) break ;; 17616b526288Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 17626b526288Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17636b526288Smrg esac 17646b526288Smrg done 17656b526288Smrg 17666b526288Smrg # save modified positional parameters for caller 17676b526288Smrg func_quote_for_eval ${1+"$@"} 17686b526288Smrg func_parse_options_result=$func_quote_for_eval_result 17696b526288Smrg} 17706b526288Smrg 17716b526288Smrg 17726b526288Smrg# func_validate_options [ARG]... 17736b526288Smrg# ------------------------------ 17746b526288Smrg# Perform any sanity checks on option settings and/or unconsumed 17756b526288Smrg# arguments. 17766b526288Smrgfunc_hookable func_validate_options 17776b526288Smrgfunc_validate_options () 17786b526288Smrg{ 17796b526288Smrg $debug_cmd 17806b526288Smrg 17816b526288Smrg # Display all warnings if -W was not given. 17826b526288Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 17836b526288Smrg 17846b526288Smrg func_run_hooks func_validate_options ${1+"$@"} 17856b526288Smrg 17866b526288Smrg # Bail if the options were screwed! 17876b526288Smrg $exit_cmd $EXIT_FAILURE 17886b526288Smrg 17896b526288Smrg # save modified positional parameters for caller 17906b526288Smrg func_validate_options_result=$func_run_hooks_result 17916b526288Smrg} 17926b526288Smrg 17936b526288Smrg 17946b526288Smrg 17956b526288Smrg## ----------------- ## 17966b526288Smrg## Helper functions. ## 17976b526288Smrg## ----------------- ## 17986b526288Smrg 17996b526288Smrg# This section contains the helper functions used by the rest of the 18006b526288Smrg# hookable option parser framework in ascii-betical order. 18016b526288Smrg 18026b526288Smrg 18036b526288Smrg# func_fatal_help ARG... 18046b526288Smrg# ---------------------- 18056b526288Smrg# Echo program name prefixed message to standard error, followed by 18066b526288Smrg# a help hint, and exit. 18076b526288Smrgfunc_fatal_help () 18086b526288Smrg{ 18096b526288Smrg $debug_cmd 18106b526288Smrg 18116b526288Smrg eval \$ECHO \""Usage: $usage"\" 18126b526288Smrg eval \$ECHO \""$fatal_help"\" 18136b526288Smrg func_error ${1+"$@"} 18146b526288Smrg exit $EXIT_FAILURE 18156b526288Smrg} 18166b526288Smrg 18176b526288Smrg 18186b526288Smrg# func_help 18196b526288Smrg# --------- 18206b526288Smrg# Echo long help message to standard output and exit. 18216b526288Smrgfunc_help () 18226b526288Smrg{ 18236b526288Smrg $debug_cmd 18246b526288Smrg 18256b526288Smrg func_usage_message 18266b526288Smrg $ECHO "$long_help_message" 18276b526288Smrg exit 0 18286b526288Smrg} 18296b526288Smrg 18306b526288Smrg 18316b526288Smrg# func_missing_arg ARGNAME 18326b526288Smrg# ------------------------ 18336b526288Smrg# Echo program name prefixed message to standard error and set global 18346b526288Smrg# exit_cmd. 18356b526288Smrgfunc_missing_arg () 18366b526288Smrg{ 18376b526288Smrg $debug_cmd 18386b526288Smrg 18396b526288Smrg func_error "Missing argument for '$1'." 18406b526288Smrg exit_cmd=exit 18416b526288Smrg} 18426b526288Smrg 18436b526288Smrg 18446b526288Smrg# func_split_equals STRING 18456b526288Smrg# ------------------------ 18466b526288Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 18476b526288Smrg# splitting STRING at the '=' sign. 18486b526288Smrgtest -z "$_G_HAVE_XSI_OPS" \ 18496b526288Smrg && (eval 'x=a/b/c; 18506b526288Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 18516b526288Smrg && _G_HAVE_XSI_OPS=yes 18526b526288Smrg 18536b526288Smrgif test yes = "$_G_HAVE_XSI_OPS" 18546b526288Smrgthen 18556b526288Smrg # This is an XSI compatible shell, allowing a faster implementation... 18566b526288Smrg eval 'func_split_equals () 18576b526288Smrg { 18586b526288Smrg $debug_cmd 18596b526288Smrg 18606b526288Smrg func_split_equals_lhs=${1%%=*} 18616b526288Smrg func_split_equals_rhs=${1#*=} 18626b526288Smrg test "x$func_split_equals_lhs" = "x$1" \ 18636b526288Smrg && func_split_equals_rhs= 18646b526288Smrg }' 18656b526288Smrgelse 18666b526288Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 18676b526288Smrg func_split_equals () 18686b526288Smrg { 18696b526288Smrg $debug_cmd 18706b526288Smrg 18716b526288Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 18726b526288Smrg func_split_equals_rhs= 18736b526288Smrg test "x$func_split_equals_lhs" = "x$1" \ 18746b526288Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 18756b526288Smrg } 18766b526288Smrgfi #func_split_equals 18776b526288Smrg 18786b526288Smrg 18796b526288Smrg# func_split_short_opt SHORTOPT 18806b526288Smrg# ----------------------------- 18816b526288Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 18826b526288Smrg# variables after splitting SHORTOPT after the 2nd character. 18836b526288Smrgif test yes = "$_G_HAVE_XSI_OPS" 18846b526288Smrgthen 18856b526288Smrg # This is an XSI compatible shell, allowing a faster implementation... 18866b526288Smrg eval 'func_split_short_opt () 18876b526288Smrg { 18886b526288Smrg $debug_cmd 18896b526288Smrg 18906b526288Smrg func_split_short_opt_arg=${1#??} 18916b526288Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 18926b526288Smrg }' 18936b526288Smrgelse 18946b526288Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 18956b526288Smrg func_split_short_opt () 18966b526288Smrg { 18976b526288Smrg $debug_cmd 18986b526288Smrg 18996b526288Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 19006b526288Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 19016b526288Smrg } 19026b526288Smrgfi #func_split_short_opt 19036b526288Smrg 19046b526288Smrg 19056b526288Smrg# func_usage 19066b526288Smrg# ---------- 19076b526288Smrg# Echo short help message to standard output and exit. 19086b526288Smrgfunc_usage () 19096b526288Smrg{ 19106b526288Smrg $debug_cmd 19116b526288Smrg 19126b526288Smrg func_usage_message 19136b526288Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 19146b526288Smrg exit 0 19156b526288Smrg} 19166b526288Smrg 19176b526288Smrg 19186b526288Smrg# func_usage_message 19196b526288Smrg# ------------------ 19206b526288Smrg# Echo short help message to standard output. 19216b526288Smrgfunc_usage_message () 19226b526288Smrg{ 19236b526288Smrg $debug_cmd 19246b526288Smrg 19256b526288Smrg eval \$ECHO \""Usage: $usage"\" 19266b526288Smrg echo 19276b526288Smrg $SED -n 's|^# || 19286b526288Smrg /^Written by/{ 19296b526288Smrg x;p;x 19306b526288Smrg } 19316b526288Smrg h 19326b526288Smrg /^Written by/q' < "$progpath" 19336b526288Smrg echo 19346b526288Smrg eval \$ECHO \""$usage_message"\" 19356b526288Smrg} 19366b526288Smrg 19376b526288Smrg 19386b526288Smrg# func_version 19396b526288Smrg# ------------ 19406b526288Smrg# Echo version message to standard output and exit. 19416b526288Smrgfunc_version () 19426b526288Smrg{ 19436b526288Smrg $debug_cmd 19446b526288Smrg 19456b526288Smrg printf '%s\n' "$progname $scriptversion" 19466b526288Smrg $SED -n ' 19476b526288Smrg /(C)/!b go 19486b526288Smrg :more 19496b526288Smrg /\./!{ 19506b526288Smrg N 19516b526288Smrg s|\n# | | 19526b526288Smrg b more 19536b526288Smrg } 19546b526288Smrg :go 19556b526288Smrg /^# Written by /,/# warranty; / { 19566b526288Smrg s|^# || 19576b526288Smrg s|^# *$|| 19586b526288Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 19596b526288Smrg p 19606b526288Smrg } 19616b526288Smrg /^# Written by / { 19626b526288Smrg s|^# || 19636b526288Smrg p 19646b526288Smrg } 19656b526288Smrg /^warranty; /q' < "$progpath" 19666b526288Smrg 19676b526288Smrg exit $? 19686b526288Smrg} 19696b526288Smrg 19706b526288Smrg 19716b526288Smrg# Local variables: 19726b526288Smrg# mode: shell-script 19736b526288Smrg# sh-indentation: 2 19746b526288Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 19756b526288Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 19766b526288Smrg# time-stamp-time-zone: "UTC" 19776b526288Smrg# End: 19786b526288Smrg 19796b526288Smrg# Set a version string. 19806b526288Smrgscriptversion='(GNU libtool) 2.4.6' 19816b526288Smrg 19826b526288Smrg 19836b526288Smrg# func_echo ARG... 19846b526288Smrg# ---------------- 19856b526288Smrg# Libtool also displays the current mode in messages, so override 19866b526288Smrg# funclib.sh func_echo with this custom definition. 19876b526288Smrgfunc_echo () 19886b526288Smrg{ 19896b526288Smrg $debug_cmd 19906b526288Smrg 19916b526288Smrg _G_message=$* 19926b526288Smrg 19936b526288Smrg func_echo_IFS=$IFS 19946b526288Smrg IFS=$nl 19956b526288Smrg for _G_line in $_G_message; do 19966b526288Smrg IFS=$func_echo_IFS 19976b526288Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 19986b526288Smrg done 19996b526288Smrg IFS=$func_echo_IFS 20006b526288Smrg} 20016b526288Smrg 20026b526288Smrg 20036b526288Smrg# func_warning ARG... 20046b526288Smrg# ------------------- 20056b526288Smrg# Libtool warnings are not categorized, so override funclib.sh 20066b526288Smrg# func_warning with this simpler definition. 20076b526288Smrgfunc_warning () 20086b526288Smrg{ 20096b526288Smrg $debug_cmd 20106b526288Smrg 20116b526288Smrg $warning_func ${1+"$@"} 20126b526288Smrg} 20136b526288Smrg 20146b526288Smrg 20156b526288Smrg## ---------------- ## 20166b526288Smrg## Options parsing. ## 20176b526288Smrg## ---------------- ## 20186b526288Smrg 20196b526288Smrg# Hook in the functions to make sure our own options are parsed during 20206b526288Smrg# the option parsing loop. 20216b526288Smrg 20226b526288Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 20236b526288Smrg 20246b526288Smrg# Short help message in response to '-h'. 20256b526288Smrgusage_message="Options: 20266b526288Smrg --config show all configuration variables 20276b526288Smrg --debug enable verbose shell tracing 20286b526288Smrg -n, --dry-run display commands without modifying any files 20296b526288Smrg --features display basic configuration information and exit 20306b526288Smrg --mode=MODE use operation mode MODE 20316b526288Smrg --no-warnings equivalent to '-Wnone' 20326b526288Smrg --preserve-dup-deps don't remove duplicate dependency libraries 20336b526288Smrg --quiet, --silent don't print informational messages 20346b526288Smrg --tag=TAG use configuration variables from tag TAG 20356b526288Smrg -v, --verbose print more informational messages than default 20366b526288Smrg --version print version information 20376b526288Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 20386b526288Smrg -h, --help, --help-all print short, long, or detailed help message 20396b526288Smrg" 20406b526288Smrg 20416b526288Smrg# Additional text appended to 'usage_message' in response to '--help'. 20426b526288Smrgfunc_help () 20436b526288Smrg{ 20446b526288Smrg $debug_cmd 20456b526288Smrg 20466b526288Smrg func_usage_message 20476b526288Smrg $ECHO "$long_help_message 20486b526288Smrg 20496b526288SmrgMODE must be one of the following: 20506b526288Smrg 20516b526288Smrg clean remove files from the build directory 20526b526288Smrg compile compile a source file into a libtool object 20536b526288Smrg execute automatically set library path, then run a program 20546b526288Smrg finish complete the installation of libtool libraries 20556b526288Smrg install install libraries or executables 20566b526288Smrg link create a library or an executable 20576b526288Smrg uninstall remove libraries from an installed directory 20586b526288Smrg 20596b526288SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 20606b526288Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 20616b526288SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 20626b526288Smrg 20636b526288SmrgWhen reporting a bug, please describe a test case to reproduce it and 20646b526288Smrginclude the following information: 20656b526288Smrg 20666b526288Smrg host-triplet: $host 20676b526288Smrg shell: $SHELL 20686b526288Smrg compiler: $LTCC 20696b526288Smrg compiler flags: $LTCFLAGS 20706b526288Smrg linker: $LD (gnu? $with_gnu_ld) 20716b526288Smrg version: $progname (GNU libtool) 2.4.6 20726b526288Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 20736b526288Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 20746b526288Smrg 20756b526288SmrgReport bugs to <bug-libtool@gnu.org>. 20766b526288SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 20776b526288SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 20786b526288Smrg exit 0 20796b526288Smrg} 20806b526288Smrg 20816b526288Smrg 20826b526288Smrg# func_lo2o OBJECT-NAME 20836b526288Smrg# --------------------- 20846b526288Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 20856b526288Smrg# object suffix. 20866b526288Smrg 20876b526288Smrglo2o=s/\\.lo\$/.$objext/ 20886b526288Smrgo2lo=s/\\.$objext\$/.lo/ 20896b526288Smrg 20906b526288Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 20916b526288Smrg eval 'func_lo2o () 20926b526288Smrg { 20936b526288Smrg case $1 in 20946b526288Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 20956b526288Smrg * ) func_lo2o_result=$1 ;; 20966b526288Smrg esac 20976b526288Smrg }' 20986b526288Smrg 20996b526288Smrg # func_xform LIBOBJ-OR-SOURCE 21006b526288Smrg # --------------------------- 21016b526288Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 21026b526288Smrg # suffix to a '.lo' libtool-object suffix. 21036b526288Smrg eval 'func_xform () 21046b526288Smrg { 21056b526288Smrg func_xform_result=${1%.*}.lo 21066b526288Smrg }' 21076b526288Smrgelse 21086b526288Smrg # ...otherwise fall back to using sed. 21096b526288Smrg func_lo2o () 21106b526288Smrg { 21116b526288Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 21126b526288Smrg } 21136b526288Smrg 21146b526288Smrg func_xform () 21156b526288Smrg { 21166b526288Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 21176b526288Smrg } 21186b526288Smrgfi 21196b526288Smrg 21206b526288Smrg 21216b526288Smrg# func_fatal_configuration ARG... 21226b526288Smrg# ------------------------------- 21236b526288Smrg# Echo program name prefixed message to standard error, followed by 21246b526288Smrg# a configuration failure hint, and exit. 21256b526288Smrgfunc_fatal_configuration () 21266b526288Smrg{ 21276b526288Smrg func__fatal_error ${1+"$@"} \ 21286b526288Smrg "See the $PACKAGE documentation for more information." \ 21296b526288Smrg "Fatal configuration error." 21306b526288Smrg} 21316b526288Smrg 21326b526288Smrg 21336b526288Smrg# func_config 21346b526288Smrg# ----------- 21356b526288Smrg# Display the configuration for all the tags in this script. 21366b526288Smrgfunc_config () 21376b526288Smrg{ 21386b526288Smrg re_begincf='^# ### BEGIN LIBTOOL' 21396b526288Smrg re_endcf='^# ### END LIBTOOL' 21406b526288Smrg 21416b526288Smrg # Default configuration. 21426b526288Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 21436b526288Smrg 21446b526288Smrg # Now print the configurations for the tags. 21456b526288Smrg for tagname in $taglist; do 21466b526288Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 21476b526288Smrg done 21486b526288Smrg 21496b526288Smrg exit $? 21506b526288Smrg} 21516b526288Smrg 21526b526288Smrg 21536b526288Smrg# func_features 21546b526288Smrg# ------------- 21556b526288Smrg# Display the features supported by this script. 21566b526288Smrgfunc_features () 21576b526288Smrg{ 21586b526288Smrg echo "host: $host" 21596b526288Smrg if test yes = "$build_libtool_libs"; then 21606b526288Smrg echo "enable shared libraries" 21616b526288Smrg else 21626b526288Smrg echo "disable shared libraries" 21636b526288Smrg fi 21646b526288Smrg if test yes = "$build_old_libs"; then 21656b526288Smrg echo "enable static libraries" 21666b526288Smrg else 21676b526288Smrg echo "disable static libraries" 21686b526288Smrg fi 21696b526288Smrg 21706b526288Smrg exit $? 21716b526288Smrg} 21726b526288Smrg 21736b526288Smrg 21746b526288Smrg# func_enable_tag TAGNAME 21756b526288Smrg# ----------------------- 21766b526288Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 21776b526288Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 21786b526288Smrg# variable here. 21796b526288Smrgfunc_enable_tag () 21806b526288Smrg{ 21816b526288Smrg # Global variable: 21826b526288Smrg tagname=$1 21836b526288Smrg 21846b526288Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 21856b526288Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 21866b526288Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 21876b526288Smrg 21886b526288Smrg # Validate tagname. 21896b526288Smrg case $tagname in 21906b526288Smrg *[!-_A-Za-z0-9,/]*) 21916b526288Smrg func_fatal_error "invalid tag name: $tagname" 21926b526288Smrg ;; 21936b526288Smrg esac 21946b526288Smrg 21956b526288Smrg # Don't test for the "default" C tag, as we know it's 21966b526288Smrg # there but not specially marked. 21976b526288Smrg case $tagname in 21986b526288Smrg CC) ;; 21996b526288Smrg *) 22006b526288Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 22016b526288Smrg taglist="$taglist $tagname" 22026b526288Smrg 22036b526288Smrg # Evaluate the configuration. Be careful to quote the path 22046b526288Smrg # and the sed script, to avoid splitting on whitespace, but 22056b526288Smrg # also don't use non-portable quotes within backquotes within 22066b526288Smrg # quotes we have to do it in 2 steps: 22076b526288Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 22086b526288Smrg eval "$extractedcf" 22096b526288Smrg else 22106b526288Smrg func_error "ignoring unknown tag $tagname" 22116b526288Smrg fi 22126b526288Smrg ;; 22136b526288Smrg esac 22146b526288Smrg} 22156b526288Smrg 22166b526288Smrg 22176b526288Smrg# func_check_version_match 22186b526288Smrg# ------------------------ 22196b526288Smrg# Ensure that we are using m4 macros, and libtool script from the same 22206b526288Smrg# release of libtool. 22216b526288Smrgfunc_check_version_match () 22226b526288Smrg{ 22236b526288Smrg if test "$package_revision" != "$macro_revision"; then 22246b526288Smrg if test "$VERSION" != "$macro_version"; then 22256b526288Smrg if test -z "$macro_version"; then 22266b526288Smrg cat >&2 <<_LT_EOF 22276b526288Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22286b526288Smrg$progname: definition of this LT_INIT comes from an older release. 22296b526288Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22306b526288Smrg$progname: and run autoconf again. 22316b526288Smrg_LT_EOF 22326b526288Smrg else 22336b526288Smrg cat >&2 <<_LT_EOF 22346b526288Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22356b526288Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 22366b526288Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22376b526288Smrg$progname: and run autoconf again. 22386b526288Smrg_LT_EOF 22396b526288Smrg fi 22406b526288Smrg else 22416b526288Smrg cat >&2 <<_LT_EOF 22426b526288Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 22436b526288Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 22446b526288Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 22456b526288Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 22466b526288Smrg_LT_EOF 22476b526288Smrg fi 22486b526288Smrg 22496b526288Smrg exit $EXIT_MISMATCH 22506b526288Smrg fi 22516b526288Smrg} 22526b526288Smrg 22536b526288Smrg 22546b526288Smrg# libtool_options_prep [ARG]... 22556b526288Smrg# ----------------------------- 22566b526288Smrg# Preparation for options parsed by libtool. 22576b526288Smrglibtool_options_prep () 22586b526288Smrg{ 22596b526288Smrg $debug_mode 22606b526288Smrg 22616b526288Smrg # Option defaults: 22626b526288Smrg opt_config=false 22636b526288Smrg opt_dlopen= 22646b526288Smrg opt_dry_run=false 22656b526288Smrg opt_help=false 22666b526288Smrg opt_mode= 22676b526288Smrg opt_preserve_dup_deps=false 22686b526288Smrg opt_quiet=false 22696b526288Smrg 22706b526288Smrg nonopt= 22716b526288Smrg preserve_args= 22726b526288Smrg 22736b526288Smrg # Shorthand for --mode=foo, only valid as the first argument 22746b526288Smrg case $1 in 22756b526288Smrg clean|clea|cle|cl) 22766b526288Smrg shift; set dummy --mode clean ${1+"$@"}; shift 22776b526288Smrg ;; 22786b526288Smrg compile|compil|compi|comp|com|co|c) 22796b526288Smrg shift; set dummy --mode compile ${1+"$@"}; shift 22806b526288Smrg ;; 22816b526288Smrg execute|execut|execu|exec|exe|ex|e) 22826b526288Smrg shift; set dummy --mode execute ${1+"$@"}; shift 22836b526288Smrg ;; 22846b526288Smrg finish|finis|fini|fin|fi|f) 22856b526288Smrg shift; set dummy --mode finish ${1+"$@"}; shift 22866b526288Smrg ;; 22876b526288Smrg install|instal|insta|inst|ins|in|i) 22886b526288Smrg shift; set dummy --mode install ${1+"$@"}; shift 22896b526288Smrg ;; 22906b526288Smrg link|lin|li|l) 22916b526288Smrg shift; set dummy --mode link ${1+"$@"}; shift 22926b526288Smrg ;; 22936b526288Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 22946b526288Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 22956b526288Smrg ;; 22966b526288Smrg esac 22976b526288Smrg 22986b526288Smrg # Pass back the list of options. 22996b526288Smrg func_quote_for_eval ${1+"$@"} 23006b526288Smrg libtool_options_prep_result=$func_quote_for_eval_result 23016b526288Smrg} 23026b526288Smrgfunc_add_hook func_options_prep libtool_options_prep 23036b526288Smrg 23046b526288Smrg 23056b526288Smrg# libtool_parse_options [ARG]... 23066b526288Smrg# --------------------------------- 23076b526288Smrg# Provide handling for libtool specific options. 23086b526288Smrglibtool_parse_options () 23096b526288Smrg{ 23106b526288Smrg $debug_cmd 23116b526288Smrg 23126b526288Smrg # Perform our own loop to consume as many options as possible in 23136b526288Smrg # each iteration. 23146b526288Smrg while test $# -gt 0; do 23156b526288Smrg _G_opt=$1 23166b526288Smrg shift 23176b526288Smrg case $_G_opt in 23186b526288Smrg --dry-run|--dryrun|-n) 23196b526288Smrg opt_dry_run=: 23206b526288Smrg ;; 23216b526288Smrg 23226b526288Smrg --config) func_config ;; 23236b526288Smrg 23246b526288Smrg --dlopen|-dlopen) 23256b526288Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 23266b526288Smrg}$1" 23276b526288Smrg shift 23286b526288Smrg ;; 23296b526288Smrg 23306b526288Smrg --preserve-dup-deps) 23316b526288Smrg opt_preserve_dup_deps=: ;; 23326b526288Smrg 23336b526288Smrg --features) func_features ;; 23346b526288Smrg 23356b526288Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 23366b526288Smrg 23376b526288Smrg --help) opt_help=: ;; 23386b526288Smrg 23396b526288Smrg --help-all) opt_help=': help-all' ;; 23406b526288Smrg 23416b526288Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 23426b526288Smrg opt_mode=$1 23436b526288Smrg case $1 in 23446b526288Smrg # Valid mode arguments: 23456b526288Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 23466b526288Smrg 23476b526288Smrg # Catch anything else as an error 23486b526288Smrg *) func_error "invalid argument for $_G_opt" 23496b526288Smrg exit_cmd=exit 23506b526288Smrg break 23516b526288Smrg ;; 23526b526288Smrg esac 23536b526288Smrg shift 23546b526288Smrg ;; 23556b526288Smrg 23566b526288Smrg --no-silent|--no-quiet) 23576b526288Smrg opt_quiet=false 23586b526288Smrg func_append preserve_args " $_G_opt" 23596b526288Smrg ;; 23606b526288Smrg 23616b526288Smrg --no-warnings|--no-warning|--no-warn) 23626b526288Smrg opt_warning=false 23636b526288Smrg func_append preserve_args " $_G_opt" 23646b526288Smrg ;; 23656b526288Smrg 23666b526288Smrg --no-verbose) 23676b526288Smrg opt_verbose=false 23686b526288Smrg func_append preserve_args " $_G_opt" 23696b526288Smrg ;; 23706b526288Smrg 23716b526288Smrg --silent|--quiet) 23726b526288Smrg opt_quiet=: 23736b526288Smrg opt_verbose=false 23746b526288Smrg func_append preserve_args " $_G_opt" 23756b526288Smrg ;; 23766b526288Smrg 23776b526288Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 23786b526288Smrg opt_tag=$1 23796b526288Smrg func_append preserve_args " $_G_opt $1" 23806b526288Smrg func_enable_tag "$1" 23816b526288Smrg shift 23826b526288Smrg ;; 23836b526288Smrg 23846b526288Smrg --verbose|-v) opt_quiet=false 23856b526288Smrg opt_verbose=: 23866b526288Smrg func_append preserve_args " $_G_opt" 23876b526288Smrg ;; 23886b526288Smrg 23896b526288Smrg # An option not handled by this hook function: 23906b526288Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 23916b526288Smrg esac 23926b526288Smrg done 23936b526288Smrg 23946b526288Smrg 23956b526288Smrg # save modified positional parameters for caller 23966b526288Smrg func_quote_for_eval ${1+"$@"} 23976b526288Smrg libtool_parse_options_result=$func_quote_for_eval_result 23986b526288Smrg} 23996b526288Smrgfunc_add_hook func_parse_options libtool_parse_options 24006b526288Smrg 24016b526288Smrg 24026b526288Smrg 24036b526288Smrg# libtool_validate_options [ARG]... 24046b526288Smrg# --------------------------------- 24056b526288Smrg# Perform any sanity checks on option settings and/or unconsumed 24066b526288Smrg# arguments. 24076b526288Smrglibtool_validate_options () 24086b526288Smrg{ 24096b526288Smrg # save first non-option argument 24106b526288Smrg if test 0 -lt $#; then 24116b526288Smrg nonopt=$1 24126b526288Smrg shift 24136b526288Smrg fi 24146b526288Smrg 24156b526288Smrg # preserve --debug 24166b526288Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 24176b526288Smrg 24186b526288Smrg case $host in 24196b526288Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 24206b526288Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 24216b526288Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 24226b526288Smrg # don't eliminate duplications in $postdeps and $predeps 24236b526288Smrg opt_duplicate_compiler_generated_deps=: 24246b526288Smrg ;; 24256b526288Smrg *) 24266b526288Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 24276b526288Smrg ;; 24286b526288Smrg esac 24296b526288Smrg 24306b526288Smrg $opt_help || { 24316b526288Smrg # Sanity checks first: 24326b526288Smrg func_check_version_match 24336b526288Smrg 24346b526288Smrg test yes != "$build_libtool_libs" \ 24356b526288Smrg && test yes != "$build_old_libs" \ 24366b526288Smrg && func_fatal_configuration "not configured to build any kind of library" 24376b526288Smrg 24386b526288Smrg # Darwin sucks 24396b526288Smrg eval std_shrext=\"$shrext_cmds\" 24406b526288Smrg 24416b526288Smrg # Only execute mode is allowed to have -dlopen flags. 24426b526288Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 24436b526288Smrg func_error "unrecognized option '-dlopen'" 24446b526288Smrg $ECHO "$help" 1>&2 24456b526288Smrg exit $EXIT_FAILURE 24466b526288Smrg fi 24476b526288Smrg 24486b526288Smrg # Change the help message to a mode-specific one. 24496b526288Smrg generic_help=$help 24506b526288Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 24516b526288Smrg } 24526b526288Smrg 24536b526288Smrg # Pass back the unparsed argument list 24546b526288Smrg func_quote_for_eval ${1+"$@"} 24556b526288Smrg libtool_validate_options_result=$func_quote_for_eval_result 24566b526288Smrg} 24576b526288Smrgfunc_add_hook func_validate_options libtool_validate_options 24586b526288Smrg 24596b526288Smrg 24606b526288Smrg# Process options as early as possible so that --help and --version 24616b526288Smrg# can return quickly. 24626b526288Smrgfunc_options ${1+"$@"} 24636b526288Smrgeval set dummy "$func_options_result"; shift 24646b526288Smrg 24656b526288Smrg 24666b526288Smrg 24676b526288Smrg## ----------- ## 24686b526288Smrg## Main. ## 24696b526288Smrg## ----------- ## 24706b526288Smrg 24716b526288Smrgmagic='%%%MAGIC variable%%%' 24726b526288Smrgmagic_exe='%%%MAGIC EXE variable%%%' 247311a29bacSmrg 247411a29bacSmrg# Global variables. 247511a29bacSmrgextracted_archives= 247611a29bacSmrgextracted_serial=0 247711a29bacSmrg 24786b526288Smrg# If this variable is set in any of the actions, the command in it 24796b526288Smrg# will be execed at the end. This prevents here-documents from being 24806b526288Smrg# left over by shells. 24816b526288Smrgexec_cmd= 24826b526288Smrg 24836b526288Smrg 24846b526288Smrg# A function that is used when there is no print builtin or printf. 24856b526288Smrgfunc_fallback_echo () 24866b526288Smrg{ 24876b526288Smrg eval 'cat <<_LTECHO_EOF 24886b526288Smrg$1 24896b526288Smrg_LTECHO_EOF' 24906b526288Smrg} 24916b526288Smrg 24926b526288Smrg# func_generated_by_libtool 24936b526288Smrg# True iff stdin has been generated by Libtool. This function is only 24946b526288Smrg# a basic sanity check; it will hardly flush out determined imposters. 24956b526288Smrgfunc_generated_by_libtool_p () 24966b526288Smrg{ 24976b526288Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 24986b526288Smrg} 24996b526288Smrg 25006b526288Smrg# func_lalib_p file 25016b526288Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25026b526288Smrg# This function is only a basic sanity check; it will hardly flush out 25036b526288Smrg# determined imposters. 25046b526288Smrgfunc_lalib_p () 25056b526288Smrg{ 25066b526288Smrg test -f "$1" && 25076b526288Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 25086b526288Smrg} 25096b526288Smrg 25106b526288Smrg# func_lalib_unsafe_p file 25116b526288Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25126b526288Smrg# This function implements the same check as func_lalib_p without 25136b526288Smrg# resorting to external programs. To this end, it redirects stdin and 25146b526288Smrg# closes it afterwards, without saving the original file descriptor. 25156b526288Smrg# As a safety measure, use it only where a negative result would be 25166b526288Smrg# fatal anyway. Works if 'file' does not exist. 25176b526288Smrgfunc_lalib_unsafe_p () 25186b526288Smrg{ 25196b526288Smrg lalib_p=no 25206b526288Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 25216b526288Smrg for lalib_p_l in 1 2 3 4 25226b526288Smrg do 25236b526288Smrg read lalib_p_line 25246b526288Smrg case $lalib_p_line in 25256b526288Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 25266b526288Smrg esac 25276b526288Smrg done 25286b526288Smrg exec 0<&5 5<&- 25296b526288Smrg fi 25306b526288Smrg test yes = "$lalib_p" 25316b526288Smrg} 25326b526288Smrg 25336b526288Smrg# func_ltwrapper_script_p file 25346b526288Smrg# True iff FILE is a libtool wrapper script 25356b526288Smrg# This function is only a basic sanity check; it will hardly flush out 25366b526288Smrg# determined imposters. 25376b526288Smrgfunc_ltwrapper_script_p () 25386b526288Smrg{ 25396b526288Smrg test -f "$1" && 25406b526288Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 25416b526288Smrg} 25426b526288Smrg 25436b526288Smrg# func_ltwrapper_executable_p file 25446b526288Smrg# True iff FILE is a libtool wrapper executable 25456b526288Smrg# This function is only a basic sanity check; it will hardly flush out 25466b526288Smrg# determined imposters. 25476b526288Smrgfunc_ltwrapper_executable_p () 25486b526288Smrg{ 25496b526288Smrg func_ltwrapper_exec_suffix= 25506b526288Smrg case $1 in 25516b526288Smrg *.exe) ;; 25526b526288Smrg *) func_ltwrapper_exec_suffix=.exe ;; 25536b526288Smrg esac 25546b526288Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 25556b526288Smrg} 25566b526288Smrg 25576b526288Smrg# func_ltwrapper_scriptname file 25586b526288Smrg# Assumes file is an ltwrapper_executable 25596b526288Smrg# uses $file to determine the appropriate filename for a 25606b526288Smrg# temporary ltwrapper_script. 25616b526288Smrgfunc_ltwrapper_scriptname () 25626b526288Smrg{ 25636b526288Smrg func_dirname_and_basename "$1" "" "." 25646b526288Smrg func_stripname '' '.exe' "$func_basename_result" 25656b526288Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 25666b526288Smrg} 25676b526288Smrg 25686b526288Smrg# func_ltwrapper_p file 25696b526288Smrg# True iff FILE is a libtool wrapper script or wrapper executable 25706b526288Smrg# This function is only a basic sanity check; it will hardly flush out 25716b526288Smrg# determined imposters. 25726b526288Smrgfunc_ltwrapper_p () 25736b526288Smrg{ 25746b526288Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 25756b526288Smrg} 25766b526288Smrg 25776b526288Smrg 25786b526288Smrg# func_execute_cmds commands fail_cmd 25796b526288Smrg# Execute tilde-delimited COMMANDS. 25806b526288Smrg# If FAIL_CMD is given, eval that upon failure. 25816b526288Smrg# FAIL_CMD may read-access the current command in variable CMD! 25826b526288Smrgfunc_execute_cmds () 25836b526288Smrg{ 25846b526288Smrg $debug_cmd 25856b526288Smrg 25866b526288Smrg save_ifs=$IFS; IFS='~' 25876b526288Smrg for cmd in $1; do 25886b526288Smrg IFS=$sp$nl 25896b526288Smrg eval cmd=\"$cmd\" 25906b526288Smrg IFS=$save_ifs 25916b526288Smrg func_show_eval "$cmd" "${2-:}" 25926b526288Smrg done 25936b526288Smrg IFS=$save_ifs 25946b526288Smrg} 25956b526288Smrg 25966b526288Smrg 25976b526288Smrg# func_source file 25986b526288Smrg# Source FILE, adding directory component if necessary. 25996b526288Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 26006b526288Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 26016b526288Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 26026b526288Smrg# 'FILE.' does not work on cygwin managed mounts. 26036b526288Smrgfunc_source () 26046b526288Smrg{ 26056b526288Smrg $debug_cmd 26066b526288Smrg 26076b526288Smrg case $1 in 26086b526288Smrg */* | *\\*) . "$1" ;; 26096b526288Smrg *) . "./$1" ;; 26106b526288Smrg esac 26116b526288Smrg} 26126b526288Smrg 26136b526288Smrg 26146b526288Smrg# func_resolve_sysroot PATH 26156b526288Smrg# Replace a leading = in PATH with a sysroot. Store the result into 26166b526288Smrg# func_resolve_sysroot_result 26176b526288Smrgfunc_resolve_sysroot () 26186b526288Smrg{ 26196b526288Smrg func_resolve_sysroot_result=$1 26206b526288Smrg case $func_resolve_sysroot_result in 26216b526288Smrg =*) 26226b526288Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 26236b526288Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 26246b526288Smrg ;; 26256b526288Smrg esac 26266b526288Smrg} 26276b526288Smrg 26286b526288Smrg# func_replace_sysroot PATH 26296b526288Smrg# If PATH begins with the sysroot, replace it with = and 26306b526288Smrg# store the result into func_replace_sysroot_result. 26316b526288Smrgfunc_replace_sysroot () 26326b526288Smrg{ 26336b526288Smrg case $lt_sysroot:$1 in 26346b526288Smrg ?*:"$lt_sysroot"*) 26356b526288Smrg func_stripname "$lt_sysroot" '' "$1" 26366b526288Smrg func_replace_sysroot_result='='$func_stripname_result 26376b526288Smrg ;; 26386b526288Smrg *) 26396b526288Smrg # Including no sysroot. 26406b526288Smrg func_replace_sysroot_result=$1 26416b526288Smrg ;; 26426b526288Smrg esac 26436b526288Smrg} 26446b526288Smrg 26456b526288Smrg# func_infer_tag arg 26466b526288Smrg# Infer tagged configuration to use if any are available and 26476b526288Smrg# if one wasn't chosen via the "--tag" command line option. 26486b526288Smrg# Only attempt this if the compiler in the base compile 26496b526288Smrg# command doesn't match the default compiler. 26506b526288Smrg# arg is usually of the form 'gcc ...' 26516b526288Smrgfunc_infer_tag () 26526b526288Smrg{ 26536b526288Smrg $debug_cmd 26546b526288Smrg 26556b526288Smrg if test -n "$available_tags" && test -z "$tagname"; then 26566b526288Smrg CC_quoted= 26576b526288Smrg for arg in $CC; do 26586b526288Smrg func_append_quoted CC_quoted "$arg" 26596b526288Smrg done 26606b526288Smrg CC_expanded=`func_echo_all $CC` 26616b526288Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26626b526288Smrg case $@ in 26636b526288Smrg # Blanks in the command may have been stripped by the calling shell, 26646b526288Smrg # but not from the CC environment variable when configure was run. 26656b526288Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26666b526288Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 26676b526288Smrg # Blanks at the start of $base_compile will cause this to fail 26686b526288Smrg # if we don't check for them as well. 26696b526288Smrg *) 26706b526288Smrg for z in $available_tags; do 26716b526288Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 26726b526288Smrg # Evaluate the configuration. 26736b526288Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 26746b526288Smrg CC_quoted= 26756b526288Smrg for arg in $CC; do 26766b526288Smrg # Double-quote args containing other shell metacharacters. 26776b526288Smrg func_append_quoted CC_quoted "$arg" 26786b526288Smrg done 26796b526288Smrg CC_expanded=`func_echo_all $CC` 26806b526288Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26816b526288Smrg case "$@ " in 26826b526288Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26836b526288Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 26846b526288Smrg # The compiler in the base compile command matches 26856b526288Smrg # the one in the tagged configuration. 26866b526288Smrg # Assume this is the tagged configuration we want. 26876b526288Smrg tagname=$z 26886b526288Smrg break 26896b526288Smrg ;; 26906b526288Smrg esac 26916b526288Smrg fi 26926b526288Smrg done 26936b526288Smrg # If $tagname still isn't set, then no tagged configuration 26946b526288Smrg # was found and let the user know that the "--tag" command 26956b526288Smrg # line option must be used. 26966b526288Smrg if test -z "$tagname"; then 26976b526288Smrg func_echo "unable to infer tagged configuration" 26986b526288Smrg func_fatal_error "specify a tag with '--tag'" 26996b526288Smrg# else 27006b526288Smrg# func_verbose "using $tagname tagged configuration" 27016b526288Smrg fi 27026b526288Smrg ;; 27036b526288Smrg esac 27046b526288Smrg fi 27056b526288Smrg} 27066b526288Smrg 270711a29bacSmrg 270811a29bacSmrg 27096b526288Smrg# func_write_libtool_object output_name pic_name nonpic_name 27106b526288Smrg# Create a libtool object file (analogous to a ".la" file), 27116b526288Smrg# but don't create it if we're doing a dry run. 27126b526288Smrgfunc_write_libtool_object () 271311a29bacSmrg{ 27146b526288Smrg write_libobj=$1 27156b526288Smrg if test yes = "$build_libtool_libs"; then 27166b526288Smrg write_lobj=\'$2\' 27176b526288Smrg else 27186b526288Smrg write_lobj=none 27196b526288Smrg fi 272011a29bacSmrg 27216b526288Smrg if test yes = "$build_old_libs"; then 27226b526288Smrg write_oldobj=\'$3\' 27236b526288Smrg else 27246b526288Smrg write_oldobj=none 27256b526288Smrg fi 272611a29bacSmrg 27276b526288Smrg $opt_dry_run || { 27286b526288Smrg cat >${write_libobj}T <<EOF 27296b526288Smrg# $write_libobj - a libtool object file 27306b526288Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 27316b526288Smrg# 27326b526288Smrg# Please DO NOT delete this file! 27336b526288Smrg# It is necessary for linking the library. 273411a29bacSmrg 27356b526288Smrg# Name of the PIC object. 27366b526288Smrgpic_object=$write_lobj 273711a29bacSmrg 27386b526288Smrg# Name of the non-PIC object 27396b526288Smrgnon_pic_object=$write_oldobj 274041b2f0bdSmrg 27416b526288SmrgEOF 27426b526288Smrg $MV "${write_libobj}T" "$write_libobj" 27436b526288Smrg } 274411a29bacSmrg} 274541b2f0bdSmrg 27466b526288Smrg 27476b526288Smrg################################################## 27486b526288Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 27496b526288Smrg################################################## 27506b526288Smrg 27516b526288Smrg# func_convert_core_file_wine_to_w32 ARG 27526b526288Smrg# Helper function used by file name conversion functions when $build is *nix, 27536b526288Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 27546b526288Smrg# correctly configured wine environment available, with the winepath program 27556b526288Smrg# in $build's $PATH. 27566b526288Smrg# 27576b526288Smrg# ARG is the $build file name to be converted to w32 format. 27586b526288Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 27596b526288Smrg# be empty on error (or when ARG is empty) 27606b526288Smrgfunc_convert_core_file_wine_to_w32 () 276111a29bacSmrg{ 27626b526288Smrg $debug_cmd 27636b526288Smrg 27646b526288Smrg func_convert_core_file_wine_to_w32_result=$1 27656b526288Smrg if test -n "$1"; then 27666b526288Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 27676b526288Smrg # are forced to check the contents of stdout. On the other hand, if the 27686b526288Smrg # command is not found, the shell will set an exit code of 127 and print 27696b526288Smrg # *an error message* to stdout. So we must check for both error code of 27706b526288Smrg # zero AND non-empty stdout, which explains the odd construction: 27716b526288Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 27726b526288Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 27736b526288Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 27746b526288Smrg $SED -e "$sed_naive_backslashify"` 277541b2f0bdSmrg else 27766b526288Smrg func_convert_core_file_wine_to_w32_result= 277741b2f0bdSmrg fi 27786b526288Smrg fi 27796b526288Smrg} 27806b526288Smrg# end: func_convert_core_file_wine_to_w32 278111a29bacSmrg 27826b526288Smrg 27836b526288Smrg# func_convert_core_path_wine_to_w32 ARG 27846b526288Smrg# Helper function used by path conversion functions when $build is *nix, and 27856b526288Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 27866b526288Smrg# configured wine environment available, with the winepath program in $build's 27876b526288Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 27886b526288Smrg# 27896b526288Smrg# ARG is path to be converted from $build format to win32. 27906b526288Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 27916b526288Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 27926b526288Smrg# are convertible, then the result may be empty. 27936b526288Smrgfunc_convert_core_path_wine_to_w32 () 27946b526288Smrg{ 27956b526288Smrg $debug_cmd 27966b526288Smrg 27976b526288Smrg # unfortunately, winepath doesn't convert paths, only file names 27986b526288Smrg func_convert_core_path_wine_to_w32_result= 27996b526288Smrg if test -n "$1"; then 28006b526288Smrg oldIFS=$IFS 28016b526288Smrg IFS=: 28026b526288Smrg for func_convert_core_path_wine_to_w32_f in $1; do 28036b526288Smrg IFS=$oldIFS 28046b526288Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 28056b526288Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 28066b526288Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 28076b526288Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 28086b526288Smrg else 28096b526288Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 28106b526288Smrg fi 28116b526288Smrg fi 28126b526288Smrg done 28136b526288Smrg IFS=$oldIFS 28146b526288Smrg fi 281511a29bacSmrg} 28166b526288Smrg# end: func_convert_core_path_wine_to_w32 28176b526288Smrg 28186b526288Smrg 28196b526288Smrg# func_cygpath ARGS... 28206b526288Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 28216b526288Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 28226b526288Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 28236b526288Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 28246b526288Smrg# file name or path is assumed to be in w32 format, as previously converted 28256b526288Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 28266b526288Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 28276b526288Smrg# Cygwin format). Returns an empty string on error. 28286b526288Smrg# 28296b526288Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 28306b526288Smrg# be converted. 28316b526288Smrg# 28326b526288Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 28336b526288Smrg# environment variable; do not put it in $PATH. 28346b526288Smrgfunc_cygpath () 28356b526288Smrg{ 28366b526288Smrg $debug_cmd 283741b2f0bdSmrg 28386b526288Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 28396b526288Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 28406b526288Smrg if test "$?" -ne 0; then 28416b526288Smrg # on failure, ensure result is empty 28426b526288Smrg func_cygpath_result= 28436b526288Smrg fi 28446b526288Smrg else 28456b526288Smrg func_cygpath_result= 28466b526288Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 28476b526288Smrg fi 28486b526288Smrg} 28496b526288Smrg#end: func_cygpath 28506b526288Smrg 28516b526288Smrg 28526b526288Smrg# func_convert_core_msys_to_w32 ARG 28536b526288Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 28546b526288Smrg# result in func_convert_core_msys_to_w32_result. 28556b526288Smrgfunc_convert_core_msys_to_w32 () 285611a29bacSmrg{ 28576b526288Smrg $debug_cmd 285841b2f0bdSmrg 28596b526288Smrg # awkward: cmd appends spaces to result 28606b526288Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 28616b526288Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 28626b526288Smrg} 28636b526288Smrg#end: func_convert_core_msys_to_w32 286441b2f0bdSmrg 286541b2f0bdSmrg 28666b526288Smrg# func_convert_file_check ARG1 ARG2 28676b526288Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 28686b526288Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 28696b526288Smrg# func_to_host_file_result to ARG1). 28706b526288Smrgfunc_convert_file_check () 28716b526288Smrg{ 28726b526288Smrg $debug_cmd 28736b526288Smrg 28746b526288Smrg if test -z "$2" && test -n "$1"; then 28756b526288Smrg func_error "Could not determine host file name corresponding to" 28766b526288Smrg func_error " '$1'" 28776b526288Smrg func_error "Continuing, but uninstalled executables may not work." 28786b526288Smrg # Fallback: 28796b526288Smrg func_to_host_file_result=$1 28806b526288Smrg fi 288111a29bacSmrg} 28826b526288Smrg# end func_convert_file_check 288311a29bacSmrg 28846b526288Smrg 28856b526288Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 28866b526288Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 28876b526288Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 28886b526288Smrg# func_to_host_file_result to a simplistic fallback value (see below). 28896b526288Smrgfunc_convert_path_check () 289011a29bacSmrg{ 28916b526288Smrg $debug_cmd 28926b526288Smrg 28936b526288Smrg if test -z "$4" && test -n "$3"; then 28946b526288Smrg func_error "Could not determine the host path corresponding to" 28956b526288Smrg func_error " '$3'" 28966b526288Smrg func_error "Continuing, but uninstalled executables may not work." 28976b526288Smrg # Fallback. This is a deliberately simplistic "conversion" and 28986b526288Smrg # should not be "improved". See libtool.info. 28996b526288Smrg if test "x$1" != "x$2"; then 29006b526288Smrg lt_replace_pathsep_chars="s|$1|$2|g" 29016b526288Smrg func_to_host_path_result=`echo "$3" | 29026b526288Smrg $SED -e "$lt_replace_pathsep_chars"` 29036b526288Smrg else 29046b526288Smrg func_to_host_path_result=$3 29056b526288Smrg fi 29066b526288Smrg fi 29076b526288Smrg} 29086b526288Smrg# end func_convert_path_check 290941b2f0bdSmrg 29106b526288Smrg 29116b526288Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 29126b526288Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 29136b526288Smrg# and appending REPL if ORIG matches BACKPAT. 29146b526288Smrgfunc_convert_path_front_back_pathsep () 29156b526288Smrg{ 29166b526288Smrg $debug_cmd 29176b526288Smrg 29186b526288Smrg case $4 in 29196b526288Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292011a29bacSmrg ;; 29216b526288Smrg esac 29226b526288Smrg case $4 in 29236b526288Smrg $2 ) func_append func_to_host_path_result "$3" 292441b2f0bdSmrg ;; 292541b2f0bdSmrg esac 29266b526288Smrg} 29276b526288Smrg# end func_convert_path_front_back_pathsep 292841b2f0bdSmrg 292941b2f0bdSmrg 29306b526288Smrg################################################## 29316b526288Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 29326b526288Smrg################################################## 29336b526288Smrg# invoked via '$to_host_file_cmd ARG' 29346b526288Smrg# 29356b526288Smrg# In each case, ARG is the path to be converted from $build to $host format. 29366b526288Smrg# Result will be available in $func_to_host_file_result. 293711a29bacSmrg 293811a29bacSmrg 29396b526288Smrg# func_to_host_file ARG 29406b526288Smrg# Converts the file name ARG from $build format to $host format. Return result 29416b526288Smrg# in func_to_host_file_result. 29426b526288Smrgfunc_to_host_file () 29436b526288Smrg{ 29446b526288Smrg $debug_cmd 29456b526288Smrg 29466b526288Smrg $to_host_file_cmd "$1" 29476b526288Smrg} 29486b526288Smrg# end func_to_host_file 29496b526288Smrg 29506b526288Smrg 29516b526288Smrg# func_to_tool_file ARG LAZY 29526b526288Smrg# converts the file name ARG from $build format to toolchain format. Return 29536b526288Smrg# result in func_to_tool_file_result. If the conversion in use is listed 29546b526288Smrg# in (the comma separated) LAZY, no conversion takes place. 29556b526288Smrgfunc_to_tool_file () 29566b526288Smrg{ 29576b526288Smrg $debug_cmd 29586b526288Smrg 29596b526288Smrg case ,$2, in 29606b526288Smrg *,"$to_tool_file_cmd",*) 29616b526288Smrg func_to_tool_file_result=$1 296241b2f0bdSmrg ;; 296341b2f0bdSmrg *) 29646b526288Smrg $to_tool_file_cmd "$1" 29656b526288Smrg func_to_tool_file_result=$func_to_host_file_result 296611a29bacSmrg ;; 296711a29bacSmrg esac 29686b526288Smrg} 29696b526288Smrg# end func_to_tool_file 297041b2f0bdSmrg 29716b526288Smrg 29726b526288Smrg# func_convert_file_noop ARG 29736b526288Smrg# Copy ARG to func_to_host_file_result. 29746b526288Smrgfunc_convert_file_noop () 29756b526288Smrg{ 29766b526288Smrg func_to_host_file_result=$1 297711a29bacSmrg} 29786b526288Smrg# end func_convert_file_noop 297911a29bacSmrg 29806b526288Smrg 29816b526288Smrg# func_convert_file_msys_to_w32 ARG 29826b526288Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 29836b526288Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 29846b526288Smrg# func_to_host_file_result. 29856b526288Smrgfunc_convert_file_msys_to_w32 () 298611a29bacSmrg{ 29876b526288Smrg $debug_cmd 298811a29bacSmrg 29896b526288Smrg func_to_host_file_result=$1 29906b526288Smrg if test -n "$1"; then 29916b526288Smrg func_convert_core_msys_to_w32 "$1" 29926b526288Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299311a29bacSmrg fi 29946b526288Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299511a29bacSmrg} 29966b526288Smrg# end func_convert_file_msys_to_w32 299711a29bacSmrg 299811a29bacSmrg 29996b526288Smrg# func_convert_file_cygwin_to_w32 ARG 30006b526288Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 30016b526288Smrg# func_to_host_file_result. 30026b526288Smrgfunc_convert_file_cygwin_to_w32 () 30036b526288Smrg{ 30046b526288Smrg $debug_cmd 300511a29bacSmrg 30066b526288Smrg func_to_host_file_result=$1 30076b526288Smrg if test -n "$1"; then 30086b526288Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 30096b526288Smrg # LT_CYGPATH in this case. 30106b526288Smrg func_to_host_file_result=`cygpath -m "$1"` 301141b2f0bdSmrg fi 30126b526288Smrg func_convert_file_check "$1" "$func_to_host_file_result" 30136b526288Smrg} 30146b526288Smrg# end func_convert_file_cygwin_to_w32 301541b2f0bdSmrg 301611a29bacSmrg 30176b526288Smrg# func_convert_file_nix_to_w32 ARG 30186b526288Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 30196b526288Smrg# and a working winepath. Returns result in func_to_host_file_result. 30206b526288Smrgfunc_convert_file_nix_to_w32 () 30216b526288Smrg{ 30226b526288Smrg $debug_cmd 302311a29bacSmrg 30246b526288Smrg func_to_host_file_result=$1 30256b526288Smrg if test -n "$1"; then 30266b526288Smrg func_convert_core_file_wine_to_w32 "$1" 30276b526288Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302841b2f0bdSmrg fi 30296b526288Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303011a29bacSmrg} 30316b526288Smrg# end func_convert_file_nix_to_w32 303241b2f0bdSmrg 303341b2f0bdSmrg 30346b526288Smrg# func_convert_file_msys_to_cygwin ARG 30356b526288Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 30366b526288Smrg# Returns result in func_to_host_file_result. 30376b526288Smrgfunc_convert_file_msys_to_cygwin () 303811a29bacSmrg{ 30396b526288Smrg $debug_cmd 304041b2f0bdSmrg 30416b526288Smrg func_to_host_file_result=$1 30426b526288Smrg if test -n "$1"; then 30436b526288Smrg func_convert_core_msys_to_w32 "$1" 30446b526288Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 30456b526288Smrg func_to_host_file_result=$func_cygpath_result 30466b526288Smrg fi 30476b526288Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304811a29bacSmrg} 30496b526288Smrg# end func_convert_file_msys_to_cygwin 305041b2f0bdSmrg 305141b2f0bdSmrg 30526b526288Smrg# func_convert_file_nix_to_cygwin ARG 30536b526288Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 30546b526288Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 30556b526288Smrg# in func_to_host_file_result. 30566b526288Smrgfunc_convert_file_nix_to_cygwin () 305711a29bacSmrg{ 30586b526288Smrg $debug_cmd 30596b526288Smrg 30606b526288Smrg func_to_host_file_result=$1 30616b526288Smrg if test -n "$1"; then 30626b526288Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 30636b526288Smrg func_convert_core_file_wine_to_w32 "$1" 30646b526288Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 30656b526288Smrg func_to_host_file_result=$func_cygpath_result 30666b526288Smrg fi 30676b526288Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306811a29bacSmrg} 30696b526288Smrg# end func_convert_file_nix_to_cygwin 307011a29bacSmrg 30716b526288Smrg 30726b526288Smrg############################################# 30736b526288Smrg# $build to $host PATH CONVERSION FUNCTIONS # 30746b526288Smrg############################################# 30756b526288Smrg# invoked via '$to_host_path_cmd ARG' 30766b526288Smrg# 30776b526288Smrg# In each case, ARG is the path to be converted from $build to $host format. 30786b526288Smrg# The result will be available in $func_to_host_path_result. 30796b526288Smrg# 30806b526288Smrg# Path separators are also converted from $build format to $host format. If 30816b526288Smrg# ARG begins or ends with a path separator character, it is preserved (but 30826b526288Smrg# converted to $host format) on output. 30836b526288Smrg# 30846b526288Smrg# All path conversion functions are named using the following convention: 30856b526288Smrg# file name conversion function : func_convert_file_X_to_Y () 30866b526288Smrg# path conversion function : func_convert_path_X_to_Y () 30876b526288Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 30886b526288Smrg# same. If conversion functions are added for new $build/$host combinations, 30896b526288Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 30906b526288Smrg# will break. 30916b526288Smrg 30926b526288Smrg 30936b526288Smrg# func_init_to_host_path_cmd 30946b526288Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 30956b526288Smrg# appropriate value, based on the value of $to_host_file_cmd. 30966b526288Smrgto_host_path_cmd= 30976b526288Smrgfunc_init_to_host_path_cmd () 309811a29bacSmrg{ 30996b526288Smrg $debug_cmd 31006b526288Smrg 31016b526288Smrg if test -z "$to_host_path_cmd"; then 31026b526288Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 31036b526288Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 31046b526288Smrg fi 310511a29bacSmrg} 310611a29bacSmrg 31076b526288Smrg 31086b526288Smrg# func_to_host_path ARG 31096b526288Smrg# Converts the path ARG from $build format to $host format. Return result 31106b526288Smrg# in func_to_host_path_result. 31116b526288Smrgfunc_to_host_path () 311211a29bacSmrg{ 31136b526288Smrg $debug_cmd 31146b526288Smrg 31156b526288Smrg func_init_to_host_path_cmd 31166b526288Smrg $to_host_path_cmd "$1" 311711a29bacSmrg} 31186b526288Smrg# end func_to_host_path 311911a29bacSmrg 312011a29bacSmrg 31216b526288Smrg# func_convert_path_noop ARG 31226b526288Smrg# Copy ARG to func_to_host_path_result. 31236b526288Smrgfunc_convert_path_noop () 312411a29bacSmrg{ 31256b526288Smrg func_to_host_path_result=$1 312611a29bacSmrg} 31276b526288Smrg# end func_convert_path_noop 312811a29bacSmrg 312911a29bacSmrg 31306b526288Smrg# func_convert_path_msys_to_w32 ARG 31316b526288Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 31326b526288Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 31336b526288Smrg# func_to_host_path_result. 31346b526288Smrgfunc_convert_path_msys_to_w32 () 313511a29bacSmrg{ 31366b526288Smrg $debug_cmd 31376b526288Smrg 31386b526288Smrg func_to_host_path_result=$1 31396b526288Smrg if test -n "$1"; then 31406b526288Smrg # Remove leading and trailing path separator characters from ARG. MSYS 31416b526288Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 31426b526288Smrg # and winepath ignores them completely. 31436b526288Smrg func_stripname : : "$1" 31446b526288Smrg func_to_host_path_tmp1=$func_stripname_result 31456b526288Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 31466b526288Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 31476b526288Smrg func_convert_path_check : ";" \ 31486b526288Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31496b526288Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31506b526288Smrg fi 315111a29bacSmrg} 31526b526288Smrg# end func_convert_path_msys_to_w32 315311a29bacSmrg 315411a29bacSmrg 31556b526288Smrg# func_convert_path_cygwin_to_w32 ARG 31566b526288Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 31576b526288Smrg# func_to_host_file_result. 31586b526288Smrgfunc_convert_path_cygwin_to_w32 () 315911a29bacSmrg{ 31606b526288Smrg $debug_cmd 31616b526288Smrg 31626b526288Smrg func_to_host_path_result=$1 31636b526288Smrg if test -n "$1"; then 31646b526288Smrg # See func_convert_path_msys_to_w32: 31656b526288Smrg func_stripname : : "$1" 31666b526288Smrg func_to_host_path_tmp1=$func_stripname_result 31676b526288Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 31686b526288Smrg func_convert_path_check : ";" \ 31696b526288Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31706b526288Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31716b526288Smrg fi 317211a29bacSmrg} 31736b526288Smrg# end func_convert_path_cygwin_to_w32 317411a29bacSmrg 317511a29bacSmrg 31766b526288Smrg# func_convert_path_nix_to_w32 ARG 31776b526288Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 31786b526288Smrg# a working winepath. Returns result in func_to_host_file_result. 31796b526288Smrgfunc_convert_path_nix_to_w32 () 31806b526288Smrg{ 31816b526288Smrg $debug_cmd 318211a29bacSmrg 31836b526288Smrg func_to_host_path_result=$1 31846b526288Smrg if test -n "$1"; then 31856b526288Smrg # See func_convert_path_msys_to_w32: 31866b526288Smrg func_stripname : : "$1" 31876b526288Smrg func_to_host_path_tmp1=$func_stripname_result 31886b526288Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 31896b526288Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 31906b526288Smrg func_convert_path_check : ";" \ 31916b526288Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31926b526288Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31936b526288Smrg fi 31946b526288Smrg} 31956b526288Smrg# end func_convert_path_nix_to_w32 31966b526288Smrg 31976b526288Smrg 31986b526288Smrg# func_convert_path_msys_to_cygwin ARG 31996b526288Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32006b526288Smrg# Returns result in func_to_host_file_result. 32016b526288Smrgfunc_convert_path_msys_to_cygwin () 320211a29bacSmrg{ 32036b526288Smrg $debug_cmd 320411a29bacSmrg 32056b526288Smrg func_to_host_path_result=$1 32066b526288Smrg if test -n "$1"; then 32076b526288Smrg # See func_convert_path_msys_to_w32: 32086b526288Smrg func_stripname : : "$1" 32096b526288Smrg func_to_host_path_tmp1=$func_stripname_result 32106b526288Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 32116b526288Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 32126b526288Smrg func_to_host_path_result=$func_cygpath_result 32136b526288Smrg func_convert_path_check : : \ 32146b526288Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32156b526288Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32166b526288Smrg fi 32176b526288Smrg} 32186b526288Smrg# end func_convert_path_msys_to_cygwin 321911a29bacSmrg 322011a29bacSmrg 32216b526288Smrg# func_convert_path_nix_to_cygwin ARG 32226b526288Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 32236b526288Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 32246b526288Smrg# func_to_host_file_result. 32256b526288Smrgfunc_convert_path_nix_to_cygwin () 32266b526288Smrg{ 32276b526288Smrg $debug_cmd 322811a29bacSmrg 32296b526288Smrg func_to_host_path_result=$1 32306b526288Smrg if test -n "$1"; then 32316b526288Smrg # Remove leading and trailing path separator characters from 32326b526288Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 32336b526288Smrg # into '.;' and ';.', and winepath ignores them completely. 32346b526288Smrg func_stripname : : "$1" 32356b526288Smrg func_to_host_path_tmp1=$func_stripname_result 32366b526288Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 32376b526288Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 32386b526288Smrg func_to_host_path_result=$func_cygpath_result 32396b526288Smrg func_convert_path_check : : \ 32406b526288Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32416b526288Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32426b526288Smrg fi 32436b526288Smrg} 32446b526288Smrg# end func_convert_path_nix_to_cygwin 324511a29bacSmrg 32466b526288Smrg 32476b526288Smrg# func_dll_def_p FILE 32486b526288Smrg# True iff FILE is a Windows DLL '.def' file. 32496b526288Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 32506b526288Smrgfunc_dll_def_p () 32516b526288Smrg{ 32526b526288Smrg $debug_cmd 32536b526288Smrg 32546b526288Smrg func_dll_def_p_tmp=`$SED -n \ 32556b526288Smrg -e 's/^[ ]*//' \ 32566b526288Smrg -e '/^\(;.*\)*$/d' \ 32576b526288Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 32586b526288Smrg -e q \ 32596b526288Smrg "$1"` 32606b526288Smrg test DEF = "$func_dll_def_p_tmp" 326111a29bacSmrg} 326211a29bacSmrg 32636b526288Smrg 326411a29bacSmrg# func_mode_compile arg... 326511a29bacSmrgfunc_mode_compile () 326611a29bacSmrg{ 32676b526288Smrg $debug_cmd 32686b526288Smrg 326911a29bacSmrg # Get the compilation command and the source file. 327011a29bacSmrg base_compile= 32716b526288Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 327211a29bacSmrg suppress_opt=yes 327311a29bacSmrg suppress_output= 327411a29bacSmrg arg_mode=normal 327511a29bacSmrg libobj= 327611a29bacSmrg later= 327711a29bacSmrg pie_flag= 327811a29bacSmrg 327911a29bacSmrg for arg 328011a29bacSmrg do 328111a29bacSmrg case $arg_mode in 328211a29bacSmrg arg ) 328311a29bacSmrg # do not "continue". Instead, add this to base_compile 32846b526288Smrg lastarg=$arg 328511a29bacSmrg arg_mode=normal 328611a29bacSmrg ;; 328711a29bacSmrg 328811a29bacSmrg target ) 32896b526288Smrg libobj=$arg 329011a29bacSmrg arg_mode=normal 329111a29bacSmrg continue 329211a29bacSmrg ;; 329311a29bacSmrg 329411a29bacSmrg normal ) 329511a29bacSmrg # Accept any command-line options. 329611a29bacSmrg case $arg in 329711a29bacSmrg -o) 329811a29bacSmrg test -n "$libobj" && \ 32996b526288Smrg func_fatal_error "you cannot specify '-o' more than once" 330011a29bacSmrg arg_mode=target 330111a29bacSmrg continue 330211a29bacSmrg ;; 330311a29bacSmrg 330411a29bacSmrg -pie | -fpie | -fPIE) 33056b526288Smrg func_append pie_flag " $arg" 330611a29bacSmrg continue 330711a29bacSmrg ;; 330811a29bacSmrg 330911a29bacSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 33106b526288Smrg func_append later " $arg" 331111a29bacSmrg continue 331211a29bacSmrg ;; 331341b2f0bdSmrg 331441b2f0bdSmrg -no-suppress) 331541b2f0bdSmrg suppress_opt=no 331641b2f0bdSmrg continue 331741b2f0bdSmrg ;; 331841b2f0bdSmrg 331941b2f0bdSmrg -Xcompiler) 332041b2f0bdSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 332141b2f0bdSmrg continue # The current "srcfile" will either be retained or 332241b2f0bdSmrg ;; # replaced later. I would guess that would be a bug. 332341b2f0bdSmrg 332441b2f0bdSmrg -Wc,*) 332511a29bacSmrg func_stripname '-Wc,' '' "$arg" 332611a29bacSmrg args=$func_stripname_result 332741b2f0bdSmrg lastarg= 33286b526288Smrg save_ifs=$IFS; IFS=, 332911a29bacSmrg for arg in $args; do 33306b526288Smrg IFS=$save_ifs 33316b526288Smrg func_append_quoted lastarg "$arg" 333241b2f0bdSmrg done 33336b526288Smrg IFS=$save_ifs 333411a29bacSmrg func_stripname ' ' '' "$lastarg" 333511a29bacSmrg lastarg=$func_stripname_result 333641b2f0bdSmrg 333741b2f0bdSmrg # Add the arguments to base_compile. 33386b526288Smrg func_append base_compile " $lastarg" 333941b2f0bdSmrg continue 334041b2f0bdSmrg ;; 334141b2f0bdSmrg 334211a29bacSmrg *) 334341b2f0bdSmrg # Accept the current argument as the source file. 334441b2f0bdSmrg # The previous "srcfile" becomes the current argument. 334541b2f0bdSmrg # 33466b526288Smrg lastarg=$srcfile 33476b526288Smrg srcfile=$arg 334841b2f0bdSmrg ;; 334941b2f0bdSmrg esac # case $arg 335041b2f0bdSmrg ;; 335141b2f0bdSmrg esac # case $arg_mode 335241b2f0bdSmrg 335341b2f0bdSmrg # Aesthetically quote the previous argument. 33546b526288Smrg func_append_quoted base_compile "$lastarg" 335541b2f0bdSmrg done # for arg 335641b2f0bdSmrg 335741b2f0bdSmrg case $arg_mode in 335841b2f0bdSmrg arg) 335911a29bacSmrg func_fatal_error "you must specify an argument for -Xcompile" 336041b2f0bdSmrg ;; 336141b2f0bdSmrg target) 33626b526288Smrg func_fatal_error "you must specify a target with '-o'" 336341b2f0bdSmrg ;; 336441b2f0bdSmrg *) 336541b2f0bdSmrg # Get the name of the library object. 336611a29bacSmrg test -z "$libobj" && { 336711a29bacSmrg func_basename "$srcfile" 33686b526288Smrg libobj=$func_basename_result 336911a29bacSmrg } 337041b2f0bdSmrg ;; 337141b2f0bdSmrg esac 337241b2f0bdSmrg 337341b2f0bdSmrg # Recognize several different file suffixes. 337441b2f0bdSmrg # If the user specifies -o file.o, it is replaced with file.lo 337541b2f0bdSmrg case $libobj in 337611a29bacSmrg *.[cCFSifmso] | \ 337711a29bacSmrg *.ada | *.adb | *.ads | *.asm | \ 337811a29bacSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 33796b526288Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 338011a29bacSmrg func_xform "$libobj" 338111a29bacSmrg libobj=$func_xform_result 338211a29bacSmrg ;; 338341b2f0bdSmrg esac 338441b2f0bdSmrg 338541b2f0bdSmrg case $libobj in 338611a29bacSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338741b2f0bdSmrg *) 33886b526288Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 338941b2f0bdSmrg ;; 339041b2f0bdSmrg esac 339141b2f0bdSmrg 339241b2f0bdSmrg func_infer_tag $base_compile 339341b2f0bdSmrg 339441b2f0bdSmrg for arg in $later; do 339541b2f0bdSmrg case $arg in 339611a29bacSmrg -shared) 33976b526288Smrg test yes = "$build_libtool_libs" \ 33986b526288Smrg || func_fatal_configuration "cannot build a shared library" 339911a29bacSmrg build_old_libs=no 340011a29bacSmrg continue 340111a29bacSmrg ;; 340211a29bacSmrg 340341b2f0bdSmrg -static) 340411a29bacSmrg build_libtool_libs=no 340541b2f0bdSmrg build_old_libs=yes 340641b2f0bdSmrg continue 340741b2f0bdSmrg ;; 340841b2f0bdSmrg 340941b2f0bdSmrg -prefer-pic) 341041b2f0bdSmrg pic_mode=yes 341141b2f0bdSmrg continue 341241b2f0bdSmrg ;; 341341b2f0bdSmrg 341441b2f0bdSmrg -prefer-non-pic) 341541b2f0bdSmrg pic_mode=no 341641b2f0bdSmrg continue 341741b2f0bdSmrg ;; 341841b2f0bdSmrg esac 341941b2f0bdSmrg done 342041b2f0bdSmrg 342111a29bacSmrg func_quote_for_eval "$libobj" 342211a29bacSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 342311a29bacSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 34246b526288Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 342511a29bacSmrg func_dirname_and_basename "$obj" "/" "" 34266b526288Smrg objname=$func_basename_result 34276b526288Smrg xdir=$func_dirname_result 34286b526288Smrg lobj=$xdir$objdir/$objname 342941b2f0bdSmrg 343011a29bacSmrg test -z "$base_compile" && \ 343111a29bacSmrg func_fatal_help "you must specify a compilation command" 343241b2f0bdSmrg 343341b2f0bdSmrg # Delete any leftover library objects. 34346b526288Smrg if test yes = "$build_old_libs"; then 343541b2f0bdSmrg removelist="$obj $lobj $libobj ${libobj}T" 343641b2f0bdSmrg else 343741b2f0bdSmrg removelist="$lobj $libobj ${libobj}T" 343841b2f0bdSmrg fi 343941b2f0bdSmrg 344041b2f0bdSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 344141b2f0bdSmrg case $host_os in 344211a29bacSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344341b2f0bdSmrg pic_mode=default 344441b2f0bdSmrg ;; 344541b2f0bdSmrg esac 34466b526288Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344741b2f0bdSmrg # non-PIC code in shared libraries is not supported 344841b2f0bdSmrg pic_mode=default 344941b2f0bdSmrg fi 345041b2f0bdSmrg 345141b2f0bdSmrg # Calculate the filename of the output object if compiler does 345241b2f0bdSmrg # not support -o with -c 34536b526288Smrg if test no = "$compiler_c_o"; then 34546b526288Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 34556b526288Smrg lockfile=$output_obj.lock 345641b2f0bdSmrg else 345741b2f0bdSmrg output_obj= 345841b2f0bdSmrg need_locks=no 345941b2f0bdSmrg lockfile= 346041b2f0bdSmrg fi 346141b2f0bdSmrg 346241b2f0bdSmrg # Lock this critical section if it is needed 346341b2f0bdSmrg # We use this script file to make the link, it avoids creating a new file 34646b526288Smrg if test yes = "$need_locks"; then 346511a29bacSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 346611a29bacSmrg func_echo "Waiting for $lockfile to be removed" 346741b2f0bdSmrg sleep 2 346841b2f0bdSmrg done 34696b526288Smrg elif test warn = "$need_locks"; then 347041b2f0bdSmrg if test -f "$lockfile"; then 347111a29bacSmrg $ECHO "\ 347241b2f0bdSmrg*** ERROR, $lockfile exists and contains: 347341b2f0bdSmrg`cat $lockfile 2>/dev/null` 347441b2f0bdSmrg 347541b2f0bdSmrgThis indicates that another process is trying to use the same 347641b2f0bdSmrgtemporary object file, and libtool could not work around it because 34776b526288Smrgyour compiler does not support '-c' and '-o' together. If you 347841b2f0bdSmrgrepeat this compilation, it may succeed, by chance, but you had better 347941b2f0bdSmrgavoid parallel builds (make -j) in this platform, or get a better 348041b2f0bdSmrgcompiler." 348141b2f0bdSmrg 348211a29bacSmrg $opt_dry_run || $RM $removelist 348341b2f0bdSmrg exit $EXIT_FAILURE 348441b2f0bdSmrg fi 34856b526288Smrg func_append removelist " $output_obj" 348611a29bacSmrg $ECHO "$srcfile" > "$lockfile" 348741b2f0bdSmrg fi 348841b2f0bdSmrg 348911a29bacSmrg $opt_dry_run || $RM $removelist 34906b526288Smrg func_append removelist " $lockfile" 349111a29bacSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 349211a29bacSmrg 34936b526288Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 34946b526288Smrg srcfile=$func_to_tool_file_result 349511a29bacSmrg func_quote_for_eval "$srcfile" 349611a29bacSmrg qsrcfile=$func_quote_for_eval_result 349741b2f0bdSmrg 349841b2f0bdSmrg # Only build a PIC object if we are building libtool libraries. 34996b526288Smrg if test yes = "$build_libtool_libs"; then 350041b2f0bdSmrg # Without this assignment, base_compile gets emptied. 350141b2f0bdSmrg fbsd_hideous_sh_bug=$base_compile 350241b2f0bdSmrg 35036b526288Smrg if test no != "$pic_mode"; then 350441b2f0bdSmrg command="$base_compile $qsrcfile $pic_flag" 350541b2f0bdSmrg else 350641b2f0bdSmrg # Don't build PIC code 350741b2f0bdSmrg command="$base_compile $qsrcfile" 350841b2f0bdSmrg fi 350941b2f0bdSmrg 351011a29bacSmrg func_mkdir_p "$xdir$objdir" 351141b2f0bdSmrg 351241b2f0bdSmrg if test -z "$output_obj"; then 351341b2f0bdSmrg # Place PIC objects in $objdir 35146b526288Smrg func_append command " -o $lobj" 351541b2f0bdSmrg fi 351641b2f0bdSmrg 351711a29bacSmrg func_show_eval_locale "$command" \ 351811a29bacSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 351941b2f0bdSmrg 35206b526288Smrg if test warn = "$need_locks" && 352141b2f0bdSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 352211a29bacSmrg $ECHO "\ 352341b2f0bdSmrg*** ERROR, $lockfile contains: 352441b2f0bdSmrg`cat $lockfile 2>/dev/null` 352541b2f0bdSmrg 352641b2f0bdSmrgbut it should contain: 352741b2f0bdSmrg$srcfile 352841b2f0bdSmrg 352941b2f0bdSmrgThis indicates that another process is trying to use the same 353041b2f0bdSmrgtemporary object file, and libtool could not work around it because 35316b526288Smrgyour compiler does not support '-c' and '-o' together. If you 353241b2f0bdSmrgrepeat this compilation, it may succeed, by chance, but you had better 353341b2f0bdSmrgavoid parallel builds (make -j) in this platform, or get a better 353441b2f0bdSmrgcompiler." 353541b2f0bdSmrg 353611a29bacSmrg $opt_dry_run || $RM $removelist 353741b2f0bdSmrg exit $EXIT_FAILURE 353841b2f0bdSmrg fi 353941b2f0bdSmrg 354041b2f0bdSmrg # Just move the object if needed, then go on to compile the next one 354141b2f0bdSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 354211a29bacSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 354311a29bacSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354441b2f0bdSmrg fi 354541b2f0bdSmrg 354641b2f0bdSmrg # Allow error messages only from the first compilation. 35476b526288Smrg if test yes = "$suppress_opt"; then 354811a29bacSmrg suppress_output=' >/dev/null 2>&1' 354941b2f0bdSmrg fi 355041b2f0bdSmrg fi 355141b2f0bdSmrg 355241b2f0bdSmrg # Only build a position-dependent object if we build old libraries. 35536b526288Smrg if test yes = "$build_old_libs"; then 35546b526288Smrg if test yes != "$pic_mode"; then 355541b2f0bdSmrg # Don't build PIC code 355611a29bacSmrg command="$base_compile $qsrcfile$pie_flag" 355741b2f0bdSmrg else 355841b2f0bdSmrg command="$base_compile $qsrcfile $pic_flag" 355941b2f0bdSmrg fi 35606b526288Smrg if test yes = "$compiler_c_o"; then 35616b526288Smrg func_append command " -o $obj" 356241b2f0bdSmrg fi 356341b2f0bdSmrg 356441b2f0bdSmrg # Suppress compiler output if we already did a PIC compilation. 35656b526288Smrg func_append command "$suppress_output" 356611a29bacSmrg func_show_eval_locale "$command" \ 356711a29bacSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 356841b2f0bdSmrg 35696b526288Smrg if test warn = "$need_locks" && 357041b2f0bdSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 357111a29bacSmrg $ECHO "\ 357241b2f0bdSmrg*** ERROR, $lockfile contains: 357341b2f0bdSmrg`cat $lockfile 2>/dev/null` 357441b2f0bdSmrg 357541b2f0bdSmrgbut it should contain: 357641b2f0bdSmrg$srcfile 357741b2f0bdSmrg 357841b2f0bdSmrgThis indicates that another process is trying to use the same 357941b2f0bdSmrgtemporary object file, and libtool could not work around it because 35806b526288Smrgyour compiler does not support '-c' and '-o' together. If you 358141b2f0bdSmrgrepeat this compilation, it may succeed, by chance, but you had better 358241b2f0bdSmrgavoid parallel builds (make -j) in this platform, or get a better 358341b2f0bdSmrgcompiler." 358441b2f0bdSmrg 358511a29bacSmrg $opt_dry_run || $RM $removelist 358641b2f0bdSmrg exit $EXIT_FAILURE 358741b2f0bdSmrg fi 358841b2f0bdSmrg 358941b2f0bdSmrg # Just move the object if needed 359041b2f0bdSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 359111a29bacSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 359211a29bacSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359341b2f0bdSmrg fi 359441b2f0bdSmrg fi 359541b2f0bdSmrg 359611a29bacSmrg $opt_dry_run || { 359711a29bacSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 359841b2f0bdSmrg 359911a29bacSmrg # Unlock the critical section if it was locked 36006b526288Smrg if test no != "$need_locks"; then 360111a29bacSmrg removelist=$lockfile 360211a29bacSmrg $RM "$lockfile" 360311a29bacSmrg fi 360411a29bacSmrg } 360541b2f0bdSmrg 360641b2f0bdSmrg exit $EXIT_SUCCESS 360711a29bacSmrg} 360841b2f0bdSmrg 360911a29bacSmrg$opt_help || { 36106b526288Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 361111a29bacSmrg} 361241b2f0bdSmrg 361311a29bacSmrgfunc_mode_help () 361411a29bacSmrg{ 361511a29bacSmrg # We need to display help for each of the modes. 36166b526288Smrg case $opt_mode in 361711a29bacSmrg "") 361811a29bacSmrg # Generic help is extracted from the usage comments 361911a29bacSmrg # at the start of this file. 362011a29bacSmrg func_help 362111a29bacSmrg ;; 362241b2f0bdSmrg 362311a29bacSmrg clean) 362411a29bacSmrg $ECHO \ 362511a29bacSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 362641b2f0bdSmrg 362711a29bacSmrgRemove files from the build directory. 362841b2f0bdSmrg 362911a29bacSmrgRM is the name of the program to use to delete files associated with each FILE 36306b526288Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 363111a29bacSmrgto RM. 363241b2f0bdSmrg 363311a29bacSmrgIf FILE is a libtool library, object or program, all the files associated 363411a29bacSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 363511a29bacSmrg ;; 363641b2f0bdSmrg 363711a29bacSmrg compile) 363811a29bacSmrg $ECHO \ 363911a29bacSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 364041b2f0bdSmrg 364111a29bacSmrgCompile a source file into a libtool library object. 364241b2f0bdSmrg 364311a29bacSmrgThis mode accepts the following additional options: 364441b2f0bdSmrg 364511a29bacSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 364611a29bacSmrg -no-suppress do not suppress compiler output for multiple passes 364711a29bacSmrg -prefer-pic try to build PIC objects only 364811a29bacSmrg -prefer-non-pic try to build non-PIC objects only 36496b526288Smrg -shared do not build a '.o' file suitable for static linking 36506b526288Smrg -static only build a '.o' file suitable for static linking 365111a29bacSmrg -Wc,FLAG pass FLAG directly to the compiler 365241b2f0bdSmrg 36536b526288SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 365411a29bacSmrgfrom the given SOURCEFILE. 365541b2f0bdSmrg 365611a29bacSmrgThe output file name is determined by removing the directory component from 36576b526288SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 36586b526288Smrglibrary object suffix, '.lo'." 365911a29bacSmrg ;; 366041b2f0bdSmrg 366111a29bacSmrg execute) 366211a29bacSmrg $ECHO \ 366311a29bacSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 366441b2f0bdSmrg 366511a29bacSmrgAutomatically set library path, then run a program. 366641b2f0bdSmrg 366711a29bacSmrgThis mode accepts the following additional options: 366841b2f0bdSmrg 366911a29bacSmrg -dlopen FILE add the directory containing FILE to the library path 367041b2f0bdSmrg 36716b526288SmrgThis mode sets the library path environment variable according to '-dlopen' 367211a29bacSmrgflags. 367341b2f0bdSmrg 367411a29bacSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 367511a29bacSmrginto their corresponding uninstalled binary, and any of their required library 367611a29bacSmrgdirectories are added to the library path. 367741b2f0bdSmrg 367811a29bacSmrgThen, COMMAND is executed, with ARGS as arguments." 367911a29bacSmrg ;; 368041b2f0bdSmrg 368111a29bacSmrg finish) 368211a29bacSmrg $ECHO \ 368311a29bacSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368441b2f0bdSmrg 368511a29bacSmrgComplete the installation of libtool libraries. 368641b2f0bdSmrg 368711a29bacSmrgEach LIBDIR is a directory that contains libtool libraries. 368841b2f0bdSmrg 368911a29bacSmrgThe commands that this mode executes may require superuser privileges. Use 36906b526288Smrgthe '--dry-run' option if you just want to see what would be executed." 369111a29bacSmrg ;; 369241b2f0bdSmrg 369311a29bacSmrg install) 369411a29bacSmrg $ECHO \ 369511a29bacSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369641b2f0bdSmrg 369711a29bacSmrgInstall executables or libraries. 369841b2f0bdSmrg 369911a29bacSmrgINSTALL-COMMAND is the installation command. The first component should be 37006b526288Smrgeither the 'install' or 'cp' program. 370141b2f0bdSmrg 370211a29bacSmrgThe following components of INSTALL-COMMAND are treated specially: 370341b2f0bdSmrg 370411a29bacSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370541b2f0bdSmrg 370611a29bacSmrgThe rest of the components are interpreted as arguments to that command (only 370711a29bacSmrgBSD-compatible install options are recognized)." 370811a29bacSmrg ;; 370941b2f0bdSmrg 371011a29bacSmrg link) 371111a29bacSmrg $ECHO \ 371211a29bacSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371341b2f0bdSmrg 371411a29bacSmrgLink object files or libraries together to form another library, or to 371511a29bacSmrgcreate an executable program. 371641b2f0bdSmrg 371711a29bacSmrgLINK-COMMAND is a command using the C compiler that you would use to create 371811a29bacSmrga program from several object files. 371941b2f0bdSmrg 372011a29bacSmrgThe following components of LINK-COMMAND are treated specially: 372141b2f0bdSmrg 372211a29bacSmrg -all-static do not do any dynamic linking at all 372311a29bacSmrg -avoid-version do not add a version suffix if possible 372411a29bacSmrg -bindir BINDIR specify path to binaries directory (for systems where 372511a29bacSmrg libraries must be found in the PATH setting at runtime) 37266b526288Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 372711a29bacSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 372811a29bacSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 372911a29bacSmrg -export-symbols SYMFILE 373011a29bacSmrg try to export only the symbols listed in SYMFILE 373111a29bacSmrg -export-symbols-regex REGEX 373211a29bacSmrg try to export only the symbols matching REGEX 373311a29bacSmrg -LLIBDIR search LIBDIR for required installed libraries 373411a29bacSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 373511a29bacSmrg -module build a library that can dlopened 373611a29bacSmrg -no-fast-install disable the fast-install mode 373711a29bacSmrg -no-install link a not-installable executable 373811a29bacSmrg -no-undefined declare that a library does not refer to external symbols 373911a29bacSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 37406b526288Smrg -objectlist FILE use a list of object files found in FILE to specify objects 37416b526288Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 374211a29bacSmrg -precious-files-regex REGEX 374311a29bacSmrg don't remove output files matching REGEX 374411a29bacSmrg -release RELEASE specify package release information 374511a29bacSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 374611a29bacSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 374711a29bacSmrg -shared only do dynamic linking of libtool libraries 374811a29bacSmrg -shrext SUFFIX override the standard shared library file extension 374911a29bacSmrg -static do not do any dynamic linking of uninstalled libtool libraries 375011a29bacSmrg -static-libtool-libs 375111a29bacSmrg do not do any dynamic linking of libtool libraries 375211a29bacSmrg -version-info CURRENT[:REVISION[:AGE]] 375311a29bacSmrg specify library version info [each variable defaults to 0] 375411a29bacSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 375511a29bacSmrg -Wc,FLAG 375611a29bacSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375711a29bacSmrg -Wl,FLAG 375811a29bacSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375911a29bacSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376041b2f0bdSmrg 37616b526288SmrgAll other options (arguments beginning with '-') are ignored. 376241b2f0bdSmrg 37636b526288SmrgEvery other argument is treated as a filename. Files ending in '.la' are 376411a29bacSmrgtreated as uninstalled libtool libraries, other files are standard or library 376511a29bacSmrgobject files. 376641b2f0bdSmrg 37676b526288SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 37686b526288Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 376911a29bacSmrgrequired, except when creating a convenience library. 377041b2f0bdSmrg 37716b526288SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 37726b526288Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377311245024Smrg 37746b526288SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 377511a29bacSmrgis created, otherwise an executable program is created." 377611a29bacSmrg ;; 377741b2f0bdSmrg 377811a29bacSmrg uninstall) 377911a29bacSmrg $ECHO \ 378011a29bacSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378141b2f0bdSmrg 378211a29bacSmrgRemove libraries from an installation directory. 378341b2f0bdSmrg 378411a29bacSmrgRM is the name of the program to use to delete files associated with each FILE 37856b526288Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 378611a29bacSmrgto RM. 378741b2f0bdSmrg 378811a29bacSmrgIf FILE is a libtool library, all the files associated with it are deleted. 378911a29bacSmrgOtherwise, only FILE itself is deleted using RM." 379011a29bacSmrg ;; 379141b2f0bdSmrg 379211a29bacSmrg *) 37936b526288Smrg func_fatal_help "invalid operation mode '$opt_mode'" 379411a29bacSmrg ;; 379511a29bacSmrg esac 379641b2f0bdSmrg 379711a29bacSmrg echo 37986b526288Smrg $ECHO "Try '$progname --help' for more information about other modes." 379911a29bacSmrg} 380041b2f0bdSmrg 380111a29bacSmrg# Now that we've collected a possible --mode arg, show help if necessary 380211a29bacSmrgif $opt_help; then 38036b526288Smrg if test : = "$opt_help"; then 380411a29bacSmrg func_mode_help 380511a29bacSmrg else 380611a29bacSmrg { 380711a29bacSmrg func_help noexit 38086b526288Smrg for opt_mode in compile link execute install finish uninstall clean; do 380911a29bacSmrg func_mode_help 381011a29bacSmrg done 38116b526288Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381211a29bacSmrg { 381311a29bacSmrg func_help noexit 38146b526288Smrg for opt_mode in compile link execute install finish uninstall clean; do 381511a29bacSmrg echo 381611a29bacSmrg func_mode_help 381711a29bacSmrg done 381811a29bacSmrg } | 38196b526288Smrg $SED '1d 382011a29bacSmrg /^When reporting/,/^Report/{ 382111a29bacSmrg H 382211a29bacSmrg d 382311a29bacSmrg } 382411a29bacSmrg $x 382511a29bacSmrg /information about other modes/d 382611a29bacSmrg /more detailed .*MODE/d 382711a29bacSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382811a29bacSmrg fi 382911a29bacSmrg exit $? 383011a29bacSmrgfi 383141b2f0bdSmrg 383241b2f0bdSmrg 383311a29bacSmrg# func_mode_execute arg... 383411a29bacSmrgfunc_mode_execute () 383511a29bacSmrg{ 38366b526288Smrg $debug_cmd 38376b526288Smrg 383811a29bacSmrg # The first argument is the command name. 38396b526288Smrg cmd=$nonopt 384011a29bacSmrg test -z "$cmd" && \ 384111a29bacSmrg func_fatal_help "you must specify a COMMAND" 384241b2f0bdSmrg 384311a29bacSmrg # Handle -dlopen flags immediately. 38446b526288Smrg for file in $opt_dlopen; do 384511a29bacSmrg test -f "$file" \ 38466b526288Smrg || func_fatal_help "'$file' is not a file" 384741b2f0bdSmrg 384811a29bacSmrg dir= 384911a29bacSmrg case $file in 385011a29bacSmrg *.la) 38516b526288Smrg func_resolve_sysroot "$file" 38526b526288Smrg file=$func_resolve_sysroot_result 38536b526288Smrg 385411a29bacSmrg # Check to see that this really is a libtool archive. 385511a29bacSmrg func_lalib_unsafe_p "$file" \ 38566b526288Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 385741b2f0bdSmrg 385811a29bacSmrg # Read the libtool library. 385911a29bacSmrg dlname= 386011a29bacSmrg library_names= 386111a29bacSmrg func_source "$file" 386241b2f0bdSmrg 386311a29bacSmrg # Skip this library if it cannot be dlopened. 386411a29bacSmrg if test -z "$dlname"; then 386511a29bacSmrg # Warn if it was a shared library. 386611a29bacSmrg test -n "$library_names" && \ 38676b526288Smrg func_warning "'$file' was not linked with '-export-dynamic'" 386811a29bacSmrg continue 386911a29bacSmrg fi 387041b2f0bdSmrg 387111a29bacSmrg func_dirname "$file" "" "." 38726b526288Smrg dir=$func_dirname_result 387341b2f0bdSmrg 387411a29bacSmrg if test -f "$dir/$objdir/$dlname"; then 38756b526288Smrg func_append dir "/$objdir" 387611a29bacSmrg else 387711a29bacSmrg if test ! -f "$dir/$dlname"; then 38786b526288Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 387911a29bacSmrg fi 388011a29bacSmrg fi 388141b2f0bdSmrg ;; 388241b2f0bdSmrg 388311a29bacSmrg *.lo) 388411a29bacSmrg # Just add the directory containing the .lo file. 388511a29bacSmrg func_dirname "$file" "" "." 38866b526288Smrg dir=$func_dirname_result 388741b2f0bdSmrg ;; 388811a29bacSmrg 388911a29bacSmrg *) 38906b526288Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 389141b2f0bdSmrg continue 389241b2f0bdSmrg ;; 389311a29bacSmrg esac 389441b2f0bdSmrg 389511a29bacSmrg # Get the absolute pathname. 389611a29bacSmrg absdir=`cd "$dir" && pwd` 38976b526288Smrg test -n "$absdir" && dir=$absdir 389841b2f0bdSmrg 389911a29bacSmrg # Now add the directory to shlibpath_var. 390011a29bacSmrg if eval "test -z \"\$$shlibpath_var\""; then 390111a29bacSmrg eval "$shlibpath_var=\"\$dir\"" 390211a29bacSmrg else 390311a29bacSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 390411a29bacSmrg fi 390511a29bacSmrg done 390641b2f0bdSmrg 390711a29bacSmrg # This variable tells wrapper scripts just to set shlibpath_var 390811a29bacSmrg # rather than running their programs. 39096b526288Smrg libtool_execute_magic=$magic 391041b2f0bdSmrg 391111a29bacSmrg # Check if any of the arguments is a wrapper script. 391211a29bacSmrg args= 391311a29bacSmrg for file 391411a29bacSmrg do 391511a29bacSmrg case $file in 391611a29bacSmrg -* | *.la | *.lo ) ;; 391711a29bacSmrg *) 391811a29bacSmrg # Do a test to see if this is really a libtool program. 391911a29bacSmrg if func_ltwrapper_script_p "$file"; then 392011a29bacSmrg func_source "$file" 392111a29bacSmrg # Transform arg to wrapped name. 39226b526288Smrg file=$progdir/$program 392311a29bacSmrg elif func_ltwrapper_executable_p "$file"; then 392411a29bacSmrg func_ltwrapper_scriptname "$file" 392511a29bacSmrg func_source "$func_ltwrapper_scriptname_result" 392611a29bacSmrg # Transform arg to wrapped name. 39276b526288Smrg file=$progdir/$program 392811a29bacSmrg fi 392941b2f0bdSmrg ;; 393011a29bacSmrg esac 393111a29bacSmrg # Quote arguments (to preserve shell metacharacters). 39326b526288Smrg func_append_quoted args "$file" 393311a29bacSmrg done 393441b2f0bdSmrg 39356b526288Smrg if $opt_dry_run; then 39366b526288Smrg # Display what would be done. 39376b526288Smrg if test -n "$shlibpath_var"; then 39386b526288Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 39396b526288Smrg echo "export $shlibpath_var" 39406b526288Smrg fi 39416b526288Smrg $ECHO "$cmd$args" 39426b526288Smrg exit $EXIT_SUCCESS 39436b526288Smrg else 394411a29bacSmrg if test -n "$shlibpath_var"; then 394511a29bacSmrg # Export the shlibpath_var. 394611a29bacSmrg eval "export $shlibpath_var" 394711a29bacSmrg fi 394841b2f0bdSmrg 394911a29bacSmrg # Restore saved environment variables 395011a29bacSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 395111a29bacSmrg do 395211a29bacSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 395311a29bacSmrg $lt_var=\$save_$lt_var; export $lt_var 395411a29bacSmrg else 395511a29bacSmrg $lt_unset $lt_var 395611a29bacSmrg fi" 395711a29bacSmrg done 395841b2f0bdSmrg 395911a29bacSmrg # Now prepare to actually exec the command. 39606b526288Smrg exec_cmd=\$cmd$args 396111a29bacSmrg fi 396211a29bacSmrg} 396341b2f0bdSmrg 39646b526288Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 396541b2f0bdSmrg 396641b2f0bdSmrg 396711a29bacSmrg# func_mode_finish arg... 396811a29bacSmrgfunc_mode_finish () 396911a29bacSmrg{ 39706b526288Smrg $debug_cmd 39716b526288Smrg 39726b526288Smrg libs= 39736b526288Smrg libdirs= 397411a29bacSmrg admincmds= 397541b2f0bdSmrg 39766b526288Smrg for opt in "$nonopt" ${1+"$@"} 39776b526288Smrg do 39786b526288Smrg if test -d "$opt"; then 39796b526288Smrg func_append libdirs " $opt" 39806b526288Smrg 39816b526288Smrg elif test -f "$opt"; then 39826b526288Smrg if func_lalib_unsafe_p "$opt"; then 39836b526288Smrg func_append libs " $opt" 39846b526288Smrg else 39856b526288Smrg func_warning "'$opt' is not a valid libtool archive" 39866b526288Smrg fi 39876b526288Smrg 39886b526288Smrg else 39896b526288Smrg func_fatal_error "invalid argument '$opt'" 39906b526288Smrg fi 39916b526288Smrg done 39926b526288Smrg 39936b526288Smrg if test -n "$libs"; then 39946b526288Smrg if test -n "$lt_sysroot"; then 39956b526288Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 39966b526288Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 39976b526288Smrg else 39986b526288Smrg sysroot_cmd= 39996b526288Smrg fi 400041b2f0bdSmrg 40016b526288Smrg # Remove sysroot references 40026b526288Smrg if $opt_dry_run; then 40036b526288Smrg for lib in $libs; do 40046b526288Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 40056b526288Smrg done 40066b526288Smrg else 40076b526288Smrg tmpdir=`func_mktempdir` 40086b526288Smrg for lib in $libs; do 40096b526288Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 40106b526288Smrg > $tmpdir/tmp-la 40116b526288Smrg mv -f $tmpdir/tmp-la $lib 40126b526288Smrg done 40136b526288Smrg ${RM}r "$tmpdir" 40146b526288Smrg fi 40156b526288Smrg fi 40166b526288Smrg 40176b526288Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 401811a29bacSmrg for libdir in $libdirs; do 401911a29bacSmrg if test -n "$finish_cmds"; then 402011a29bacSmrg # Do each command in the finish commands. 402111a29bacSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 402211a29bacSmrg'"$cmd"'"' 402311a29bacSmrg fi 402411a29bacSmrg if test -n "$finish_eval"; then 402511a29bacSmrg # Do the single finish_eval. 402611a29bacSmrg eval cmds=\"$finish_eval\" 40276b526288Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 402811a29bacSmrg $cmds" 402911a29bacSmrg fi 403011a29bacSmrg done 403111a29bacSmrg fi 403241b2f0bdSmrg 403311a29bacSmrg # Exit here if they wanted silent mode. 40346b526288Smrg $opt_quiet && exit $EXIT_SUCCESS 403541b2f0bdSmrg 40366b526288Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40376b526288Smrg echo "----------------------------------------------------------------------" 40386b526288Smrg echo "Libraries have been installed in:" 40396b526288Smrg for libdir in $libdirs; do 40406b526288Smrg $ECHO " $libdir" 40416b526288Smrg done 40426b526288Smrg echo 40436b526288Smrg echo "If you ever happen to want to link against installed libraries" 40446b526288Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 40456b526288Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 40466b526288Smrg echo "flag during linking and do at least one of the following:" 40476b526288Smrg if test -n "$shlibpath_var"; then 40486b526288Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 40496b526288Smrg echo " during execution" 40506b526288Smrg fi 40516b526288Smrg if test -n "$runpath_var"; then 40526b526288Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 40536b526288Smrg echo " during linking" 40546b526288Smrg fi 40556b526288Smrg if test -n "$hardcode_libdir_flag_spec"; then 40566b526288Smrg libdir=LIBDIR 40576b526288Smrg eval flag=\"$hardcode_libdir_flag_spec\" 405841b2f0bdSmrg 40596b526288Smrg $ECHO " - use the '$flag' linker flag" 40606b526288Smrg fi 40616b526288Smrg if test -n "$admincmds"; then 40626b526288Smrg $ECHO " - have your system administrator run these commands:$admincmds" 40636b526288Smrg fi 40646b526288Smrg if test -f /etc/ld.so.conf; then 40656b526288Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 40666b526288Smrg fi 40676b526288Smrg echo 406841b2f0bdSmrg 40696b526288Smrg echo "See any operating system documentation about shared libraries for" 40706b526288Smrg case $host in 40716b526288Smrg solaris2.[6789]|solaris2.1[0-9]) 40726b526288Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 40736b526288Smrg echo "pages." 40746b526288Smrg ;; 40756b526288Smrg *) 40766b526288Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 40776b526288Smrg ;; 40786b526288Smrg esac 40796b526288Smrg echo "----------------------------------------------------------------------" 40806b526288Smrg fi 408111a29bacSmrg exit $EXIT_SUCCESS 408211a29bacSmrg} 408341b2f0bdSmrg 40846b526288Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 408541b2f0bdSmrg 408641b2f0bdSmrg 408711a29bacSmrg# func_mode_install arg... 408811a29bacSmrgfunc_mode_install () 408911a29bacSmrg{ 40906b526288Smrg $debug_cmd 40916b526288Smrg 409211a29bacSmrg # There may be an optional sh(1) argument at the beginning of 409311a29bacSmrg # install_prog (especially on Windows NT). 40946b526288Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 409511a29bacSmrg # Allow the use of GNU shtool's install command. 40966b526288Smrg case $nonopt in *shtool*) :;; *) false;; esac 40976b526288Smrg then 409811a29bacSmrg # Aesthetically quote it. 409911a29bacSmrg func_quote_for_eval "$nonopt" 410011a29bacSmrg install_prog="$func_quote_for_eval_result " 410111a29bacSmrg arg=$1 410211a29bacSmrg shift 410311a29bacSmrg else 410411a29bacSmrg install_prog= 410511a29bacSmrg arg=$nonopt 410611a29bacSmrg fi 410741b2f0bdSmrg 410811a29bacSmrg # The real first argument should be the name of the installation program. 410911a29bacSmrg # Aesthetically quote it. 411011a29bacSmrg func_quote_for_eval "$arg" 41116b526288Smrg func_append install_prog "$func_quote_for_eval_result" 411211a29bacSmrg install_shared_prog=$install_prog 411311a29bacSmrg case " $install_prog " in 411411a29bacSmrg *[\\\ /]cp\ *) install_cp=: ;; 411511a29bacSmrg *) install_cp=false ;; 411611a29bacSmrg esac 411741b2f0bdSmrg 411811a29bacSmrg # We need to accept at least all the BSD install flags. 411911a29bacSmrg dest= 412011a29bacSmrg files= 412111a29bacSmrg opts= 412211a29bacSmrg prev= 412311a29bacSmrg install_type= 41246b526288Smrg isdir=false 412511a29bacSmrg stripme= 412611a29bacSmrg no_mode=: 412711a29bacSmrg for arg 412811a29bacSmrg do 412911a29bacSmrg arg2= 413011a29bacSmrg if test -n "$dest"; then 41316b526288Smrg func_append files " $dest" 413211a29bacSmrg dest=$arg 413341b2f0bdSmrg continue 413411a29bacSmrg fi 413541b2f0bdSmrg 413611a29bacSmrg case $arg in 41376b526288Smrg -d) isdir=: ;; 413811a29bacSmrg -f) 413911a29bacSmrg if $install_cp; then :; else 414011a29bacSmrg prev=$arg 414141b2f0bdSmrg fi 414211a29bacSmrg ;; 414311a29bacSmrg -g | -m | -o) 414411a29bacSmrg prev=$arg 414511a29bacSmrg ;; 414611a29bacSmrg -s) 414711a29bacSmrg stripme=" -s" 414841b2f0bdSmrg continue 414941b2f0bdSmrg ;; 415011a29bacSmrg -*) 415111a29bacSmrg ;; 415241b2f0bdSmrg *) 415311a29bacSmrg # If the previous option needed an argument, then skip it. 415411a29bacSmrg if test -n "$prev"; then 41556b526288Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415611a29bacSmrg arg2=$install_override_mode 415711a29bacSmrg no_mode=false 415811a29bacSmrg fi 415911a29bacSmrg prev= 416011a29bacSmrg else 416111a29bacSmrg dest=$arg 416211a29bacSmrg continue 416311a29bacSmrg fi 416441b2f0bdSmrg ;; 416511a29bacSmrg esac 416641b2f0bdSmrg 416711a29bacSmrg # Aesthetically quote the argument. 416811a29bacSmrg func_quote_for_eval "$arg" 41696b526288Smrg func_append install_prog " $func_quote_for_eval_result" 417011a29bacSmrg if test -n "$arg2"; then 417111a29bacSmrg func_quote_for_eval "$arg2" 417241b2f0bdSmrg fi 41736b526288Smrg func_append install_shared_prog " $func_quote_for_eval_result" 417411a29bacSmrg done 417541b2f0bdSmrg 417611a29bacSmrg test -z "$install_prog" && \ 417711a29bacSmrg func_fatal_help "you must specify an install program" 417841b2f0bdSmrg 417911a29bacSmrg test -n "$prev" && \ 41806b526288Smrg func_fatal_help "the '$prev' option requires an argument" 418141b2f0bdSmrg 418211a29bacSmrg if test -n "$install_override_mode" && $no_mode; then 418311a29bacSmrg if $install_cp; then :; else 418411a29bacSmrg func_quote_for_eval "$install_override_mode" 41856b526288Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418611a29bacSmrg fi 418741b2f0bdSmrg fi 418841b2f0bdSmrg 418911a29bacSmrg if test -z "$files"; then 419011a29bacSmrg if test -z "$dest"; then 419111a29bacSmrg func_fatal_help "no file or destination specified" 419211a29bacSmrg else 419311a29bacSmrg func_fatal_help "you must specify a destination" 419441b2f0bdSmrg fi 419541b2f0bdSmrg fi 419641b2f0bdSmrg 419711a29bacSmrg # Strip any trailing slash from the destination. 419811a29bacSmrg func_stripname '' '/' "$dest" 419911a29bacSmrg dest=$func_stripname_result 420041b2f0bdSmrg 420111a29bacSmrg # Check to see that the destination is a directory. 42026b526288Smrg test -d "$dest" && isdir=: 42036b526288Smrg if $isdir; then 42046b526288Smrg destdir=$dest 420511a29bacSmrg destname= 420611a29bacSmrg else 420711a29bacSmrg func_dirname_and_basename "$dest" "" "." 42086b526288Smrg destdir=$func_dirname_result 42096b526288Smrg destname=$func_basename_result 421011a29bacSmrg 421111a29bacSmrg # Not a directory, so check to see that there is only one file specified. 421211a29bacSmrg set dummy $files; shift 421311a29bacSmrg test "$#" -gt 1 && \ 42146b526288Smrg func_fatal_help "'$dest' is not a directory" 421511a29bacSmrg fi 421611a29bacSmrg case $destdir in 421711a29bacSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 421841b2f0bdSmrg *) 421911a29bacSmrg for file in $files; do 422011a29bacSmrg case $file in 422111a29bacSmrg *.lo) ;; 422211a29bacSmrg *) 42236b526288Smrg func_fatal_help "'$destdir' must be an absolute directory name" 422411a29bacSmrg ;; 422511a29bacSmrg esac 422611a29bacSmrg done 422741b2f0bdSmrg ;; 422841b2f0bdSmrg esac 422941b2f0bdSmrg 423011a29bacSmrg # This variable tells wrapper scripts just to set variables rather 423111a29bacSmrg # than running their programs. 42326b526288Smrg libtool_install_magic=$magic 423341b2f0bdSmrg 423411a29bacSmrg staticlibs= 423511a29bacSmrg future_libdirs= 423611a29bacSmrg current_libdirs= 423711a29bacSmrg for file in $files; do 423841b2f0bdSmrg 423911a29bacSmrg # Do each installation. 424011a29bacSmrg case $file in 424111a29bacSmrg *.$libext) 424211a29bacSmrg # Do the static libraries later. 42436b526288Smrg func_append staticlibs " $file" 424411a29bacSmrg ;; 424511a29bacSmrg 424611a29bacSmrg *.la) 42476b526288Smrg func_resolve_sysroot "$file" 42486b526288Smrg file=$func_resolve_sysroot_result 42496b526288Smrg 425011a29bacSmrg # Check to see that this really is a libtool archive. 425111a29bacSmrg func_lalib_unsafe_p "$file" \ 42526b526288Smrg || func_fatal_help "'$file' is not a valid libtool archive" 425311a29bacSmrg 425411a29bacSmrg library_names= 425511a29bacSmrg old_library= 425611a29bacSmrg relink_command= 425711a29bacSmrg func_source "$file" 425811a29bacSmrg 425911a29bacSmrg # Add the libdir to current_libdirs if it is the destination. 426011a29bacSmrg if test "X$destdir" = "X$libdir"; then 426111a29bacSmrg case "$current_libdirs " in 426211a29bacSmrg *" $libdir "*) ;; 42636b526288Smrg *) func_append current_libdirs " $libdir" ;; 426441b2f0bdSmrg esac 426511a29bacSmrg else 426611a29bacSmrg # Note the libdir as a future libdir. 426711a29bacSmrg case "$future_libdirs " in 426811a29bacSmrg *" $libdir "*) ;; 42696b526288Smrg *) func_append future_libdirs " $libdir" ;; 427011a29bacSmrg esac 427111a29bacSmrg fi 427241b2f0bdSmrg 427311a29bacSmrg func_dirname "$file" "/" "" 42746b526288Smrg dir=$func_dirname_result 42756b526288Smrg func_append dir "$objdir" 427611a29bacSmrg 427711a29bacSmrg if test -n "$relink_command"; then 427811a29bacSmrg # Determine the prefix the user has applied to our future dir. 427911a29bacSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 428011a29bacSmrg 428111a29bacSmrg # Don't allow the user to place us outside of our expected 428211a29bacSmrg # location b/c this prevents finding dependent libraries that 428311a29bacSmrg # are installed to the same prefix. 428411a29bacSmrg # At present, this check doesn't affect windows .dll's that 428511a29bacSmrg # are installed into $libdir/../bin (currently, that works fine) 428611a29bacSmrg # but it's something to keep an eye on. 428711a29bacSmrg test "$inst_prefix_dir" = "$destdir" && \ 42886b526288Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 428911a29bacSmrg 429011a29bacSmrg if test -n "$inst_prefix_dir"; then 429111a29bacSmrg # Stick the inst_prefix_dir data into the link command. 429211a29bacSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 429311a29bacSmrg else 429411a29bacSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 429511a29bacSmrg fi 429611a29bacSmrg 42976b526288Smrg func_warning "relinking '$file'" 429811a29bacSmrg func_show_eval "$relink_command" \ 42996b526288Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 430011a29bacSmrg fi 430111a29bacSmrg 430211a29bacSmrg # See the names of the shared library. 430311a29bacSmrg set dummy $library_names; shift 430411a29bacSmrg if test -n "$1"; then 43056b526288Smrg realname=$1 430611a29bacSmrg shift 430711a29bacSmrg 43086b526288Smrg srcname=$realname 43096b526288Smrg test -n "$relink_command" && srcname=${realname}T 431011a29bacSmrg 431111a29bacSmrg # Install the shared library and build the symlinks. 431211a29bacSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 431311a29bacSmrg 'exit $?' 43146b526288Smrg tstripme=$stripme 431511a29bacSmrg case $host_os in 431611a29bacSmrg cygwin* | mingw* | pw32* | cegcc*) 431711a29bacSmrg case $realname in 431811a29bacSmrg *.dll.a) 43196b526288Smrg tstripme= 43206b526288Smrg ;; 43216b526288Smrg esac 43226b526288Smrg ;; 43236b526288Smrg os2*) 43246b526288Smrg case $realname in 43256b526288Smrg *_dll.a) 43266b526288Smrg tstripme= 432711a29bacSmrg ;; 432811a29bacSmrg esac 432941b2f0bdSmrg ;; 433041b2f0bdSmrg esac 433111a29bacSmrg if test -n "$tstripme" && test -n "$striplib"; then 433211a29bacSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 433311a29bacSmrg fi 433411a29bacSmrg 433511a29bacSmrg if test "$#" -gt 0; then 433611a29bacSmrg # Delete the old symlinks, and create new ones. 43376b526288Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 433811a29bacSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 433911a29bacSmrg # so we also need to try rm && ln -s. 434011a29bacSmrg for linkname 434111a29bacSmrg do 434211a29bacSmrg test "$linkname" != "$realname" \ 434311a29bacSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 434411a29bacSmrg done 434511a29bacSmrg fi 434611a29bacSmrg 434711a29bacSmrg # Do each command in the postinstall commands. 43486b526288Smrg lib=$destdir/$realname 434911a29bacSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 435011a29bacSmrg fi 435111a29bacSmrg 435211a29bacSmrg # Install the pseudo-library for information purposes. 435311a29bacSmrg func_basename "$file" 43546b526288Smrg name=$func_basename_result 43556b526288Smrg instname=$dir/${name}i 435611a29bacSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 435711a29bacSmrg 435811a29bacSmrg # Maybe install the static library, too. 43596b526288Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 436041b2f0bdSmrg ;; 436111a29bacSmrg 436211a29bacSmrg *.lo) 436311a29bacSmrg # Install (i.e. copy) a libtool object. 436411a29bacSmrg 436511a29bacSmrg # Figure out destination file name, if it wasn't already specified. 436611a29bacSmrg if test -n "$destname"; then 43676b526288Smrg destfile=$destdir/$destname 436811a29bacSmrg else 436911a29bacSmrg func_basename "$file" 43706b526288Smrg destfile=$func_basename_result 43716b526288Smrg destfile=$destdir/$destfile 437211a29bacSmrg fi 437311a29bacSmrg 437411a29bacSmrg # Deduce the name of the destination old-style object file. 437511a29bacSmrg case $destfile in 437611a29bacSmrg *.lo) 437711a29bacSmrg func_lo2o "$destfile" 437811a29bacSmrg staticdest=$func_lo2o_result 437941b2f0bdSmrg ;; 438011a29bacSmrg *.$objext) 43816b526288Smrg staticdest=$destfile 438211a29bacSmrg destfile= 438341b2f0bdSmrg ;; 438411a29bacSmrg *) 43856b526288Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 438641b2f0bdSmrg ;; 438711a29bacSmrg esac 438811a29bacSmrg 438911a29bacSmrg # Install the libtool object if requested. 439011a29bacSmrg test -n "$destfile" && \ 439111a29bacSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 439211a29bacSmrg 439311a29bacSmrg # Install the old object if enabled. 43946b526288Smrg if test yes = "$build_old_libs"; then 439511a29bacSmrg # Deduce the name of the old-style object file. 439611a29bacSmrg func_lo2o "$file" 439711a29bacSmrg staticobj=$func_lo2o_result 439811a29bacSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439941b2f0bdSmrg fi 440011a29bacSmrg exit $EXIT_SUCCESS 440111a29bacSmrg ;; 440241b2f0bdSmrg 440311a29bacSmrg *) 440411a29bacSmrg # Figure out destination file name, if it wasn't already specified. 440511a29bacSmrg if test -n "$destname"; then 44066b526288Smrg destfile=$destdir/$destname 440741b2f0bdSmrg else 440811a29bacSmrg func_basename "$file" 44096b526288Smrg destfile=$func_basename_result 44106b526288Smrg destfile=$destdir/$destfile 441141b2f0bdSmrg fi 441241b2f0bdSmrg 441311a29bacSmrg # If the file is missing, and there is a .exe on the end, strip it 441411a29bacSmrg # because it is most likely a libtool script we actually want to 441511a29bacSmrg # install 44166b526288Smrg stripped_ext= 441711a29bacSmrg case $file in 441811a29bacSmrg *.exe) 441911a29bacSmrg if test ! -f "$file"; then 442011a29bacSmrg func_stripname '' '.exe' "$file" 442111a29bacSmrg file=$func_stripname_result 44226b526288Smrg stripped_ext=.exe 442311a29bacSmrg fi 442411a29bacSmrg ;; 442511a29bacSmrg esac 442641b2f0bdSmrg 442711a29bacSmrg # Do a test to see if this is really a libtool program. 442811a29bacSmrg case $host in 442911a29bacSmrg *cygwin* | *mingw*) 443011a29bacSmrg if func_ltwrapper_executable_p "$file"; then 443111a29bacSmrg func_ltwrapper_scriptname "$file" 443211a29bacSmrg wrapper=$func_ltwrapper_scriptname_result 443311a29bacSmrg else 443411a29bacSmrg func_stripname '' '.exe' "$file" 443511a29bacSmrg wrapper=$func_stripname_result 443611a29bacSmrg fi 443711a29bacSmrg ;; 443811a29bacSmrg *) 443911a29bacSmrg wrapper=$file 444011a29bacSmrg ;; 444111a29bacSmrg esac 444211a29bacSmrg if func_ltwrapper_script_p "$wrapper"; then 444311a29bacSmrg notinst_deplibs= 444411a29bacSmrg relink_command= 444541b2f0bdSmrg 444611a29bacSmrg func_source "$wrapper" 444741b2f0bdSmrg 444811a29bacSmrg # Check the variables that should have been set. 444911a29bacSmrg test -z "$generated_by_libtool_version" && \ 44506b526288Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 445141b2f0bdSmrg 44526b526288Smrg finalize=: 445311a29bacSmrg for lib in $notinst_deplibs; do 445411a29bacSmrg # Check to see that each library is installed. 445511a29bacSmrg libdir= 445611a29bacSmrg if test -f "$lib"; then 445711a29bacSmrg func_source "$lib" 445841b2f0bdSmrg fi 44596b526288Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 446011a29bacSmrg if test -n "$libdir" && test ! -f "$libfile"; then 44616b526288Smrg func_warning "'$lib' has not been installed in '$libdir'" 44626b526288Smrg finalize=false 446311a29bacSmrg fi 446411a29bacSmrg done 446541b2f0bdSmrg 446611a29bacSmrg relink_command= 446711a29bacSmrg func_source "$wrapper" 446841b2f0bdSmrg 446911a29bacSmrg outputname= 44706b526288Smrg if test no = "$fast_install" && test -n "$relink_command"; then 447111a29bacSmrg $opt_dry_run || { 44726b526288Smrg if $finalize; then 447311a29bacSmrg tmpdir=`func_mktempdir` 447411a29bacSmrg func_basename "$file$stripped_ext" 44756b526288Smrg file=$func_basename_result 44766b526288Smrg outputname=$tmpdir/$file 447711a29bacSmrg # Replace the output file specification. 447811a29bacSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 447911a29bacSmrg 44806b526288Smrg $opt_quiet || { 448111a29bacSmrg func_quote_for_expand "$relink_command" 448211a29bacSmrg eval "func_echo $func_quote_for_expand_result" 448311a29bacSmrg } 448411a29bacSmrg if eval "$relink_command"; then : 448511a29bacSmrg else 44866b526288Smrg func_error "error: relink '$file' with the above command before installing it" 448711a29bacSmrg $opt_dry_run || ${RM}r "$tmpdir" 448811a29bacSmrg continue 448911a29bacSmrg fi 44906b526288Smrg file=$outputname 449111a29bacSmrg else 44926b526288Smrg func_warning "cannot relink '$file'" 449311a29bacSmrg fi 449411a29bacSmrg } 449541b2f0bdSmrg else 449611a29bacSmrg # Install the binary that we compiled earlier. 449711a29bacSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 449841b2f0bdSmrg fi 449911a29bacSmrg fi 450041b2f0bdSmrg 450111a29bacSmrg # remove .exe since cygwin /usr/bin/install will append another 450211a29bacSmrg # one anyway 450311a29bacSmrg case $install_prog,$host in 450411a29bacSmrg */usr/bin/install*,*cygwin*) 450511a29bacSmrg case $file:$destfile in 450611a29bacSmrg *.exe:*.exe) 450711a29bacSmrg # this is ok 450811a29bacSmrg ;; 450911a29bacSmrg *.exe:*) 451011a29bacSmrg destfile=$destfile.exe 451111a29bacSmrg ;; 451211a29bacSmrg *:*.exe) 451311a29bacSmrg func_stripname '' '.exe' "$destfile" 451411a29bacSmrg destfile=$func_stripname_result 451511a29bacSmrg ;; 451611a29bacSmrg esac 451741b2f0bdSmrg ;; 451841b2f0bdSmrg esac 451911a29bacSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 452011a29bacSmrg $opt_dry_run || if test -n "$outputname"; then 452111a29bacSmrg ${RM}r "$tmpdir" 452211a29bacSmrg fi 452311a29bacSmrg ;; 452411a29bacSmrg esac 452511a29bacSmrg done 452641b2f0bdSmrg 452711a29bacSmrg for file in $staticlibs; do 452811a29bacSmrg func_basename "$file" 45296b526288Smrg name=$func_basename_result 453011a29bacSmrg 453111a29bacSmrg # Set up the ranlib parameters. 45326b526288Smrg oldlib=$destdir/$name 45336b526288Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 45346b526288Smrg tool_oldlib=$func_to_tool_file_result 453511a29bacSmrg 453611a29bacSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 453711a29bacSmrg 453811a29bacSmrg if test -n "$stripme" && test -n "$old_striplib"; then 45396b526288Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 454011a29bacSmrg fi 454111a29bacSmrg 454211a29bacSmrg # Do each command in the postinstall commands. 454311a29bacSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 454411a29bacSmrg done 454511a29bacSmrg 454611a29bacSmrg test -n "$future_libdirs" && \ 45476b526288Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 454811a29bacSmrg 454911a29bacSmrg if test -n "$current_libdirs"; then 455011a29bacSmrg # Maybe just do a dry run. 455111a29bacSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 45526b526288Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 455311a29bacSmrg else 455411a29bacSmrg exit $EXIT_SUCCESS 455511a29bacSmrg fi 455611a29bacSmrg} 455711a29bacSmrg 45586b526288Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 455911a29bacSmrg 456011a29bacSmrg 456111a29bacSmrg# func_generate_dlsyms outputname originator pic_p 456211a29bacSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 456311a29bacSmrg# a dlpreopen symbol table. 456411a29bacSmrgfunc_generate_dlsyms () 456511a29bacSmrg{ 45666b526288Smrg $debug_cmd 45676b526288Smrg 45686b526288Smrg my_outputname=$1 45696b526288Smrg my_originator=$2 45706b526288Smrg my_pic_p=${3-false} 45716b526288Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 457211a29bacSmrg my_dlsyms= 457311a29bacSmrg 45746b526288Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 457511a29bacSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 45766b526288Smrg my_dlsyms=${my_outputname}S.c 457711a29bacSmrg else 457811a29bacSmrg func_error "not configured to extract global symbols from dlpreopened files" 457911a29bacSmrg fi 458011a29bacSmrg fi 458111a29bacSmrg 458211a29bacSmrg if test -n "$my_dlsyms"; then 458311a29bacSmrg case $my_dlsyms in 458411a29bacSmrg "") ;; 458511a29bacSmrg *.c) 458611a29bacSmrg # Discover the nlist of each of the dlfiles. 45876b526288Smrg nlist=$output_objdir/$my_outputname.nm 458811a29bacSmrg 458911a29bacSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 459011a29bacSmrg 459111a29bacSmrg # Parse the name list into a source file. 459211a29bacSmrg func_verbose "creating $output_objdir/$my_dlsyms" 459311a29bacSmrg 459411a29bacSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 45956b526288Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 45966b526288Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 459711a29bacSmrg 459811a29bacSmrg#ifdef __cplusplus 459911a29bacSmrgextern \"C\" { 460011a29bacSmrg#endif 460111a29bacSmrg 46026b526288Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460311a29bacSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460411a29bacSmrg#endif 460511a29bacSmrg 46066b526288Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 46076b526288Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 46086b526288Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 46096b526288Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 46106b526288Smrg# define LT_DLSYM_CONST 46116b526288Smrg#elif defined __osf__ 46126b526288Smrg/* This system does not cope well with relocations in const data. */ 46136b526288Smrg# define LT_DLSYM_CONST 46146b526288Smrg#else 46156b526288Smrg# define LT_DLSYM_CONST const 46166b526288Smrg#endif 46176b526288Smrg 46186b526288Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 46196b526288Smrg 462011a29bacSmrg/* External symbol declarations for the compiler. */\ 462111a29bacSmrg" 462211a29bacSmrg 46236b526288Smrg if test yes = "$dlself"; then 46246b526288Smrg func_verbose "generating symbol list for '$output'" 462511a29bacSmrg 462611a29bacSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 462711a29bacSmrg 462811a29bacSmrg # Add our own program objects to the symbol list. 462911a29bacSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 463011a29bacSmrg for progfile in $progfiles; do 46316b526288Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 46326b526288Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 46336b526288Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 463411a29bacSmrg done 463511a29bacSmrg 463611a29bacSmrg if test -n "$exclude_expsyms"; then 463711a29bacSmrg $opt_dry_run || { 463811a29bacSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 463911a29bacSmrg eval '$MV "$nlist"T "$nlist"' 464011a29bacSmrg } 464141b2f0bdSmrg fi 464211a29bacSmrg 464311a29bacSmrg if test -n "$export_symbols_regex"; then 464411a29bacSmrg $opt_dry_run || { 464511a29bacSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 464611a29bacSmrg eval '$MV "$nlist"T "$nlist"' 464711a29bacSmrg } 464811a29bacSmrg fi 464911a29bacSmrg 465011a29bacSmrg # Prepare the list of exported symbols 465111a29bacSmrg if test -z "$export_symbols"; then 46526b526288Smrg export_symbols=$output_objdir/$outputname.exp 465311a29bacSmrg $opt_dry_run || { 465411a29bacSmrg $RM $export_symbols 46556b526288Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 465611a29bacSmrg case $host in 465711a29bacSmrg *cygwin* | *mingw* | *cegcc* ) 465811a29bacSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 465911a29bacSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 466011a29bacSmrg ;; 466111a29bacSmrg esac 466211a29bacSmrg } 466341b2f0bdSmrg else 466411a29bacSmrg $opt_dry_run || { 46656b526288Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 466611a29bacSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 466711a29bacSmrg eval '$MV "$nlist"T "$nlist"' 466811a29bacSmrg case $host in 466911a29bacSmrg *cygwin* | *mingw* | *cegcc* ) 467011a29bacSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 467111a29bacSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 467211a29bacSmrg ;; 467311a29bacSmrg esac 467411a29bacSmrg } 467541b2f0bdSmrg fi 467611a29bacSmrg fi 467741b2f0bdSmrg 467811a29bacSmrg for dlprefile in $dlprefiles; do 46796b526288Smrg func_verbose "extracting global C symbols from '$dlprefile'" 468011a29bacSmrg func_basename "$dlprefile" 46816b526288Smrg name=$func_basename_result 46826b526288Smrg case $host in 46836b526288Smrg *cygwin* | *mingw* | *cegcc* ) 46846b526288Smrg # if an import library, we need to obtain dlname 46856b526288Smrg if func_win32_import_lib_p "$dlprefile"; then 46866b526288Smrg func_tr_sh "$dlprefile" 46876b526288Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 46886b526288Smrg dlprefile_dlbasename= 46896b526288Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 46906b526288Smrg # Use subshell, to avoid clobbering current variable values 46916b526288Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 46926b526288Smrg if test -n "$dlprefile_dlname"; then 46936b526288Smrg func_basename "$dlprefile_dlname" 46946b526288Smrg dlprefile_dlbasename=$func_basename_result 46956b526288Smrg else 46966b526288Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 46976b526288Smrg $sharedlib_from_linklib_cmd "$dlprefile" 46986b526288Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 46996b526288Smrg fi 47006b526288Smrg fi 47016b526288Smrg $opt_dry_run || { 47026b526288Smrg if test -n "$dlprefile_dlbasename"; then 47036b526288Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 47046b526288Smrg else 47056b526288Smrg func_warning "Could not compute DLL name from $name" 47066b526288Smrg eval '$ECHO ": $name " >> "$nlist"' 47076b526288Smrg fi 47086b526288Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47096b526288Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 47106b526288Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 47116b526288Smrg } 47126b526288Smrg else # not an import lib 47136b526288Smrg $opt_dry_run || { 47146b526288Smrg eval '$ECHO ": $name " >> "$nlist"' 47156b526288Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47166b526288Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47176b526288Smrg } 47186b526288Smrg fi 47196b526288Smrg ;; 47206b526288Smrg *) 47216b526288Smrg $opt_dry_run || { 47226b526288Smrg eval '$ECHO ": $name " >> "$nlist"' 47236b526288Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47246b526288Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47256b526288Smrg } 47266b526288Smrg ;; 47276b526288Smrg esac 472811a29bacSmrg done 472911a29bacSmrg 473011a29bacSmrg $opt_dry_run || { 473111a29bacSmrg # Make sure we have at least an empty file. 473211a29bacSmrg test -f "$nlist" || : > "$nlist" 473311a29bacSmrg 473411a29bacSmrg if test -n "$exclude_expsyms"; then 473511a29bacSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 473611a29bacSmrg $MV "$nlist"T "$nlist" 473741b2f0bdSmrg fi 473811a29bacSmrg 473911a29bacSmrg # Try sorting and uniquifying the output. 474011a29bacSmrg if $GREP -v "^: " < "$nlist" | 474111a29bacSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 474211a29bacSmrg sort -k 3 474311a29bacSmrg else 474411a29bacSmrg sort +2 474511a29bacSmrg fi | 474611a29bacSmrg uniq > "$nlist"S; then 474711a29bacSmrg : 474841b2f0bdSmrg else 474911a29bacSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 475041b2f0bdSmrg fi 475141b2f0bdSmrg 475211a29bacSmrg if test -f "$nlist"S; then 475311a29bacSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 475441b2f0bdSmrg else 475511a29bacSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 475641b2f0bdSmrg fi 475741b2f0bdSmrg 47586b526288Smrg func_show_eval '$RM "${nlist}I"' 47596b526288Smrg if test -n "$global_symbol_to_import"; then 47606b526288Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 47616b526288Smrg fi 47626b526288Smrg 476311a29bacSmrg echo >> "$output_objdir/$my_dlsyms" "\ 476441b2f0bdSmrg 476511a29bacSmrg/* The mapping between symbol names and symbols. */ 476611a29bacSmrgtypedef struct { 476711a29bacSmrg const char *name; 476811a29bacSmrg void *address; 476911a29bacSmrg} lt_dlsymlist; 47706b526288Smrgextern LT_DLSYM_CONST lt_dlsymlist 47716b526288Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477211a29bacSmrg" 47736b526288Smrg 47746b526288Smrg if test -s "$nlist"I; then 477511a29bacSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47766b526288Smrgstatic void lt_syminit(void) 47776b526288Smrg{ 47786b526288Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 47796b526288Smrg for (; symbol->name; ++symbol) 47806b526288Smrg {" 47816b526288Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478211a29bacSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47836b526288Smrg } 47846b526288Smrg}" 47856b526288Smrg fi 478611a29bacSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47876b526288SmrgLT_DLSYM_CONST lt_dlsymlist 478811a29bacSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 47896b526288Smrg{ {\"$my_originator\", (void *) 0}," 47906b526288Smrg 47916b526288Smrg if test -s "$nlist"I; then 47926b526288Smrg echo >> "$output_objdir/$my_dlsyms" "\ 47936b526288Smrg {\"@INIT@\", (void *) <_syminit}," 47946b526288Smrg fi 479541b2f0bdSmrg 479611a29bacSmrg case $need_lib_prefix in 479711a29bacSmrg no) 479811a29bacSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 479911a29bacSmrg ;; 480011a29bacSmrg *) 480111a29bacSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 480211a29bacSmrg ;; 480311a29bacSmrg esac 480411a29bacSmrg echo >> "$output_objdir/$my_dlsyms" "\ 480511a29bacSmrg {0, (void *) 0} 480611a29bacSmrg}; 480741b2f0bdSmrg 480811a29bacSmrg/* This works around a problem in FreeBSD linker */ 480911a29bacSmrg#ifdef FREEBSD_WORKAROUND 481011a29bacSmrgstatic const void *lt_preloaded_setup() { 481111a29bacSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 481211a29bacSmrg} 481311a29bacSmrg#endif 481441b2f0bdSmrg 481511a29bacSmrg#ifdef __cplusplus 481611a29bacSmrg} 481711a29bacSmrg#endif\ 481811a29bacSmrg" 481911a29bacSmrg } # !$opt_dry_run 482041b2f0bdSmrg 482111a29bacSmrg pic_flag_for_symtable= 482211a29bacSmrg case "$compile_command " in 482311a29bacSmrg *" -static "*) ;; 482411a29bacSmrg *) 482511a29bacSmrg case $host in 482611a29bacSmrg # compiling the symbol table file with pic_flag works around 482711a29bacSmrg # a FreeBSD bug that causes programs to crash when -lm is 482811a29bacSmrg # linked before any other PIC object. But we must not use 482911a29bacSmrg # pic_flag when linking with -static. The problem exists in 483011a29bacSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 48316b526288Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 483211a29bacSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 483311a29bacSmrg *-*-hpux*) 483411a29bacSmrg pic_flag_for_symtable=" $pic_flag" ;; 483511a29bacSmrg *) 48366b526288Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 483711a29bacSmrg ;; 483811a29bacSmrg esac 483911a29bacSmrg ;; 484011a29bacSmrg esac 484111a29bacSmrg symtab_cflags= 484211a29bacSmrg for arg in $LTCFLAGS; do 484311a29bacSmrg case $arg in 484411a29bacSmrg -pie | -fpie | -fPIE) ;; 48456b526288Smrg *) func_append symtab_cflags " $arg" ;; 484611a29bacSmrg esac 484711a29bacSmrg done 484841b2f0bdSmrg 484911a29bacSmrg # Now compile the dynamic symbol file. 485011a29bacSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 485141b2f0bdSmrg 485211a29bacSmrg # Clean up the generated files. 48536b526288Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485441b2f0bdSmrg 485511a29bacSmrg # Transform the symbol file into the correct name. 48566b526288Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 485711a29bacSmrg case $host in 485811a29bacSmrg *cygwin* | *mingw* | *cegcc* ) 485911a29bacSmrg if test -f "$output_objdir/$my_outputname.def"; then 486011a29bacSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486111a29bacSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486211a29bacSmrg else 486311a29bacSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486411a29bacSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486511a29bacSmrg fi 486611a29bacSmrg ;; 486711a29bacSmrg *) 486811a29bacSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486911a29bacSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 487011a29bacSmrg ;; 487111a29bacSmrg esac 487211a29bacSmrg ;; 487311a29bacSmrg *) 48746b526288Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 487511a29bacSmrg ;; 487611a29bacSmrg esac 487711a29bacSmrg else 487811a29bacSmrg # We keep going just in case the user didn't refer to 487911a29bacSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 488011a29bacSmrg # really was required. 488141b2f0bdSmrg 488211a29bacSmrg # Nullify the symbol file. 488311a29bacSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488411a29bacSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 488511a29bacSmrg fi 488611a29bacSmrg} 488741b2f0bdSmrg 48886b526288Smrg# func_cygming_gnu_implib_p ARG 48896b526288Smrg# This predicate returns with zero status (TRUE) if 48906b526288Smrg# ARG is a GNU/binutils-style import library. Returns 48916b526288Smrg# with nonzero status (FALSE) otherwise. 48926b526288Smrgfunc_cygming_gnu_implib_p () 48936b526288Smrg{ 48946b526288Smrg $debug_cmd 48956b526288Smrg 48966b526288Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 48976b526288Smrg 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)$'` 48986b526288Smrg test -n "$func_cygming_gnu_implib_tmp" 48996b526288Smrg} 49006b526288Smrg 49016b526288Smrg# func_cygming_ms_implib_p ARG 49026b526288Smrg# This predicate returns with zero status (TRUE) if 49036b526288Smrg# ARG is an MS-style import library. Returns 49046b526288Smrg# with nonzero status (FALSE) otherwise. 49056b526288Smrgfunc_cygming_ms_implib_p () 49066b526288Smrg{ 49076b526288Smrg $debug_cmd 49086b526288Smrg 49096b526288Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49106b526288Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 49116b526288Smrg test -n "$func_cygming_ms_implib_tmp" 49126b526288Smrg} 49136b526288Smrg 491411a29bacSmrg# func_win32_libid arg 491511a29bacSmrg# return the library type of file 'arg' 491611a29bacSmrg# 491711a29bacSmrg# Need a lot of goo to handle *both* DLLs and import libs 491811a29bacSmrg# Has to be a shell function in order to 'eat' the argument 491911a29bacSmrg# that is supplied when $file_magic_command is called. 492011a29bacSmrg# Despite the name, also deal with 64 bit binaries. 492111a29bacSmrgfunc_win32_libid () 492211a29bacSmrg{ 49236b526288Smrg $debug_cmd 49246b526288Smrg 49256b526288Smrg win32_libid_type=unknown 492611a29bacSmrg win32_fileres=`file -L $1 2>/dev/null` 492711a29bacSmrg case $win32_fileres in 492811a29bacSmrg *ar\ archive\ import\ library*) # definitely import 492911a29bacSmrg win32_libid_type="x86 archive import" 493011a29bacSmrg ;; 493111a29bacSmrg *ar\ archive*) # could be an import, or static 493211a29bacSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 493311a29bacSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493411a29bacSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 49356b526288Smrg case $nm_interface in 49366b526288Smrg "MS dumpbin") 49376b526288Smrg if func_cygming_ms_implib_p "$1" || 49386b526288Smrg func_cygming_gnu_implib_p "$1" 49396b526288Smrg then 49406b526288Smrg win32_nmres=import 49416b526288Smrg else 49426b526288Smrg win32_nmres= 49436b526288Smrg fi 49446b526288Smrg ;; 49456b526288Smrg *) 49466b526288Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49476b526288Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 49486b526288Smrg $SED -n -e ' 494911a29bacSmrg 1,100{ 495011a29bacSmrg / I /{ 49516b526288Smrg s|.*|import| 495211a29bacSmrg p 495311a29bacSmrg q 495411a29bacSmrg } 495511a29bacSmrg }'` 49566b526288Smrg ;; 49576b526288Smrg esac 495811a29bacSmrg case $win32_nmres in 495911a29bacSmrg import*) win32_libid_type="x86 archive import";; 496011a29bacSmrg *) win32_libid_type="x86 archive static";; 496111a29bacSmrg esac 496211a29bacSmrg fi 496311a29bacSmrg ;; 496411a29bacSmrg *DLL*) 496511a29bacSmrg win32_libid_type="x86 DLL" 496611a29bacSmrg ;; 496711a29bacSmrg *executable*) # but shell scripts are "executable" too... 496811a29bacSmrg case $win32_fileres in 496911a29bacSmrg *MS\ Windows\ PE\ Intel*) 497011a29bacSmrg win32_libid_type="x86 DLL" 497111a29bacSmrg ;; 497211a29bacSmrg esac 497311a29bacSmrg ;; 497411a29bacSmrg esac 497511a29bacSmrg $ECHO "$win32_libid_type" 497611a29bacSmrg} 497741b2f0bdSmrg 49786b526288Smrg# func_cygming_dll_for_implib ARG 49796b526288Smrg# 49806b526288Smrg# Platform-specific function to extract the 49816b526288Smrg# name of the DLL associated with the specified 49826b526288Smrg# import library ARG. 49836b526288Smrg# Invoked by eval'ing the libtool variable 49846b526288Smrg# $sharedlib_from_linklib_cmd 49856b526288Smrg# Result is available in the variable 49866b526288Smrg# $sharedlib_from_linklib_result 49876b526288Smrgfunc_cygming_dll_for_implib () 49886b526288Smrg{ 49896b526288Smrg $debug_cmd 49906b526288Smrg 49916b526288Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 49926b526288Smrg} 49936b526288Smrg 49946b526288Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 49956b526288Smrg# 49966b526288Smrg# The is the core of a fallback implementation of a 49976b526288Smrg# platform-specific function to extract the name of the 49986b526288Smrg# DLL associated with the specified import library LIBNAME. 49996b526288Smrg# 50006b526288Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 50016b526288Smrg# on the platform and compiler that created the implib. 50026b526288Smrg# 50036b526288Smrg# Echos the name of the DLL associated with the 50046b526288Smrg# specified import library. 50056b526288Smrgfunc_cygming_dll_for_implib_fallback_core () 50066b526288Smrg{ 50076b526288Smrg $debug_cmd 50086b526288Smrg 50096b526288Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 50106b526288Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 50116b526288Smrg $SED '/^Contents of section '"$match_literal"':/{ 50126b526288Smrg # Place marker at beginning of archive member dllname section 50136b526288Smrg s/.*/====MARK====/ 50146b526288Smrg p 50156b526288Smrg d 50166b526288Smrg } 50176b526288Smrg # These lines can sometimes be longer than 43 characters, but 50186b526288Smrg # are always uninteresting 50196b526288Smrg /:[ ]*file format pe[i]\{,1\}-/d 50206b526288Smrg /^In archive [^:]*:/d 50216b526288Smrg # Ensure marker is printed 50226b526288Smrg /^====MARK====/p 50236b526288Smrg # Remove all lines with less than 43 characters 50246b526288Smrg /^.\{43\}/!d 50256b526288Smrg # From remaining lines, remove first 43 characters 50266b526288Smrg s/^.\{43\}//' | 50276b526288Smrg $SED -n ' 50286b526288Smrg # Join marker and all lines until next marker into a single line 50296b526288Smrg /^====MARK====/ b para 50306b526288Smrg H 50316b526288Smrg $ b para 50326b526288Smrg b 50336b526288Smrg :para 50346b526288Smrg x 50356b526288Smrg s/\n//g 50366b526288Smrg # Remove the marker 50376b526288Smrg s/^====MARK====// 50386b526288Smrg # Remove trailing dots and whitespace 50396b526288Smrg s/[\. \t]*$// 50406b526288Smrg # Print 50416b526288Smrg /./p' | 50426b526288Smrg # we now have a list, one entry per line, of the stringified 50436b526288Smrg # contents of the appropriate section of all members of the 50446b526288Smrg # archive that possess that section. Heuristic: eliminate 50456b526288Smrg # all those that have a first or second character that is 50466b526288Smrg # a '.' (that is, objdump's representation of an unprintable 50476b526288Smrg # character.) This should work for all archives with less than 50486b526288Smrg # 0x302f exports -- but will fail for DLLs whose name actually 50496b526288Smrg # begins with a literal '.' or a single character followed by 50506b526288Smrg # a '.'. 50516b526288Smrg # 50526b526288Smrg # Of those that remain, print the first one. 50536b526288Smrg $SED -e '/^\./d;/^.\./d;q' 50546b526288Smrg} 50556b526288Smrg 50566b526288Smrg# func_cygming_dll_for_implib_fallback ARG 50576b526288Smrg# Platform-specific function to extract the 50586b526288Smrg# name of the DLL associated with the specified 50596b526288Smrg# import library ARG. 50606b526288Smrg# 50616b526288Smrg# This fallback implementation is for use when $DLLTOOL 50626b526288Smrg# does not support the --identify-strict option. 50636b526288Smrg# Invoked by eval'ing the libtool variable 50646b526288Smrg# $sharedlib_from_linklib_cmd 50656b526288Smrg# Result is available in the variable 50666b526288Smrg# $sharedlib_from_linklib_result 50676b526288Smrgfunc_cygming_dll_for_implib_fallback () 50686b526288Smrg{ 50696b526288Smrg $debug_cmd 50706b526288Smrg 50716b526288Smrg if func_cygming_gnu_implib_p "$1"; then 50726b526288Smrg # binutils import library 50736b526288Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 50746b526288Smrg elif func_cygming_ms_implib_p "$1"; then 50756b526288Smrg # ms-generated import library 50766b526288Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 50776b526288Smrg else 50786b526288Smrg # unknown 50796b526288Smrg sharedlib_from_linklib_result= 50806b526288Smrg fi 50816b526288Smrg} 508241b2f0bdSmrg 508341b2f0bdSmrg 508411a29bacSmrg# func_extract_an_archive dir oldlib 508511a29bacSmrgfunc_extract_an_archive () 508611a29bacSmrg{ 50876b526288Smrg $debug_cmd 50886b526288Smrg 50896b526288Smrg f_ex_an_ar_dir=$1; shift 50906b526288Smrg f_ex_an_ar_oldlib=$1 50916b526288Smrg if test yes = "$lock_old_archive_extraction"; then 509211a29bacSmrg lockfile=$f_ex_an_ar_oldlib.lock 509311a29bacSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509411a29bacSmrg func_echo "Waiting for $lockfile to be removed" 509511a29bacSmrg sleep 2 509611a29bacSmrg done 509711a29bacSmrg fi 509811a29bacSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509911a29bacSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 51006b526288Smrg if test yes = "$lock_old_archive_extraction"; then 510111a29bacSmrg $opt_dry_run || rm -f "$lockfile" 510211a29bacSmrg fi 510311a29bacSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 510411a29bacSmrg : 510511a29bacSmrg else 510611a29bacSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 510711a29bacSmrg fi 510811a29bacSmrg} 510941b2f0bdSmrg 511041b2f0bdSmrg 511111a29bacSmrg# func_extract_archives gentop oldlib ... 511211a29bacSmrgfunc_extract_archives () 511311a29bacSmrg{ 51146b526288Smrg $debug_cmd 51156b526288Smrg 51166b526288Smrg my_gentop=$1; shift 511711a29bacSmrg my_oldlibs=${1+"$@"} 51186b526288Smrg my_oldobjs= 51196b526288Smrg my_xlib= 51206b526288Smrg my_xabs= 51216b526288Smrg my_xdir= 512241b2f0bdSmrg 512311a29bacSmrg for my_xlib in $my_oldlibs; do 512411a29bacSmrg # Extract the objects. 512511a29bacSmrg case $my_xlib in 51266b526288Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 512711a29bacSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 512811a29bacSmrg esac 512911a29bacSmrg func_basename "$my_xlib" 51306b526288Smrg my_xlib=$func_basename_result 513111a29bacSmrg my_xlib_u=$my_xlib 513211a29bacSmrg while :; do 513311a29bacSmrg case " $extracted_archives " in 513411a29bacSmrg *" $my_xlib_u "*) 513511a29bacSmrg func_arith $extracted_serial + 1 513611a29bacSmrg extracted_serial=$func_arith_result 513711a29bacSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 513811a29bacSmrg *) break ;; 513911a29bacSmrg esac 514011a29bacSmrg done 514111a29bacSmrg extracted_archives="$extracted_archives $my_xlib_u" 51426b526288Smrg my_xdir=$my_gentop/$my_xlib_u 514341b2f0bdSmrg 514411a29bacSmrg func_mkdir_p "$my_xdir" 514511a29bacSmrg 514611a29bacSmrg case $host in 514711a29bacSmrg *-darwin*) 514811a29bacSmrg func_verbose "Extracting $my_xabs" 514911a29bacSmrg # Do not bother doing anything if just a dry run 515011a29bacSmrg $opt_dry_run || { 515111a29bacSmrg darwin_orig_dir=`pwd` 515211a29bacSmrg cd $my_xdir || exit $? 515311a29bacSmrg darwin_archive=$my_xabs 515411a29bacSmrg darwin_curdir=`pwd` 51556b526288Smrg func_basename "$darwin_archive" 51566b526288Smrg darwin_base_archive=$func_basename_result 515711a29bacSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 515811a29bacSmrg if test -n "$darwin_arches"; then 515911a29bacSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 516011a29bacSmrg darwin_arch= 516111a29bacSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 51626b526288Smrg for darwin_arch in $darwin_arches; do 51636b526288Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 51646b526288Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 51656b526288Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 51666b526288Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 516711a29bacSmrg cd "$darwin_curdir" 51686b526288Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 516911a29bacSmrg done # $darwin_arches 517011a29bacSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 51716b526288Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 517211a29bacSmrg darwin_file= 517311a29bacSmrg darwin_files= 517411a29bacSmrg for darwin_file in $darwin_filelist; do 517511a29bacSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 517611a29bacSmrg $LIPO -create -output "$darwin_file" $darwin_files 517711a29bacSmrg done # $darwin_filelist 517811a29bacSmrg $RM -rf unfat-$$ 517911a29bacSmrg cd "$darwin_orig_dir" 518041b2f0bdSmrg else 518111a29bacSmrg cd $darwin_orig_dir 518211a29bacSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 518311a29bacSmrg fi # $darwin_arches 518411a29bacSmrg } # !$opt_dry_run 518511a29bacSmrg ;; 518611a29bacSmrg *) 518711a29bacSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 518811a29bacSmrg ;; 518911a29bacSmrg esac 519011a29bacSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 519111a29bacSmrg done 519241b2f0bdSmrg 51936b526288Smrg func_extract_archives_result=$my_oldobjs 519411a29bacSmrg} 519541b2f0bdSmrg 519641b2f0bdSmrg 519711a29bacSmrg# func_emit_wrapper [arg=no] 519811a29bacSmrg# 519911a29bacSmrg# Emit a libtool wrapper script on stdout. 520011a29bacSmrg# Don't directly open a file because we may want to 520111a29bacSmrg# incorporate the script contents within a cygwin/mingw 520211a29bacSmrg# wrapper executable. Must ONLY be called from within 520311a29bacSmrg# func_mode_link because it depends on a number of variables 520411a29bacSmrg# set therein. 520511a29bacSmrg# 520611a29bacSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520711a29bacSmrg# variable will take. If 'yes', then the emitted script 52086b526288Smrg# will assume that the directory where it is stored is 520911a29bacSmrg# the $objdir directory. This is a cygwin/mingw-specific 521011a29bacSmrg# behavior. 521111a29bacSmrgfunc_emit_wrapper () 521211a29bacSmrg{ 521311a29bacSmrg func_emit_wrapper_arg1=${1-no} 521441b2f0bdSmrg 521511a29bacSmrg $ECHO "\ 521611a29bacSmrg#! $SHELL 521741b2f0bdSmrg 521811a29bacSmrg# $output - temporary wrapper script for $objdir/$outputname 52196b526288Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 522011a29bacSmrg# 522111a29bacSmrg# The $output program cannot be directly executed until all the libtool 522211a29bacSmrg# libraries that it depends on are installed. 522311a29bacSmrg# 522411a29bacSmrg# This wrapper script should never be moved out of the build directory. 522511a29bacSmrg# If it is, it will not operate correctly. 522641b2f0bdSmrg 522711a29bacSmrg# Sed substitution that helps us do robust quoting. It backslashifies 522811a29bacSmrg# metacharacters that are still active within double-quoted strings. 522911a29bacSmrgsed_quote_subst='$sed_quote_subst' 523041b2f0bdSmrg 523111a29bacSmrg# Be Bourne compatible 523211a29bacSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 523311a29bacSmrg emulate sh 523411a29bacSmrg NULLCMD=: 523511a29bacSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 523611a29bacSmrg # is contrary to our usage. Disable this feature. 523711a29bacSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 523811a29bacSmrg setopt NO_GLOB_SUBST 523911a29bacSmrgelse 524011a29bacSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 524111a29bacSmrgfi 524211a29bacSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 524311a29bacSmrgDUALCASE=1; export DUALCASE # for MKS sh 524441b2f0bdSmrg 524511a29bacSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 524611a29bacSmrg# if CDPATH is set. 524711a29bacSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 524841b2f0bdSmrg 524911a29bacSmrgrelink_command=\"$relink_command\" 525041b2f0bdSmrg 525111a29bacSmrg# This environment variable determines our operation mode. 525211a29bacSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 525311a29bacSmrg # install mode needs the following variables: 525411a29bacSmrg generated_by_libtool_version='$macro_version' 525511a29bacSmrg notinst_deplibs='$notinst_deplibs' 525611a29bacSmrgelse 525711a29bacSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 525811a29bacSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525911a29bacSmrg file=\"\$0\"" 526041b2f0bdSmrg 526111a29bacSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526211a29bacSmrg $ECHO "\ 526341b2f0bdSmrg 526411a29bacSmrg# A function that is used when there is no print builtin or printf. 526511a29bacSmrgfunc_fallback_echo () 526611a29bacSmrg{ 526711a29bacSmrg eval 'cat <<_LTECHO_EOF 526811a29bacSmrg\$1 526911a29bacSmrg_LTECHO_EOF' 527011a29bacSmrg} 527111a29bacSmrg ECHO=\"$qECHO\" 527211a29bacSmrg fi 527311a29bacSmrg 527411a29bacSmrg# Very basic option parsing. These options are (a) specific to 527511a29bacSmrg# the libtool wrapper, (b) are identical between the wrapper 52766b526288Smrg# /script/ and the wrapper /executable/ that is used only on 527711a29bacSmrg# windows platforms, and (c) all begin with the string "--lt-" 52786b526288Smrg# (application programs are unlikely to have options that match 527911a29bacSmrg# this pattern). 528011a29bacSmrg# 528111a29bacSmrg# There are only two supported options: --lt-debug and 528211a29bacSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 528311a29bacSmrg# 528411a29bacSmrg# The first argument to this parsing function should be the 528511a29bacSmrg# script's $0 value, followed by "$@". 528611a29bacSmrglt_option_debug= 528711a29bacSmrgfunc_parse_lt_options () 528811a29bacSmrg{ 528911a29bacSmrg lt_script_arg0=\$0 529011a29bacSmrg shift 529111a29bacSmrg for lt_opt 529211a29bacSmrg do 529311a29bacSmrg case \"\$lt_opt\" in 529411a29bacSmrg --lt-debug) lt_option_debug=1 ;; 529511a29bacSmrg --lt-dump-script) 529611a29bacSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529711a29bacSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529811a29bacSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529911a29bacSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 530011a29bacSmrg exit 0 530111a29bacSmrg ;; 530211a29bacSmrg --lt-*) 530311a29bacSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530411a29bacSmrg exit 1 530541b2f0bdSmrg ;; 530611a29bacSmrg esac 530711a29bacSmrg done 530841b2f0bdSmrg 530911a29bacSmrg # Print the debug banner immediately: 531011a29bacSmrg if test -n \"\$lt_option_debug\"; then 53116b526288Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531211a29bacSmrg fi 531311a29bacSmrg} 531441b2f0bdSmrg 531511a29bacSmrg# Used when --lt-debug. Prints its arguments to stdout 531611a29bacSmrg# (redirection is the responsibility of the caller) 531711a29bacSmrgfunc_lt_dump_args () 531811a29bacSmrg{ 531911a29bacSmrg lt_dump_args_N=1; 532011a29bacSmrg for lt_arg 532111a29bacSmrg do 53226b526288Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532311a29bacSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532411a29bacSmrg done 532511a29bacSmrg} 532641b2f0bdSmrg 532711a29bacSmrg# Core function for launching the target application 532811a29bacSmrgfunc_exec_program_core () 532911a29bacSmrg{ 533011a29bacSmrg" 533111a29bacSmrg case $host in 533211a29bacSmrg # Backslashes separate directories on plain windows 533311a29bacSmrg *-*-mingw | *-*-os2* | *-cegcc*) 533411a29bacSmrg $ECHO "\ 533511a29bacSmrg if test -n \"\$lt_option_debug\"; then 53366b526288Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533711a29bacSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533841b2f0bdSmrg fi 533911a29bacSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534011a29bacSmrg" 534111a29bacSmrg ;; 534241b2f0bdSmrg 534311a29bacSmrg *) 534411a29bacSmrg $ECHO "\ 534511a29bacSmrg if test -n \"\$lt_option_debug\"; then 53466b526288Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534711a29bacSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534841b2f0bdSmrg fi 534911a29bacSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535011a29bacSmrg" 535111a29bacSmrg ;; 535211a29bacSmrg esac 535311a29bacSmrg $ECHO "\ 535411a29bacSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535511a29bacSmrg exit 1 535611a29bacSmrg} 535741b2f0bdSmrg 535811a29bacSmrg# A function to encapsulate launching the target application 535911a29bacSmrg# Strips options in the --lt-* namespace from \$@ and 536011a29bacSmrg# launches target application with the remaining arguments. 536111a29bacSmrgfunc_exec_program () 536211a29bacSmrg{ 53636b526288Smrg case \" \$* \" in 53646b526288Smrg *\\ --lt-*) 53656b526288Smrg for lt_wr_arg 53666b526288Smrg do 53676b526288Smrg case \$lt_wr_arg in 53686b526288Smrg --lt-*) ;; 53696b526288Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 53706b526288Smrg esac 53716b526288Smrg shift 53726b526288Smrg done ;; 53736b526288Smrg esac 537411a29bacSmrg func_exec_program_core \${1+\"\$@\"} 537511a29bacSmrg} 537641b2f0bdSmrg 537711a29bacSmrg # Parse options 537811a29bacSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 537941b2f0bdSmrg 538011a29bacSmrg # Find the directory that this script lives in. 538111a29bacSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 538211a29bacSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 538341b2f0bdSmrg 538411a29bacSmrg # Follow symbolic links until we get to the real thisdir. 538511a29bacSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 538611a29bacSmrg while test -n \"\$file\"; do 538711a29bacSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 538841b2f0bdSmrg 538911a29bacSmrg # If there was a directory component, then change thisdir. 539011a29bacSmrg if test \"x\$destdir\" != \"x\$file\"; then 539111a29bacSmrg case \"\$destdir\" in 539211a29bacSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 539311a29bacSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 539411a29bacSmrg esac 539511a29bacSmrg fi 539641b2f0bdSmrg 539711a29bacSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539811a29bacSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 539911a29bacSmrg done 540041b2f0bdSmrg 540111a29bacSmrg # Usually 'no', except on cygwin/mingw when embedded into 540211a29bacSmrg # the cwrapper. 540311a29bacSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 540411a29bacSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 540511a29bacSmrg # special case for '.' 540611a29bacSmrg if test \"\$thisdir\" = \".\"; then 540711a29bacSmrg thisdir=\`pwd\` 540811a29bacSmrg fi 540911a29bacSmrg # remove .libs from thisdir 541011a29bacSmrg case \"\$thisdir\" in 541111a29bacSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 541211a29bacSmrg $objdir ) thisdir=. ;; 541311a29bacSmrg esac 541411a29bacSmrg fi 541541b2f0bdSmrg 541611a29bacSmrg # Try to get the absolute directory name. 541711a29bacSmrg absdir=\`cd \"\$thisdir\" && pwd\` 541811a29bacSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 541911a29bacSmrg" 542041b2f0bdSmrg 54216b526288Smrg if test yes = "$fast_install"; then 542211a29bacSmrg $ECHO "\ 542311a29bacSmrg program=lt-'$outputname'$exeext 542411a29bacSmrg progdir=\"\$thisdir/$objdir\" 542541b2f0bdSmrg 542611a29bacSmrg if test ! -f \"\$progdir/\$program\" || 54276b526288Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 542811a29bacSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 542941b2f0bdSmrg 543011a29bacSmrg file=\"\$\$-\$program\" 543141b2f0bdSmrg 543211a29bacSmrg if test ! -d \"\$progdir\"; then 543311a29bacSmrg $MKDIR \"\$progdir\" 543411a29bacSmrg else 543511a29bacSmrg $RM \"\$progdir/\$file\" 543611a29bacSmrg fi" 543741b2f0bdSmrg 543811a29bacSmrg $ECHO "\ 543941b2f0bdSmrg 544011a29bacSmrg # relink executable if necessary 544111a29bacSmrg if test -n \"\$relink_command\"; then 544211a29bacSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 544311a29bacSmrg else 54446b526288Smrg \$ECHO \"\$relink_command_output\" >&2 544511a29bacSmrg $RM \"\$progdir/\$file\" 544611a29bacSmrg exit 1 544711a29bacSmrg fi 544811a29bacSmrg fi 544941b2f0bdSmrg 545011a29bacSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 545111a29bacSmrg { $RM \"\$progdir/\$program\"; 545211a29bacSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 545311a29bacSmrg $RM \"\$progdir/\$file\" 545411a29bacSmrg fi" 545511a29bacSmrg else 545611a29bacSmrg $ECHO "\ 545711a29bacSmrg program='$outputname' 545811a29bacSmrg progdir=\"\$thisdir/$objdir\" 545911a29bacSmrg" 546011a29bacSmrg fi 546141b2f0bdSmrg 546211a29bacSmrg $ECHO "\ 546341b2f0bdSmrg 546411a29bacSmrg if test -f \"\$progdir/\$program\"; then" 546541b2f0bdSmrg 54666b526288Smrg # fixup the dll searchpath if we need to. 54676b526288Smrg # 54686b526288Smrg # Fix the DLL searchpath if we need to. Do this before prepending 54696b526288Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 54706b526288Smrg # libraries must come first. 54716b526288Smrg if test -n "$dllsearchpath"; then 54726b526288Smrg $ECHO "\ 54736b526288Smrg # Add the dll search path components to the executable PATH 54746b526288Smrg PATH=$dllsearchpath:\$PATH 54756b526288Smrg" 54766b526288Smrg fi 54776b526288Smrg 547811a29bacSmrg # Export our shlibpath_var if we have one. 54796b526288Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 548011a29bacSmrg $ECHO "\ 548111a29bacSmrg # Add our own library path to $shlibpath_var 548211a29bacSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 548341b2f0bdSmrg 548411a29bacSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 548511a29bacSmrg # The second colon is a workaround for a bug in BeOS R4 sed 548611a29bacSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 548741b2f0bdSmrg 548811a29bacSmrg export $shlibpath_var 548911a29bacSmrg" 549011a29bacSmrg fi 549141b2f0bdSmrg 549211a29bacSmrg $ECHO "\ 549311a29bacSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 549411a29bacSmrg # Run the actual program with our arguments. 549511a29bacSmrg func_exec_program \${1+\"\$@\"} 549611a29bacSmrg fi 549711a29bacSmrg else 549811a29bacSmrg # The program doesn't exist. 54996b526288Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 550011a29bacSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550111a29bacSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 550211a29bacSmrg exit 1 550311a29bacSmrg fi 550411a29bacSmrgfi\ 550511a29bacSmrg" 550611a29bacSmrg} 550741b2f0bdSmrg 550841b2f0bdSmrg 550911a29bacSmrg# func_emit_cwrapperexe_src 551011a29bacSmrg# emit the source code for a wrapper executable on stdout 551111a29bacSmrg# Must ONLY be called from within func_mode_link because 551211a29bacSmrg# it depends on a number of variable set therein. 551311a29bacSmrgfunc_emit_cwrapperexe_src () 551411a29bacSmrg{ 551511a29bacSmrg cat <<EOF 551641b2f0bdSmrg 551711a29bacSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 55186b526288Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 551941b2f0bdSmrg 552011a29bacSmrg The $output program cannot be directly executed until all the libtool 552111a29bacSmrg libraries that it depends on are installed. 552241b2f0bdSmrg 552311a29bacSmrg This wrapper executable should never be moved out of the build directory. 552411a29bacSmrg If it is, it will not operate correctly. 552511a29bacSmrg*/ 552611a29bacSmrgEOF 552711a29bacSmrg cat <<"EOF" 552811a29bacSmrg#ifdef _MSC_VER 552911a29bacSmrg# define _CRT_SECURE_NO_DEPRECATE 1 553011a29bacSmrg#endif 553111a29bacSmrg#include <stdio.h> 553211a29bacSmrg#include <stdlib.h> 553311a29bacSmrg#ifdef _MSC_VER 553411a29bacSmrg# include <direct.h> 553511a29bacSmrg# include <process.h> 553611a29bacSmrg# include <io.h> 553711a29bacSmrg#else 553811a29bacSmrg# include <unistd.h> 553911a29bacSmrg# include <stdint.h> 554011a29bacSmrg# ifdef __CYGWIN__ 554111a29bacSmrg# include <io.h> 554211a29bacSmrg# endif 554311a29bacSmrg#endif 554411a29bacSmrg#include <malloc.h> 554511a29bacSmrg#include <stdarg.h> 554611a29bacSmrg#include <assert.h> 554711a29bacSmrg#include <string.h> 554811a29bacSmrg#include <ctype.h> 554911a29bacSmrg#include <errno.h> 555011a29bacSmrg#include <fcntl.h> 555111a29bacSmrg#include <sys/stat.h> 555241b2f0bdSmrg 55536b526288Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 55546b526288Smrg 555511a29bacSmrg/* declarations of non-ANSI functions */ 55566b526288Smrg#if defined __MINGW32__ 555711a29bacSmrg# ifdef __STRICT_ANSI__ 555811a29bacSmrgint _putenv (const char *); 555911a29bacSmrg# endif 55606b526288Smrg#elif defined __CYGWIN__ 556111a29bacSmrg# ifdef __STRICT_ANSI__ 556211a29bacSmrgchar *realpath (const char *, char *); 556311a29bacSmrgint putenv (char *); 556411a29bacSmrgint setenv (const char *, const char *, int); 556511a29bacSmrg# endif 55666b526288Smrg/* #elif defined other_platform || defined ... */ 556711a29bacSmrg#endif 556841b2f0bdSmrg 556911a29bacSmrg/* portability defines, excluding path handling macros */ 55706b526288Smrg#if defined _MSC_VER 557111a29bacSmrg# define setmode _setmode 557211a29bacSmrg# define stat _stat 557311a29bacSmrg# define chmod _chmod 557411a29bacSmrg# define getcwd _getcwd 557511a29bacSmrg# define putenv _putenv 557611a29bacSmrg# define S_IXUSR _S_IEXEC 55776b526288Smrg#elif defined __MINGW32__ 557811a29bacSmrg# define setmode _setmode 557911a29bacSmrg# define stat _stat 558011a29bacSmrg# define chmod _chmod 558111a29bacSmrg# define getcwd _getcwd 558211a29bacSmrg# define putenv _putenv 55836b526288Smrg#elif defined __CYGWIN__ 558411a29bacSmrg# define HAVE_SETENV 558511a29bacSmrg# define FOPEN_WB "wb" 55866b526288Smrg/* #elif defined other platforms ... */ 558711a29bacSmrg#endif 558841b2f0bdSmrg 55896b526288Smrg#if defined PATH_MAX 559011a29bacSmrg# define LT_PATHMAX PATH_MAX 55916b526288Smrg#elif defined MAXPATHLEN 559211a29bacSmrg# define LT_PATHMAX MAXPATHLEN 559311a29bacSmrg#else 559411a29bacSmrg# define LT_PATHMAX 1024 559511a29bacSmrg#endif 559641b2f0bdSmrg 559711a29bacSmrg#ifndef S_IXOTH 559811a29bacSmrg# define S_IXOTH 0 559911a29bacSmrg#endif 560011a29bacSmrg#ifndef S_IXGRP 560111a29bacSmrg# define S_IXGRP 0 560211a29bacSmrg#endif 560341b2f0bdSmrg 560411a29bacSmrg/* path handling portability macros */ 560511a29bacSmrg#ifndef DIR_SEPARATOR 560611a29bacSmrg# define DIR_SEPARATOR '/' 560711a29bacSmrg# define PATH_SEPARATOR ':' 560811a29bacSmrg#endif 560941b2f0bdSmrg 56106b526288Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 56116b526288Smrg defined __OS2__ 561211a29bacSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 561311a29bacSmrg# define FOPEN_WB "wb" 561411a29bacSmrg# ifndef DIR_SEPARATOR_2 561511a29bacSmrg# define DIR_SEPARATOR_2 '\\' 561611a29bacSmrg# endif 561711a29bacSmrg# ifndef PATH_SEPARATOR_2 561811a29bacSmrg# define PATH_SEPARATOR_2 ';' 561911a29bacSmrg# endif 562011a29bacSmrg#endif 562141b2f0bdSmrg 562211a29bacSmrg#ifndef DIR_SEPARATOR_2 562311a29bacSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 562411a29bacSmrg#else /* DIR_SEPARATOR_2 */ 562511a29bacSmrg# define IS_DIR_SEPARATOR(ch) \ 562611a29bacSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 562711a29bacSmrg#endif /* DIR_SEPARATOR_2 */ 562841b2f0bdSmrg 562911a29bacSmrg#ifndef PATH_SEPARATOR_2 563011a29bacSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 563111a29bacSmrg#else /* PATH_SEPARATOR_2 */ 563211a29bacSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 563311a29bacSmrg#endif /* PATH_SEPARATOR_2 */ 563411a29bacSmrg 563511a29bacSmrg#ifndef FOPEN_WB 563611a29bacSmrg# define FOPEN_WB "w" 563711a29bacSmrg#endif 563811a29bacSmrg#ifndef _O_BINARY 563911a29bacSmrg# define _O_BINARY 0 564011a29bacSmrg#endif 564111a29bacSmrg 564211a29bacSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 564311a29bacSmrg#define XFREE(stale) do { \ 56446b526288Smrg if (stale) { free (stale); stale = 0; } \ 564511a29bacSmrg} while (0) 564611a29bacSmrg 56476b526288Smrg#if defined LT_DEBUGWRAPPER 564811a29bacSmrgstatic int lt_debug = 1; 564911a29bacSmrg#else 565011a29bacSmrgstatic int lt_debug = 0; 565111a29bacSmrg#endif 565211a29bacSmrg 565311a29bacSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565411a29bacSmrg 565511a29bacSmrgvoid *xmalloc (size_t num); 565611a29bacSmrgchar *xstrdup (const char *string); 565711a29bacSmrgconst char *base_name (const char *name); 565811a29bacSmrgchar *find_executable (const char *wrapper); 565911a29bacSmrgchar *chase_symlinks (const char *pathspec); 566011a29bacSmrgint make_executable (const char *path); 566111a29bacSmrgint check_executable (const char *path); 566211a29bacSmrgchar *strendzap (char *str, const char *pat); 566311a29bacSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566411a29bacSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566511a29bacSmrgstatic const char *nonnull (const char *s); 566611a29bacSmrgstatic const char *nonempty (const char *s); 566711a29bacSmrgvoid lt_setenv (const char *name, const char *value); 566811a29bacSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 566911a29bacSmrgvoid lt_update_exe_path (const char *name, const char *value); 567011a29bacSmrgvoid lt_update_lib_path (const char *name, const char *value); 567111a29bacSmrgchar **prepare_spawn (char **argv); 567211a29bacSmrgvoid lt_dump_script (FILE *f); 567311a29bacSmrgEOF 567411a29bacSmrg 567511a29bacSmrg cat <<EOF 56766b526288Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 56776b526288Smrg# define externally_visible volatile 56786b526288Smrg#else 56796b526288Smrg# define externally_visible __attribute__((externally_visible)) volatile 56806b526288Smrg#endif 56816b526288Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 568211a29bacSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 568311a29bacSmrgEOF 568411a29bacSmrg 56856b526288Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 56866b526288Smrg func_to_host_path "$temp_rpath" 568711a29bacSmrg cat <<EOF 56886b526288Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 568941b2f0bdSmrgEOF 569041b2f0bdSmrg else 569111a29bacSmrg cat <<"EOF" 569211a29bacSmrgconst char * LIB_PATH_VALUE = ""; 569311a29bacSmrgEOF 569441b2f0bdSmrg fi 569511a29bacSmrg 569611a29bacSmrg if test -n "$dllsearchpath"; then 56976b526288Smrg func_to_host_path "$dllsearchpath:" 569811a29bacSmrg cat <<EOF 569911a29bacSmrgconst char * EXE_PATH_VARNAME = "PATH"; 57006b526288Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 570111a29bacSmrgEOF 570241b2f0bdSmrg else 570311a29bacSmrg cat <<"EOF" 570411a29bacSmrgconst char * EXE_PATH_VARNAME = ""; 570511a29bacSmrgconst char * EXE_PATH_VALUE = ""; 570611a29bacSmrgEOF 570741b2f0bdSmrg fi 570811a29bacSmrg 57096b526288Smrg if test yes = "$fast_install"; then 571011a29bacSmrg cat <<EOF 571111a29bacSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 571211a29bacSmrgEOF 571341b2f0bdSmrg else 571411a29bacSmrg cat <<EOF 571511a29bacSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 571611a29bacSmrgEOF 571741b2f0bdSmrg fi 571841b2f0bdSmrg 571941b2f0bdSmrg 572011a29bacSmrg cat <<"EOF" 572141b2f0bdSmrg 572211a29bacSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 572341b2f0bdSmrg 572411a29bacSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 572511a29bacSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572611a29bacSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 572741b2f0bdSmrg 572811a29bacSmrgint 572911a29bacSmrgmain (int argc, char *argv[]) 573011a29bacSmrg{ 573111a29bacSmrg char **newargz; 573211a29bacSmrg int newargc; 573311a29bacSmrg char *tmp_pathspec; 573411a29bacSmrg char *actual_cwrapper_path; 573511a29bacSmrg char *actual_cwrapper_name; 573611a29bacSmrg char *target_name; 573711a29bacSmrg char *lt_argv_zero; 57386b526288Smrg int rval = 127; 573941b2f0bdSmrg 574011a29bacSmrg int i; 574141b2f0bdSmrg 574211a29bacSmrg program_name = (char *) xstrdup (base_name (argv[0])); 57436b526288Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 574441b2f0bdSmrg 574511a29bacSmrg /* very simple arg parsing; don't want to rely on getopt 574611a29bacSmrg * also, copy all non cwrapper options to newargz, except 574711a29bacSmrg * argz[0], which is handled differently 574811a29bacSmrg */ 574911a29bacSmrg newargc=0; 575011a29bacSmrg for (i = 1; i < argc; i++) 575111a29bacSmrg { 57526b526288Smrg if (STREQ (argv[i], dumpscript_opt)) 575311a29bacSmrg { 575411a29bacSmrgEOF 57556b526288Smrg case $host in 575611a29bacSmrg *mingw* | *cygwin* ) 575711a29bacSmrg # make stdout use "unix" line endings 575811a29bacSmrg echo " setmode(1,_O_BINARY);" 575911a29bacSmrg ;; 576011245024Smrg esac 576141b2f0bdSmrg 576211a29bacSmrg cat <<"EOF" 576311a29bacSmrg lt_dump_script (stdout); 576411a29bacSmrg return 0; 576511a29bacSmrg } 57666b526288Smrg if (STREQ (argv[i], debug_opt)) 576711a29bacSmrg { 576811a29bacSmrg lt_debug = 1; 576911a29bacSmrg continue; 577011a29bacSmrg } 57716b526288Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577211a29bacSmrg { 577311a29bacSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577411a29bacSmrg namespace, but it is not one of the ones we know about and 577511a29bacSmrg have already dealt with, above (inluding dump-script), then 577611a29bacSmrg report an error. Otherwise, targets might begin to believe 577711a29bacSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577811a29bacSmrg namespace. The first time any user complains about this, we'll 577911a29bacSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578011a29bacSmrg or a configure.ac-settable value. 578111a29bacSmrg */ 578211a29bacSmrg lt_fatal (__FILE__, __LINE__, 578311a29bacSmrg "unrecognized %s option: '%s'", 578411a29bacSmrg ltwrapper_option_prefix, argv[i]); 578511a29bacSmrg } 578611a29bacSmrg /* otherwise ... */ 578711a29bacSmrg newargz[++newargc] = xstrdup (argv[i]); 578811a29bacSmrg } 578911a29bacSmrg newargz[++newargc] = NULL; 579041b2f0bdSmrg 579111a29bacSmrgEOF 579211a29bacSmrg cat <<EOF 579311a29bacSmrg /* The GNU banner must be the first non-error debug message */ 57946b526288Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579511a29bacSmrgEOF 579611a29bacSmrg cat <<"EOF" 579711a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579811a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579911a29bacSmrg 580011a29bacSmrg tmp_pathspec = find_executable (argv[0]); 580111a29bacSmrg if (tmp_pathspec == NULL) 580211a29bacSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580311a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 580411a29bacSmrg "(main) found exe (before symlink chase) at: %s\n", 580511a29bacSmrg tmp_pathspec); 580611a29bacSmrg 580711a29bacSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580811a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 580911a29bacSmrg "(main) found exe (after symlink chase) at: %s\n", 581011a29bacSmrg actual_cwrapper_path); 581111a29bacSmrg XFREE (tmp_pathspec); 581211a29bacSmrg 581311a29bacSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 581411a29bacSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 581511a29bacSmrg 581611a29bacSmrg /* wrapper name transforms */ 581711a29bacSmrg strendzap (actual_cwrapper_name, ".exe"); 581811a29bacSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 581911a29bacSmrg XFREE (actual_cwrapper_name); 582011a29bacSmrg actual_cwrapper_name = tmp_pathspec; 582111a29bacSmrg tmp_pathspec = 0; 582211a29bacSmrg 582311a29bacSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 582411a29bacSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 582511a29bacSmrg strendzap (target_name, ".exe"); 582611a29bacSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 582711a29bacSmrg XFREE (target_name); 582811a29bacSmrg target_name = tmp_pathspec; 582911a29bacSmrg tmp_pathspec = 0; 583011a29bacSmrg 583111a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 583211a29bacSmrg "(main) libtool target name: %s\n", 583311a29bacSmrg target_name); 583411a29bacSmrgEOF 583541b2f0bdSmrg 583611a29bacSmrg cat <<EOF 583711a29bacSmrg newargz[0] = 583811a29bacSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 583911a29bacSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 584011a29bacSmrg strcpy (newargz[0], actual_cwrapper_path); 584111a29bacSmrg strcat (newargz[0], "$objdir"); 584211a29bacSmrg strcat (newargz[0], "/"); 584311a29bacSmrgEOF 584441b2f0bdSmrg 584511a29bacSmrg cat <<"EOF" 584611a29bacSmrg /* stop here, and copy so we don't have to do this twice */ 584711a29bacSmrg tmp_pathspec = xstrdup (newargz[0]); 584841b2f0bdSmrg 584911a29bacSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 585011a29bacSmrg strcat (newargz[0], actual_cwrapper_name); 585141b2f0bdSmrg 585211a29bacSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 585311a29bacSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 585411a29bacSmrg XFREE (tmp_pathspec); 585511a29bacSmrg tmp_pathspec = NULL; 585611a29bacSmrgEOF 585741b2f0bdSmrg 585811a29bacSmrg case $host_os in 585911a29bacSmrg mingw*) 586011a29bacSmrg cat <<"EOF" 586111a29bacSmrg { 586211a29bacSmrg char* p; 586311a29bacSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 586411a29bacSmrg { 586511a29bacSmrg *p = '/'; 586611a29bacSmrg } 586711a29bacSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 586811a29bacSmrg { 586911a29bacSmrg *p = '/'; 587011a29bacSmrg } 587111a29bacSmrg } 587211a29bacSmrgEOF 587311a29bacSmrg ;; 587411a29bacSmrg esac 587541b2f0bdSmrg 587611a29bacSmrg cat <<"EOF" 587711a29bacSmrg XFREE (target_name); 587811a29bacSmrg XFREE (actual_cwrapper_path); 587911a29bacSmrg XFREE (actual_cwrapper_name); 588041b2f0bdSmrg 588111a29bacSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 588211a29bacSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 58836b526288Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 58846b526288Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 58856b526288Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 58866b526288Smrg libraries must come first. */ 588711a29bacSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 58886b526288Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588941b2f0bdSmrg 589011a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589111a29bacSmrg nonnull (lt_argv_zero)); 589211a29bacSmrg for (i = 0; i < newargc; i++) 589311a29bacSmrg { 589411a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589511a29bacSmrg i, nonnull (newargz[i])); 589611a29bacSmrg } 589741b2f0bdSmrg 589811a29bacSmrgEOF 589941b2f0bdSmrg 590011a29bacSmrg case $host_os in 590111a29bacSmrg mingw*) 590211a29bacSmrg cat <<"EOF" 590311a29bacSmrg /* execv doesn't actually work on mingw as expected on unix */ 590411a29bacSmrg newargz = prepare_spawn (newargz); 59056b526288Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 590611a29bacSmrg if (rval == -1) 590711a29bacSmrg { 590811a29bacSmrg /* failed to start process */ 590911a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 591011a29bacSmrg "(main) failed to launch target \"%s\": %s\n", 591111a29bacSmrg lt_argv_zero, nonnull (strerror (errno))); 591211a29bacSmrg return 127; 591311a29bacSmrg } 591411a29bacSmrg return rval; 591511a29bacSmrgEOF 591611a29bacSmrg ;; 591711a29bacSmrg *) 591811a29bacSmrg cat <<"EOF" 591911a29bacSmrg execv (lt_argv_zero, newargz); 592011a29bacSmrg return rval; /* =127, but avoids unused variable warning */ 592111a29bacSmrgEOF 592211a29bacSmrg ;; 592311a29bacSmrg esac 592441b2f0bdSmrg 592511a29bacSmrg cat <<"EOF" 592611a29bacSmrg} 592741b2f0bdSmrg 592811a29bacSmrgvoid * 592911a29bacSmrgxmalloc (size_t num) 593011a29bacSmrg{ 593111a29bacSmrg void *p = (void *) malloc (num); 593211a29bacSmrg if (!p) 593311a29bacSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 593441b2f0bdSmrg 593511a29bacSmrg return p; 593611a29bacSmrg} 593741b2f0bdSmrg 593811a29bacSmrgchar * 593911a29bacSmrgxstrdup (const char *string) 594011a29bacSmrg{ 594111a29bacSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 594211a29bacSmrg string) : NULL; 594311a29bacSmrg} 594441b2f0bdSmrg 594511a29bacSmrgconst char * 594611a29bacSmrgbase_name (const char *name) 594711a29bacSmrg{ 594811a29bacSmrg const char *base; 594941b2f0bdSmrg 59506b526288Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 595111a29bacSmrg /* Skip over the disk name in MSDOS pathnames. */ 595211a29bacSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 595311a29bacSmrg name += 2; 595411a29bacSmrg#endif 595541b2f0bdSmrg 595611a29bacSmrg for (base = name; *name; name++) 595711a29bacSmrg if (IS_DIR_SEPARATOR (*name)) 595811a29bacSmrg base = name + 1; 595911a29bacSmrg return base; 596011a29bacSmrg} 596141b2f0bdSmrg 596211a29bacSmrgint 596311a29bacSmrgcheck_executable (const char *path) 596411a29bacSmrg{ 596511a29bacSmrg struct stat st; 596641b2f0bdSmrg 596711a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596811a29bacSmrg nonempty (path)); 596911a29bacSmrg if ((!path) || (!*path)) 597011a29bacSmrg return 0; 597141b2f0bdSmrg 597211a29bacSmrg if ((stat (path, &st) >= 0) 597311a29bacSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 597411a29bacSmrg return 1; 597511a29bacSmrg else 597611a29bacSmrg return 0; 597711a29bacSmrg} 597841b2f0bdSmrg 597911a29bacSmrgint 598011a29bacSmrgmake_executable (const char *path) 598111a29bacSmrg{ 598211a29bacSmrg int rval = 0; 598311a29bacSmrg struct stat st; 598441b2f0bdSmrg 598511a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598611a29bacSmrg nonempty (path)); 598711a29bacSmrg if ((!path) || (!*path)) 598811a29bacSmrg return 0; 598941b2f0bdSmrg 599011a29bacSmrg if (stat (path, &st) >= 0) 599111a29bacSmrg { 599211a29bacSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 599311a29bacSmrg } 599411a29bacSmrg return rval; 599511a29bacSmrg} 599641b2f0bdSmrg 599711a29bacSmrg/* Searches for the full path of the wrapper. Returns 599811a29bacSmrg newly allocated full path name if found, NULL otherwise 599911a29bacSmrg Does not chase symlinks, even on platforms that support them. 600011a29bacSmrg*/ 600111a29bacSmrgchar * 600211a29bacSmrgfind_executable (const char *wrapper) 600311a29bacSmrg{ 600411a29bacSmrg int has_slash = 0; 600511a29bacSmrg const char *p; 600611a29bacSmrg const char *p_next; 600711a29bacSmrg /* static buffer for getcwd */ 600811a29bacSmrg char tmp[LT_PATHMAX + 1]; 60096b526288Smrg size_t tmp_len; 601011a29bacSmrg char *concat_name; 601141b2f0bdSmrg 601211a29bacSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601311a29bacSmrg nonempty (wrapper)); 601441b2f0bdSmrg 601511a29bacSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 601611a29bacSmrg return NULL; 601741b2f0bdSmrg 601811a29bacSmrg /* Absolute path? */ 60196b526288Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 602011a29bacSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 602111a29bacSmrg { 602211a29bacSmrg concat_name = xstrdup (wrapper); 602311a29bacSmrg if (check_executable (concat_name)) 602411a29bacSmrg return concat_name; 602511a29bacSmrg XFREE (concat_name); 602611a29bacSmrg } 602711a29bacSmrg else 602811a29bacSmrg { 602911a29bacSmrg#endif 603011a29bacSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 603111a29bacSmrg { 603211a29bacSmrg concat_name = xstrdup (wrapper); 603311a29bacSmrg if (check_executable (concat_name)) 603411a29bacSmrg return concat_name; 603511a29bacSmrg XFREE (concat_name); 603611a29bacSmrg } 60376b526288Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 603811a29bacSmrg } 603911a29bacSmrg#endif 604041b2f0bdSmrg 604111a29bacSmrg for (p = wrapper; *p; p++) 604211a29bacSmrg if (*p == '/') 604311a29bacSmrg { 604411a29bacSmrg has_slash = 1; 604511a29bacSmrg break; 604611a29bacSmrg } 604711a29bacSmrg if (!has_slash) 604811a29bacSmrg { 604911a29bacSmrg /* no slashes; search PATH */ 605011a29bacSmrg const char *path = getenv ("PATH"); 605111a29bacSmrg if (path != NULL) 605211a29bacSmrg { 605311a29bacSmrg for (p = path; *p; p = p_next) 605411a29bacSmrg { 605511a29bacSmrg const char *q; 605611a29bacSmrg size_t p_len; 605711a29bacSmrg for (q = p; *q; q++) 605811a29bacSmrg if (IS_PATH_SEPARATOR (*q)) 605911a29bacSmrg break; 60606b526288Smrg p_len = (size_t) (q - p); 606111a29bacSmrg p_next = (*q == '\0' ? q : q + 1); 606211a29bacSmrg if (p_len == 0) 606311a29bacSmrg { 606411a29bacSmrg /* empty path: current directory */ 606511a29bacSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606611a29bacSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606711a29bacSmrg nonnull (strerror (errno))); 606811a29bacSmrg tmp_len = strlen (tmp); 606911a29bacSmrg concat_name = 607011a29bacSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 607111a29bacSmrg memcpy (concat_name, tmp, tmp_len); 607211a29bacSmrg concat_name[tmp_len] = '/'; 607311a29bacSmrg strcpy (concat_name + tmp_len + 1, wrapper); 607411a29bacSmrg } 607511a29bacSmrg else 607611a29bacSmrg { 607711a29bacSmrg concat_name = 607811a29bacSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 607911a29bacSmrg memcpy (concat_name, p, p_len); 608011a29bacSmrg concat_name[p_len] = '/'; 608111a29bacSmrg strcpy (concat_name + p_len + 1, wrapper); 608211a29bacSmrg } 608311a29bacSmrg if (check_executable (concat_name)) 608411a29bacSmrg return concat_name; 608511a29bacSmrg XFREE (concat_name); 608611a29bacSmrg } 608711a29bacSmrg } 608811a29bacSmrg /* not found in PATH; assume curdir */ 608911a29bacSmrg } 609011a29bacSmrg /* Relative path | not found in path: prepend cwd */ 609111a29bacSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609211a29bacSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609311a29bacSmrg nonnull (strerror (errno))); 609411a29bacSmrg tmp_len = strlen (tmp); 609511a29bacSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 609611a29bacSmrg memcpy (concat_name, tmp, tmp_len); 609711a29bacSmrg concat_name[tmp_len] = '/'; 609811a29bacSmrg strcpy (concat_name + tmp_len + 1, wrapper); 609941b2f0bdSmrg 610011a29bacSmrg if (check_executable (concat_name)) 610111a29bacSmrg return concat_name; 610211a29bacSmrg XFREE (concat_name); 610311a29bacSmrg return NULL; 610411a29bacSmrg} 610541b2f0bdSmrg 610611a29bacSmrgchar * 610711a29bacSmrgchase_symlinks (const char *pathspec) 610811a29bacSmrg{ 610911a29bacSmrg#ifndef S_ISLNK 611011a29bacSmrg return xstrdup (pathspec); 611111a29bacSmrg#else 611211a29bacSmrg char buf[LT_PATHMAX]; 611311a29bacSmrg struct stat s; 611411a29bacSmrg char *tmp_pathspec = xstrdup (pathspec); 611511a29bacSmrg char *p; 611611a29bacSmrg int has_symlinks = 0; 611711a29bacSmrg while (strlen (tmp_pathspec) && !has_symlinks) 611811a29bacSmrg { 611911a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 612011a29bacSmrg "checking path component for symlinks: %s\n", 612111a29bacSmrg tmp_pathspec); 612211a29bacSmrg if (lstat (tmp_pathspec, &s) == 0) 612311a29bacSmrg { 612411a29bacSmrg if (S_ISLNK (s.st_mode) != 0) 612511a29bacSmrg { 612611a29bacSmrg has_symlinks = 1; 612711a29bacSmrg break; 612811a29bacSmrg } 612941b2f0bdSmrg 613011a29bacSmrg /* search backwards for last DIR_SEPARATOR */ 613111a29bacSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 613211a29bacSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613311a29bacSmrg p--; 613411a29bacSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613511a29bacSmrg { 613611a29bacSmrg /* no more DIR_SEPARATORS left */ 613711a29bacSmrg break; 613811a29bacSmrg } 613911a29bacSmrg *p = '\0'; 614011a29bacSmrg } 614111a29bacSmrg else 614211a29bacSmrg { 614311a29bacSmrg lt_fatal (__FILE__, __LINE__, 614411a29bacSmrg "error accessing file \"%s\": %s", 614511a29bacSmrg tmp_pathspec, nonnull (strerror (errno))); 614611a29bacSmrg } 614711a29bacSmrg } 614811a29bacSmrg XFREE (tmp_pathspec); 614941b2f0bdSmrg 615011a29bacSmrg if (!has_symlinks) 615111a29bacSmrg { 615211a29bacSmrg return xstrdup (pathspec); 615311a29bacSmrg } 615441b2f0bdSmrg 615511a29bacSmrg tmp_pathspec = realpath (pathspec, buf); 615611a29bacSmrg if (tmp_pathspec == 0) 615711a29bacSmrg { 615811a29bacSmrg lt_fatal (__FILE__, __LINE__, 615911a29bacSmrg "could not follow symlinks for %s", pathspec); 616011a29bacSmrg } 616111a29bacSmrg return xstrdup (tmp_pathspec); 616211a29bacSmrg#endif 616311a29bacSmrg} 616441b2f0bdSmrg 616511a29bacSmrgchar * 616611a29bacSmrgstrendzap (char *str, const char *pat) 616711a29bacSmrg{ 616811a29bacSmrg size_t len, patlen; 616941b2f0bdSmrg 617011a29bacSmrg assert (str != NULL); 617111a29bacSmrg assert (pat != NULL); 617241b2f0bdSmrg 617311a29bacSmrg len = strlen (str); 617411a29bacSmrg patlen = strlen (pat); 617541b2f0bdSmrg 617611a29bacSmrg if (patlen <= len) 617711a29bacSmrg { 617811a29bacSmrg str += len - patlen; 61796b526288Smrg if (STREQ (str, pat)) 618011a29bacSmrg *str = '\0'; 618111a29bacSmrg } 618211a29bacSmrg return str; 618311a29bacSmrg} 618441b2f0bdSmrg 618511a29bacSmrgvoid 618611a29bacSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618711a29bacSmrg{ 618811a29bacSmrg va_list args; 618911a29bacSmrg if (lt_debug) 619011a29bacSmrg { 619111a29bacSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619211a29bacSmrg va_start (args, fmt); 619311a29bacSmrg (void) vfprintf (stderr, fmt, args); 619411a29bacSmrg va_end (args); 619511a29bacSmrg } 619611a29bacSmrg} 619741b2f0bdSmrg 619811a29bacSmrgstatic void 619911a29bacSmrglt_error_core (int exit_status, const char *file, 620011a29bacSmrg int line, const char *mode, 620111a29bacSmrg const char *message, va_list ap) 620211a29bacSmrg{ 620311a29bacSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 620411a29bacSmrg vfprintf (stderr, message, ap); 620511a29bacSmrg fprintf (stderr, ".\n"); 620641b2f0bdSmrg 620711a29bacSmrg if (exit_status >= 0) 620811a29bacSmrg exit (exit_status); 620911a29bacSmrg} 621041b2f0bdSmrg 621111a29bacSmrgvoid 621211a29bacSmrglt_fatal (const char *file, int line, const char *message, ...) 621311a29bacSmrg{ 621411a29bacSmrg va_list ap; 621511a29bacSmrg va_start (ap, message); 621611a29bacSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 621711a29bacSmrg va_end (ap); 621811a29bacSmrg} 621941b2f0bdSmrg 622011a29bacSmrgstatic const char * 622111a29bacSmrgnonnull (const char *s) 622211a29bacSmrg{ 622311a29bacSmrg return s ? s : "(null)"; 622411a29bacSmrg} 622541b2f0bdSmrg 622611a29bacSmrgstatic const char * 622711a29bacSmrgnonempty (const char *s) 622811a29bacSmrg{ 622911a29bacSmrg return (s && !*s) ? "(empty)" : nonnull (s); 623011a29bacSmrg} 623141b2f0bdSmrg 623211a29bacSmrgvoid 623311a29bacSmrglt_setenv (const char *name, const char *value) 623411a29bacSmrg{ 623511a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 623611a29bacSmrg "(lt_setenv) setting '%s' to '%s'\n", 623711a29bacSmrg nonnull (name), nonnull (value)); 623811a29bacSmrg { 623911a29bacSmrg#ifdef HAVE_SETENV 624011a29bacSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 624111a29bacSmrg char *str = xstrdup (value); 624211a29bacSmrg setenv (name, str, 1); 624311a29bacSmrg#else 62446b526288Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 624511a29bacSmrg char *str = XMALLOC (char, len); 624611a29bacSmrg sprintf (str, "%s=%s", name, value); 624711a29bacSmrg if (putenv (str) != EXIT_SUCCESS) 624811a29bacSmrg { 624911a29bacSmrg XFREE (str); 625011a29bacSmrg } 625111a29bacSmrg#endif 625211a29bacSmrg } 625311a29bacSmrg} 625441b2f0bdSmrg 625511a29bacSmrgchar * 625611a29bacSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 625711a29bacSmrg{ 625811a29bacSmrg char *new_value; 625911a29bacSmrg if (orig_value && *orig_value) 626011a29bacSmrg { 62616b526288Smrg size_t orig_value_len = strlen (orig_value); 62626b526288Smrg size_t add_len = strlen (add); 626311a29bacSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 626411a29bacSmrg if (to_end) 626511a29bacSmrg { 626611a29bacSmrg strcpy (new_value, orig_value); 626711a29bacSmrg strcpy (new_value + orig_value_len, add); 626811a29bacSmrg } 626911a29bacSmrg else 627011a29bacSmrg { 627111a29bacSmrg strcpy (new_value, add); 627211a29bacSmrg strcpy (new_value + add_len, orig_value); 627311a29bacSmrg } 627411a29bacSmrg } 627511a29bacSmrg else 627611a29bacSmrg { 627711a29bacSmrg new_value = xstrdup (add); 627811a29bacSmrg } 627911a29bacSmrg return new_value; 628011a29bacSmrg} 628141b2f0bdSmrg 628211a29bacSmrgvoid 628311a29bacSmrglt_update_exe_path (const char *name, const char *value) 628411a29bacSmrg{ 628511a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 628611a29bacSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628711a29bacSmrg nonnull (name), nonnull (value)); 628841b2f0bdSmrg 628911a29bacSmrg if (name && *name && value && *value) 629011a29bacSmrg { 629111a29bacSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 629211a29bacSmrg /* some systems can't cope with a ':'-terminated path #' */ 62936b526288Smrg size_t len = strlen (new_value); 62946b526288Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 629511a29bacSmrg { 62966b526288Smrg new_value[--len] = '\0'; 629711a29bacSmrg } 629811a29bacSmrg lt_setenv (name, new_value); 629911a29bacSmrg XFREE (new_value); 630011a29bacSmrg } 630111a29bacSmrg} 630241b2f0bdSmrg 630311a29bacSmrgvoid 630411a29bacSmrglt_update_lib_path (const char *name, const char *value) 630511a29bacSmrg{ 630611a29bacSmrg lt_debugprintf (__FILE__, __LINE__, 630711a29bacSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630811a29bacSmrg nonnull (name), nonnull (value)); 630941b2f0bdSmrg 631011a29bacSmrg if (name && *name && value && *value) 631111a29bacSmrg { 631211a29bacSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 631311a29bacSmrg lt_setenv (name, new_value); 631411a29bacSmrg XFREE (new_value); 631511a29bacSmrg } 631611a29bacSmrg} 631741b2f0bdSmrg 631811a29bacSmrgEOF 631911a29bacSmrg case $host_os in 632011a29bacSmrg mingw*) 632111a29bacSmrg cat <<"EOF" 632211a29bacSmrg 632311a29bacSmrg/* Prepares an argument vector before calling spawn(). 632411a29bacSmrg Note that spawn() does not by itself call the command interpreter 632511a29bacSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632611a29bacSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632711a29bacSmrg GetVersionEx(&v); 632811a29bacSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632911a29bacSmrg }) ? "cmd.exe" : "command.com"). 633011a29bacSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 633111a29bacSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633211a29bacSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633311a29bacSmrg special way: 633411a29bacSmrg - Space and tab are interpreted as delimiters. They are not treated as 633511a29bacSmrg delimiters if they are surrounded by double quotes: "...". 633611a29bacSmrg - Unescaped double quotes are removed from the input. Their only effect is 633711a29bacSmrg that within double quotes, space and tab are treated like normal 633811a29bacSmrg characters. 633911a29bacSmrg - Backslashes not followed by double quotes are not special. 634011a29bacSmrg - But 2*n+1 backslashes followed by a double quote become 634111a29bacSmrg n backslashes followed by a double quote (n >= 0): 634211a29bacSmrg \" -> " 634311a29bacSmrg \\\" -> \" 634411a29bacSmrg \\\\\" -> \\" 634511a29bacSmrg */ 634611a29bacSmrg#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" 634711a29bacSmrg#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" 634811a29bacSmrgchar ** 634911a29bacSmrgprepare_spawn (char **argv) 635011a29bacSmrg{ 635111a29bacSmrg size_t argc; 635211a29bacSmrg char **new_argv; 635311a29bacSmrg size_t i; 635441b2f0bdSmrg 635511a29bacSmrg /* Count number of arguments. */ 635611a29bacSmrg for (argc = 0; argv[argc] != NULL; argc++) 635711a29bacSmrg ; 635841b2f0bdSmrg 635911a29bacSmrg /* Allocate new argument vector. */ 636011a29bacSmrg new_argv = XMALLOC (char *, argc + 1); 636141b2f0bdSmrg 636211a29bacSmrg /* Put quoted arguments into the new argument vector. */ 636311a29bacSmrg for (i = 0; i < argc; i++) 636411a29bacSmrg { 636511a29bacSmrg const char *string = argv[i]; 636611a29bacSmrg 636711a29bacSmrg if (string[0] == '\0') 636811a29bacSmrg new_argv[i] = xstrdup ("\"\""); 636911a29bacSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637011a29bacSmrg { 637111a29bacSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637211a29bacSmrg size_t length; 637311a29bacSmrg unsigned int backslashes; 637411a29bacSmrg const char *s; 637511a29bacSmrg char *quoted_string; 637611a29bacSmrg char *p; 637711a29bacSmrg 637811a29bacSmrg length = 0; 637911a29bacSmrg backslashes = 0; 638011a29bacSmrg if (quote_around) 638111a29bacSmrg length++; 638211a29bacSmrg for (s = string; *s != '\0'; s++) 638311a29bacSmrg { 638411a29bacSmrg char c = *s; 638511a29bacSmrg if (c == '"') 638611a29bacSmrg length += backslashes + 1; 638711a29bacSmrg length++; 638811a29bacSmrg if (c == '\\') 638911a29bacSmrg backslashes++; 639011a29bacSmrg else 639111a29bacSmrg backslashes = 0; 639211a29bacSmrg } 639311a29bacSmrg if (quote_around) 639411a29bacSmrg length += backslashes + 1; 639511a29bacSmrg 639611a29bacSmrg quoted_string = XMALLOC (char, length + 1); 639711a29bacSmrg 639811a29bacSmrg p = quoted_string; 639911a29bacSmrg backslashes = 0; 640011a29bacSmrg if (quote_around) 640111a29bacSmrg *p++ = '"'; 640211a29bacSmrg for (s = string; *s != '\0'; s++) 640311a29bacSmrg { 640411a29bacSmrg char c = *s; 640511a29bacSmrg if (c == '"') 640611a29bacSmrg { 640711a29bacSmrg unsigned int j; 640811a29bacSmrg for (j = backslashes + 1; j > 0; j--) 640911a29bacSmrg *p++ = '\\'; 641011a29bacSmrg } 641111a29bacSmrg *p++ = c; 641211a29bacSmrg if (c == '\\') 641311a29bacSmrg backslashes++; 641411a29bacSmrg else 641511a29bacSmrg backslashes = 0; 641611a29bacSmrg } 641711a29bacSmrg if (quote_around) 641811a29bacSmrg { 641911a29bacSmrg unsigned int j; 642011a29bacSmrg for (j = backslashes; j > 0; j--) 642111a29bacSmrg *p++ = '\\'; 642211a29bacSmrg *p++ = '"'; 642311a29bacSmrg } 642411a29bacSmrg *p = '\0'; 642541b2f0bdSmrg 642611a29bacSmrg new_argv[i] = quoted_string; 642711a29bacSmrg } 642811a29bacSmrg else 642911a29bacSmrg new_argv[i] = (char *) string; 643011a29bacSmrg } 643111a29bacSmrg new_argv[argc] = NULL; 643241b2f0bdSmrg 643311a29bacSmrg return new_argv; 643411a29bacSmrg} 643511a29bacSmrgEOF 643641b2f0bdSmrg ;; 643711a29bacSmrg esac 643841b2f0bdSmrg 643911a29bacSmrg cat <<"EOF" 644011a29bacSmrgvoid lt_dump_script (FILE* f) 644111a29bacSmrg{ 644211a29bacSmrgEOF 644311a29bacSmrg func_emit_wrapper yes | 64446b526288Smrg $SED -n -e ' 64456b526288Smrgs/^\(.\{79\}\)\(..*\)/\1\ 64466b526288Smrg\2/ 64476b526288Smrgh 64486b526288Smrgs/\([\\"]\)/\\\1/g 64496b526288Smrgs/$/\\n/ 64506b526288Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 64516b526288Smrgg 64526b526288SmrgD' 645311a29bacSmrg cat <<"EOF" 645411a29bacSmrg} 645511a29bacSmrgEOF 645611a29bacSmrg} 645711a29bacSmrg# end: func_emit_cwrapperexe_src 645841b2f0bdSmrg 645911a29bacSmrg# func_win32_import_lib_p ARG 646011a29bacSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646111a29bacSmrgfunc_win32_import_lib_p () 646211a29bacSmrg{ 64636b526288Smrg $debug_cmd 64646b526288Smrg 646511a29bacSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646611a29bacSmrg *import*) : ;; 646711a29bacSmrg *) false ;; 646811a29bacSmrg esac 646911a29bacSmrg} 647041b2f0bdSmrg 64716b526288Smrg# func_suncc_cstd_abi 64726b526288Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 64736b526288Smrg# Several compiler flags select an ABI that is incompatible with the 64746b526288Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 64756b526288Smrgfunc_suncc_cstd_abi () 64766b526288Smrg{ 64776b526288Smrg $debug_cmd 64786b526288Smrg 64796b526288Smrg case " $compile_command " in 64806b526288Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 64816b526288Smrg suncc_use_cstd_abi=no 64826b526288Smrg ;; 64836b526288Smrg *) 64846b526288Smrg suncc_use_cstd_abi=yes 64856b526288Smrg ;; 64866b526288Smrg esac 64876b526288Smrg} 64886b526288Smrg 648911a29bacSmrg# func_mode_link arg... 649011a29bacSmrgfunc_mode_link () 649111a29bacSmrg{ 64926b526288Smrg $debug_cmd 64936b526288Smrg 649411a29bacSmrg case $host in 649511a29bacSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 649611a29bacSmrg # It is impossible to link a dll without this setting, and 649711a29bacSmrg # we shouldn't force the makefile maintainer to figure out 64986b526288Smrg # what system we are compiling for in order to pass an extra 649911a29bacSmrg # flag for every libtool invocation. 650011a29bacSmrg # allow_undefined=no 650141b2f0bdSmrg 650211a29bacSmrg # FIXME: Unfortunately, there are problems with the above when trying 65036b526288Smrg # to make a dll that has undefined symbols, in which case not 650411a29bacSmrg # even a static library is built. For now, we need to specify 650511a29bacSmrg # -no-undefined on the libtool link line when we can be certain 650611a29bacSmrg # that all symbols are satisfied, otherwise we get a static library. 650711a29bacSmrg allow_undefined=yes 650811a29bacSmrg ;; 650911a29bacSmrg *) 651011a29bacSmrg allow_undefined=yes 651111a29bacSmrg ;; 651211a29bacSmrg esac 651311a29bacSmrg libtool_args=$nonopt 651411a29bacSmrg base_compile="$nonopt $@" 651511a29bacSmrg compile_command=$nonopt 651611a29bacSmrg finalize_command=$nonopt 651741b2f0bdSmrg 651811a29bacSmrg compile_rpath= 651911a29bacSmrg finalize_rpath= 652011a29bacSmrg compile_shlibpath= 652111a29bacSmrg finalize_shlibpath= 652211a29bacSmrg convenience= 652311a29bacSmrg old_convenience= 652411a29bacSmrg deplibs= 652511a29bacSmrg old_deplibs= 652611a29bacSmrg compiler_flags= 652711a29bacSmrg linker_flags= 652811a29bacSmrg dllsearchpath= 652911a29bacSmrg lib_search_path=`pwd` 653011a29bacSmrg inst_prefix_dir= 653111a29bacSmrg new_inherited_linker_flags= 653241b2f0bdSmrg 653311a29bacSmrg avoid_version=no 653411a29bacSmrg bindir= 653511a29bacSmrg dlfiles= 653611a29bacSmrg dlprefiles= 653711a29bacSmrg dlself=no 653811a29bacSmrg export_dynamic=no 653911a29bacSmrg export_symbols= 654011a29bacSmrg export_symbols_regex= 654111a29bacSmrg generated= 654211a29bacSmrg libobjs= 654311a29bacSmrg ltlibs= 654411a29bacSmrg module=no 654511a29bacSmrg no_install=no 654611a29bacSmrg objs= 65476b526288Smrg os2dllname= 654811a29bacSmrg non_pic_objects= 654911a29bacSmrg precious_files_regex= 655011a29bacSmrg prefer_static_libs=no 65516b526288Smrg preload=false 655211a29bacSmrg prev= 655311a29bacSmrg prevarg= 655411a29bacSmrg release= 655511a29bacSmrg rpath= 655611a29bacSmrg xrpath= 655711a29bacSmrg perm_rpath= 655811a29bacSmrg temp_rpath= 655911a29bacSmrg thread_safe=no 656011a29bacSmrg vinfo= 656111a29bacSmrg vinfo_number=no 656211a29bacSmrg weak_libs= 65636b526288Smrg single_module=$wl-single_module 656411a29bacSmrg func_infer_tag $base_compile 656541b2f0bdSmrg 656611a29bacSmrg # We need to know -static, to get the right output filenames. 656711a29bacSmrg for arg 656811a29bacSmrg do 656911a29bacSmrg case $arg in 657011a29bacSmrg -shared) 65716b526288Smrg test yes != "$build_libtool_libs" \ 65726b526288Smrg && func_fatal_configuration "cannot build a shared library" 657311a29bacSmrg build_old_libs=no 657411a29bacSmrg break 657511a29bacSmrg ;; 657611a29bacSmrg -all-static | -static | -static-libtool-libs) 657711a29bacSmrg case $arg in 657811a29bacSmrg -all-static) 65796b526288Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 658011a29bacSmrg func_warning "complete static linking is impossible in this configuration" 658111a29bacSmrg fi 658211a29bacSmrg if test -n "$link_static_flag"; then 658311a29bacSmrg dlopen_self=$dlopen_self_static 658411a29bacSmrg fi 658511a29bacSmrg prefer_static_libs=yes 658611a29bacSmrg ;; 658711a29bacSmrg -static) 658811a29bacSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 658911a29bacSmrg dlopen_self=$dlopen_self_static 659011a29bacSmrg fi 659111a29bacSmrg prefer_static_libs=built 659211a29bacSmrg ;; 659311a29bacSmrg -static-libtool-libs) 659411a29bacSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 659511a29bacSmrg dlopen_self=$dlopen_self_static 659611a29bacSmrg fi 659711a29bacSmrg prefer_static_libs=yes 659811a29bacSmrg ;; 659911a29bacSmrg esac 660011a29bacSmrg build_libtool_libs=no 660111a29bacSmrg build_old_libs=yes 660211a29bacSmrg break 660311a29bacSmrg ;; 660411a29bacSmrg esac 660511a29bacSmrg done 660641b2f0bdSmrg 660711a29bacSmrg # See if our shared archives depend on static archives. 660811a29bacSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 660941b2f0bdSmrg 661011a29bacSmrg # Go through the arguments, transforming them on the way. 661111a29bacSmrg while test "$#" -gt 0; do 66126b526288Smrg arg=$1 661311a29bacSmrg shift 661411a29bacSmrg func_quote_for_eval "$arg" 661511a29bacSmrg qarg=$func_quote_for_eval_unquoted_result 661611a29bacSmrg func_append libtool_args " $func_quote_for_eval_result" 661741b2f0bdSmrg 661811a29bacSmrg # If the previous option needs an argument, assign it. 661911a29bacSmrg if test -n "$prev"; then 662011a29bacSmrg case $prev in 662111a29bacSmrg output) 662211a29bacSmrg func_append compile_command " @OUTPUT@" 662311a29bacSmrg func_append finalize_command " @OUTPUT@" 662411a29bacSmrg ;; 662511a29bacSmrg esac 662641b2f0bdSmrg 662711a29bacSmrg case $prev in 662811a29bacSmrg bindir) 66296b526288Smrg bindir=$arg 663011a29bacSmrg prev= 663111a29bacSmrg continue 663211a29bacSmrg ;; 663311a29bacSmrg dlfiles|dlprefiles) 66346b526288Smrg $preload || { 663511a29bacSmrg # Add the symbol object into the linking commands. 663611a29bacSmrg func_append compile_command " @SYMFILE@" 663711a29bacSmrg func_append finalize_command " @SYMFILE@" 66386b526288Smrg preload=: 66396b526288Smrg } 664011a29bacSmrg case $arg in 664111a29bacSmrg *.la | *.lo) ;; # We handle these cases below. 664211a29bacSmrg force) 66436b526288Smrg if test no = "$dlself"; then 664411a29bacSmrg dlself=needless 664511a29bacSmrg export_dynamic=yes 664641b2f0bdSmrg fi 664711a29bacSmrg prev= 664811a29bacSmrg continue 664911a29bacSmrg ;; 665011a29bacSmrg self) 66516b526288Smrg if test dlprefiles = "$prev"; then 665211a29bacSmrg dlself=yes 66536b526288Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 665411a29bacSmrg dlself=yes 665541b2f0bdSmrg else 665611a29bacSmrg dlself=needless 665711a29bacSmrg export_dynamic=yes 665841b2f0bdSmrg fi 665911a29bacSmrg prev= 666011a29bacSmrg continue 666111a29bacSmrg ;; 666211a29bacSmrg *) 66636b526288Smrg if test dlfiles = "$prev"; then 66646b526288Smrg func_append dlfiles " $arg" 666541b2f0bdSmrg else 66666b526288Smrg func_append dlprefiles " $arg" 666741b2f0bdSmrg fi 666811a29bacSmrg prev= 666911a29bacSmrg continue 667011a29bacSmrg ;; 667111a29bacSmrg esac 667211a29bacSmrg ;; 667311a29bacSmrg expsyms) 66746b526288Smrg export_symbols=$arg 667511a29bacSmrg test -f "$arg" \ 66766b526288Smrg || func_fatal_error "symbol file '$arg' does not exist" 667711a29bacSmrg prev= 667811a29bacSmrg continue 667911a29bacSmrg ;; 668011a29bacSmrg expsyms_regex) 66816b526288Smrg export_symbols_regex=$arg 668211a29bacSmrg prev= 668311a29bacSmrg continue 668411a29bacSmrg ;; 668511a29bacSmrg framework) 668641b2f0bdSmrg case $host in 668711a29bacSmrg *-*-darwin*) 668811a29bacSmrg case "$deplibs " in 668911a29bacSmrg *" $qarg.ltframework "*) ;; 66906b526288Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 669111a29bacSmrg ;; 669211a29bacSmrg esac 669311a29bacSmrg ;; 669441b2f0bdSmrg esac 669511a29bacSmrg prev= 669611a29bacSmrg continue 669741b2f0bdSmrg ;; 669811a29bacSmrg inst_prefix) 66996b526288Smrg inst_prefix_dir=$arg 67006b526288Smrg prev= 67016b526288Smrg continue 67026b526288Smrg ;; 67036b526288Smrg mllvm) 67046b526288Smrg # Clang does not use LLVM to link, so we can simply discard any 67056b526288Smrg # '-mllvm $arg' options when doing the link step. 670611a29bacSmrg prev= 670711a29bacSmrg continue 670841b2f0bdSmrg ;; 670911a29bacSmrg objectlist) 671011a29bacSmrg if test -f "$arg"; then 671111a29bacSmrg save_arg=$arg 671211a29bacSmrg moreargs= 671311a29bacSmrg for fil in `cat "$save_arg"` 671411a29bacSmrg do 67156b526288Smrg# func_append moreargs " $fil" 671611a29bacSmrg arg=$fil 671711a29bacSmrg # A libtool-controlled object. 671841b2f0bdSmrg 671911a29bacSmrg # Check to see that this really is a libtool object. 672011a29bacSmrg if func_lalib_unsafe_p "$arg"; then 672111a29bacSmrg pic_object= 672211a29bacSmrg non_pic_object= 672341b2f0bdSmrg 672411a29bacSmrg # Read the .lo file 672511a29bacSmrg func_source "$arg" 672641b2f0bdSmrg 672711a29bacSmrg if test -z "$pic_object" || 672811a29bacSmrg test -z "$non_pic_object" || 67296b526288Smrg test none = "$pic_object" && 67306b526288Smrg test none = "$non_pic_object"; then 67316b526288Smrg func_fatal_error "cannot find name of object for '$arg'" 673211a29bacSmrg fi 673341b2f0bdSmrg 673411a29bacSmrg # Extract subdirectory from the argument. 673511a29bacSmrg func_dirname "$arg" "/" "" 67366b526288Smrg xdir=$func_dirname_result 673741b2f0bdSmrg 67386b526288Smrg if test none != "$pic_object"; then 673911a29bacSmrg # Prepend the subdirectory the object is found in. 67406b526288Smrg pic_object=$xdir$pic_object 674141b2f0bdSmrg 67426b526288Smrg if test dlfiles = "$prev"; then 67436b526288Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 67446b526288Smrg func_append dlfiles " $pic_object" 674511a29bacSmrg prev= 674611a29bacSmrg continue 674711a29bacSmrg else 674811a29bacSmrg # If libtool objects are unsupported, then we need to preload. 674911a29bacSmrg prev=dlprefiles 675011a29bacSmrg fi 675111a29bacSmrg fi 675241b2f0bdSmrg 675311a29bacSmrg # CHECK ME: I think I busted this. -Ossama 67546b526288Smrg if test dlprefiles = "$prev"; then 675511a29bacSmrg # Preload the old-style object. 67566b526288Smrg func_append dlprefiles " $pic_object" 675711a29bacSmrg prev= 675811a29bacSmrg fi 675941b2f0bdSmrg 676011a29bacSmrg # A PIC object. 676111a29bacSmrg func_append libobjs " $pic_object" 67626b526288Smrg arg=$pic_object 676311a29bacSmrg fi 676441b2f0bdSmrg 676511a29bacSmrg # Non-PIC object. 67666b526288Smrg if test none != "$non_pic_object"; then 676711a29bacSmrg # Prepend the subdirectory the object is found in. 67686b526288Smrg non_pic_object=$xdir$non_pic_object 676941b2f0bdSmrg 677011a29bacSmrg # A standard non-PIC object 677111a29bacSmrg func_append non_pic_objects " $non_pic_object" 67726b526288Smrg if test -z "$pic_object" || test none = "$pic_object"; then 67736b526288Smrg arg=$non_pic_object 677411a29bacSmrg fi 677511a29bacSmrg else 677611a29bacSmrg # If the PIC object exists, use it instead. 677711a29bacSmrg # $xdir was prepended to $pic_object above. 67786b526288Smrg non_pic_object=$pic_object 677911a29bacSmrg func_append non_pic_objects " $non_pic_object" 678011a29bacSmrg fi 678111a29bacSmrg else 678211a29bacSmrg # Only an error if not doing a dry-run. 678311a29bacSmrg if $opt_dry_run; then 678411a29bacSmrg # Extract subdirectory from the argument. 678511a29bacSmrg func_dirname "$arg" "/" "" 67866b526288Smrg xdir=$func_dirname_result 678711a29bacSmrg 678811a29bacSmrg func_lo2o "$arg" 678911a29bacSmrg pic_object=$xdir$objdir/$func_lo2o_result 679011a29bacSmrg non_pic_object=$xdir$func_lo2o_result 679111a29bacSmrg func_append libobjs " $pic_object" 679211a29bacSmrg func_append non_pic_objects " $non_pic_object" 679311a29bacSmrg else 67946b526288Smrg func_fatal_error "'$arg' is not a valid libtool object" 679511a29bacSmrg fi 679611a29bacSmrg fi 679711a29bacSmrg done 679841b2f0bdSmrg else 67996b526288Smrg func_fatal_error "link input file '$arg' does not exist" 680041b2f0bdSmrg fi 680111a29bacSmrg arg=$save_arg 680211a29bacSmrg prev= 680311a29bacSmrg continue 680411a29bacSmrg ;; 68056b526288Smrg os2dllname) 68066b526288Smrg os2dllname=$arg 68076b526288Smrg prev= 68086b526288Smrg continue 68096b526288Smrg ;; 681011a29bacSmrg precious_regex) 68116b526288Smrg precious_files_regex=$arg 681211a29bacSmrg prev= 681311a29bacSmrg continue 681411a29bacSmrg ;; 681511a29bacSmrg release) 68166b526288Smrg release=-$arg 681711a29bacSmrg prev= 681811a29bacSmrg continue 681911a29bacSmrg ;; 682011a29bacSmrg rpath | xrpath) 682111a29bacSmrg # We need an absolute path. 682211a29bacSmrg case $arg in 682311a29bacSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 682411a29bacSmrg *) 682511a29bacSmrg func_fatal_error "only absolute run-paths are allowed" 682611a29bacSmrg ;; 682711a29bacSmrg esac 68286b526288Smrg if test rpath = "$prev"; then 682911a29bacSmrg case "$rpath " in 683011a29bacSmrg *" $arg "*) ;; 68316b526288Smrg *) func_append rpath " $arg" ;; 683211a29bacSmrg esac 683341b2f0bdSmrg else 683411a29bacSmrg case "$xrpath " in 683511a29bacSmrg *" $arg "*) ;; 68366b526288Smrg *) func_append xrpath " $arg" ;; 683711a29bacSmrg esac 683841b2f0bdSmrg fi 683911a29bacSmrg prev= 684011a29bacSmrg continue 684111a29bacSmrg ;; 684211a29bacSmrg shrext) 68436b526288Smrg shrext_cmds=$arg 684411a29bacSmrg prev= 684511a29bacSmrg continue 684611a29bacSmrg ;; 684711a29bacSmrg weak) 68486b526288Smrg func_append weak_libs " $arg" 684911a29bacSmrg prev= 685011a29bacSmrg continue 685111a29bacSmrg ;; 685211a29bacSmrg xcclinker) 68536b526288Smrg func_append linker_flags " $qarg" 68546b526288Smrg func_append compiler_flags " $qarg" 685511a29bacSmrg prev= 685611a29bacSmrg func_append compile_command " $qarg" 685711a29bacSmrg func_append finalize_command " $qarg" 685811a29bacSmrg continue 685911a29bacSmrg ;; 686011a29bacSmrg xcompiler) 68616b526288Smrg func_append compiler_flags " $qarg" 686211a29bacSmrg prev= 686311a29bacSmrg func_append compile_command " $qarg" 686411a29bacSmrg func_append finalize_command " $qarg" 686511a29bacSmrg continue 686611a29bacSmrg ;; 686711a29bacSmrg xlinker) 68686b526288Smrg func_append linker_flags " $qarg" 68696b526288Smrg func_append compiler_flags " $wl$qarg" 687011a29bacSmrg prev= 687111a29bacSmrg func_append compile_command " $wl$qarg" 687211a29bacSmrg func_append finalize_command " $wl$qarg" 687311a29bacSmrg continue 687411a29bacSmrg ;; 687511a29bacSmrg *) 687611a29bacSmrg eval "$prev=\"\$arg\"" 687711a29bacSmrg prev= 687811a29bacSmrg continue 687911a29bacSmrg ;; 688041b2f0bdSmrg esac 688111a29bacSmrg fi # test -n "$prev" 688241b2f0bdSmrg 68836b526288Smrg prevarg=$arg 688441b2f0bdSmrg 688511a29bacSmrg case $arg in 688611a29bacSmrg -all-static) 688711a29bacSmrg if test -n "$link_static_flag"; then 688811a29bacSmrg # See comment for -static flag below, for more details. 688911a29bacSmrg func_append compile_command " $link_static_flag" 689011a29bacSmrg func_append finalize_command " $link_static_flag" 689111a29bacSmrg fi 689211a29bacSmrg continue 689311a29bacSmrg ;; 689441b2f0bdSmrg 689511a29bacSmrg -allow-undefined) 689611a29bacSmrg # FIXME: remove this flag sometime in the future. 68976b526288Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 689811a29bacSmrg ;; 689941b2f0bdSmrg 690011a29bacSmrg -avoid-version) 690111a29bacSmrg avoid_version=yes 690211a29bacSmrg continue 690311a29bacSmrg ;; 690441b2f0bdSmrg 690511a29bacSmrg -bindir) 690611a29bacSmrg prev=bindir 690711a29bacSmrg continue 690811a29bacSmrg ;; 690941b2f0bdSmrg 691011a29bacSmrg -dlopen) 691111a29bacSmrg prev=dlfiles 691211a29bacSmrg continue 691311a29bacSmrg ;; 691441b2f0bdSmrg 691511a29bacSmrg -dlpreopen) 691611a29bacSmrg prev=dlprefiles 691711a29bacSmrg continue 691811a29bacSmrg ;; 691941b2f0bdSmrg 692011a29bacSmrg -export-dynamic) 692111a29bacSmrg export_dynamic=yes 692211a29bacSmrg continue 692311a29bacSmrg ;; 692441b2f0bdSmrg 692511a29bacSmrg -export-symbols | -export-symbols-regex) 692611a29bacSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 692711a29bacSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 692811a29bacSmrg fi 69296b526288Smrg if test X-export-symbols = "X$arg"; then 693011a29bacSmrg prev=expsyms 693111a29bacSmrg else 693211a29bacSmrg prev=expsyms_regex 693311a29bacSmrg fi 693411a29bacSmrg continue 693511a29bacSmrg ;; 693641b2f0bdSmrg 693711a29bacSmrg -framework) 693811a29bacSmrg prev=framework 693911a29bacSmrg continue 694011a29bacSmrg ;; 694141b2f0bdSmrg 694211a29bacSmrg -inst-prefix-dir) 694311a29bacSmrg prev=inst_prefix 694411a29bacSmrg continue 694511a29bacSmrg ;; 694641b2f0bdSmrg 694711a29bacSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 694811a29bacSmrg # so, if we see these flags be careful not to treat them like -L 694911a29bacSmrg -L[A-Z][A-Z]*:*) 695011a29bacSmrg case $with_gcc/$host in 695111a29bacSmrg no/*-*-irix* | /*-*-irix*) 695211a29bacSmrg func_append compile_command " $arg" 695311a29bacSmrg func_append finalize_command " $arg" 695411a29bacSmrg ;; 695511a29bacSmrg esac 695611a29bacSmrg continue 695711a29bacSmrg ;; 695841b2f0bdSmrg 695911a29bacSmrg -L*) 69606b526288Smrg func_stripname "-L" '' "$arg" 69616b526288Smrg if test -z "$func_stripname_result"; then 696211a29bacSmrg if test "$#" -gt 0; then 69636b526288Smrg func_fatal_error "require no space between '-L' and '$1'" 696411a29bacSmrg else 69656b526288Smrg func_fatal_error "need path for '-L' option" 696611a29bacSmrg fi 696711a29bacSmrg fi 69686b526288Smrg func_resolve_sysroot "$func_stripname_result" 69696b526288Smrg dir=$func_resolve_sysroot_result 697011a29bacSmrg # We need an absolute path. 697111a29bacSmrg case $dir in 697211a29bacSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 697311a29bacSmrg *) 697411a29bacSmrg absdir=`cd "$dir" && pwd` 697511a29bacSmrg test -z "$absdir" && \ 69766b526288Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 69776b526288Smrg dir=$absdir 697811a29bacSmrg ;; 697911a29bacSmrg esac 698011a29bacSmrg case "$deplibs " in 69816b526288Smrg *" -L$dir "* | *" $arg "*) 69826b526288Smrg # Will only happen for absolute or sysroot arguments 69836b526288Smrg ;; 698411a29bacSmrg *) 69856b526288Smrg # Preserve sysroot, but never include relative directories 69866b526288Smrg case $dir in 69876b526288Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 69886b526288Smrg *) func_append deplibs " -L$dir" ;; 69896b526288Smrg esac 69906b526288Smrg func_append lib_search_path " $dir" 699111a29bacSmrg ;; 699211a29bacSmrg esac 699311a29bacSmrg case $host in 699411a29bacSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699511a29bacSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 699611a29bacSmrg case :$dllsearchpath: in 699711a29bacSmrg *":$dir:"*) ;; 699811a29bacSmrg ::) dllsearchpath=$dir;; 69996b526288Smrg *) func_append dllsearchpath ":$dir";; 700011a29bacSmrg esac 700111a29bacSmrg case :$dllsearchpath: in 700211a29bacSmrg *":$testbindir:"*) ;; 700311a29bacSmrg ::) dllsearchpath=$testbindir;; 70046b526288Smrg *) func_append dllsearchpath ":$testbindir";; 700511a29bacSmrg esac 700611a29bacSmrg ;; 700711a29bacSmrg esac 700811a29bacSmrg continue 700911a29bacSmrg ;; 701041b2f0bdSmrg 701111a29bacSmrg -l*) 70126b526288Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 701311a29bacSmrg case $host in 701411a29bacSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 701511a29bacSmrg # These systems don't actually have a C or math library (as such) 701611a29bacSmrg continue 701711a29bacSmrg ;; 701811a29bacSmrg *-*-os2*) 701911a29bacSmrg # These systems don't actually have a C library (as such) 70206b526288Smrg test X-lc = "X$arg" && continue 702111a29bacSmrg ;; 70226b526288Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 702311a29bacSmrg # Do not include libc due to us having libc/libc_r. 70246b526288Smrg test X-lc = "X$arg" && continue 702511a29bacSmrg ;; 702611a29bacSmrg *-*-rhapsody* | *-*-darwin1.[012]) 702711a29bacSmrg # Rhapsody C and math libraries are in the System framework 70286b526288Smrg func_append deplibs " System.ltframework" 702911a29bacSmrg continue 703011a29bacSmrg ;; 703111a29bacSmrg *-*-sco3.2v5* | *-*-sco5v6*) 703211a29bacSmrg # Causes problems with __ctype 70336b526288Smrg test X-lc = "X$arg" && continue 703411a29bacSmrg ;; 703511a29bacSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 703611a29bacSmrg # Compiler inserts libc in the correct place for threads to work 70376b526288Smrg test X-lc = "X$arg" && continue 703811a29bacSmrg ;; 703911a29bacSmrg esac 70406b526288Smrg elif test X-lc_r = "X$arg"; then 704111a29bacSmrg case $host in 70426b526288Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 704311a29bacSmrg # Do not include libc_r directly, use -pthread flag. 704411a29bacSmrg continue 704511a29bacSmrg ;; 704611a29bacSmrg esac 704711a29bacSmrg fi 70486b526288Smrg func_append deplibs " $arg" 70496b526288Smrg continue 70506b526288Smrg ;; 70516b526288Smrg 70526b526288Smrg -mllvm) 70536b526288Smrg prev=mllvm 705411a29bacSmrg continue 705511a29bacSmrg ;; 705641b2f0bdSmrg 705711a29bacSmrg -module) 705811a29bacSmrg module=yes 705911a29bacSmrg continue 706011a29bacSmrg ;; 706141b2f0bdSmrg 706211a29bacSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 706311a29bacSmrg # classes, name mangling, and exception handling. 706411a29bacSmrg # Darwin uses the -arch flag to determine output architecture. 70656b526288Smrg -model|-arch|-isysroot|--sysroot) 70666b526288Smrg func_append compiler_flags " $arg" 706711a29bacSmrg func_append compile_command " $arg" 706811a29bacSmrg func_append finalize_command " $arg" 706911a29bacSmrg prev=xcompiler 707011a29bacSmrg continue 707111a29bacSmrg ;; 707241b2f0bdSmrg 70736b526288Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 70746b526288Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 70756b526288Smrg func_append compiler_flags " $arg" 707611a29bacSmrg func_append compile_command " $arg" 707711a29bacSmrg func_append finalize_command " $arg" 707811a29bacSmrg case "$new_inherited_linker_flags " in 707911a29bacSmrg *" $arg "*) ;; 70806b526288Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 708111a29bacSmrg esac 708211a29bacSmrg continue 708311a29bacSmrg ;; 708441b2f0bdSmrg 708511a29bacSmrg -multi_module) 70866b526288Smrg single_module=$wl-multi_module 708711a29bacSmrg continue 708811a29bacSmrg ;; 708941b2f0bdSmrg 709011a29bacSmrg -no-fast-install) 709111a29bacSmrg fast_install=no 709211a29bacSmrg continue 709311a29bacSmrg ;; 709441b2f0bdSmrg 709511a29bacSmrg -no-install) 709611a29bacSmrg case $host in 709711a29bacSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 709811a29bacSmrg # The PATH hackery in wrapper scripts is required on Windows 709911a29bacSmrg # and Darwin in order for the loader to find any dlls it needs. 71006b526288Smrg func_warning "'-no-install' is ignored for $host" 71016b526288Smrg func_warning "assuming '-no-fast-install' instead" 710211a29bacSmrg fast_install=no 710311a29bacSmrg ;; 710411a29bacSmrg *) no_install=yes ;; 710511a29bacSmrg esac 710611a29bacSmrg continue 710711a29bacSmrg ;; 710841b2f0bdSmrg 710911a29bacSmrg -no-undefined) 711011a29bacSmrg allow_undefined=no 711111a29bacSmrg continue 711211a29bacSmrg ;; 711341b2f0bdSmrg 711411a29bacSmrg -objectlist) 711511a29bacSmrg prev=objectlist 711611a29bacSmrg continue 711711a29bacSmrg ;; 711841b2f0bdSmrg 71196b526288Smrg -os2dllname) 71206b526288Smrg prev=os2dllname 71216b526288Smrg continue 71226b526288Smrg ;; 71236b526288Smrg 712411a29bacSmrg -o) prev=output ;; 712541b2f0bdSmrg 712611a29bacSmrg -precious-files-regex) 712711a29bacSmrg prev=precious_regex 712811a29bacSmrg continue 712911a29bacSmrg ;; 713041b2f0bdSmrg 713111a29bacSmrg -release) 713211a29bacSmrg prev=release 713311a29bacSmrg continue 713411a29bacSmrg ;; 713541b2f0bdSmrg 713611a29bacSmrg -rpath) 713711a29bacSmrg prev=rpath 713811a29bacSmrg continue 713911a29bacSmrg ;; 714041b2f0bdSmrg 714111a29bacSmrg -R) 714211a29bacSmrg prev=xrpath 714311a29bacSmrg continue 714411a29bacSmrg ;; 714541b2f0bdSmrg 714611a29bacSmrg -R*) 714711a29bacSmrg func_stripname '-R' '' "$arg" 714811a29bacSmrg dir=$func_stripname_result 714911a29bacSmrg # We need an absolute path. 715011a29bacSmrg case $dir in 715111a29bacSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 71526b526288Smrg =*) 71536b526288Smrg func_stripname '=' '' "$dir" 71546b526288Smrg dir=$lt_sysroot$func_stripname_result 71556b526288Smrg ;; 715611a29bacSmrg *) 715711a29bacSmrg func_fatal_error "only absolute run-paths are allowed" 715811a29bacSmrg ;; 715911a29bacSmrg esac 716011a29bacSmrg case "$xrpath " in 716111a29bacSmrg *" $dir "*) ;; 71626b526288Smrg *) func_append xrpath " $dir" ;; 716311a29bacSmrg esac 716411a29bacSmrg continue 716511a29bacSmrg ;; 716641b2f0bdSmrg 716711a29bacSmrg -shared) 716811a29bacSmrg # The effects of -shared are defined in a previous loop. 716911a29bacSmrg continue 717011a29bacSmrg ;; 717141b2f0bdSmrg 717211a29bacSmrg -shrext) 717311a29bacSmrg prev=shrext 717411a29bacSmrg continue 717511a29bacSmrg ;; 717641b2f0bdSmrg 717711a29bacSmrg -static | -static-libtool-libs) 717811a29bacSmrg # The effects of -static are defined in a previous loop. 717911a29bacSmrg # We used to do the same as -all-static on platforms that 718011a29bacSmrg # didn't have a PIC flag, but the assumption that the effects 718111a29bacSmrg # would be equivalent was wrong. It would break on at least 718211a29bacSmrg # Digital Unix and AIX. 718311a29bacSmrg continue 718411a29bacSmrg ;; 718541b2f0bdSmrg 718611a29bacSmrg -thread-safe) 718711a29bacSmrg thread_safe=yes 718811a29bacSmrg continue 718911a29bacSmrg ;; 719041b2f0bdSmrg 719111a29bacSmrg -version-info) 719211a29bacSmrg prev=vinfo 719311a29bacSmrg continue 719411a29bacSmrg ;; 719541b2f0bdSmrg 719611a29bacSmrg -version-number) 719711a29bacSmrg prev=vinfo 719811a29bacSmrg vinfo_number=yes 719911a29bacSmrg continue 720011a29bacSmrg ;; 720141b2f0bdSmrg 720211a29bacSmrg -weak) 720311a29bacSmrg prev=weak 720411a29bacSmrg continue 720511a29bacSmrg ;; 720641b2f0bdSmrg 720711a29bacSmrg -Wc,*) 720811a29bacSmrg func_stripname '-Wc,' '' "$arg" 720911a29bacSmrg args=$func_stripname_result 721011a29bacSmrg arg= 72116b526288Smrg save_ifs=$IFS; IFS=, 721211a29bacSmrg for flag in $args; do 72136b526288Smrg IFS=$save_ifs 721411a29bacSmrg func_quote_for_eval "$flag" 72156b526288Smrg func_append arg " $func_quote_for_eval_result" 72166b526288Smrg func_append compiler_flags " $func_quote_for_eval_result" 721711a29bacSmrg done 72186b526288Smrg IFS=$save_ifs 721911a29bacSmrg func_stripname ' ' '' "$arg" 722011a29bacSmrg arg=$func_stripname_result 722111a29bacSmrg ;; 722241b2f0bdSmrg 722311a29bacSmrg -Wl,*) 722411a29bacSmrg func_stripname '-Wl,' '' "$arg" 722511a29bacSmrg args=$func_stripname_result 722611a29bacSmrg arg= 72276b526288Smrg save_ifs=$IFS; IFS=, 722811a29bacSmrg for flag in $args; do 72296b526288Smrg IFS=$save_ifs 723011a29bacSmrg func_quote_for_eval "$flag" 72316b526288Smrg func_append arg " $wl$func_quote_for_eval_result" 72326b526288Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 72336b526288Smrg func_append linker_flags " $func_quote_for_eval_result" 723411a29bacSmrg done 72356b526288Smrg IFS=$save_ifs 723611a29bacSmrg func_stripname ' ' '' "$arg" 723711a29bacSmrg arg=$func_stripname_result 723811a29bacSmrg ;; 723941b2f0bdSmrg 724011a29bacSmrg -Xcompiler) 724111a29bacSmrg prev=xcompiler 724211a29bacSmrg continue 724311a29bacSmrg ;; 724441b2f0bdSmrg 724511a29bacSmrg -Xlinker) 724611a29bacSmrg prev=xlinker 724711a29bacSmrg continue 724811a29bacSmrg ;; 724941b2f0bdSmrg 725011a29bacSmrg -XCClinker) 725111a29bacSmrg prev=xcclinker 725211a29bacSmrg continue 725311a29bacSmrg ;; 725441b2f0bdSmrg 725511a29bacSmrg # -msg_* for osf cc 725611a29bacSmrg -msg_*) 725711a29bacSmrg func_quote_for_eval "$arg" 72586b526288Smrg arg=$func_quote_for_eval_result 725911a29bacSmrg ;; 726041b2f0bdSmrg 726111a29bacSmrg # Flags to be passed through unchanged, with rationale: 726211a29bacSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726311a29bacSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 726411a29bacSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726511a29bacSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726611a29bacSmrg # -q* compiler args for the IBM compiler 726711a29bacSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726811a29bacSmrg # -F/path path to uninstalled frameworks, gcc on darwin 726911a29bacSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 72706b526288Smrg # -fstack-protector* stack protector flags for GCC 727111a29bacSmrg # @file GCC response files 727211a29bacSmrg # -tp=* Portland pgcc target processor selection 72736b526288Smrg # --sysroot=* for sysroot support 72746b526288Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 72756b526288Smrg # -specs=* GCC specs files 72766b526288Smrg # -stdlib=* select c++ std lib with clang 727711a29bacSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 72786b526288Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 72796b526288Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 72806b526288Smrg -specs=*) 728111a29bacSmrg func_quote_for_eval "$arg" 72826b526288Smrg arg=$func_quote_for_eval_result 728311a29bacSmrg func_append compile_command " $arg" 728411a29bacSmrg func_append finalize_command " $arg" 72856b526288Smrg func_append compiler_flags " $arg" 728611a29bacSmrg continue 728711a29bacSmrg ;; 728841b2f0bdSmrg 72896b526288Smrg -Z*) 72906b526288Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 72916b526288Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 72926b526288Smrg compiler_flags="$compiler_flags $arg" 72936b526288Smrg func_append compile_command " $arg" 72946b526288Smrg func_append finalize_command " $arg" 72956b526288Smrg case $arg in 72966b526288Smrg -Zlinker | -Zstack) 72976b526288Smrg prev=xcompiler 72986b526288Smrg ;; 72996b526288Smrg esac 73006b526288Smrg continue 73016b526288Smrg else 73026b526288Smrg # Otherwise treat like 'Some other compiler flag' below 73036b526288Smrg func_quote_for_eval "$arg" 73046b526288Smrg arg=$func_quote_for_eval_result 73056b526288Smrg fi 73066b526288Smrg ;; 73076b526288Smrg 730811a29bacSmrg # Some other compiler flag. 730911a29bacSmrg -* | +*) 731011a29bacSmrg func_quote_for_eval "$arg" 73116b526288Smrg arg=$func_quote_for_eval_result 731211a29bacSmrg ;; 731341b2f0bdSmrg 731411a29bacSmrg *.$objext) 731511a29bacSmrg # A standard object. 73166b526288Smrg func_append objs " $arg" 731711a29bacSmrg ;; 731841b2f0bdSmrg 731911a29bacSmrg *.lo) 732011a29bacSmrg # A libtool-controlled object. 732141b2f0bdSmrg 732211a29bacSmrg # Check to see that this really is a libtool object. 732311a29bacSmrg if func_lalib_unsafe_p "$arg"; then 732411a29bacSmrg pic_object= 732511a29bacSmrg non_pic_object= 732641b2f0bdSmrg 732711a29bacSmrg # Read the .lo file 732811a29bacSmrg func_source "$arg" 732941b2f0bdSmrg 733011a29bacSmrg if test -z "$pic_object" || 733111a29bacSmrg test -z "$non_pic_object" || 73326b526288Smrg test none = "$pic_object" && 73336b526288Smrg test none = "$non_pic_object"; then 73346b526288Smrg func_fatal_error "cannot find name of object for '$arg'" 733511a29bacSmrg fi 733611245024Smrg 733711a29bacSmrg # Extract subdirectory from the argument. 733811a29bacSmrg func_dirname "$arg" "/" "" 73396b526288Smrg xdir=$func_dirname_result 734041b2f0bdSmrg 73416b526288Smrg test none = "$pic_object" || { 734211a29bacSmrg # Prepend the subdirectory the object is found in. 73436b526288Smrg pic_object=$xdir$pic_object 734441b2f0bdSmrg 73456b526288Smrg if test dlfiles = "$prev"; then 73466b526288Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 73476b526288Smrg func_append dlfiles " $pic_object" 734811a29bacSmrg prev= 734911a29bacSmrg continue 735011a29bacSmrg else 735111a29bacSmrg # If libtool objects are unsupported, then we need to preload. 735211a29bacSmrg prev=dlprefiles 735311a29bacSmrg fi 735411a29bacSmrg fi 735511a29bacSmrg 735611a29bacSmrg # CHECK ME: I think I busted this. -Ossama 73576b526288Smrg if test dlprefiles = "$prev"; then 735811a29bacSmrg # Preload the old-style object. 73596b526288Smrg func_append dlprefiles " $pic_object" 736011a29bacSmrg prev= 736111a29bacSmrg fi 736211a29bacSmrg 736311a29bacSmrg # A PIC object. 736411a29bacSmrg func_append libobjs " $pic_object" 73656b526288Smrg arg=$pic_object 73666b526288Smrg } 736711a29bacSmrg 736811a29bacSmrg # Non-PIC object. 73696b526288Smrg if test none != "$non_pic_object"; then 737011a29bacSmrg # Prepend the subdirectory the object is found in. 73716b526288Smrg non_pic_object=$xdir$non_pic_object 737211a29bacSmrg 737311a29bacSmrg # A standard non-PIC object 737411a29bacSmrg func_append non_pic_objects " $non_pic_object" 73756b526288Smrg if test -z "$pic_object" || test none = "$pic_object"; then 73766b526288Smrg arg=$non_pic_object 737711a29bacSmrg fi 737811a29bacSmrg else 737911a29bacSmrg # If the PIC object exists, use it instead. 738011a29bacSmrg # $xdir was prepended to $pic_object above. 73816b526288Smrg non_pic_object=$pic_object 738211a29bacSmrg func_append non_pic_objects " $non_pic_object" 738311a29bacSmrg fi 738411a29bacSmrg else 738511a29bacSmrg # Only an error if not doing a dry-run. 738611a29bacSmrg if $opt_dry_run; then 738711a29bacSmrg # Extract subdirectory from the argument. 738811a29bacSmrg func_dirname "$arg" "/" "" 73896b526288Smrg xdir=$func_dirname_result 739011a29bacSmrg 739111a29bacSmrg func_lo2o "$arg" 739211a29bacSmrg pic_object=$xdir$objdir/$func_lo2o_result 739311a29bacSmrg non_pic_object=$xdir$func_lo2o_result 739411a29bacSmrg func_append libobjs " $pic_object" 739511a29bacSmrg func_append non_pic_objects " $non_pic_object" 739611a29bacSmrg else 73976b526288Smrg func_fatal_error "'$arg' is not a valid libtool object" 739811a29bacSmrg fi 739911a29bacSmrg fi 740011a29bacSmrg ;; 740111a29bacSmrg 740211a29bacSmrg *.$libext) 740311a29bacSmrg # An archive. 74046b526288Smrg func_append deplibs " $arg" 74056b526288Smrg func_append old_deplibs " $arg" 740611a29bacSmrg continue 740711a29bacSmrg ;; 740811a29bacSmrg 740911a29bacSmrg *.la) 741011a29bacSmrg # A libtool-controlled library. 741111a29bacSmrg 74126b526288Smrg func_resolve_sysroot "$arg" 74136b526288Smrg if test dlfiles = "$prev"; then 741411a29bacSmrg # This library was specified with -dlopen. 74156b526288Smrg func_append dlfiles " $func_resolve_sysroot_result" 741611a29bacSmrg prev= 74176b526288Smrg elif test dlprefiles = "$prev"; then 741811a29bacSmrg # The library was specified with -dlpreopen. 74196b526288Smrg func_append dlprefiles " $func_resolve_sysroot_result" 742011a29bacSmrg prev= 742111a29bacSmrg else 74226b526288Smrg func_append deplibs " $func_resolve_sysroot_result" 742311a29bacSmrg fi 742411a29bacSmrg continue 742511a29bacSmrg ;; 742611a29bacSmrg 742711a29bacSmrg # Some other compiler argument. 742811a29bacSmrg *) 742911a29bacSmrg # Unknown arguments in both finalize_command and compile_command need 743011a29bacSmrg # to be aesthetically quoted because they are evaled later. 743111a29bacSmrg func_quote_for_eval "$arg" 74326b526288Smrg arg=$func_quote_for_eval_result 743311a29bacSmrg ;; 743411a29bacSmrg esac # arg 743511a29bacSmrg 743611a29bacSmrg # Now actually substitute the argument into the commands. 743711a29bacSmrg if test -n "$arg"; then 743811a29bacSmrg func_append compile_command " $arg" 743911a29bacSmrg func_append finalize_command " $arg" 744011a29bacSmrg fi 744111a29bacSmrg done # argument parsing loop 744211a29bacSmrg 744311a29bacSmrg test -n "$prev" && \ 74446b526288Smrg func_fatal_help "the '$prevarg' option requires an argument" 744511a29bacSmrg 74466b526288Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 744711a29bacSmrg eval arg=\"$export_dynamic_flag_spec\" 744811a29bacSmrg func_append compile_command " $arg" 744911a29bacSmrg func_append finalize_command " $arg" 745011a29bacSmrg fi 745111a29bacSmrg 745211a29bacSmrg oldlibs= 745311a29bacSmrg # calculate the name of the file, without its directory 745411a29bacSmrg func_basename "$output" 74556b526288Smrg outputname=$func_basename_result 74566b526288Smrg libobjs_save=$libobjs 745711a29bacSmrg 745811a29bacSmrg if test -n "$shlibpath_var"; then 745911a29bacSmrg # get the directories listed in $shlibpath_var 74606b526288Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 746141b2f0bdSmrg else 746211a29bacSmrg shlib_search_path= 746341b2f0bdSmrg fi 746411a29bacSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 746511a29bacSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 746641b2f0bdSmrg 74676b526288Smrg # Definition is injected by LT_CONFIG during libtool generation. 74686b526288Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 74696b526288Smrg 747011a29bacSmrg func_dirname "$output" "/" "" 74716b526288Smrg output_objdir=$func_dirname_result$objdir 74726b526288Smrg func_to_tool_file "$output_objdir/" 74736b526288Smrg tool_output_objdir=$func_to_tool_file_result 747411a29bacSmrg # Create the object directory. 747511a29bacSmrg func_mkdir_p "$output_objdir" 747641b2f0bdSmrg 747711a29bacSmrg # Determine the type of output 747811a29bacSmrg case $output in 747911a29bacSmrg "") 748011a29bacSmrg func_fatal_help "you must specify an output file" 748111a29bacSmrg ;; 748211a29bacSmrg *.$libext) linkmode=oldlib ;; 748311a29bacSmrg *.lo | *.$objext) linkmode=obj ;; 748411a29bacSmrg *.la) linkmode=lib ;; 748511a29bacSmrg *) linkmode=prog ;; # Anything else should be a program. 748611a29bacSmrg esac 748711a29bacSmrg 748811a29bacSmrg specialdeplibs= 748911a29bacSmrg 749011a29bacSmrg libs= 749111a29bacSmrg # Find all interdependent deplibs by searching for libraries 749211a29bacSmrg # that are linked more than once (e.g. -la -lb -la) 749311a29bacSmrg for deplib in $deplibs; do 74946b526288Smrg if $opt_preserve_dup_deps; then 749511a29bacSmrg case "$libs " in 74966b526288Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 749711a29bacSmrg esac 749811a29bacSmrg fi 74996b526288Smrg func_append libs " $deplib" 750011a29bacSmrg done 750111a29bacSmrg 75026b526288Smrg if test lib = "$linkmode"; then 750311a29bacSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 750411a29bacSmrg 750511a29bacSmrg # Compute libraries that are listed more than once in $predeps 750611a29bacSmrg # $postdeps and mark them as special (i.e., whose duplicates are 750711a29bacSmrg # not to be eliminated). 750811a29bacSmrg pre_post_deps= 750911a29bacSmrg if $opt_duplicate_compiler_generated_deps; then 751011a29bacSmrg for pre_post_dep in $predeps $postdeps; do 751111a29bacSmrg case "$pre_post_deps " in 75126b526288Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 751311a29bacSmrg esac 75146b526288Smrg func_append pre_post_deps " $pre_post_dep" 751511a29bacSmrg done 751611a29bacSmrg fi 751711a29bacSmrg pre_post_deps= 751811a29bacSmrg fi 751911a29bacSmrg 752011a29bacSmrg deplibs= 752111a29bacSmrg newdependency_libs= 752211a29bacSmrg newlib_search_path= 752311a29bacSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 752411a29bacSmrg notinst_deplibs= # not-installed libtool libraries 752511a29bacSmrg notinst_path= # paths that contain not-installed libtool libraries 752611a29bacSmrg 752711a29bacSmrg case $linkmode in 752811a29bacSmrg lib) 752911a29bacSmrg passes="conv dlpreopen link" 753011a29bacSmrg for file in $dlfiles $dlprefiles; do 753111a29bacSmrg case $file in 753211a29bacSmrg *.la) ;; 753311a29bacSmrg *) 75346b526288Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 753511a29bacSmrg ;; 753611a29bacSmrg esac 753711a29bacSmrg done 753811a29bacSmrg ;; 753911a29bacSmrg prog) 754011a29bacSmrg compile_deplibs= 754111a29bacSmrg finalize_deplibs= 75426b526288Smrg alldeplibs=false 754311a29bacSmrg newdlfiles= 754411a29bacSmrg newdlprefiles= 754511a29bacSmrg passes="conv scan dlopen dlpreopen link" 754611a29bacSmrg ;; 754711a29bacSmrg *) passes="conv" 754811a29bacSmrg ;; 754911a29bacSmrg esac 755011a29bacSmrg 755111a29bacSmrg for pass in $passes; do 755211a29bacSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 755311a29bacSmrg # so that -L comes before libs that need it for instance... 75546b526288Smrg if test lib,link = "$linkmode,$pass"; then 755511a29bacSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 755611a29bacSmrg ## order, and fix it there properly 755711a29bacSmrg tmp_deplibs= 755811a29bacSmrg for deplib in $deplibs; do 755911a29bacSmrg tmp_deplibs="$deplib $tmp_deplibs" 756011a29bacSmrg done 75616b526288Smrg deplibs=$tmp_deplibs 756211a29bacSmrg fi 756311a29bacSmrg 75646b526288Smrg if test lib,link = "$linkmode,$pass" || 75656b526288Smrg test prog,scan = "$linkmode,$pass"; then 75666b526288Smrg libs=$deplibs 756711a29bacSmrg deplibs= 756811a29bacSmrg fi 75696b526288Smrg if test prog = "$linkmode"; then 757011a29bacSmrg case $pass in 75716b526288Smrg dlopen) libs=$dlfiles ;; 75726b526288Smrg dlpreopen) libs=$dlprefiles ;; 757311a29bacSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 757411a29bacSmrg esac 757511a29bacSmrg fi 75766b526288Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 757711a29bacSmrg # Collect and forward deplibs of preopened libtool libs 757811a29bacSmrg for lib in $dlprefiles; do 757911a29bacSmrg # Ignore non-libtool-libs 758011a29bacSmrg dependency_libs= 75816b526288Smrg func_resolve_sysroot "$lib" 758211a29bacSmrg case $lib in 75836b526288Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 758411a29bacSmrg esac 758511a29bacSmrg 758611a29bacSmrg # Collect preopened libtool deplibs, except any this library 758711a29bacSmrg # has declared as weak libs 758811a29bacSmrg for deplib in $dependency_libs; do 758911a29bacSmrg func_basename "$deplib" 759011a29bacSmrg deplib_base=$func_basename_result 759111a29bacSmrg case " $weak_libs " in 759211a29bacSmrg *" $deplib_base "*) ;; 75936b526288Smrg *) func_append deplibs " $deplib" ;; 759411a29bacSmrg esac 759511a29bacSmrg done 759611a29bacSmrg done 75976b526288Smrg libs=$dlprefiles 759811a29bacSmrg fi 75996b526288Smrg if test dlopen = "$pass"; then 760011a29bacSmrg # Collect dlpreopened libraries 76016b526288Smrg save_deplibs=$deplibs 760211a29bacSmrg deplibs= 760311a29bacSmrg fi 760411a29bacSmrg 760511a29bacSmrg for deplib in $libs; do 760611a29bacSmrg lib= 76076b526288Smrg found=false 760811a29bacSmrg case $deplib in 76096b526288Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 76106b526288Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 76116b526288Smrg if test prog,link = "$linkmode,$pass"; then 761211a29bacSmrg compile_deplibs="$deplib $compile_deplibs" 761311a29bacSmrg finalize_deplibs="$deplib $finalize_deplibs" 761411a29bacSmrg else 76156b526288Smrg func_append compiler_flags " $deplib" 76166b526288Smrg if test lib = "$linkmode"; then 761711a29bacSmrg case "$new_inherited_linker_flags " in 761811a29bacSmrg *" $deplib "*) ;; 76196b526288Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 762011a29bacSmrg esac 762111a29bacSmrg fi 762211a29bacSmrg fi 762311a29bacSmrg continue 762411a29bacSmrg ;; 762511a29bacSmrg -l*) 76266b526288Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 76276b526288Smrg func_warning "'-l' is ignored for archives/objects" 762811a29bacSmrg continue 762911a29bacSmrg fi 763011a29bacSmrg func_stripname '-l' '' "$deplib" 763111a29bacSmrg name=$func_stripname_result 76326b526288Smrg if test lib = "$linkmode"; then 763311a29bacSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 763411a29bacSmrg else 763511a29bacSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 763611a29bacSmrg fi 763711a29bacSmrg for searchdir in $searchdirs; do 763811a29bacSmrg for search_ext in .la $std_shrext .so .a; do 763911a29bacSmrg # Search the libtool library 76406b526288Smrg lib=$searchdir/lib$name$search_ext 764111a29bacSmrg if test -f "$lib"; then 76426b526288Smrg if test .la = "$search_ext"; then 76436b526288Smrg found=: 764411a29bacSmrg else 76456b526288Smrg found=false 764611a29bacSmrg fi 764711a29bacSmrg break 2 764811a29bacSmrg fi 764911a29bacSmrg done 765011a29bacSmrg done 76516b526288Smrg if $found; then 76526b526288Smrg # deplib is a libtool library 765311a29bacSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 765411a29bacSmrg # We need to do some special things here, and not later. 76556b526288Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 765611a29bacSmrg case " $predeps $postdeps " in 765711a29bacSmrg *" $deplib "*) 765811a29bacSmrg if func_lalib_p "$lib"; then 765911a29bacSmrg library_names= 766011a29bacSmrg old_library= 766111a29bacSmrg func_source "$lib" 766211a29bacSmrg for l in $old_library $library_names; do 76636b526288Smrg ll=$l 766411a29bacSmrg done 76656b526288Smrg if test "X$ll" = "X$old_library"; then # only static version available 76666b526288Smrg found=false 766711a29bacSmrg func_dirname "$lib" "" "." 76686b526288Smrg ladir=$func_dirname_result 766911a29bacSmrg lib=$ladir/$old_library 76706b526288Smrg if test prog,link = "$linkmode,$pass"; then 767111a29bacSmrg compile_deplibs="$deplib $compile_deplibs" 767211a29bacSmrg finalize_deplibs="$deplib $finalize_deplibs" 767311a29bacSmrg else 767411a29bacSmrg deplibs="$deplib $deplibs" 76756b526288Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 767611a29bacSmrg fi 767711a29bacSmrg continue 767811a29bacSmrg fi 767911a29bacSmrg fi 768011a29bacSmrg ;; 768111a29bacSmrg *) ;; 768211a29bacSmrg esac 768311a29bacSmrg fi 76846b526288Smrg else 76856b526288Smrg # deplib doesn't seem to be a libtool library 76866b526288Smrg if test prog,link = "$linkmode,$pass"; then 76876b526288Smrg compile_deplibs="$deplib $compile_deplibs" 76886b526288Smrg finalize_deplibs="$deplib $finalize_deplibs" 76896b526288Smrg else 76906b526288Smrg deplibs="$deplib $deplibs" 76916b526288Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76926b526288Smrg fi 76936b526288Smrg continue 769411a29bacSmrg fi 769511a29bacSmrg ;; # -l 769611a29bacSmrg *.ltframework) 76976b526288Smrg if test prog,link = "$linkmode,$pass"; then 769811a29bacSmrg compile_deplibs="$deplib $compile_deplibs" 769911a29bacSmrg finalize_deplibs="$deplib $finalize_deplibs" 770011a29bacSmrg else 770111a29bacSmrg deplibs="$deplib $deplibs" 77026b526288Smrg if test lib = "$linkmode"; then 770311a29bacSmrg case "$new_inherited_linker_flags " in 770411a29bacSmrg *" $deplib "*) ;; 77056b526288Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 770611a29bacSmrg esac 770711a29bacSmrg fi 770811a29bacSmrg fi 770911a29bacSmrg continue 771011a29bacSmrg ;; 771111a29bacSmrg -L*) 771211a29bacSmrg case $linkmode in 771311a29bacSmrg lib) 771411a29bacSmrg deplibs="$deplib $deplibs" 77156b526288Smrg test conv = "$pass" && continue 771611a29bacSmrg newdependency_libs="$deplib $newdependency_libs" 771711a29bacSmrg func_stripname '-L' '' "$deplib" 77186b526288Smrg func_resolve_sysroot "$func_stripname_result" 77196b526288Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 772011a29bacSmrg ;; 772111a29bacSmrg prog) 77226b526288Smrg if test conv = "$pass"; then 772311a29bacSmrg deplibs="$deplib $deplibs" 772411a29bacSmrg continue 772511a29bacSmrg fi 77266b526288Smrg if test scan = "$pass"; then 772711a29bacSmrg deplibs="$deplib $deplibs" 772811a29bacSmrg else 772911a29bacSmrg compile_deplibs="$deplib $compile_deplibs" 773011a29bacSmrg finalize_deplibs="$deplib $finalize_deplibs" 773111a29bacSmrg fi 773211a29bacSmrg func_stripname '-L' '' "$deplib" 77336b526288Smrg func_resolve_sysroot "$func_stripname_result" 77346b526288Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 773511a29bacSmrg ;; 773611a29bacSmrg *) 77376b526288Smrg func_warning "'-L' is ignored for archives/objects" 773811a29bacSmrg ;; 773911a29bacSmrg esac # linkmode 774011a29bacSmrg continue 774111a29bacSmrg ;; # -L 774211a29bacSmrg -R*) 77436b526288Smrg if test link = "$pass"; then 774411a29bacSmrg func_stripname '-R' '' "$deplib" 77456b526288Smrg func_resolve_sysroot "$func_stripname_result" 77466b526288Smrg dir=$func_resolve_sysroot_result 774711a29bacSmrg # Make sure the xrpath contains only unique directories. 774811a29bacSmrg case "$xrpath " in 774911a29bacSmrg *" $dir "*) ;; 77506b526288Smrg *) func_append xrpath " $dir" ;; 775111a29bacSmrg esac 775211a29bacSmrg fi 775311a29bacSmrg deplibs="$deplib $deplibs" 775411a29bacSmrg continue 775511a29bacSmrg ;; 77566b526288Smrg *.la) 77576b526288Smrg func_resolve_sysroot "$deplib" 77586b526288Smrg lib=$func_resolve_sysroot_result 77596b526288Smrg ;; 776011a29bacSmrg *.$libext) 77616b526288Smrg if test conv = "$pass"; then 776211a29bacSmrg deplibs="$deplib $deplibs" 776311a29bacSmrg continue 776411a29bacSmrg fi 776511a29bacSmrg case $linkmode in 776611a29bacSmrg lib) 776711a29bacSmrg # Linking convenience modules into shared libraries is allowed, 776811a29bacSmrg # but linking other static libraries is non-portable. 776911a29bacSmrg case " $dlpreconveniencelibs " in 777011a29bacSmrg *" $deplib "*) ;; 777111a29bacSmrg *) 77726b526288Smrg valid_a_lib=false 777311a29bacSmrg case $deplibs_check_method in 777411a29bacSmrg match_pattern*) 777511a29bacSmrg set dummy $deplibs_check_method; shift 777611a29bacSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777711a29bacSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 777811a29bacSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 77796b526288Smrg valid_a_lib=: 778011a29bacSmrg fi 778111a29bacSmrg ;; 778211a29bacSmrg pass_all) 77836b526288Smrg valid_a_lib=: 778411a29bacSmrg ;; 778511a29bacSmrg esac 77866b526288Smrg if $valid_a_lib; then 77876b526288Smrg echo 77886b526288Smrg $ECHO "*** Warning: Linking the shared library $output against the" 77896b526288Smrg $ECHO "*** static library $deplib is not portable!" 77906b526288Smrg deplibs="$deplib $deplibs" 77916b526288Smrg else 779211a29bacSmrg echo 779311a29bacSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779411a29bacSmrg echo "*** I have the capability to make that library automatically link in when" 779511a29bacSmrg echo "*** you link to this library. But I can only do this if you have a" 779611a29bacSmrg echo "*** shared version of the library, which you do not appear to have" 779711a29bacSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 779811a29bacSmrg echo "*** that it is just a static archive that I should not use here." 779911a29bacSmrg fi 780011a29bacSmrg ;; 780111a29bacSmrg esac 780211a29bacSmrg continue 780311a29bacSmrg ;; 780411a29bacSmrg prog) 78056b526288Smrg if test link != "$pass"; then 780611a29bacSmrg deplibs="$deplib $deplibs" 780711a29bacSmrg else 780811a29bacSmrg compile_deplibs="$deplib $compile_deplibs" 780911a29bacSmrg finalize_deplibs="$deplib $finalize_deplibs" 781011a29bacSmrg fi 781111a29bacSmrg continue 781211a29bacSmrg ;; 781311a29bacSmrg esac # linkmode 781411a29bacSmrg ;; # *.$libext 781511a29bacSmrg *.lo | *.$objext) 78166b526288Smrg if test conv = "$pass"; then 781711a29bacSmrg deplibs="$deplib $deplibs" 78186b526288Smrg elif test prog = "$linkmode"; then 78196b526288Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 782011a29bacSmrg # If there is no dlopen support or we're linking statically, 782111a29bacSmrg # we need to preload. 78226b526288Smrg func_append newdlprefiles " $deplib" 782311a29bacSmrg compile_deplibs="$deplib $compile_deplibs" 782411a29bacSmrg finalize_deplibs="$deplib $finalize_deplibs" 782511a29bacSmrg else 78266b526288Smrg func_append newdlfiles " $deplib" 782711a29bacSmrg fi 782811a29bacSmrg fi 782911a29bacSmrg continue 783011a29bacSmrg ;; 783111a29bacSmrg %DEPLIBS%) 78326b526288Smrg alldeplibs=: 783311a29bacSmrg continue 783411a29bacSmrg ;; 783511a29bacSmrg esac # case $deplib 783611a29bacSmrg 78376b526288Smrg $found || test -f "$lib" \ 78386b526288Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 783911a29bacSmrg 784011a29bacSmrg # Check to see that this really is a libtool archive. 784111a29bacSmrg func_lalib_unsafe_p "$lib" \ 78426b526288Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 784311a29bacSmrg 784411a29bacSmrg func_dirname "$lib" "" "." 78456b526288Smrg ladir=$func_dirname_result 784611a29bacSmrg 784711a29bacSmrg dlname= 784811a29bacSmrg dlopen= 784911a29bacSmrg dlpreopen= 785011a29bacSmrg libdir= 785111a29bacSmrg library_names= 785211a29bacSmrg old_library= 785311a29bacSmrg inherited_linker_flags= 785411a29bacSmrg # If the library was installed with an old release of libtool, 785511a29bacSmrg # it will not redefine variables installed, or shouldnotlink 785611a29bacSmrg installed=yes 785711a29bacSmrg shouldnotlink=no 785811a29bacSmrg avoidtemprpath= 785911a29bacSmrg 786011a29bacSmrg 786111a29bacSmrg # Read the .la file 786211a29bacSmrg func_source "$lib" 786311a29bacSmrg 786411a29bacSmrg # Convert "-framework foo" to "foo.ltframework" 786511a29bacSmrg if test -n "$inherited_linker_flags"; then 786611a29bacSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 786711a29bacSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 786811a29bacSmrg case " $new_inherited_linker_flags " in 786911a29bacSmrg *" $tmp_inherited_linker_flag "*) ;; 78706b526288Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 787111a29bacSmrg esac 787211a29bacSmrg done 787311a29bacSmrg fi 787411a29bacSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 78756b526288Smrg if test lib,link = "$linkmode,$pass" || 78766b526288Smrg test prog,scan = "$linkmode,$pass" || 78776b526288Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 78786b526288Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 78796b526288Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 788011a29bacSmrg fi 788111a29bacSmrg 78826b526288Smrg if test conv = "$pass"; then 788311a29bacSmrg # Only check for convenience libraries 788411a29bacSmrg deplibs="$lib $deplibs" 788511a29bacSmrg if test -z "$libdir"; then 788611a29bacSmrg if test -z "$old_library"; then 78876b526288Smrg func_fatal_error "cannot find name of link library for '$lib'" 788811a29bacSmrg fi 788911a29bacSmrg # It is a libtool convenience library, so add in its objects. 78906b526288Smrg func_append convenience " $ladir/$objdir/$old_library" 78916b526288Smrg func_append old_convenience " $ladir/$objdir/$old_library" 78926b526288Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 78936b526288Smrg func_fatal_error "'$lib' is not a convenience library" 789411a29bacSmrg fi 789511a29bacSmrg tmp_libs= 789611a29bacSmrg for deplib in $dependency_libs; do 789711a29bacSmrg deplibs="$deplib $deplibs" 78986b526288Smrg if $opt_preserve_dup_deps; then 789911a29bacSmrg case "$tmp_libs " in 79006b526288Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 790111a29bacSmrg esac 790211a29bacSmrg fi 79036b526288Smrg func_append tmp_libs " $deplib" 790411a29bacSmrg done 790511a29bacSmrg continue 790611a29bacSmrg fi # $pass = conv 790711a29bacSmrg 790811a29bacSmrg 790911a29bacSmrg # Get the name of the library we link against. 791011a29bacSmrg linklib= 79116b526288Smrg if test -n "$old_library" && 79126b526288Smrg { test yes = "$prefer_static_libs" || 79136b526288Smrg test built,no = "$prefer_static_libs,$installed"; }; then 79146b526288Smrg linklib=$old_library 79156b526288Smrg else 79166b526288Smrg for l in $old_library $library_names; do 79176b526288Smrg linklib=$l 79186b526288Smrg done 79196b526288Smrg fi 792011a29bacSmrg if test -z "$linklib"; then 79216b526288Smrg func_fatal_error "cannot find name of link library for '$lib'" 792211a29bacSmrg fi 792311a29bacSmrg 792411a29bacSmrg # This library was specified with -dlopen. 79256b526288Smrg if test dlopen = "$pass"; then 79266b526288Smrg test -z "$libdir" \ 79276b526288Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 792811a29bacSmrg if test -z "$dlname" || 79296b526288Smrg test yes != "$dlopen_support" || 79306b526288Smrg test no = "$build_libtool_libs" 79316b526288Smrg then 793211a29bacSmrg # If there is no dlname, no dlopen support or we're linking 793311a29bacSmrg # statically, we need to preload. We also need to preload any 793411a29bacSmrg # dependent libraries so libltdl's deplib preloader doesn't 793511a29bacSmrg # bomb out in the load deplibs phase. 79366b526288Smrg func_append dlprefiles " $lib $dependency_libs" 793711a29bacSmrg else 79386b526288Smrg func_append newdlfiles " $lib" 793911a29bacSmrg fi 794011a29bacSmrg continue 794111a29bacSmrg fi # $pass = dlopen 794211a29bacSmrg 794311a29bacSmrg # We need an absolute path. 794411a29bacSmrg case $ladir in 79456b526288Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 794611a29bacSmrg *) 794711a29bacSmrg abs_ladir=`cd "$ladir" && pwd` 794811a29bacSmrg if test -z "$abs_ladir"; then 79496b526288Smrg func_warning "cannot determine absolute directory name of '$ladir'" 795011a29bacSmrg func_warning "passing it literally to the linker, although it might fail" 79516b526288Smrg abs_ladir=$ladir 795211a29bacSmrg fi 795311a29bacSmrg ;; 795411a29bacSmrg esac 795511a29bacSmrg func_basename "$lib" 79566b526288Smrg laname=$func_basename_result 795711a29bacSmrg 795811a29bacSmrg # Find the relevant object directory and library name. 79596b526288Smrg if test yes = "$installed"; then 79606b526288Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 79616b526288Smrg func_warning "library '$lib' was moved." 79626b526288Smrg dir=$ladir 79636b526288Smrg absdir=$abs_ladir 79646b526288Smrg libdir=$abs_ladir 796511a29bacSmrg else 79666b526288Smrg dir=$lt_sysroot$libdir 79676b526288Smrg absdir=$lt_sysroot$libdir 796811a29bacSmrg fi 79696b526288Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 797011a29bacSmrg else 797111a29bacSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 79726b526288Smrg dir=$ladir 79736b526288Smrg absdir=$abs_ladir 797411a29bacSmrg # Remove this search path later 79756b526288Smrg func_append notinst_path " $abs_ladir" 797611a29bacSmrg else 79776b526288Smrg dir=$ladir/$objdir 79786b526288Smrg absdir=$abs_ladir/$objdir 797911a29bacSmrg # Remove this search path later 79806b526288Smrg func_append notinst_path " $abs_ladir" 798111a29bacSmrg fi 798211a29bacSmrg fi # $installed = yes 798311a29bacSmrg func_stripname 'lib' '.la' "$laname" 798411a29bacSmrg name=$func_stripname_result 798511a29bacSmrg 798611a29bacSmrg # This library was specified with -dlpreopen. 79876b526288Smrg if test dlpreopen = "$pass"; then 79886b526288Smrg if test -z "$libdir" && test prog = "$linkmode"; then 79896b526288Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 799011a29bacSmrg fi 79916b526288Smrg case $host in 79926b526288Smrg # special handling for platforms with PE-DLLs. 79936b526288Smrg *cygwin* | *mingw* | *cegcc* ) 79946b526288Smrg # Linker will automatically link against shared library if both 79956b526288Smrg # static and shared are present. Therefore, ensure we extract 79966b526288Smrg # symbols from the import library if a shared library is present 79976b526288Smrg # (otherwise, the dlopen module name will be incorrect). We do 79986b526288Smrg # this by putting the import library name into $newdlprefiles. 79996b526288Smrg # We recover the dlopen module name by 'saving' the la file 80006b526288Smrg # name in a special purpose variable, and (later) extracting the 80016b526288Smrg # dlname from the la file. 80026b526288Smrg if test -n "$dlname"; then 80036b526288Smrg func_tr_sh "$dir/$linklib" 80046b526288Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 80056b526288Smrg func_append newdlprefiles " $dir/$linklib" 80066b526288Smrg else 80076b526288Smrg func_append newdlprefiles " $dir/$old_library" 80086b526288Smrg # Keep a list of preopened convenience libraries to check 80096b526288Smrg # that they are being used correctly in the link pass. 80106b526288Smrg test -z "$libdir" && \ 80116b526288Smrg func_append dlpreconveniencelibs " $dir/$old_library" 80126b526288Smrg fi 80136b526288Smrg ;; 80146b526288Smrg * ) 80156b526288Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 80166b526288Smrg # are required to link). 80176b526288Smrg if test -n "$old_library"; then 80186b526288Smrg func_append newdlprefiles " $dir/$old_library" 80196b526288Smrg # Keep a list of preopened convenience libraries to check 80206b526288Smrg # that they are being used correctly in the link pass. 80216b526288Smrg test -z "$libdir" && \ 80226b526288Smrg func_append dlpreconveniencelibs " $dir/$old_library" 80236b526288Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 80246b526288Smrg elif test -n "$dlname"; then 80256b526288Smrg func_append newdlprefiles " $dir/$dlname" 80266b526288Smrg else 80276b526288Smrg func_append newdlprefiles " $dir/$linklib" 80286b526288Smrg fi 80296b526288Smrg ;; 80306b526288Smrg esac 803111a29bacSmrg fi # $pass = dlpreopen 803211a29bacSmrg 803311a29bacSmrg if test -z "$libdir"; then 803411a29bacSmrg # Link the convenience library 80356b526288Smrg if test lib = "$linkmode"; then 803611a29bacSmrg deplibs="$dir/$old_library $deplibs" 80376b526288Smrg elif test prog,link = "$linkmode,$pass"; then 803811a29bacSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 803911a29bacSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 804011a29bacSmrg else 804111a29bacSmrg deplibs="$lib $deplibs" # used for prog,scan pass 804211a29bacSmrg fi 804311a29bacSmrg continue 804411a29bacSmrg fi 804511a29bacSmrg 804611a29bacSmrg 80476b526288Smrg if test prog = "$linkmode" && test link != "$pass"; then 80486b526288Smrg func_append newlib_search_path " $ladir" 804911a29bacSmrg deplibs="$lib $deplibs" 805011a29bacSmrg 80516b526288Smrg linkalldeplibs=false 80526b526288Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 80536b526288Smrg test no = "$build_libtool_libs"; then 80546b526288Smrg linkalldeplibs=: 805511a29bacSmrg fi 805611a29bacSmrg 805711a29bacSmrg tmp_libs= 805811a29bacSmrg for deplib in $dependency_libs; do 805911a29bacSmrg case $deplib in 806011a29bacSmrg -L*) func_stripname '-L' '' "$deplib" 80616b526288Smrg func_resolve_sysroot "$func_stripname_result" 80626b526288Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 806311a29bacSmrg ;; 806411a29bacSmrg esac 806511a29bacSmrg # Need to link against all dependency_libs? 80666b526288Smrg if $linkalldeplibs; then 806711a29bacSmrg deplibs="$deplib $deplibs" 806811a29bacSmrg else 806911a29bacSmrg # Need to hardcode shared library paths 807011a29bacSmrg # or/and link against static libraries 807111a29bacSmrg newdependency_libs="$deplib $newdependency_libs" 807211a29bacSmrg fi 80736b526288Smrg if $opt_preserve_dup_deps; then 807411a29bacSmrg case "$tmp_libs " in 80756b526288Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 807611a29bacSmrg esac 807711a29bacSmrg fi 80786b526288Smrg func_append tmp_libs " $deplib" 807911a29bacSmrg done # for deplib 808011a29bacSmrg continue 808111a29bacSmrg fi # $linkmode = prog... 808211a29bacSmrg 80836b526288Smrg if test prog,link = "$linkmode,$pass"; then 808411a29bacSmrg if test -n "$library_names" && 80856b526288Smrg { { test no = "$prefer_static_libs" || 80866b526288Smrg test built,yes = "$prefer_static_libs,$installed"; } || 808711a29bacSmrg test -z "$old_library"; }; then 808811a29bacSmrg # We need to hardcode the library path 80896b526288Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 809011a29bacSmrg # Make sure the rpath contains only unique directories. 80916b526288Smrg case $temp_rpath: in 809211a29bacSmrg *"$absdir:"*) ;; 80936b526288Smrg *) func_append temp_rpath "$absdir:" ;; 809411a29bacSmrg esac 809511a29bacSmrg fi 809611a29bacSmrg 809711a29bacSmrg # Hardcode the library path. 809811a29bacSmrg # Skip directories that are in the system default run-time 809911a29bacSmrg # search path. 810011a29bacSmrg case " $sys_lib_dlsearch_path " in 810111a29bacSmrg *" $absdir "*) ;; 810211a29bacSmrg *) 810311a29bacSmrg case "$compile_rpath " in 810411a29bacSmrg *" $absdir "*) ;; 81056b526288Smrg *) func_append compile_rpath " $absdir" ;; 810611a29bacSmrg esac 810711a29bacSmrg ;; 810811a29bacSmrg esac 810911a29bacSmrg case " $sys_lib_dlsearch_path " in 811011a29bacSmrg *" $libdir "*) ;; 811111a29bacSmrg *) 811211a29bacSmrg case "$finalize_rpath " in 811311a29bacSmrg *" $libdir "*) ;; 81146b526288Smrg *) func_append finalize_rpath " $libdir" ;; 811511a29bacSmrg esac 811611a29bacSmrg ;; 811711a29bacSmrg esac 811811a29bacSmrg fi # $linkmode,$pass = prog,link... 811911a29bacSmrg 81206b526288Smrg if $alldeplibs && 81216b526288Smrg { test pass_all = "$deplibs_check_method" || 81226b526288Smrg { test yes = "$build_libtool_libs" && 812311a29bacSmrg test -n "$library_names"; }; }; then 812411a29bacSmrg # We only need to search for static libraries 812511a29bacSmrg continue 812611a29bacSmrg fi 812711a29bacSmrg fi 812811a29bacSmrg 812911a29bacSmrg link_static=no # Whether the deplib will be linked statically 813011a29bacSmrg use_static_libs=$prefer_static_libs 81316b526288Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 813211a29bacSmrg use_static_libs=no 813311a29bacSmrg fi 813411a29bacSmrg if test -n "$library_names" && 81356b526288Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 813611a29bacSmrg case $host in 81376b526288Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 813811a29bacSmrg # No point in relinking DLLs because paths are not encoded 81396b526288Smrg func_append notinst_deplibs " $lib" 814011a29bacSmrg need_relink=no 814111a29bacSmrg ;; 814211a29bacSmrg *) 81436b526288Smrg if test no = "$installed"; then 81446b526288Smrg func_append notinst_deplibs " $lib" 814511a29bacSmrg need_relink=yes 814611a29bacSmrg fi 814711a29bacSmrg ;; 814811a29bacSmrg esac 814911a29bacSmrg # This is a shared library 815011a29bacSmrg 815111a29bacSmrg # Warn about portability, can't link against -module's on some 815211a29bacSmrg # systems (darwin). Don't bleat about dlopened modules though! 81536b526288Smrg dlopenmodule= 815411a29bacSmrg for dlpremoduletest in $dlprefiles; do 815511a29bacSmrg if test "X$dlpremoduletest" = "X$lib"; then 81566b526288Smrg dlopenmodule=$dlpremoduletest 815711a29bacSmrg break 815811a29bacSmrg fi 815911a29bacSmrg done 81606b526288Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 816111a29bacSmrg echo 81626b526288Smrg if test prog = "$linkmode"; then 816311a29bacSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 816411a29bacSmrg else 816511a29bacSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 816611a29bacSmrg fi 816711a29bacSmrg $ECHO "*** $linklib is not portable!" 816811a29bacSmrg fi 81696b526288Smrg if test lib = "$linkmode" && 81706b526288Smrg test yes = "$hardcode_into_libs"; then 817111a29bacSmrg # Hardcode the library path. 817211a29bacSmrg # Skip directories that are in the system default run-time 817311a29bacSmrg # search path. 817411a29bacSmrg case " $sys_lib_dlsearch_path " in 817511a29bacSmrg *" $absdir "*) ;; 817611a29bacSmrg *) 817711a29bacSmrg case "$compile_rpath " in 817811a29bacSmrg *" $absdir "*) ;; 81796b526288Smrg *) func_append compile_rpath " $absdir" ;; 818011a29bacSmrg esac 818111a29bacSmrg ;; 818211a29bacSmrg esac 818311a29bacSmrg case " $sys_lib_dlsearch_path " in 818411a29bacSmrg *" $libdir "*) ;; 818511a29bacSmrg *) 818611a29bacSmrg case "$finalize_rpath " in 818711a29bacSmrg *" $libdir "*) ;; 81886b526288Smrg *) func_append finalize_rpath " $libdir" ;; 818911a29bacSmrg esac 819011a29bacSmrg ;; 819111a29bacSmrg esac 819211a29bacSmrg fi 819311a29bacSmrg 819411a29bacSmrg if test -n "$old_archive_from_expsyms_cmds"; then 819511a29bacSmrg # figure out the soname 819611a29bacSmrg set dummy $library_names 819711a29bacSmrg shift 81986b526288Smrg realname=$1 819911a29bacSmrg shift 820011a29bacSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 820111a29bacSmrg # use dlname if we got it. it's perfectly good, no? 820211a29bacSmrg if test -n "$dlname"; then 82036b526288Smrg soname=$dlname 820411a29bacSmrg elif test -n "$soname_spec"; then 820511a29bacSmrg # bleh windows 820611a29bacSmrg case $host in 82076b526288Smrg *cygwin* | mingw* | *cegcc* | *os2*) 820811a29bacSmrg func_arith $current - $age 820911a29bacSmrg major=$func_arith_result 82106b526288Smrg versuffix=-$major 821111a29bacSmrg ;; 821211a29bacSmrg esac 821311a29bacSmrg eval soname=\"$soname_spec\" 821411a29bacSmrg else 82156b526288Smrg soname=$realname 821611a29bacSmrg fi 821711a29bacSmrg 821811a29bacSmrg # Make a new name for the extract_expsyms_cmds to use 82196b526288Smrg soroot=$soname 822011a29bacSmrg func_basename "$soroot" 82216b526288Smrg soname=$func_basename_result 822211a29bacSmrg func_stripname 'lib' '.dll' "$soname" 822311a29bacSmrg newlib=libimp-$func_stripname_result.a 822411a29bacSmrg 822511a29bacSmrg # If the library has no export list, then create one now 822611a29bacSmrg if test -f "$output_objdir/$soname-def"; then : 822711a29bacSmrg else 82286b526288Smrg func_verbose "extracting exported symbol list from '$soname'" 822911a29bacSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 823011a29bacSmrg fi 823111a29bacSmrg 823211a29bacSmrg # Create $newlib 823311a29bacSmrg if test -f "$output_objdir/$newlib"; then :; else 82346b526288Smrg func_verbose "generating import library for '$soname'" 823511a29bacSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 823611a29bacSmrg fi 823711a29bacSmrg # make sure the library variables are pointing to the new library 823811a29bacSmrg dir=$output_objdir 823911a29bacSmrg linklib=$newlib 824011a29bacSmrg fi # test -n "$old_archive_from_expsyms_cmds" 824111a29bacSmrg 82426b526288Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 824311a29bacSmrg add_shlibpath= 824411a29bacSmrg add_dir= 824511a29bacSmrg add= 824611a29bacSmrg lib_linked=yes 824711a29bacSmrg case $hardcode_action in 824811a29bacSmrg immediate | unsupported) 82496b526288Smrg if test no = "$hardcode_direct"; then 82506b526288Smrg add=$dir/$linklib 825111a29bacSmrg case $host in 82526b526288Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 82536b526288Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 825411a29bacSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 82556b526288Smrg *-*-unixware7*) add_dir=-L$dir ;; 825611a29bacSmrg *-*-darwin* ) 82576b526288Smrg # if the lib is a (non-dlopened) module then we cannot 825811a29bacSmrg # link against it, someone is ignoring the earlier warnings 825911a29bacSmrg if /usr/bin/file -L $add 2> /dev/null | 82606b526288Smrg $GREP ": [^:]* bundle" >/dev/null; then 826111a29bacSmrg if test "X$dlopenmodule" != "X$lib"; then 826211a29bacSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 82636b526288Smrg if test -z "$old_library"; then 826411a29bacSmrg echo 826511a29bacSmrg echo "*** And there doesn't seem to be a static archive available" 826611a29bacSmrg echo "*** The link will probably fail, sorry" 826711a29bacSmrg else 82686b526288Smrg add=$dir/$old_library 826911a29bacSmrg fi 827011a29bacSmrg elif test -n "$old_library"; then 82716b526288Smrg add=$dir/$old_library 827211a29bacSmrg fi 827311a29bacSmrg fi 827411a29bacSmrg esac 82756b526288Smrg elif test no = "$hardcode_minus_L"; then 827611a29bacSmrg case $host in 82776b526288Smrg *-*-sunos*) add_shlibpath=$dir ;; 827811a29bacSmrg esac 82796b526288Smrg add_dir=-L$dir 82806b526288Smrg add=-l$name 82816b526288Smrg elif test no = "$hardcode_shlibpath_var"; then 82826b526288Smrg add_shlibpath=$dir 82836b526288Smrg add=-l$name 828411a29bacSmrg else 828511a29bacSmrg lib_linked=no 828611a29bacSmrg fi 828711a29bacSmrg ;; 828811a29bacSmrg relink) 82896b526288Smrg if test yes = "$hardcode_direct" && 82906b526288Smrg test no = "$hardcode_direct_absolute"; then 82916b526288Smrg add=$dir/$linklib 82926b526288Smrg elif test yes = "$hardcode_minus_L"; then 82936b526288Smrg add_dir=-L$absdir 829411a29bacSmrg # Try looking first in the location we're being installed to. 829511a29bacSmrg if test -n "$inst_prefix_dir"; then 829611a29bacSmrg case $libdir in 829711a29bacSmrg [\\/]*) 82986b526288Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 829911a29bacSmrg ;; 830011a29bacSmrg esac 830111a29bacSmrg fi 83026b526288Smrg add=-l$name 83036b526288Smrg elif test yes = "$hardcode_shlibpath_var"; then 83046b526288Smrg add_shlibpath=$dir 83056b526288Smrg add=-l$name 830611a29bacSmrg else 830711a29bacSmrg lib_linked=no 830811a29bacSmrg fi 830911a29bacSmrg ;; 831011a29bacSmrg *) lib_linked=no ;; 831111a29bacSmrg esac 831211a29bacSmrg 83136b526288Smrg if test yes != "$lib_linked"; then 831411a29bacSmrg func_fatal_configuration "unsupported hardcode properties" 831511a29bacSmrg fi 831611a29bacSmrg 831711a29bacSmrg if test -n "$add_shlibpath"; then 831811a29bacSmrg case :$compile_shlibpath: in 831911a29bacSmrg *":$add_shlibpath:"*) ;; 83206b526288Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 832111a29bacSmrg esac 832211a29bacSmrg fi 83236b526288Smrg if test prog = "$linkmode"; then 832411a29bacSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 832511a29bacSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 832611a29bacSmrg else 832711a29bacSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 832811a29bacSmrg test -n "$add" && deplibs="$add $deplibs" 83296b526288Smrg if test yes != "$hardcode_direct" && 83306b526288Smrg test yes != "$hardcode_minus_L" && 83316b526288Smrg test yes = "$hardcode_shlibpath_var"; then 833211a29bacSmrg case :$finalize_shlibpath: in 833311a29bacSmrg *":$libdir:"*) ;; 83346b526288Smrg *) func_append finalize_shlibpath "$libdir:" ;; 833511a29bacSmrg esac 833611a29bacSmrg fi 833711a29bacSmrg fi 833811a29bacSmrg fi 833911a29bacSmrg 83406b526288Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 834111a29bacSmrg add_shlibpath= 834211a29bacSmrg add_dir= 834311a29bacSmrg add= 834411a29bacSmrg # Finalize command for both is simple: just hardcode it. 83456b526288Smrg if test yes = "$hardcode_direct" && 83466b526288Smrg test no = "$hardcode_direct_absolute"; then 83476b526288Smrg add=$libdir/$linklib 83486b526288Smrg elif test yes = "$hardcode_minus_L"; then 83496b526288Smrg add_dir=-L$libdir 83506b526288Smrg add=-l$name 83516b526288Smrg elif test yes = "$hardcode_shlibpath_var"; then 835211a29bacSmrg case :$finalize_shlibpath: in 835311a29bacSmrg *":$libdir:"*) ;; 83546b526288Smrg *) func_append finalize_shlibpath "$libdir:" ;; 835511a29bacSmrg esac 83566b526288Smrg add=-l$name 83576b526288Smrg elif test yes = "$hardcode_automatic"; then 835811a29bacSmrg if test -n "$inst_prefix_dir" && 83596b526288Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 83606b526288Smrg add=$inst_prefix_dir$libdir/$linklib 836111a29bacSmrg else 83626b526288Smrg add=$libdir/$linklib 836311a29bacSmrg fi 836411a29bacSmrg else 836511a29bacSmrg # We cannot seem to hardcode it, guess we'll fake it. 83666b526288Smrg add_dir=-L$libdir 836711a29bacSmrg # Try looking first in the location we're being installed to. 836811a29bacSmrg if test -n "$inst_prefix_dir"; then 836911a29bacSmrg case $libdir in 837011a29bacSmrg [\\/]*) 83716b526288Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 837211a29bacSmrg ;; 837311a29bacSmrg esac 837411a29bacSmrg fi 83756b526288Smrg add=-l$name 837611a29bacSmrg fi 837711a29bacSmrg 83786b526288Smrg if test prog = "$linkmode"; then 837911a29bacSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 838011a29bacSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 838111a29bacSmrg else 838211a29bacSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 838311a29bacSmrg test -n "$add" && deplibs="$add $deplibs" 838411a29bacSmrg fi 838511a29bacSmrg fi 83866b526288Smrg elif test prog = "$linkmode"; then 838711a29bacSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 838811a29bacSmrg # is not unsupported. This is valid on all known static and 838911a29bacSmrg # shared platforms. 83906b526288Smrg if test unsupported != "$hardcode_direct"; then 83916b526288Smrg test -n "$old_library" && linklib=$old_library 839211a29bacSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 839311a29bacSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 839411a29bacSmrg else 839511a29bacSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 839611a29bacSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 839711a29bacSmrg fi 83986b526288Smrg elif test yes = "$build_libtool_libs"; then 839911a29bacSmrg # Not a shared library 84006b526288Smrg if test pass_all != "$deplibs_check_method"; then 840111a29bacSmrg # We're trying link a shared library against a static one 840211a29bacSmrg # but the system doesn't support it. 840311a29bacSmrg 840411a29bacSmrg # Just print a warning and add the library to dependency_libs so 840511a29bacSmrg # that the program can be linked against the static library. 840611a29bacSmrg echo 84076b526288Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 840811a29bacSmrg echo "*** I have the capability to make that library automatically link in when" 840911a29bacSmrg echo "*** you link to this library. But I can only do this if you have a" 841011a29bacSmrg echo "*** shared version of the library, which you do not appear to have." 84116b526288Smrg if test yes = "$module"; then 841211a29bacSmrg echo "*** But as you try to build a module library, libtool will still create " 841311a29bacSmrg echo "*** a static module, that should work as long as the dlopening application" 841411a29bacSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 841511a29bacSmrg if test -z "$global_symbol_pipe"; then 841611a29bacSmrg echo 841711a29bacSmrg echo "*** However, this would only work if libtool was able to extract symbol" 84186b526288Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 841911a29bacSmrg echo "*** not find such a program. So, this module is probably useless." 84206b526288Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 842111a29bacSmrg fi 84226b526288Smrg if test no = "$build_old_libs"; then 842311a29bacSmrg build_libtool_libs=module 842411a29bacSmrg build_old_libs=yes 842511a29bacSmrg else 842611a29bacSmrg build_libtool_libs=no 842711a29bacSmrg fi 842811a29bacSmrg fi 842911a29bacSmrg else 843011a29bacSmrg deplibs="$dir/$old_library $deplibs" 843111a29bacSmrg link_static=yes 843211a29bacSmrg fi 843311a29bacSmrg fi # link shared/static library? 843411a29bacSmrg 84356b526288Smrg if test lib = "$linkmode"; then 843611a29bacSmrg if test -n "$dependency_libs" && 84376b526288Smrg { test yes != "$hardcode_into_libs" || 84386b526288Smrg test yes = "$build_old_libs" || 84396b526288Smrg test yes = "$link_static"; }; then 844011a29bacSmrg # Extract -R from dependency_libs 844111a29bacSmrg temp_deplibs= 844211a29bacSmrg for libdir in $dependency_libs; do 844311a29bacSmrg case $libdir in 844411a29bacSmrg -R*) func_stripname '-R' '' "$libdir" 844511a29bacSmrg temp_xrpath=$func_stripname_result 844611a29bacSmrg case " $xrpath " in 844711a29bacSmrg *" $temp_xrpath "*) ;; 84486b526288Smrg *) func_append xrpath " $temp_xrpath";; 844911a29bacSmrg esac;; 84506b526288Smrg *) func_append temp_deplibs " $libdir";; 845111a29bacSmrg esac 845211a29bacSmrg done 84536b526288Smrg dependency_libs=$temp_deplibs 845411a29bacSmrg fi 845511a29bacSmrg 84566b526288Smrg func_append newlib_search_path " $absdir" 845711a29bacSmrg # Link against this library 84586b526288Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 845911a29bacSmrg # ... and its dependency_libs 846011a29bacSmrg tmp_libs= 846111a29bacSmrg for deplib in $dependency_libs; do 846211a29bacSmrg newdependency_libs="$deplib $newdependency_libs" 84636b526288Smrg case $deplib in 84646b526288Smrg -L*) func_stripname '-L' '' "$deplib" 84656b526288Smrg func_resolve_sysroot "$func_stripname_result";; 84666b526288Smrg *) func_resolve_sysroot "$deplib" ;; 84676b526288Smrg esac 84686b526288Smrg if $opt_preserve_dup_deps; then 846911a29bacSmrg case "$tmp_libs " in 84706b526288Smrg *" $func_resolve_sysroot_result "*) 84716b526288Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 847211a29bacSmrg esac 847311a29bacSmrg fi 84746b526288Smrg func_append tmp_libs " $func_resolve_sysroot_result" 847511a29bacSmrg done 847611a29bacSmrg 84776b526288Smrg if test no != "$link_all_deplibs"; then 847811a29bacSmrg # Add the search paths of all dependency libraries 847911a29bacSmrg for deplib in $dependency_libs; do 848011a29bacSmrg path= 848111a29bacSmrg case $deplib in 84826b526288Smrg -L*) path=$deplib ;; 848311a29bacSmrg *.la) 84846b526288Smrg func_resolve_sysroot "$deplib" 84856b526288Smrg deplib=$func_resolve_sysroot_result 848611a29bacSmrg func_dirname "$deplib" "" "." 84876b526288Smrg dir=$func_dirname_result 848811a29bacSmrg # We need an absolute path. 848911a29bacSmrg case $dir in 84906b526288Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 849111a29bacSmrg *) 849211a29bacSmrg absdir=`cd "$dir" && pwd` 849311a29bacSmrg if test -z "$absdir"; then 84946b526288Smrg func_warning "cannot determine absolute directory name of '$dir'" 84956b526288Smrg absdir=$dir 849611a29bacSmrg fi 849711a29bacSmrg ;; 849811a29bacSmrg esac 849911a29bacSmrg if $GREP "^installed=no" $deplib > /dev/null; then 850011a29bacSmrg case $host in 850111a29bacSmrg *-*-darwin*) 850211a29bacSmrg depdepl= 85036b526288Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 85046b526288Smrg if test -n "$deplibrary_names"; then 85056b526288Smrg for tmp in $deplibrary_names; do 850611a29bacSmrg depdepl=$tmp 850711a29bacSmrg done 85086b526288Smrg if test -f "$absdir/$objdir/$depdepl"; then 85096b526288Smrg depdepl=$absdir/$objdir/$depdepl 85106b526288Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 851111a29bacSmrg if test -z "$darwin_install_name"; then 85126b526288Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 851311a29bacSmrg fi 85146b526288Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 85156b526288Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 851611a29bacSmrg path= 851711a29bacSmrg fi 851811a29bacSmrg fi 851911a29bacSmrg ;; 852011a29bacSmrg *) 85216b526288Smrg path=-L$absdir/$objdir 852211a29bacSmrg ;; 852311a29bacSmrg esac 852411a29bacSmrg else 85256b526288Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 852611a29bacSmrg test -z "$libdir" && \ 85276b526288Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 852811a29bacSmrg test "$absdir" != "$libdir" && \ 85296b526288Smrg func_warning "'$deplib' seems to be moved" 853011a29bacSmrg 85316b526288Smrg path=-L$absdir 853211a29bacSmrg fi 853311a29bacSmrg ;; 853411a29bacSmrg esac 853511a29bacSmrg case " $deplibs " in 853611a29bacSmrg *" $path "*) ;; 853711a29bacSmrg *) deplibs="$path $deplibs" ;; 853811a29bacSmrg esac 853911a29bacSmrg done 854011a29bacSmrg fi # link_all_deplibs != no 854111a29bacSmrg fi # linkmode = lib 854211a29bacSmrg done # for deplib in $libs 85436b526288Smrg if test link = "$pass"; then 85446b526288Smrg if test prog = "$linkmode"; then 854511a29bacSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 854611a29bacSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 854711a29bacSmrg else 854811a29bacSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 854911a29bacSmrg fi 855011a29bacSmrg fi 85516b526288Smrg dependency_libs=$newdependency_libs 85526b526288Smrg if test dlpreopen = "$pass"; then 855311a29bacSmrg # Link the dlpreopened libraries before other libraries 855411a29bacSmrg for deplib in $save_deplibs; do 855511a29bacSmrg deplibs="$deplib $deplibs" 855611a29bacSmrg done 855711a29bacSmrg fi 85586b526288Smrg if test dlopen != "$pass"; then 85596b526288Smrg test conv = "$pass" || { 856011a29bacSmrg # Make sure lib_search_path contains only unique directories. 856111a29bacSmrg lib_search_path= 856211a29bacSmrg for dir in $newlib_search_path; do 856311a29bacSmrg case "$lib_search_path " in 856411a29bacSmrg *" $dir "*) ;; 85656b526288Smrg *) func_append lib_search_path " $dir" ;; 856611a29bacSmrg esac 856711a29bacSmrg done 856811a29bacSmrg newlib_search_path= 85696b526288Smrg } 857011a29bacSmrg 85716b526288Smrg if test prog,link = "$linkmode,$pass"; then 857211a29bacSmrg vars="compile_deplibs finalize_deplibs" 85736b526288Smrg else 85746b526288Smrg vars=deplibs 857511a29bacSmrg fi 857611a29bacSmrg for var in $vars dependency_libs; do 857711a29bacSmrg # Add libraries to $var in reverse order 857811a29bacSmrg eval tmp_libs=\"\$$var\" 857911a29bacSmrg new_libs= 858011a29bacSmrg for deplib in $tmp_libs; do 858111a29bacSmrg # FIXME: Pedantically, this is the right thing to do, so 858211a29bacSmrg # that some nasty dependency loop isn't accidentally 858311a29bacSmrg # broken: 858411a29bacSmrg #new_libs="$deplib $new_libs" 858511a29bacSmrg # Pragmatically, this seems to cause very few problems in 858611a29bacSmrg # practice: 858711a29bacSmrg case $deplib in 858811a29bacSmrg -L*) new_libs="$deplib $new_libs" ;; 858911a29bacSmrg -R*) ;; 859011a29bacSmrg *) 859111a29bacSmrg # And here is the reason: when a library appears more 859211a29bacSmrg # than once as an explicit dependence of a library, or 859311a29bacSmrg # is implicitly linked in more than once by the 859411a29bacSmrg # compiler, it is considered special, and multiple 859511a29bacSmrg # occurrences thereof are not removed. Compare this 859611a29bacSmrg # with having the same library being listed as a 859711a29bacSmrg # dependency of multiple other libraries: in this case, 859811a29bacSmrg # we know (pedantically, we assume) the library does not 859911a29bacSmrg # need to be listed more than once, so we keep only the 860011a29bacSmrg # last copy. This is not always right, but it is rare 860111a29bacSmrg # enough that we require users that really mean to play 860211a29bacSmrg # such unportable linking tricks to link the library 860311a29bacSmrg # using -Wl,-lname, so that libtool does not consider it 860411a29bacSmrg # for duplicate removal. 860511a29bacSmrg case " $specialdeplibs " in 860611a29bacSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 860711a29bacSmrg *) 860811a29bacSmrg case " $new_libs " in 860911a29bacSmrg *" $deplib "*) ;; 861011a29bacSmrg *) new_libs="$deplib $new_libs" ;; 861111a29bacSmrg esac 861211a29bacSmrg ;; 861311a29bacSmrg esac 861411a29bacSmrg ;; 861511a29bacSmrg esac 861611a29bacSmrg done 861711a29bacSmrg tmp_libs= 861811a29bacSmrg for deplib in $new_libs; do 861911a29bacSmrg case $deplib in 862011a29bacSmrg -L*) 862111a29bacSmrg case " $tmp_libs " in 862211a29bacSmrg *" $deplib "*) ;; 86236b526288Smrg *) func_append tmp_libs " $deplib" ;; 862411a29bacSmrg esac 862511a29bacSmrg ;; 86266b526288Smrg *) func_append tmp_libs " $deplib" ;; 862711a29bacSmrg esac 862811a29bacSmrg done 862911a29bacSmrg eval $var=\"$tmp_libs\" 863011a29bacSmrg done # for var 863111a29bacSmrg fi 86326b526288Smrg 86336b526288Smrg # Add Sun CC postdeps if required: 86346b526288Smrg test CXX = "$tagname" && { 86356b526288Smrg case $host_os in 86366b526288Smrg linux*) 86376b526288Smrg case `$CC -V 2>&1 | sed 5q` in 86386b526288Smrg *Sun\ C*) # Sun C++ 5.9 86396b526288Smrg func_suncc_cstd_abi 86406b526288Smrg 86416b526288Smrg if test no != "$suncc_use_cstd_abi"; then 86426b526288Smrg func_append postdeps ' -library=Cstd -library=Crun' 86436b526288Smrg fi 86446b526288Smrg ;; 86456b526288Smrg esac 86466b526288Smrg ;; 86476b526288Smrg 86486b526288Smrg solaris*) 86496b526288Smrg func_cc_basename "$CC" 86506b526288Smrg case $func_cc_basename_result in 86516b526288Smrg CC* | sunCC*) 86526b526288Smrg func_suncc_cstd_abi 86536b526288Smrg 86546b526288Smrg if test no != "$suncc_use_cstd_abi"; then 86556b526288Smrg func_append postdeps ' -library=Cstd -library=Crun' 86566b526288Smrg fi 86576b526288Smrg ;; 86586b526288Smrg esac 86596b526288Smrg ;; 86606b526288Smrg esac 86616b526288Smrg } 86626b526288Smrg 866311a29bacSmrg # Last step: remove runtime libs from dependency_libs 866411a29bacSmrg # (they stay in deplibs) 866511a29bacSmrg tmp_libs= 86666b526288Smrg for i in $dependency_libs; do 866711a29bacSmrg case " $predeps $postdeps $compiler_lib_search_path " in 866811a29bacSmrg *" $i "*) 86696b526288Smrg i= 867011a29bacSmrg ;; 867111a29bacSmrg esac 86726b526288Smrg if test -n "$i"; then 86736b526288Smrg func_append tmp_libs " $i" 867411a29bacSmrg fi 867511a29bacSmrg done 867611a29bacSmrg dependency_libs=$tmp_libs 867711a29bacSmrg done # for pass 86786b526288Smrg if test prog = "$linkmode"; then 86796b526288Smrg dlfiles=$newdlfiles 868011a29bacSmrg fi 86816b526288Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 86826b526288Smrg dlprefiles=$newdlprefiles 868311a29bacSmrg fi 868411a29bacSmrg 868511a29bacSmrg case $linkmode in 868611a29bacSmrg oldlib) 86876b526288Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 86886b526288Smrg func_warning "'-dlopen' is ignored for archives" 868911a29bacSmrg fi 869011a29bacSmrg 869111a29bacSmrg case " $deplibs" in 869211a29bacSmrg *\ -l* | *\ -L*) 86936b526288Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 869411a29bacSmrg esac 869511a29bacSmrg 869611a29bacSmrg test -n "$rpath" && \ 86976b526288Smrg func_warning "'-rpath' is ignored for archives" 869811a29bacSmrg 869911a29bacSmrg test -n "$xrpath" && \ 87006b526288Smrg func_warning "'-R' is ignored for archives" 870111a29bacSmrg 870211a29bacSmrg test -n "$vinfo" && \ 87036b526288Smrg func_warning "'-version-info/-version-number' is ignored for archives" 870411a29bacSmrg 870511a29bacSmrg test -n "$release" && \ 87066b526288Smrg func_warning "'-release' is ignored for archives" 870711a29bacSmrg 870811a29bacSmrg test -n "$export_symbols$export_symbols_regex" && \ 87096b526288Smrg func_warning "'-export-symbols' is ignored for archives" 871011a29bacSmrg 871111a29bacSmrg # Now set the variables for building old libraries. 871211a29bacSmrg build_libtool_libs=no 87136b526288Smrg oldlibs=$output 87146b526288Smrg func_append objs "$old_deplibs" 871511a29bacSmrg ;; 871611a29bacSmrg 871711a29bacSmrg lib) 87186b526288Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 871911a29bacSmrg case $outputname in 872011a29bacSmrg lib*) 872111a29bacSmrg func_stripname 'lib' '.la' "$outputname" 872211a29bacSmrg name=$func_stripname_result 872311a29bacSmrg eval shared_ext=\"$shrext_cmds\" 872411a29bacSmrg eval libname=\"$libname_spec\" 872511a29bacSmrg ;; 872611a29bacSmrg *) 87276b526288Smrg test no = "$module" \ 87286b526288Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 872911a29bacSmrg 87306b526288Smrg if test no != "$need_lib_prefix"; then 873111a29bacSmrg # Add the "lib" prefix for modules if required 873211a29bacSmrg func_stripname '' '.la' "$outputname" 873311a29bacSmrg name=$func_stripname_result 873411a29bacSmrg eval shared_ext=\"$shrext_cmds\" 873511a29bacSmrg eval libname=\"$libname_spec\" 873611a29bacSmrg else 873711a29bacSmrg func_stripname '' '.la' "$outputname" 873811a29bacSmrg libname=$func_stripname_result 873911a29bacSmrg fi 874011a29bacSmrg ;; 874111a29bacSmrg esac 874211a29bacSmrg 874311a29bacSmrg if test -n "$objs"; then 87446b526288Smrg if test pass_all != "$deplibs_check_method"; then 87456b526288Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 874611a29bacSmrg else 874711a29bacSmrg echo 874811a29bacSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 874911a29bacSmrg $ECHO "*** objects $objs is not portable!" 87506b526288Smrg func_append libobjs " $objs" 875111a29bacSmrg fi 875211a29bacSmrg fi 875311a29bacSmrg 87546b526288Smrg test no = "$dlself" \ 87556b526288Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 875611a29bacSmrg 875711a29bacSmrg set dummy $rpath 875811a29bacSmrg shift 87596b526288Smrg test 1 -lt "$#" \ 87606b526288Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 876111a29bacSmrg 87626b526288Smrg install_libdir=$1 876311a29bacSmrg 876411a29bacSmrg oldlibs= 876511a29bacSmrg if test -z "$rpath"; then 87666b526288Smrg if test yes = "$build_libtool_libs"; then 876711a29bacSmrg # Building a libtool convenience library. 87686b526288Smrg # Some compilers have problems with a '.al' extension so 876911a29bacSmrg # convenience libraries should have the same extension an 877011a29bacSmrg # archive normally would. 877111a29bacSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 877211a29bacSmrg build_libtool_libs=convenience 877311a29bacSmrg build_old_libs=yes 877411a29bacSmrg fi 877511a29bacSmrg 877611a29bacSmrg test -n "$vinfo" && \ 87776b526288Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 877811a29bacSmrg 877911a29bacSmrg test -n "$release" && \ 87806b526288Smrg func_warning "'-release' is ignored for convenience libraries" 878111a29bacSmrg else 878211a29bacSmrg 878311a29bacSmrg # Parse the version information argument. 87846b526288Smrg save_ifs=$IFS; IFS=: 878511a29bacSmrg set dummy $vinfo 0 0 0 878611a29bacSmrg shift 87876b526288Smrg IFS=$save_ifs 878811a29bacSmrg 878911a29bacSmrg test -n "$7" && \ 87906b526288Smrg func_fatal_help "too many parameters to '-version-info'" 879111a29bacSmrg 879211a29bacSmrg # convert absolute version numbers to libtool ages 879311a29bacSmrg # this retains compatibility with .la files and attempts 879411a29bacSmrg # to make the code below a bit more comprehensible 879511a29bacSmrg 879611a29bacSmrg case $vinfo_number in 879711a29bacSmrg yes) 87986b526288Smrg number_major=$1 87996b526288Smrg number_minor=$2 88006b526288Smrg number_revision=$3 880111a29bacSmrg # 880211a29bacSmrg # There are really only two kinds -- those that 880311a29bacSmrg # use the current revision as the major version 880411a29bacSmrg # and those that subtract age and use age as 880511a29bacSmrg # a minor version. But, then there is irix 88066b526288Smrg # that has an extra 1 added just for fun 880711a29bacSmrg # 880811a29bacSmrg case $version_type in 88096b526288Smrg # correct linux to gnu/linux during the next big refactor 88106b526288Smrg darwin|freebsd-elf|linux|osf|windows|none) 881111a29bacSmrg func_arith $number_major + $number_minor 881211a29bacSmrg current=$func_arith_result 88136b526288Smrg age=$number_minor 88146b526288Smrg revision=$number_revision 881511a29bacSmrg ;; 88166b526288Smrg freebsd-aout|qnx|sunos) 88176b526288Smrg current=$number_major 88186b526288Smrg revision=$number_minor 88196b526288Smrg age=0 882011a29bacSmrg ;; 882111a29bacSmrg irix|nonstopux) 882211a29bacSmrg func_arith $number_major + $number_minor 882311a29bacSmrg current=$func_arith_result 88246b526288Smrg age=$number_minor 88256b526288Smrg revision=$number_minor 882611a29bacSmrg lt_irix_increment=no 882711a29bacSmrg ;; 882811a29bacSmrg esac 882911a29bacSmrg ;; 883011a29bacSmrg no) 88316b526288Smrg current=$1 88326b526288Smrg revision=$2 88336b526288Smrg age=$3 883411a29bacSmrg ;; 883511a29bacSmrg esac 883611a29bacSmrg 883711a29bacSmrg # Check that each of the things are valid numbers. 883811a29bacSmrg case $current in 883911a29bacSmrg 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]) ;; 884011a29bacSmrg *) 88416b526288Smrg func_error "CURRENT '$current' must be a nonnegative integer" 88426b526288Smrg func_fatal_error "'$vinfo' is not valid version information" 884311a29bacSmrg ;; 884411a29bacSmrg esac 884511a29bacSmrg 884611a29bacSmrg case $revision in 884711a29bacSmrg 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]) ;; 884811a29bacSmrg *) 88496b526288Smrg func_error "REVISION '$revision' must be a nonnegative integer" 88506b526288Smrg func_fatal_error "'$vinfo' is not valid version information" 885111a29bacSmrg ;; 885211a29bacSmrg esac 885311a29bacSmrg 885411a29bacSmrg case $age in 885511a29bacSmrg 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]) ;; 885611a29bacSmrg *) 88576b526288Smrg func_error "AGE '$age' must be a nonnegative integer" 88586b526288Smrg func_fatal_error "'$vinfo' is not valid version information" 885911a29bacSmrg ;; 886011a29bacSmrg esac 886111a29bacSmrg 886211a29bacSmrg if test "$age" -gt "$current"; then 88636b526288Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 88646b526288Smrg func_fatal_error "'$vinfo' is not valid version information" 886511a29bacSmrg fi 886611a29bacSmrg 886711a29bacSmrg # Calculate the version variables. 886811a29bacSmrg major= 886911a29bacSmrg versuffix= 887011a29bacSmrg verstring= 887111a29bacSmrg case $version_type in 887211a29bacSmrg none) ;; 887311a29bacSmrg 887411a29bacSmrg darwin) 887511a29bacSmrg # Like Linux, but with the current version available in 887611a29bacSmrg # verstring for coding it into the library header 887711a29bacSmrg func_arith $current - $age 887811a29bacSmrg major=.$func_arith_result 88796b526288Smrg versuffix=$major.$age.$revision 888011a29bacSmrg # Darwin ld doesn't like 0 for these options... 888111a29bacSmrg func_arith $current + 1 888211a29bacSmrg minor_current=$func_arith_result 88836b526288Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888411a29bacSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 88856b526288Smrg # On Darwin other compilers 88866b526288Smrg case $CC in 88876b526288Smrg nagfor*) 88886b526288Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88896b526288Smrg ;; 88906b526288Smrg *) 88916b526288Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 88926b526288Smrg ;; 88936b526288Smrg esac 889411a29bacSmrg ;; 889511a29bacSmrg 889611a29bacSmrg freebsd-aout) 88976b526288Smrg major=.$current 88986b526288Smrg versuffix=.$current.$revision 889911a29bacSmrg ;; 890011a29bacSmrg 890111a29bacSmrg freebsd-elf) 89026b526288Smrg func_arith $current - $age 89036b526288Smrg major=.$func_arith_result 89046b526288Smrg versuffix=$major.$age.$revision 890511a29bacSmrg ;; 890611a29bacSmrg 890711a29bacSmrg irix | nonstopux) 89086b526288Smrg if test no = "$lt_irix_increment"; then 890911a29bacSmrg func_arith $current - $age 891011a29bacSmrg else 891111a29bacSmrg func_arith $current - $age + 1 891211a29bacSmrg fi 891311a29bacSmrg major=$func_arith_result 891411a29bacSmrg 891511a29bacSmrg case $version_type in 891611a29bacSmrg nonstopux) verstring_prefix=nonstopux ;; 891711a29bacSmrg *) verstring_prefix=sgi ;; 891811a29bacSmrg esac 89196b526288Smrg verstring=$verstring_prefix$major.$revision 892011a29bacSmrg 892111a29bacSmrg # Add in all the interfaces that we are compatible with. 892211a29bacSmrg loop=$revision 89236b526288Smrg while test 0 -ne "$loop"; do 892411a29bacSmrg func_arith $revision - $loop 892511a29bacSmrg iface=$func_arith_result 892611a29bacSmrg func_arith $loop - 1 892711a29bacSmrg loop=$func_arith_result 89286b526288Smrg verstring=$verstring_prefix$major.$iface:$verstring 892911a29bacSmrg done 893011a29bacSmrg 89316b526288Smrg # Before this point, $major must not contain '.'. 893211a29bacSmrg major=.$major 89336b526288Smrg versuffix=$major.$revision 893411a29bacSmrg ;; 893511a29bacSmrg 89366b526288Smrg linux) # correct to gnu/linux during the next big refactor 893711a29bacSmrg func_arith $current - $age 893811a29bacSmrg major=.$func_arith_result 89396b526288Smrg versuffix=$major.$age.$revision 894011a29bacSmrg ;; 894111a29bacSmrg 894211a29bacSmrg osf) 894311a29bacSmrg func_arith $current - $age 894411a29bacSmrg major=.$func_arith_result 89456b526288Smrg versuffix=.$current.$age.$revision 89466b526288Smrg verstring=$current.$age.$revision 894711a29bacSmrg 894811a29bacSmrg # Add in all the interfaces that we are compatible with. 894911a29bacSmrg loop=$age 89506b526288Smrg while test 0 -ne "$loop"; do 895111a29bacSmrg func_arith $current - $loop 895211a29bacSmrg iface=$func_arith_result 895311a29bacSmrg func_arith $loop - 1 895411a29bacSmrg loop=$func_arith_result 89556b526288Smrg verstring=$verstring:$iface.0 895611a29bacSmrg done 895711a29bacSmrg 895811a29bacSmrg # Make executables depend on our current version. 89596b526288Smrg func_append verstring ":$current.0" 896011a29bacSmrg ;; 896111a29bacSmrg 896211a29bacSmrg qnx) 89636b526288Smrg major=.$current 89646b526288Smrg versuffix=.$current 89656b526288Smrg ;; 89666b526288Smrg 89676b526288Smrg sco) 89686b526288Smrg major=.$current 89696b526288Smrg versuffix=.$current 897011a29bacSmrg ;; 897111a29bacSmrg 897211a29bacSmrg sunos) 89736b526288Smrg major=.$current 89746b526288Smrg versuffix=.$current.$revision 897511a29bacSmrg ;; 897611a29bacSmrg 897711a29bacSmrg windows) 897811a29bacSmrg # Use '-' rather than '.', since we only want one 89796b526288Smrg # extension on DOS 8.3 file systems. 898011a29bacSmrg func_arith $current - $age 898111a29bacSmrg major=$func_arith_result 89826b526288Smrg versuffix=-$major 898311a29bacSmrg ;; 898411a29bacSmrg 898511a29bacSmrg *) 89866b526288Smrg func_fatal_configuration "unknown library version type '$version_type'" 898711a29bacSmrg ;; 898811a29bacSmrg esac 898911a29bacSmrg 899011a29bacSmrg # Clear the version info if we defaulted, and they specified a release. 899111a29bacSmrg if test -z "$vinfo" && test -n "$release"; then 899211a29bacSmrg major= 899311a29bacSmrg case $version_type in 899411a29bacSmrg darwin) 899511a29bacSmrg # we can't check for "0.0" in archive_cmds due to quoting 899611a29bacSmrg # problems, so we reset it completely 899711a29bacSmrg verstring= 899811a29bacSmrg ;; 899911a29bacSmrg *) 90006b526288Smrg verstring=0.0 900111a29bacSmrg ;; 900211a29bacSmrg esac 90036b526288Smrg if test no = "$need_version"; then 900411a29bacSmrg versuffix= 900511a29bacSmrg else 90066b526288Smrg versuffix=.0.0 900711a29bacSmrg fi 900811a29bacSmrg fi 900911a29bacSmrg 901011a29bacSmrg # Remove version info from name if versioning should be avoided 90116b526288Smrg if test yes,no = "$avoid_version,$need_version"; then 901211a29bacSmrg major= 901311a29bacSmrg versuffix= 90146b526288Smrg verstring= 901511a29bacSmrg fi 901611a29bacSmrg 901711a29bacSmrg # Check to see if the archive will have undefined symbols. 90186b526288Smrg if test yes = "$allow_undefined"; then 90196b526288Smrg if test unsupported = "$allow_undefined_flag"; then 90206b526288Smrg if test yes = "$build_old_libs"; then 90216b526288Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 90226b526288Smrg build_libtool_libs=no 90236b526288Smrg else 90246b526288Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 90256b526288Smrg fi 902611a29bacSmrg fi 902711a29bacSmrg else 902811a29bacSmrg # Don't allow undefined symbols. 90296b526288Smrg allow_undefined_flag=$no_undefined_flag 903011a29bacSmrg fi 903111a29bacSmrg 903211a29bacSmrg fi 903311a29bacSmrg 90346b526288Smrg func_generate_dlsyms "$libname" "$libname" : 90356b526288Smrg func_append libobjs " $symfileobj" 90366b526288Smrg test " " = "$libobjs" && libobjs= 903711a29bacSmrg 90386b526288Smrg if test relink != "$opt_mode"; then 903911a29bacSmrg # Remove our outputs, but don't remove object files since they 904011a29bacSmrg # may have been created when compiling PIC objects. 904111a29bacSmrg removelist= 904211a29bacSmrg tempremovelist=`$ECHO "$output_objdir/*"` 904311a29bacSmrg for p in $tempremovelist; do 904411a29bacSmrg case $p in 904511a29bacSmrg *.$objext | *.gcno) 904611a29bacSmrg ;; 90476b526288Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 90486b526288Smrg if test -n "$precious_files_regex"; then 904911a29bacSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 905011a29bacSmrg then 905111a29bacSmrg continue 905211a29bacSmrg fi 905311a29bacSmrg fi 90546b526288Smrg func_append removelist " $p" 905511a29bacSmrg ;; 905611a29bacSmrg *) ;; 905711a29bacSmrg esac 905811a29bacSmrg done 905911a29bacSmrg test -n "$removelist" && \ 906011a29bacSmrg func_show_eval "${RM}r \$removelist" 906111a29bacSmrg fi 906211a29bacSmrg 906311a29bacSmrg # Now set the variables for building old libraries. 90646b526288Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 90656b526288Smrg func_append oldlibs " $output_objdir/$libname.$libext" 906611a29bacSmrg 906711a29bacSmrg # Transform .lo files to .o files. 90686b526288Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 906911a29bacSmrg fi 907011a29bacSmrg 907111a29bacSmrg # Eliminate all temporary directories. 907211a29bacSmrg #for path in $notinst_path; do 907311a29bacSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 907411a29bacSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 907511a29bacSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 907611a29bacSmrg #done 907711a29bacSmrg 907811a29bacSmrg if test -n "$xrpath"; then 907911a29bacSmrg # If the user specified any rpath flags, then add them. 908011a29bacSmrg temp_xrpath= 908111a29bacSmrg for libdir in $xrpath; do 90826b526288Smrg func_replace_sysroot "$libdir" 90836b526288Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 908411a29bacSmrg case "$finalize_rpath " in 908511a29bacSmrg *" $libdir "*) ;; 90866b526288Smrg *) func_append finalize_rpath " $libdir" ;; 908711a29bacSmrg esac 908811a29bacSmrg done 90896b526288Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 909011a29bacSmrg dependency_libs="$temp_xrpath $dependency_libs" 909111a29bacSmrg fi 909211a29bacSmrg fi 909311a29bacSmrg 909411a29bacSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 90956b526288Smrg old_dlfiles=$dlfiles 909611a29bacSmrg dlfiles= 909711a29bacSmrg for lib in $old_dlfiles; do 909811a29bacSmrg case " $dlprefiles $dlfiles " in 909911a29bacSmrg *" $lib "*) ;; 91006b526288Smrg *) func_append dlfiles " $lib" ;; 910111a29bacSmrg esac 910211a29bacSmrg done 910311a29bacSmrg 910411a29bacSmrg # Make sure dlprefiles contains only unique files 91056b526288Smrg old_dlprefiles=$dlprefiles 910611a29bacSmrg dlprefiles= 910711a29bacSmrg for lib in $old_dlprefiles; do 910811a29bacSmrg case "$dlprefiles " in 910911a29bacSmrg *" $lib "*) ;; 91106b526288Smrg *) func_append dlprefiles " $lib" ;; 911111a29bacSmrg esac 911211a29bacSmrg done 911311a29bacSmrg 91146b526288Smrg if test yes = "$build_libtool_libs"; then 911511a29bacSmrg if test -n "$rpath"; then 911611a29bacSmrg case $host in 911711a29bacSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 911811a29bacSmrg # these systems don't actually have a c library (as such)! 911911a29bacSmrg ;; 912011a29bacSmrg *-*-rhapsody* | *-*-darwin1.[012]) 912111a29bacSmrg # Rhapsody C library is in the System framework 91226b526288Smrg func_append deplibs " System.ltframework" 912311a29bacSmrg ;; 912411a29bacSmrg *-*-netbsd*) 912511a29bacSmrg # Don't link with libc until the a.out ld.so is fixed. 912611a29bacSmrg ;; 912711a29bacSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 912811a29bacSmrg # Do not include libc due to us having libc/libc_r. 912911a29bacSmrg ;; 913011a29bacSmrg *-*-sco3.2v5* | *-*-sco5v6*) 913111a29bacSmrg # Causes problems with __ctype 913211a29bacSmrg ;; 913311a29bacSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 913411a29bacSmrg # Compiler inserts libc in the correct place for threads to work 913511a29bacSmrg ;; 913611a29bacSmrg *) 913711a29bacSmrg # Add libc to deplibs on all other systems if necessary. 91386b526288Smrg if test yes = "$build_libtool_need_lc"; then 91396b526288Smrg func_append deplibs " -lc" 914011a29bacSmrg fi 914111a29bacSmrg ;; 914211a29bacSmrg esac 914311a29bacSmrg fi 914411a29bacSmrg 914511a29bacSmrg # Transform deplibs into only deplibs that can be linked in shared. 914611a29bacSmrg name_save=$name 914711a29bacSmrg libname_save=$libname 914811a29bacSmrg release_save=$release 914911a29bacSmrg versuffix_save=$versuffix 915011a29bacSmrg major_save=$major 915111a29bacSmrg # I'm not sure if I'm treating the release correctly. I think 915211a29bacSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 915311a29bacSmrg # add it in twice. Is that correct? 91546b526288Smrg release= 91556b526288Smrg versuffix= 91566b526288Smrg major= 915711a29bacSmrg newdeplibs= 915811a29bacSmrg droppeddeps=no 915911a29bacSmrg case $deplibs_check_method in 916011a29bacSmrg pass_all) 916111a29bacSmrg # Don't check for shared/static. Everything works. 916211a29bacSmrg # This might be a little naive. We might want to check 916311a29bacSmrg # whether the library exists or not. But this is on 916411a29bacSmrg # osf3 & osf4 and I'm not really sure... Just 916511a29bacSmrg # implementing what was already the behavior. 916611a29bacSmrg newdeplibs=$deplibs 916711a29bacSmrg ;; 916811a29bacSmrg test_compile) 916911a29bacSmrg # This code stresses the "libraries are programs" paradigm to its 917011a29bacSmrg # limits. Maybe even breaks it. We compile a program, linking it 917111a29bacSmrg # against the deplibs as a proxy for the library. Then we can check 917211a29bacSmrg # whether they linked in statically or dynamically with ldd. 917311a29bacSmrg $opt_dry_run || $RM conftest.c 917411a29bacSmrg cat > conftest.c <<EOF 917511a29bacSmrg int main() { return 0; } 917611a29bacSmrgEOF 917711a29bacSmrg $opt_dry_run || $RM conftest 917811a29bacSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 917911a29bacSmrg ldd_output=`ldd conftest` 918011a29bacSmrg for i in $deplibs; do 918111a29bacSmrg case $i in 918211a29bacSmrg -l*) 918311a29bacSmrg func_stripname -l '' "$i" 918411a29bacSmrg name=$func_stripname_result 91856b526288Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 918611a29bacSmrg case " $predeps $postdeps " in 918711a29bacSmrg *" $i "*) 91886b526288Smrg func_append newdeplibs " $i" 91896b526288Smrg i= 919011a29bacSmrg ;; 919111a29bacSmrg esac 919211a29bacSmrg fi 91936b526288Smrg if test -n "$i"; then 919411a29bacSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 919511a29bacSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 919611a29bacSmrg set dummy $deplib_matches; shift 919711a29bacSmrg deplib_match=$1 91986b526288Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 91996b526288Smrg func_append newdeplibs " $i" 920011a29bacSmrg else 920111a29bacSmrg droppeddeps=yes 920211a29bacSmrg echo 920311a29bacSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 920411a29bacSmrg echo "*** I have the capability to make that library automatically link in when" 920511a29bacSmrg echo "*** you link to this library. But I can only do this if you have a" 920611a29bacSmrg echo "*** shared version of the library, which I believe you do not have" 920711a29bacSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 920811a29bacSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 920911a29bacSmrg fi 921011a29bacSmrg fi 921111a29bacSmrg ;; 921211a29bacSmrg *) 92136b526288Smrg func_append newdeplibs " $i" 921411a29bacSmrg ;; 921511a29bacSmrg esac 921611a29bacSmrg done 921711a29bacSmrg else 921811a29bacSmrg # Error occurred in the first compile. Let's try to salvage 921911a29bacSmrg # the situation: Compile a separate program for each library. 922011a29bacSmrg for i in $deplibs; do 922111a29bacSmrg case $i in 922211a29bacSmrg -l*) 922311a29bacSmrg func_stripname -l '' "$i" 922411a29bacSmrg name=$func_stripname_result 922511a29bacSmrg $opt_dry_run || $RM conftest 922611a29bacSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 922711a29bacSmrg ldd_output=`ldd conftest` 92286b526288Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 922911a29bacSmrg case " $predeps $postdeps " in 923011a29bacSmrg *" $i "*) 92316b526288Smrg func_append newdeplibs " $i" 92326b526288Smrg i= 923311a29bacSmrg ;; 923411a29bacSmrg esac 923511a29bacSmrg fi 92366b526288Smrg if test -n "$i"; then 923711a29bacSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 923811a29bacSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 923911a29bacSmrg set dummy $deplib_matches; shift 924011a29bacSmrg deplib_match=$1 92416b526288Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 92426b526288Smrg func_append newdeplibs " $i" 924311a29bacSmrg else 924411a29bacSmrg droppeddeps=yes 924511a29bacSmrg echo 924611a29bacSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 924711a29bacSmrg echo "*** I have the capability to make that library automatically link in when" 924811a29bacSmrg echo "*** you link to this library. But I can only do this if you have a" 924911a29bacSmrg echo "*** shared version of the library, which you do not appear to have" 925011a29bacSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 925111a29bacSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 925211a29bacSmrg fi 925311a29bacSmrg fi 925411a29bacSmrg else 925511a29bacSmrg droppeddeps=yes 925611a29bacSmrg echo 925711a29bacSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 925811a29bacSmrg echo "*** make it link in! You will probably need to install it or some" 925911a29bacSmrg echo "*** library that it depends on before this library will be fully" 926011a29bacSmrg echo "*** functional. Installing it before continuing would be even better." 926111a29bacSmrg fi 926211a29bacSmrg ;; 926311a29bacSmrg *) 92646b526288Smrg func_append newdeplibs " $i" 926511a29bacSmrg ;; 926611a29bacSmrg esac 926711a29bacSmrg done 926811a29bacSmrg fi 926911a29bacSmrg ;; 927011a29bacSmrg file_magic*) 927111a29bacSmrg set dummy $deplibs_check_method; shift 927211a29bacSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 927311a29bacSmrg for a_deplib in $deplibs; do 927411a29bacSmrg case $a_deplib in 927511a29bacSmrg -l*) 927611a29bacSmrg func_stripname -l '' "$a_deplib" 927711a29bacSmrg name=$func_stripname_result 92786b526288Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 927911a29bacSmrg case " $predeps $postdeps " in 928011a29bacSmrg *" $a_deplib "*) 92816b526288Smrg func_append newdeplibs " $a_deplib" 92826b526288Smrg a_deplib= 928311a29bacSmrg ;; 928411a29bacSmrg esac 928511a29bacSmrg fi 92866b526288Smrg if test -n "$a_deplib"; then 928711a29bacSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92886b526288Smrg if test -n "$file_magic_glob"; then 92896b526288Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 92906b526288Smrg else 92916b526288Smrg libnameglob=$libname 92926b526288Smrg fi 92936b526288Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 929411a29bacSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 92956b526288Smrg if test yes = "$want_nocaseglob"; then 92966b526288Smrg shopt -s nocaseglob 92976b526288Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 92986b526288Smrg $nocaseglob 92996b526288Smrg else 93006b526288Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 93016b526288Smrg fi 930211a29bacSmrg for potent_lib in $potential_libs; do 930311a29bacSmrg # Follow soft links. 930411a29bacSmrg if ls -lLd "$potent_lib" 2>/dev/null | 930511a29bacSmrg $GREP " -> " >/dev/null; then 930611a29bacSmrg continue 930711a29bacSmrg fi 930811a29bacSmrg # The statement above tries to avoid entering an 930911a29bacSmrg # endless loop below, in case of cyclic links. 931011a29bacSmrg # We might still enter an endless loop, since a link 931111a29bacSmrg # loop can be closed while we follow links, 931211a29bacSmrg # but so what? 93136b526288Smrg potlib=$potent_lib 931411a29bacSmrg while test -h "$potlib" 2>/dev/null; do 93156b526288Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 931611a29bacSmrg case $potliblink in 93176b526288Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 93186b526288Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 931911a29bacSmrg esac 932011a29bacSmrg done 932111a29bacSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 932211a29bacSmrg $SED -e 10q | 932311a29bacSmrg $EGREP "$file_magic_regex" > /dev/null; then 93246b526288Smrg func_append newdeplibs " $a_deplib" 93256b526288Smrg a_deplib= 932611a29bacSmrg break 2 932711a29bacSmrg fi 932811a29bacSmrg done 932911a29bacSmrg done 933011a29bacSmrg fi 93316b526288Smrg if test -n "$a_deplib"; then 933211a29bacSmrg droppeddeps=yes 933311a29bacSmrg echo 933411a29bacSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 933511a29bacSmrg echo "*** I have the capability to make that library automatically link in when" 933611a29bacSmrg echo "*** you link to this library. But I can only do this if you have a" 933711a29bacSmrg echo "*** shared version of the library, which you do not appear to have" 933811a29bacSmrg echo "*** because I did check the linker path looking for a file starting" 93396b526288Smrg if test -z "$potlib"; then 934011a29bacSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 934111a29bacSmrg else 934211a29bacSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 934311a29bacSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 934411a29bacSmrg fi 934511a29bacSmrg fi 934611a29bacSmrg ;; 934711a29bacSmrg *) 934811a29bacSmrg # Add a -L argument. 93496b526288Smrg func_append newdeplibs " $a_deplib" 935011a29bacSmrg ;; 935111a29bacSmrg esac 935211a29bacSmrg done # Gone through all deplibs. 935311a29bacSmrg ;; 935411a29bacSmrg match_pattern*) 935511a29bacSmrg set dummy $deplibs_check_method; shift 935611a29bacSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 935711a29bacSmrg for a_deplib in $deplibs; do 935811a29bacSmrg case $a_deplib in 935911a29bacSmrg -l*) 936011a29bacSmrg func_stripname -l '' "$a_deplib" 936111a29bacSmrg name=$func_stripname_result 93626b526288Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 936311a29bacSmrg case " $predeps $postdeps " in 936411a29bacSmrg *" $a_deplib "*) 93656b526288Smrg func_append newdeplibs " $a_deplib" 93666b526288Smrg a_deplib= 936711a29bacSmrg ;; 936811a29bacSmrg esac 936911a29bacSmrg fi 93706b526288Smrg if test -n "$a_deplib"; then 937111a29bacSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 937211a29bacSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 937311a29bacSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 937411a29bacSmrg for potent_lib in $potential_libs; do 93756b526288Smrg potlib=$potent_lib # see symlink-check above in file_magic test 937611a29bacSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 937711a29bacSmrg $EGREP "$match_pattern_regex" > /dev/null; then 93786b526288Smrg func_append newdeplibs " $a_deplib" 93796b526288Smrg a_deplib= 938011a29bacSmrg break 2 938111a29bacSmrg fi 938211a29bacSmrg done 938311a29bacSmrg done 938411a29bacSmrg fi 93856b526288Smrg if test -n "$a_deplib"; then 938611a29bacSmrg droppeddeps=yes 938711a29bacSmrg echo 938811a29bacSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 938911a29bacSmrg echo "*** I have the capability to make that library automatically link in when" 939011a29bacSmrg echo "*** you link to this library. But I can only do this if you have a" 939111a29bacSmrg echo "*** shared version of the library, which you do not appear to have" 939211a29bacSmrg echo "*** because I did check the linker path looking for a file starting" 93936b526288Smrg if test -z "$potlib"; then 939411a29bacSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 939511a29bacSmrg else 939611a29bacSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 939711a29bacSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 939811a29bacSmrg fi 939911a29bacSmrg fi 940011a29bacSmrg ;; 940111a29bacSmrg *) 940211a29bacSmrg # Add a -L argument. 94036b526288Smrg func_append newdeplibs " $a_deplib" 940411a29bacSmrg ;; 940511a29bacSmrg esac 940611a29bacSmrg done # Gone through all deplibs. 940711a29bacSmrg ;; 940811a29bacSmrg none | unknown | *) 94096b526288Smrg newdeplibs= 941011a29bacSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 94116b526288Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94126b526288Smrg for i in $predeps $postdeps; do 941311a29bacSmrg # can't use Xsed below, because $i might contain '/' 94146b526288Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 941511a29bacSmrg done 941611a29bacSmrg fi 941711a29bacSmrg case $tmp_deplibs in 941811a29bacSmrg *[!\ \ ]*) 941911a29bacSmrg echo 94206b526288Smrg if test none = "$deplibs_check_method"; then 942111a29bacSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 942211a29bacSmrg else 942311a29bacSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 942411a29bacSmrg fi 942511a29bacSmrg echo "*** All declared inter-library dependencies are being dropped." 942611a29bacSmrg droppeddeps=yes 942711a29bacSmrg ;; 942811a29bacSmrg esac 942911a29bacSmrg ;; 943011a29bacSmrg esac 943111a29bacSmrg versuffix=$versuffix_save 943211a29bacSmrg major=$major_save 943311a29bacSmrg release=$release_save 943411a29bacSmrg libname=$libname_save 943511a29bacSmrg name=$name_save 943611a29bacSmrg 943711a29bacSmrg case $host in 943811a29bacSmrg *-*-rhapsody* | *-*-darwin1.[012]) 943911a29bacSmrg # On Rhapsody replace the C library with the System framework 944011a29bacSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 944111a29bacSmrg ;; 944211a29bacSmrg esac 944311a29bacSmrg 94446b526288Smrg if test yes = "$droppeddeps"; then 94456b526288Smrg if test yes = "$module"; then 944611a29bacSmrg echo 944711a29bacSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 944811a29bacSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 944911a29bacSmrg echo "*** a static module, that should work as long as the dlopening" 945011a29bacSmrg echo "*** application is linked with the -dlopen flag." 945111a29bacSmrg if test -z "$global_symbol_pipe"; then 945211a29bacSmrg echo 945311a29bacSmrg echo "*** However, this would only work if libtool was able to extract symbol" 94546b526288Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 945511a29bacSmrg echo "*** not find such a program. So, this module is probably useless." 94566b526288Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 945711a29bacSmrg fi 94586b526288Smrg if test no = "$build_old_libs"; then 94596b526288Smrg oldlibs=$output_objdir/$libname.$libext 946011a29bacSmrg build_libtool_libs=module 946111a29bacSmrg build_old_libs=yes 946211a29bacSmrg else 946311a29bacSmrg build_libtool_libs=no 946411a29bacSmrg fi 946511a29bacSmrg else 946611a29bacSmrg echo "*** The inter-library dependencies that have been dropped here will be" 946711a29bacSmrg echo "*** automatically added whenever a program is linked with this library" 946811a29bacSmrg echo "*** or is declared to -dlopen it." 946911a29bacSmrg 94706b526288Smrg if test no = "$allow_undefined"; then 947111a29bacSmrg echo 947211a29bacSmrg echo "*** Since this library must not contain undefined symbols," 947311a29bacSmrg echo "*** because either the platform does not support them or" 947411a29bacSmrg echo "*** it was explicitly requested with -no-undefined," 947511a29bacSmrg echo "*** libtool will only create a static version of it." 94766b526288Smrg if test no = "$build_old_libs"; then 94776b526288Smrg oldlibs=$output_objdir/$libname.$libext 947811a29bacSmrg build_libtool_libs=module 947911a29bacSmrg build_old_libs=yes 948011a29bacSmrg else 948111a29bacSmrg build_libtool_libs=no 948211a29bacSmrg fi 948311a29bacSmrg fi 948411a29bacSmrg fi 948511a29bacSmrg fi 948611a29bacSmrg # Done checking deplibs! 948711a29bacSmrg deplibs=$newdeplibs 948811a29bacSmrg fi 948911a29bacSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 949011a29bacSmrg case $host in 949111a29bacSmrg *-*-darwin*) 949211a29bacSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949311a29bacSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949411a29bacSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949511a29bacSmrg ;; 949611a29bacSmrg esac 949711a29bacSmrg 949811a29bacSmrg # move library search paths that coincide with paths to not yet 949911a29bacSmrg # installed libraries to the beginning of the library search list 950011a29bacSmrg new_libs= 950111a29bacSmrg for path in $notinst_path; do 950211a29bacSmrg case " $new_libs " in 950311a29bacSmrg *" -L$path/$objdir "*) ;; 950411a29bacSmrg *) 950511a29bacSmrg case " $deplibs " in 950611a29bacSmrg *" -L$path/$objdir "*) 95076b526288Smrg func_append new_libs " -L$path/$objdir" ;; 950811a29bacSmrg esac 950911a29bacSmrg ;; 951011a29bacSmrg esac 951111a29bacSmrg done 951211a29bacSmrg for deplib in $deplibs; do 951311a29bacSmrg case $deplib in 951411a29bacSmrg -L*) 951511a29bacSmrg case " $new_libs " in 951611a29bacSmrg *" $deplib "*) ;; 95176b526288Smrg *) func_append new_libs " $deplib" ;; 951811a29bacSmrg esac 951911a29bacSmrg ;; 95206b526288Smrg *) func_append new_libs " $deplib" ;; 952111a29bacSmrg esac 952211a29bacSmrg done 95236b526288Smrg deplibs=$new_libs 952411a29bacSmrg 952511a29bacSmrg # All the library-specific variables (install_libdir is set above). 952611a29bacSmrg library_names= 952711a29bacSmrg old_library= 952811a29bacSmrg dlname= 952911a29bacSmrg 953011a29bacSmrg # Test again, we may have decided not to build it any more 95316b526288Smrg if test yes = "$build_libtool_libs"; then 95326b526288Smrg # Remove $wl instances when linking with ld. 95336b526288Smrg # FIXME: should test the right _cmds variable. 95346b526288Smrg case $archive_cmds in 95356b526288Smrg *\$LD\ *) wl= ;; 95366b526288Smrg esac 95376b526288Smrg if test yes = "$hardcode_into_libs"; then 953811a29bacSmrg # Hardcode the library paths 953911a29bacSmrg hardcode_libdirs= 954011a29bacSmrg dep_rpath= 95416b526288Smrg rpath=$finalize_rpath 95426b526288Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 954311a29bacSmrg for libdir in $rpath; do 954411a29bacSmrg if test -n "$hardcode_libdir_flag_spec"; then 954511a29bacSmrg if test -n "$hardcode_libdir_separator"; then 95466b526288Smrg func_replace_sysroot "$libdir" 95476b526288Smrg libdir=$func_replace_sysroot_result 954811a29bacSmrg if test -z "$hardcode_libdirs"; then 95496b526288Smrg hardcode_libdirs=$libdir 955011a29bacSmrg else 955111a29bacSmrg # Just accumulate the unique libdirs. 955211a29bacSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 955311a29bacSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 955411a29bacSmrg ;; 955511a29bacSmrg *) 95566b526288Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 955711a29bacSmrg ;; 955811a29bacSmrg esac 955911a29bacSmrg fi 956011a29bacSmrg else 956111a29bacSmrg eval flag=\"$hardcode_libdir_flag_spec\" 95626b526288Smrg func_append dep_rpath " $flag" 956311a29bacSmrg fi 956411a29bacSmrg elif test -n "$runpath_var"; then 956511a29bacSmrg case "$perm_rpath " in 956611a29bacSmrg *" $libdir "*) ;; 95676b526288Smrg *) func_append perm_rpath " $libdir" ;; 956811a29bacSmrg esac 956911a29bacSmrg fi 957011a29bacSmrg done 957111a29bacSmrg # Substitute the hardcoded libdirs into the rpath. 957211a29bacSmrg if test -n "$hardcode_libdir_separator" && 957311a29bacSmrg test -n "$hardcode_libdirs"; then 95746b526288Smrg libdir=$hardcode_libdirs 95756b526288Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 957611a29bacSmrg fi 957711a29bacSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 957811a29bacSmrg # We should set the runpath_var. 957911a29bacSmrg rpath= 958011a29bacSmrg for dir in $perm_rpath; do 95816b526288Smrg func_append rpath "$dir:" 958211a29bacSmrg done 958311a29bacSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 958411a29bacSmrg fi 958511a29bacSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 958611a29bacSmrg fi 958741b2f0bdSmrg 95886b526288Smrg shlibpath=$finalize_shlibpath 95896b526288Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 959011a29bacSmrg if test -n "$shlibpath"; then 959111a29bacSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 959211a29bacSmrg fi 959341b2f0bdSmrg 959411a29bacSmrg # Get the real and link names of the library. 959511a29bacSmrg eval shared_ext=\"$shrext_cmds\" 959611a29bacSmrg eval library_names=\"$library_names_spec\" 959711a29bacSmrg set dummy $library_names 959811a29bacSmrg shift 95996b526288Smrg realname=$1 960011a29bacSmrg shift 960141b2f0bdSmrg 960211a29bacSmrg if test -n "$soname_spec"; then 960311a29bacSmrg eval soname=\"$soname_spec\" 960411a29bacSmrg else 96056b526288Smrg soname=$realname 960611a29bacSmrg fi 960711a29bacSmrg if test -z "$dlname"; then 960811a29bacSmrg dlname=$soname 960911a29bacSmrg fi 961041b2f0bdSmrg 96116b526288Smrg lib=$output_objdir/$realname 961211a29bacSmrg linknames= 961311a29bacSmrg for link 961411a29bacSmrg do 96156b526288Smrg func_append linknames " $link" 961611a29bacSmrg done 961741b2f0bdSmrg 961811a29bacSmrg # Use standard objects if they are pic 961911a29bacSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 962011a29bacSmrg test "X$libobjs" = "X " && libobjs= 962141b2f0bdSmrg 962211a29bacSmrg delfiles= 962311a29bacSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 962411a29bacSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 96256b526288Smrg export_symbols=$output_objdir/$libname.uexp 96266b526288Smrg func_append delfiles " $export_symbols" 962711a29bacSmrg fi 962841b2f0bdSmrg 962911a29bacSmrg orig_export_symbols= 963011a29bacSmrg case $host_os in 963111a29bacSmrg cygwin* | mingw* | cegcc*) 963211a29bacSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 963311a29bacSmrg # exporting using user supplied symfile 96346b526288Smrg func_dll_def_p "$export_symbols" || { 963511a29bacSmrg # and it's NOT already a .def file. Must figure out 963611a29bacSmrg # which of the given symbols are data symbols and tag 963711a29bacSmrg # them as such. So, trigger use of export_symbols_cmds. 963811a29bacSmrg # export_symbols gets reassigned inside the "prepare 963911a29bacSmrg # the list of exported symbols" if statement, so the 964011a29bacSmrg # include_expsyms logic still works. 96416b526288Smrg orig_export_symbols=$export_symbols 964211a29bacSmrg export_symbols= 964311a29bacSmrg always_export_symbols=yes 96446b526288Smrg } 964511a29bacSmrg fi 964611a29bacSmrg ;; 964711a29bacSmrg esac 964841b2f0bdSmrg 964911a29bacSmrg # Prepare the list of exported symbols 965011a29bacSmrg if test -z "$export_symbols"; then 96516b526288Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 96526b526288Smrg func_verbose "generating symbol list for '$libname.la'" 96536b526288Smrg export_symbols=$output_objdir/$libname.exp 965411a29bacSmrg $opt_dry_run || $RM $export_symbols 965511a29bacSmrg cmds=$export_symbols_cmds 96566b526288Smrg save_ifs=$IFS; IFS='~' 96576b526288Smrg for cmd1 in $cmds; do 96586b526288Smrg IFS=$save_ifs 96596b526288Smrg # Take the normal branch if the nm_file_list_spec branch 96606b526288Smrg # doesn't work or if tool conversion is not needed. 96616b526288Smrg case $nm_file_list_spec~$to_tool_file_cmd in 96626b526288Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 96636b526288Smrg try_normal_branch=yes 96646b526288Smrg eval cmd=\"$cmd1\" 96656b526288Smrg func_len " $cmd" 96666b526288Smrg len=$func_len_result 96676b526288Smrg ;; 96686b526288Smrg *) 96696b526288Smrg try_normal_branch=no 96706b526288Smrg ;; 96716b526288Smrg esac 96726b526288Smrg if test yes = "$try_normal_branch" \ 96736b526288Smrg && { test "$len" -lt "$max_cmd_len" \ 96746b526288Smrg || test "$max_cmd_len" -le -1; } 96756b526288Smrg then 96766b526288Smrg func_show_eval "$cmd" 'exit $?' 96776b526288Smrg skipped_export=false 96786b526288Smrg elif test -n "$nm_file_list_spec"; then 96796b526288Smrg func_basename "$output" 96806b526288Smrg output_la=$func_basename_result 96816b526288Smrg save_libobjs=$libobjs 96826b526288Smrg save_output=$output 96836b526288Smrg output=$output_objdir/$output_la.nm 96846b526288Smrg func_to_tool_file "$output" 96856b526288Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 96866b526288Smrg func_append delfiles " $output" 96876b526288Smrg func_verbose "creating $NM input file list: $output" 96886b526288Smrg for obj in $save_libobjs; do 96896b526288Smrg func_to_tool_file "$obj" 96906b526288Smrg $ECHO "$func_to_tool_file_result" 96916b526288Smrg done > "$output" 96926b526288Smrg eval cmd=\"$cmd1\" 969311a29bacSmrg func_show_eval "$cmd" 'exit $?' 96946b526288Smrg output=$save_output 96956b526288Smrg libobjs=$save_libobjs 969611a29bacSmrg skipped_export=false 969711a29bacSmrg else 969811a29bacSmrg # The command line is too long to execute in one step. 969911a29bacSmrg func_verbose "using reloadable object file for export list..." 970011a29bacSmrg skipped_export=: 970111a29bacSmrg # Break out early, otherwise skipped_export may be 970211a29bacSmrg # set to false by a later but shorter cmd. 970311a29bacSmrg break 970411a29bacSmrg fi 970511a29bacSmrg done 97066b526288Smrg IFS=$save_ifs 97076b526288Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 970811a29bacSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 970911a29bacSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 971011a29bacSmrg fi 971111a29bacSmrg fi 971211a29bacSmrg fi 971341b2f0bdSmrg 971411a29bacSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 97156b526288Smrg tmp_export_symbols=$export_symbols 97166b526288Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 971711a29bacSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 971811a29bacSmrg fi 971941b2f0bdSmrg 97206b526288Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 972111a29bacSmrg # The given exports_symbols file has to be filtered, so filter it. 97226b526288Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 972311a29bacSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 97246b526288Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 972511a29bacSmrg # though. Also, the filter scales superlinearly with the number of 972611a29bacSmrg # global variables. join(1) would be nice here, but unfortunately 972711a29bacSmrg # isn't a blessed tool. 972811a29bacSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 97296b526288Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 973011a29bacSmrg export_symbols=$output_objdir/$libname.def 973111a29bacSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 973241b2f0bdSmrg fi 973341b2f0bdSmrg 973411a29bacSmrg tmp_deplibs= 973511a29bacSmrg for test_deplib in $deplibs; do 973611a29bacSmrg case " $convenience " in 973711a29bacSmrg *" $test_deplib "*) ;; 973811a29bacSmrg *) 97396b526288Smrg func_append tmp_deplibs " $test_deplib" 974011a29bacSmrg ;; 974111a29bacSmrg esac 974211a29bacSmrg done 97436b526288Smrg deplibs=$tmp_deplibs 974441b2f0bdSmrg 974511a29bacSmrg if test -n "$convenience"; then 974611a29bacSmrg if test -n "$whole_archive_flag_spec" && 97476b526288Smrg test yes = "$compiler_needs_object" && 974811a29bacSmrg test -z "$libobjs"; then 974911a29bacSmrg # extract the archives, so we have objects to list. 975011a29bacSmrg # TODO: could optimize this to just extract one archive. 975111a29bacSmrg whole_archive_flag_spec= 975211a29bacSmrg fi 975311a29bacSmrg if test -n "$whole_archive_flag_spec"; then 975411a29bacSmrg save_libobjs=$libobjs 975511a29bacSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 975611a29bacSmrg test "X$libobjs" = "X " && libobjs= 975711a29bacSmrg else 97586b526288Smrg gentop=$output_objdir/${outputname}x 97596b526288Smrg func_append generated " $gentop" 976041b2f0bdSmrg 976111a29bacSmrg func_extract_archives $gentop $convenience 97626b526288Smrg func_append libobjs " $func_extract_archives_result" 976311a29bacSmrg test "X$libobjs" = "X " && libobjs= 976411a29bacSmrg fi 976511a29bacSmrg fi 976641b2f0bdSmrg 97676b526288Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 976811a29bacSmrg eval flag=\"$thread_safe_flag_spec\" 97696b526288Smrg func_append linker_flags " $flag" 977011a29bacSmrg fi 977141b2f0bdSmrg 977211a29bacSmrg # Make a backup of the uninstalled library when relinking 97736b526288Smrg if test relink = "$opt_mode"; then 977411a29bacSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 977541b2f0bdSmrg fi 977641b2f0bdSmrg 977711a29bacSmrg # Do each of the archive commands. 97786b526288Smrg if test yes = "$module" && test -n "$module_cmds"; then 977911a29bacSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 978011a29bacSmrg eval test_cmds=\"$module_expsym_cmds\" 978111a29bacSmrg cmds=$module_expsym_cmds 978211a29bacSmrg else 978311a29bacSmrg eval test_cmds=\"$module_cmds\" 978411a29bacSmrg cmds=$module_cmds 978511a29bacSmrg fi 978611a29bacSmrg else 978711a29bacSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 978811a29bacSmrg eval test_cmds=\"$archive_expsym_cmds\" 978911a29bacSmrg cmds=$archive_expsym_cmds 979011a29bacSmrg else 979111a29bacSmrg eval test_cmds=\"$archive_cmds\" 979211a29bacSmrg cmds=$archive_cmds 979311a29bacSmrg fi 979441b2f0bdSmrg fi 979541b2f0bdSmrg 97966b526288Smrg if test : != "$skipped_export" && 979711a29bacSmrg func_len " $test_cmds" && 979811a29bacSmrg len=$func_len_result && 979911a29bacSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 980011a29bacSmrg : 980111a29bacSmrg else 980211a29bacSmrg # The command line is too long to link in one step, link piecewise 980311a29bacSmrg # or, if using GNU ld and skipped_export is not :, use a linker 980411a29bacSmrg # script. 980541b2f0bdSmrg 980611a29bacSmrg # Save the value of $output and $libobjs because we want to 980711a29bacSmrg # use them later. If we have whole_archive_flag_spec, we 980811a29bacSmrg # want to use save_libobjs as it was before 980911a29bacSmrg # whole_archive_flag_spec was expanded, because we can't 981011a29bacSmrg # assume the linker understands whole_archive_flag_spec. 981111a29bacSmrg # This may have to be revisited, in case too many 981211a29bacSmrg # convenience libraries get linked in and end up exceeding 981311a29bacSmrg # the spec. 981411a29bacSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 981511a29bacSmrg save_libobjs=$libobjs 981611a29bacSmrg fi 981711a29bacSmrg save_output=$output 981811a29bacSmrg func_basename "$output" 981911a29bacSmrg output_la=$func_basename_result 982041b2f0bdSmrg 982111a29bacSmrg # Clear the reloadable object creation command queue and 982211a29bacSmrg # initialize k to one. 982311a29bacSmrg test_cmds= 982411a29bacSmrg concat_cmds= 982511a29bacSmrg objlist= 982611a29bacSmrg last_robj= 982711a29bacSmrg k=1 982841b2f0bdSmrg 98296b526288Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 98306b526288Smrg output=$output_objdir/$output_la.lnkscript 983111a29bacSmrg func_verbose "creating GNU ld script: $output" 983211a29bacSmrg echo 'INPUT (' > $output 983311a29bacSmrg for obj in $save_libobjs 983411a29bacSmrg do 98356b526288Smrg func_to_tool_file "$obj" 98366b526288Smrg $ECHO "$func_to_tool_file_result" >> $output 983711a29bacSmrg done 983811a29bacSmrg echo ')' >> $output 98396b526288Smrg func_append delfiles " $output" 98406b526288Smrg func_to_tool_file "$output" 98416b526288Smrg output=$func_to_tool_file_result 98426b526288Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 98436b526288Smrg output=$output_objdir/$output_la.lnk 984411a29bacSmrg func_verbose "creating linker input file list: $output" 984511a29bacSmrg : > $output 984611a29bacSmrg set x $save_libobjs 984711a29bacSmrg shift 984811a29bacSmrg firstobj= 98496b526288Smrg if test yes = "$compiler_needs_object"; then 985011a29bacSmrg firstobj="$1 " 985111a29bacSmrg shift 985211a29bacSmrg fi 985311a29bacSmrg for obj 985411a29bacSmrg do 98556b526288Smrg func_to_tool_file "$obj" 98566b526288Smrg $ECHO "$func_to_tool_file_result" >> $output 985711a29bacSmrg done 98586b526288Smrg func_append delfiles " $output" 98596b526288Smrg func_to_tool_file "$output" 98606b526288Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 986111a29bacSmrg else 986211a29bacSmrg if test -n "$save_libobjs"; then 986311a29bacSmrg func_verbose "creating reloadable object files..." 98646b526288Smrg output=$output_objdir/$output_la-$k.$objext 986511a29bacSmrg eval test_cmds=\"$reload_cmds\" 986611a29bacSmrg func_len " $test_cmds" 986711a29bacSmrg len0=$func_len_result 986811a29bacSmrg len=$len0 986911a29bacSmrg 987011a29bacSmrg # Loop over the list of objects to be linked. 987111a29bacSmrg for obj in $save_libobjs 987211a29bacSmrg do 987311a29bacSmrg func_len " $obj" 987411a29bacSmrg func_arith $len + $func_len_result 987511a29bacSmrg len=$func_arith_result 98766b526288Smrg if test -z "$objlist" || 987711a29bacSmrg test "$len" -lt "$max_cmd_len"; then 987811a29bacSmrg func_append objlist " $obj" 987911a29bacSmrg else 988011a29bacSmrg # The command $test_cmds is almost too long, add a 988111a29bacSmrg # command to the queue. 98826b526288Smrg if test 1 -eq "$k"; then 988311a29bacSmrg # The first file doesn't have a previous command to add. 988411a29bacSmrg reload_objs=$objlist 988511a29bacSmrg eval concat_cmds=\"$reload_cmds\" 988611a29bacSmrg else 988711a29bacSmrg # All subsequent reloadable object files will link in 988811a29bacSmrg # the last one created. 988911a29bacSmrg reload_objs="$objlist $last_robj" 989011a29bacSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 989111a29bacSmrg fi 98926b526288Smrg last_robj=$output_objdir/$output_la-$k.$objext 989311a29bacSmrg func_arith $k + 1 989411a29bacSmrg k=$func_arith_result 98956b526288Smrg output=$output_objdir/$output_la-$k.$objext 989611a29bacSmrg objlist=" $obj" 989711a29bacSmrg func_len " $last_robj" 989811a29bacSmrg func_arith $len0 + $func_len_result 989911a29bacSmrg len=$func_arith_result 990011a29bacSmrg fi 990111a29bacSmrg done 990211a29bacSmrg # Handle the remaining objects by creating one last 990311a29bacSmrg # reloadable object file. All subsequent reloadable object 990411a29bacSmrg # files will link in the last one created. 990511a29bacSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 990611a29bacSmrg reload_objs="$objlist $last_robj" 99076b526288Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 990811a29bacSmrg if test -n "$last_robj"; then 99096b526288Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 991011a29bacSmrg fi 99116b526288Smrg func_append delfiles " $output" 991211a29bacSmrg 991311a29bacSmrg else 991411a29bacSmrg output= 991511a29bacSmrg fi 991641b2f0bdSmrg 99176b526288Smrg ${skipped_export-false} && { 99186b526288Smrg func_verbose "generating symbol list for '$libname.la'" 99196b526288Smrg export_symbols=$output_objdir/$libname.exp 992011a29bacSmrg $opt_dry_run || $RM $export_symbols 992111a29bacSmrg libobjs=$output 992211a29bacSmrg # Append the command to create the export file. 992311a29bacSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 992411a29bacSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 992511a29bacSmrg if test -n "$last_robj"; then 992611a29bacSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 992711a29bacSmrg fi 99286b526288Smrg } 992941b2f0bdSmrg 993011a29bacSmrg test -n "$save_libobjs" && 993111a29bacSmrg func_verbose "creating a temporary reloadable object file: $output" 993241b2f0bdSmrg 993311a29bacSmrg # Loop through the commands generated above and execute them. 99346b526288Smrg save_ifs=$IFS; IFS='~' 993511a29bacSmrg for cmd in $concat_cmds; do 99366b526288Smrg IFS=$save_ifs 99376b526288Smrg $opt_quiet || { 993811a29bacSmrg func_quote_for_expand "$cmd" 993911a29bacSmrg eval "func_echo $func_quote_for_expand_result" 994011a29bacSmrg } 994111a29bacSmrg $opt_dry_run || eval "$cmd" || { 994211a29bacSmrg lt_exit=$? 994311a29bacSmrg 994411a29bacSmrg # Restore the uninstalled library and exit 99456b526288Smrg if test relink = "$opt_mode"; then 994611a29bacSmrg ( cd "$output_objdir" && \ 994711a29bacSmrg $RM "${realname}T" && \ 994811a29bacSmrg $MV "${realname}U" "$realname" ) 994911a29bacSmrg fi 995041b2f0bdSmrg 995111a29bacSmrg exit $lt_exit 995211a29bacSmrg } 995311a29bacSmrg done 99546b526288Smrg IFS=$save_ifs 995541b2f0bdSmrg 995611a29bacSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 995711a29bacSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 995811a29bacSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 995941b2f0bdSmrg fi 996041b2f0bdSmrg fi 996141b2f0bdSmrg 99626b526288Smrg ${skipped_export-false} && { 996311a29bacSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99646b526288Smrg tmp_export_symbols=$export_symbols 99656b526288Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 996611a29bacSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 996711a29bacSmrg fi 996841b2f0bdSmrg 996911a29bacSmrg if test -n "$orig_export_symbols"; then 997011a29bacSmrg # The given exports_symbols file has to be filtered, so filter it. 99716b526288Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 997211a29bacSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 99736b526288Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 997411a29bacSmrg # though. Also, the filter scales superlinearly with the number of 997511a29bacSmrg # global variables. join(1) would be nice here, but unfortunately 997611a29bacSmrg # isn't a blessed tool. 997711a29bacSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 99786b526288Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 997911a29bacSmrg export_symbols=$output_objdir/$libname.def 998011a29bacSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 998111a29bacSmrg fi 99826b526288Smrg } 998341b2f0bdSmrg 998411a29bacSmrg libobjs=$output 998511a29bacSmrg # Restore the value of output. 998611a29bacSmrg output=$save_output 998741b2f0bdSmrg 998811a29bacSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 998911a29bacSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 999011a29bacSmrg test "X$libobjs" = "X " && libobjs= 999111a29bacSmrg fi 999211a29bacSmrg # Expand the library linking commands again to reset the 999311a29bacSmrg # value of $libobjs for piecewise linking. 999411a29bacSmrg 999511a29bacSmrg # Do each of the archive commands. 99966b526288Smrg if test yes = "$module" && test -n "$module_cmds"; then 999711a29bacSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 999811a29bacSmrg cmds=$module_expsym_cmds 999941b2f0bdSmrg else 1000011a29bacSmrg cmds=$module_cmds 1000141b2f0bdSmrg fi 1000241b2f0bdSmrg else 1000311a29bacSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1000411a29bacSmrg cmds=$archive_expsym_cmds 1000511a29bacSmrg else 1000611a29bacSmrg cmds=$archive_cmds 1000711a29bacSmrg fi 1000841b2f0bdSmrg fi 1000941b2f0bdSmrg fi 1001041b2f0bdSmrg 1001111a29bacSmrg if test -n "$delfiles"; then 1001211a29bacSmrg # Append the command to remove temporary files to $cmds. 1001311a29bacSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 1001411a29bacSmrg fi 1001541b2f0bdSmrg 1001611a29bacSmrg # Add any objects from preloaded convenience libraries 1001711a29bacSmrg if test -n "$dlprefiles"; then 100186b526288Smrg gentop=$output_objdir/${outputname}x 100196b526288Smrg func_append generated " $gentop" 1002041b2f0bdSmrg 1002111a29bacSmrg func_extract_archives $gentop $dlprefiles 100226b526288Smrg func_append libobjs " $func_extract_archives_result" 1002311a29bacSmrg test "X$libobjs" = "X " && libobjs= 1002441b2f0bdSmrg fi 1002541b2f0bdSmrg 100266b526288Smrg save_ifs=$IFS; IFS='~' 1002711a29bacSmrg for cmd in $cmds; do 100286b526288Smrg IFS=$sp$nl 1002911a29bacSmrg eval cmd=\"$cmd\" 100306b526288Smrg IFS=$save_ifs 100316b526288Smrg $opt_quiet || { 1003211a29bacSmrg func_quote_for_expand "$cmd" 1003311a29bacSmrg eval "func_echo $func_quote_for_expand_result" 1003411a29bacSmrg } 1003511a29bacSmrg $opt_dry_run || eval "$cmd" || { 1003611a29bacSmrg lt_exit=$? 1003741b2f0bdSmrg 1003811a29bacSmrg # Restore the uninstalled library and exit 100396b526288Smrg if test relink = "$opt_mode"; then 1004011a29bacSmrg ( cd "$output_objdir" && \ 1004111a29bacSmrg $RM "${realname}T" && \ 1004211a29bacSmrg $MV "${realname}U" "$realname" ) 1004341b2f0bdSmrg fi 1004441b2f0bdSmrg 1004511a29bacSmrg exit $lt_exit 1004611a29bacSmrg } 1004711a29bacSmrg done 100486b526288Smrg IFS=$save_ifs 1004941b2f0bdSmrg 1005011a29bacSmrg # Restore the uninstalled library and exit 100516b526288Smrg if test relink = "$opt_mode"; then 1005211a29bacSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1005341b2f0bdSmrg 1005411a29bacSmrg if test -n "$convenience"; then 1005511a29bacSmrg if test -z "$whole_archive_flag_spec"; then 1005611a29bacSmrg func_show_eval '${RM}r "$gentop"' 1005711a29bacSmrg fi 1005811a29bacSmrg fi 1005941b2f0bdSmrg 1006011a29bacSmrg exit $EXIT_SUCCESS 1006111a29bacSmrg fi 1006241b2f0bdSmrg 1006311a29bacSmrg # Create links to the real library. 1006411a29bacSmrg for linkname in $linknames; do 1006511a29bacSmrg if test "$realname" != "$linkname"; then 1006611a29bacSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1006711a29bacSmrg fi 1006811a29bacSmrg done 1006941b2f0bdSmrg 1007011a29bacSmrg # If -module or -export-dynamic was specified, set the dlname. 100716b526288Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 1007211a29bacSmrg # On all known operating systems, these are identical. 100736b526288Smrg dlname=$soname 1007411a29bacSmrg fi 1007511a29bacSmrg fi 1007611a29bacSmrg ;; 1007741b2f0bdSmrg 1007811a29bacSmrg obj) 100796b526288Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 100806b526288Smrg func_warning "'-dlopen' is ignored for objects" 1008111a29bacSmrg fi 1008241b2f0bdSmrg 1008311a29bacSmrg case " $deplibs" in 1008411a29bacSmrg *\ -l* | *\ -L*) 100856b526288Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 1008611a29bacSmrg esac 1008741b2f0bdSmrg 1008811a29bacSmrg test -n "$rpath" && \ 100896b526288Smrg func_warning "'-rpath' is ignored for objects" 1009041b2f0bdSmrg 1009111a29bacSmrg test -n "$xrpath" && \ 100926b526288Smrg func_warning "'-R' is ignored for objects" 1009311a29bacSmrg 1009411a29bacSmrg test -n "$vinfo" && \ 100956b526288Smrg func_warning "'-version-info' is ignored for objects" 1009641b2f0bdSmrg 1009711a29bacSmrg test -n "$release" && \ 100986b526288Smrg func_warning "'-release' is ignored for objects" 1009941b2f0bdSmrg 1010011a29bacSmrg case $output in 1010111a29bacSmrg *.lo) 1010211a29bacSmrg test -n "$objs$old_deplibs" && \ 101036b526288Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1010411a29bacSmrg 1010511a29bacSmrg libobj=$output 1010611a29bacSmrg func_lo2o "$libobj" 1010711a29bacSmrg obj=$func_lo2o_result 1010811a29bacSmrg ;; 1010911a29bacSmrg *) 1011011a29bacSmrg libobj= 101116b526288Smrg obj=$output 1011241b2f0bdSmrg ;; 1011341b2f0bdSmrg esac 1011441b2f0bdSmrg 1011511a29bacSmrg # Delete the old objects. 1011611a29bacSmrg $opt_dry_run || $RM $obj $libobj 1011741b2f0bdSmrg 1011811a29bacSmrg # Objects from convenience libraries. This assumes 1011911a29bacSmrg # single-version convenience libraries. Whenever we create 1012011a29bacSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 1012111a29bacSmrg # the extraction. 1012211a29bacSmrg reload_conv_objs= 1012311a29bacSmrg gentop= 101246b526288Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 101256b526288Smrg # whole_archive_flag_spec and hope we can get by with turning comma 101266b526288Smrg # into space. 101276b526288Smrg case $reload_cmds in 101286b526288Smrg *\$LD[\ \$]*) wl= ;; 101296b526288Smrg esac 1013011a29bacSmrg if test -n "$convenience"; then 1013111a29bacSmrg if test -n "$whole_archive_flag_spec"; then 1013211a29bacSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 101336b526288Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 101346b526288Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1013541b2f0bdSmrg else 101366b526288Smrg gentop=$output_objdir/${obj}x 101376b526288Smrg func_append generated " $gentop" 1013811a29bacSmrg 1013911a29bacSmrg func_extract_archives $gentop $convenience 1014011a29bacSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1014141b2f0bdSmrg fi 1014211a29bacSmrg fi 1014341b2f0bdSmrg 101446b526288Smrg # If we're not building shared, we need to use non_pic_objs 101456b526288Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 101466b526288Smrg 1014711a29bacSmrg # Create the old-style object. 101486b526288Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 1014941b2f0bdSmrg 101506b526288Smrg output=$obj 1015111a29bacSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1015241b2f0bdSmrg 1015311a29bacSmrg # Exit if we aren't doing a library object file. 1015411a29bacSmrg if test -z "$libobj"; then 1015511a29bacSmrg if test -n "$gentop"; then 1015611a29bacSmrg func_show_eval '${RM}r "$gentop"' 1015711a29bacSmrg fi 1015841b2f0bdSmrg 1015911a29bacSmrg exit $EXIT_SUCCESS 1016041b2f0bdSmrg fi 1016141b2f0bdSmrg 101626b526288Smrg test yes = "$build_libtool_libs" || { 1016311a29bacSmrg if test -n "$gentop"; then 1016411a29bacSmrg func_show_eval '${RM}r "$gentop"' 1016511a29bacSmrg fi 1016641b2f0bdSmrg 1016711a29bacSmrg # Create an invalid libtool object if no PIC, so that we don't 1016811a29bacSmrg # accidentally link it into a program. 1016911a29bacSmrg # $show "echo timestamp > $libobj" 1017011a29bacSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1017111a29bacSmrg exit $EXIT_SUCCESS 101726b526288Smrg } 1017341b2f0bdSmrg 101746b526288Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1017511a29bacSmrg # Only do commands if we really have different PIC objects. 1017611a29bacSmrg reload_objs="$libobjs $reload_conv_objs" 101776b526288Smrg output=$libobj 1017811a29bacSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1017941b2f0bdSmrg fi 1018011a29bacSmrg 1018111a29bacSmrg if test -n "$gentop"; then 1018211a29bacSmrg func_show_eval '${RM}r "$gentop"' 1018311a29bacSmrg fi 1018411a29bacSmrg 1018511a29bacSmrg exit $EXIT_SUCCESS 1018641b2f0bdSmrg ;; 1018741b2f0bdSmrg 1018811a29bacSmrg prog) 1018911a29bacSmrg case $host in 1019011a29bacSmrg *cygwin*) func_stripname '' '.exe' "$output" 1019111a29bacSmrg output=$func_stripname_result.exe;; 1019211a29bacSmrg esac 1019311a29bacSmrg test -n "$vinfo" && \ 101946b526288Smrg func_warning "'-version-info' is ignored for programs" 1019541b2f0bdSmrg 1019611a29bacSmrg test -n "$release" && \ 101976b526288Smrg func_warning "'-release' is ignored for programs" 1019841b2f0bdSmrg 101996b526288Smrg $preload \ 102006b526288Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 102016b526288Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1020211a29bacSmrg 1020311a29bacSmrg case $host in 1020411a29bacSmrg *-*-rhapsody* | *-*-darwin1.[012]) 1020511a29bacSmrg # On Rhapsody replace the C library is the System framework 1020611a29bacSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020711a29bacSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020841b2f0bdSmrg ;; 1020911a29bacSmrg esac 1021041b2f0bdSmrg 1021111a29bacSmrg case $host in 1021211a29bacSmrg *-*-darwin*) 1021311a29bacSmrg # Don't allow lazy linking, it breaks C++ global constructors 1021411a29bacSmrg # But is supposedly fixed on 10.4 or later (yay!). 102156b526288Smrg if test CXX = "$tagname"; then 1021611a29bacSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1021711a29bacSmrg 10.[0123]) 102186b526288Smrg func_append compile_command " $wl-bind_at_load" 102196b526288Smrg func_append finalize_command " $wl-bind_at_load" 1022011a29bacSmrg ;; 1022111a29bacSmrg esac 1022241b2f0bdSmrg fi 1022311a29bacSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1022411a29bacSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022511a29bacSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022611a29bacSmrg ;; 1022711a29bacSmrg esac 1022841b2f0bdSmrg 1022941b2f0bdSmrg 1023011a29bacSmrg # move library search paths that coincide with paths to not yet 1023111a29bacSmrg # installed libraries to the beginning of the library search list 1023211a29bacSmrg new_libs= 1023311a29bacSmrg for path in $notinst_path; do 1023411a29bacSmrg case " $new_libs " in 1023511a29bacSmrg *" -L$path/$objdir "*) ;; 1023611a29bacSmrg *) 1023711a29bacSmrg case " $compile_deplibs " in 1023811a29bacSmrg *" -L$path/$objdir "*) 102396b526288Smrg func_append new_libs " -L$path/$objdir" ;; 1024041b2f0bdSmrg esac 1024111a29bacSmrg ;; 1024211a29bacSmrg esac 1024311a29bacSmrg done 1024411a29bacSmrg for deplib in $compile_deplibs; do 1024511a29bacSmrg case $deplib in 1024611a29bacSmrg -L*) 1024711a29bacSmrg case " $new_libs " in 1024811a29bacSmrg *" $deplib "*) ;; 102496b526288Smrg *) func_append new_libs " $deplib" ;; 1025041b2f0bdSmrg esac 1025111a29bacSmrg ;; 102526b526288Smrg *) func_append new_libs " $deplib" ;; 1025311a29bacSmrg esac 1025411a29bacSmrg done 102556b526288Smrg compile_deplibs=$new_libs 1025641b2f0bdSmrg 1025741b2f0bdSmrg 102586b526288Smrg func_append compile_command " $compile_deplibs" 102596b526288Smrg func_append finalize_command " $finalize_deplibs" 1026041b2f0bdSmrg 1026111a29bacSmrg if test -n "$rpath$xrpath"; then 1026211a29bacSmrg # If the user specified any rpath flags, then add them. 1026311a29bacSmrg for libdir in $rpath $xrpath; do 1026411a29bacSmrg # This is the magic to use -rpath. 1026511a29bacSmrg case "$finalize_rpath " in 1026611a29bacSmrg *" $libdir "*) ;; 102676b526288Smrg *) func_append finalize_rpath " $libdir" ;; 1026811a29bacSmrg esac 1026911a29bacSmrg done 1027011a29bacSmrg fi 1027141b2f0bdSmrg 1027211a29bacSmrg # Now hardcode the library paths 1027311a29bacSmrg rpath= 1027411a29bacSmrg hardcode_libdirs= 1027511a29bacSmrg for libdir in $compile_rpath $finalize_rpath; do 1027611a29bacSmrg if test -n "$hardcode_libdir_flag_spec"; then 1027711a29bacSmrg if test -n "$hardcode_libdir_separator"; then 1027811a29bacSmrg if test -z "$hardcode_libdirs"; then 102796b526288Smrg hardcode_libdirs=$libdir 1028011a29bacSmrg else 1028111a29bacSmrg # Just accumulate the unique libdirs. 1028211a29bacSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1028311a29bacSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1028411a29bacSmrg ;; 1028511a29bacSmrg *) 102866b526288Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1028711a29bacSmrg ;; 1028811a29bacSmrg esac 1028911a29bacSmrg fi 1029041b2f0bdSmrg else 1029111a29bacSmrg eval flag=\"$hardcode_libdir_flag_spec\" 102926b526288Smrg func_append rpath " $flag" 1029341b2f0bdSmrg fi 1029411a29bacSmrg elif test -n "$runpath_var"; then 1029511a29bacSmrg case "$perm_rpath " in 1029611a29bacSmrg *" $libdir "*) ;; 102976b526288Smrg *) func_append perm_rpath " $libdir" ;; 1029811a29bacSmrg esac 1029911a29bacSmrg fi 1030011a29bacSmrg case $host in 1030111a29bacSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 103026b526288Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1030311a29bacSmrg case :$dllsearchpath: in 1030411a29bacSmrg *":$libdir:"*) ;; 1030511a29bacSmrg ::) dllsearchpath=$libdir;; 103066b526288Smrg *) func_append dllsearchpath ":$libdir";; 1030711a29bacSmrg esac 1030811a29bacSmrg case :$dllsearchpath: in 1030911a29bacSmrg *":$testbindir:"*) ;; 1031011a29bacSmrg ::) dllsearchpath=$testbindir;; 103116b526288Smrg *) func_append dllsearchpath ":$testbindir";; 1031211a29bacSmrg esac 1031311a29bacSmrg ;; 1031411a29bacSmrg esac 1031511a29bacSmrg done 1031611a29bacSmrg # Substitute the hardcoded libdirs into the rpath. 1031711a29bacSmrg if test -n "$hardcode_libdir_separator" && 1031811a29bacSmrg test -n "$hardcode_libdirs"; then 103196b526288Smrg libdir=$hardcode_libdirs 1032011a29bacSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1032111a29bacSmrg fi 103226b526288Smrg compile_rpath=$rpath 1032341b2f0bdSmrg 1032411a29bacSmrg rpath= 1032511a29bacSmrg hardcode_libdirs= 1032611a29bacSmrg for libdir in $finalize_rpath; do 1032711a29bacSmrg if test -n "$hardcode_libdir_flag_spec"; then 1032811a29bacSmrg if test -n "$hardcode_libdir_separator"; then 1032911a29bacSmrg if test -z "$hardcode_libdirs"; then 103306b526288Smrg hardcode_libdirs=$libdir 1033111a29bacSmrg else 1033211a29bacSmrg # Just accumulate the unique libdirs. 1033311a29bacSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1033411a29bacSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1033511a29bacSmrg ;; 1033611a29bacSmrg *) 103376b526288Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1033811a29bacSmrg ;; 1033911a29bacSmrg esac 1034011a29bacSmrg fi 1034141b2f0bdSmrg else 1034211a29bacSmrg eval flag=\"$hardcode_libdir_flag_spec\" 103436b526288Smrg func_append rpath " $flag" 1034441b2f0bdSmrg fi 1034511a29bacSmrg elif test -n "$runpath_var"; then 1034611a29bacSmrg case "$finalize_perm_rpath " in 1034711a29bacSmrg *" $libdir "*) ;; 103486b526288Smrg *) func_append finalize_perm_rpath " $libdir" ;; 1034911a29bacSmrg esac 1035041b2f0bdSmrg fi 1035111a29bacSmrg done 1035211a29bacSmrg # Substitute the hardcoded libdirs into the rpath. 1035311a29bacSmrg if test -n "$hardcode_libdir_separator" && 1035411a29bacSmrg test -n "$hardcode_libdirs"; then 103556b526288Smrg libdir=$hardcode_libdirs 1035611a29bacSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1035711a29bacSmrg fi 103586b526288Smrg finalize_rpath=$rpath 1035941b2f0bdSmrg 103606b526288Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1036111a29bacSmrg # Transform all the library objects into standard objects. 1036211a29bacSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036311a29bacSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036411a29bacSmrg fi 1036541b2f0bdSmrg 103666b526288Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1036741b2f0bdSmrg 1036811a29bacSmrg # template prelinking step 1036911a29bacSmrg if test -n "$prelink_cmds"; then 1037011a29bacSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 1037111a29bacSmrg fi 1037241b2f0bdSmrg 103736b526288Smrg wrappers_required=: 1037411a29bacSmrg case $host in 1037511a29bacSmrg *cegcc* | *mingw32ce*) 1037611a29bacSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 103776b526288Smrg wrappers_required=false 1037811a29bacSmrg ;; 1037911a29bacSmrg *cygwin* | *mingw* ) 103806b526288Smrg test yes = "$build_libtool_libs" || wrappers_required=false 1038111a29bacSmrg ;; 1038211a29bacSmrg *) 103836b526288Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 103846b526288Smrg wrappers_required=false 1038511a29bacSmrg fi 1038611a29bacSmrg ;; 1038711a29bacSmrg esac 103886b526288Smrg $wrappers_required || { 1038911a29bacSmrg # Replace the output file specification. 1039011a29bacSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 103916b526288Smrg link_command=$compile_command$compile_rpath 1039241b2f0bdSmrg 1039311a29bacSmrg # We have no uninstalled library dependencies, so finalize right now. 1039411a29bacSmrg exit_status=0 1039511a29bacSmrg func_show_eval "$link_command" 'exit_status=$?' 1039641b2f0bdSmrg 103976b526288Smrg if test -n "$postlink_cmds"; then 103986b526288Smrg func_to_tool_file "$output" 103996b526288Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 104006b526288Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104016b526288Smrg fi 104026b526288Smrg 1040311a29bacSmrg # Delete the generated files. 104046b526288Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 104056b526288Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1040641b2f0bdSmrg fi 1040741b2f0bdSmrg 1040811a29bacSmrg exit $exit_status 104096b526288Smrg } 1041041b2f0bdSmrg 1041111a29bacSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1041211a29bacSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1041311a29bacSmrg fi 1041411a29bacSmrg if test -n "$finalize_shlibpath"; then 1041511a29bacSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1041611a29bacSmrg fi 1041741b2f0bdSmrg 1041811a29bacSmrg compile_var= 1041911a29bacSmrg finalize_var= 1042011a29bacSmrg if test -n "$runpath_var"; then 1042111a29bacSmrg if test -n "$perm_rpath"; then 1042211a29bacSmrg # We should set the runpath_var. 1042311a29bacSmrg rpath= 1042411a29bacSmrg for dir in $perm_rpath; do 104256b526288Smrg func_append rpath "$dir:" 1042611a29bacSmrg done 1042711a29bacSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1042841b2f0bdSmrg fi 1042911a29bacSmrg if test -n "$finalize_perm_rpath"; then 1043011a29bacSmrg # We should set the runpath_var. 1043111a29bacSmrg rpath= 1043211a29bacSmrg for dir in $finalize_perm_rpath; do 104336b526288Smrg func_append rpath "$dir:" 1043411a29bacSmrg done 1043511a29bacSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043641b2f0bdSmrg fi 1043711a29bacSmrg fi 1043841b2f0bdSmrg 104396b526288Smrg if test yes = "$no_install"; then 1044011a29bacSmrg # We don't need to create a wrapper script. 104416b526288Smrg link_command=$compile_var$compile_command$compile_rpath 1044211a29bacSmrg # Replace the output file specification. 1044311a29bacSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1044411a29bacSmrg # Delete the old output file. 1044511a29bacSmrg $opt_dry_run || $RM $output 1044611a29bacSmrg # Link the executable and exit 1044711a29bacSmrg func_show_eval "$link_command" 'exit $?' 104486b526288Smrg 104496b526288Smrg if test -n "$postlink_cmds"; then 104506b526288Smrg func_to_tool_file "$output" 104516b526288Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 104526b526288Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104536b526288Smrg fi 104546b526288Smrg 1045541b2f0bdSmrg exit $EXIT_SUCCESS 1045611a29bacSmrg fi 1045741b2f0bdSmrg 104586b526288Smrg case $hardcode_action,$fast_install in 104596b526288Smrg relink,*) 104606b526288Smrg # Fast installation is not supported 104616b526288Smrg link_command=$compile_var$compile_command$compile_rpath 104626b526288Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1046311a29bacSmrg 104646b526288Smrg func_warning "this platform does not like uninstalled shared libraries" 104656b526288Smrg func_warning "'$output' will be relinked during installation" 104666b526288Smrg ;; 104676b526288Smrg *,yes) 104686b526288Smrg link_command=$finalize_var$compile_command$finalize_rpath 104696b526288Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 104706b526288Smrg ;; 104716b526288Smrg *,no) 104726b526288Smrg link_command=$compile_var$compile_command$compile_rpath 104736b526288Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 104746b526288Smrg ;; 104756b526288Smrg *,needless) 104766b526288Smrg link_command=$finalize_var$compile_command$finalize_rpath 104776b526288Smrg relink_command= 104786b526288Smrg ;; 104796b526288Smrg esac 1048041b2f0bdSmrg 1048111a29bacSmrg # Replace the output file specification. 1048211a29bacSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1048341b2f0bdSmrg 1048411a29bacSmrg # Delete the old output files. 1048511a29bacSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1048641b2f0bdSmrg 1048711a29bacSmrg func_show_eval "$link_command" 'exit $?' 1048841b2f0bdSmrg 104896b526288Smrg if test -n "$postlink_cmds"; then 104906b526288Smrg func_to_tool_file "$output_objdir/$outputname" 104916b526288Smrg 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'` 104926b526288Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 104936b526288Smrg fi 104946b526288Smrg 1049511a29bacSmrg # Now create the wrapper script. 1049611a29bacSmrg func_verbose "creating $output" 1049741b2f0bdSmrg 1049811a29bacSmrg # Quote the relink command for shipping. 1049911a29bacSmrg if test -n "$relink_command"; then 1050011a29bacSmrg # Preserve any variables that may affect compiler behavior 1050111a29bacSmrg for var in $variables_saved_for_relink; do 1050211a29bacSmrg if eval test -z \"\${$var+set}\"; then 1050311a29bacSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1050411a29bacSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1050511a29bacSmrg relink_command="$var=; export $var; $relink_command" 1050641b2f0bdSmrg else 1050711a29bacSmrg func_quote_for_eval "$var_value" 1050811a29bacSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1050941b2f0bdSmrg fi 1051011a29bacSmrg done 1051111a29bacSmrg relink_command="(cd `pwd`; $relink_command)" 1051211a29bacSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1051311a29bacSmrg fi 1051441b2f0bdSmrg 1051511a29bacSmrg # Only actually do things if not in dry run mode. 1051611a29bacSmrg $opt_dry_run || { 1051711a29bacSmrg # win32 will think the script is a binary if it has 1051811a29bacSmrg # a .exe suffix, so we strip it off here. 1051911a29bacSmrg case $output in 1052011a29bacSmrg *.exe) func_stripname '' '.exe' "$output" 1052111a29bacSmrg output=$func_stripname_result ;; 1052211a29bacSmrg esac 1052311a29bacSmrg # test for cygwin because mv fails w/o .exe extensions 1052411a29bacSmrg case $host in 1052511a29bacSmrg *cygwin*) 1052611a29bacSmrg exeext=.exe 1052711a29bacSmrg func_stripname '' '.exe' "$outputname" 1052811a29bacSmrg outputname=$func_stripname_result ;; 1052911a29bacSmrg *) exeext= ;; 1053041b2f0bdSmrg esac 1053111a29bacSmrg case $host in 1053211a29bacSmrg *cygwin* | *mingw* ) 1053311a29bacSmrg func_dirname_and_basename "$output" "" "." 1053411a29bacSmrg output_name=$func_basename_result 1053511a29bacSmrg output_path=$func_dirname_result 105366b526288Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 105376b526288Smrg cwrapper=$output_path/$output_name.exe 1053811a29bacSmrg $RM $cwrappersource $cwrapper 1053911a29bacSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1054011a29bacSmrg 1054111a29bacSmrg func_emit_cwrapperexe_src > $cwrappersource 1054211a29bacSmrg 1054311a29bacSmrg # The wrapper executable is built using the $host compiler, 1054411a29bacSmrg # because it contains $host paths and files. If cross- 1054511a29bacSmrg # compiling, it, like the target executable, must be 1054611a29bacSmrg # executed on the $host or under an emulation environment. 1054711a29bacSmrg $opt_dry_run || { 1054811a29bacSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1054911a29bacSmrg $STRIP $cwrapper 1055011a29bacSmrg } 1055141b2f0bdSmrg 1055211a29bacSmrg # Now, create the wrapper script for func_source use: 1055311a29bacSmrg func_ltwrapper_scriptname $cwrapper 1055411a29bacSmrg $RM $func_ltwrapper_scriptname_result 1055511a29bacSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1055611a29bacSmrg $opt_dry_run || { 1055711a29bacSmrg # note: this script will not be executed, so do not chmod. 105586b526288Smrg if test "x$build" = "x$host"; then 1055911a29bacSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1056011a29bacSmrg else 1056111a29bacSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1056211a29bacSmrg fi 1056311a29bacSmrg } 1056411a29bacSmrg ;; 1056511a29bacSmrg * ) 1056611a29bacSmrg $RM $output 1056711a29bacSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1056841b2f0bdSmrg 1056911a29bacSmrg func_emit_wrapper no > $output 1057011a29bacSmrg chmod +x $output 1057111a29bacSmrg ;; 1057211a29bacSmrg esac 1057311a29bacSmrg } 1057411a29bacSmrg exit $EXIT_SUCCESS 1057511a29bacSmrg ;; 1057611a29bacSmrg esac 1057741b2f0bdSmrg 1057811a29bacSmrg # See if we need to build an old-fashioned archive. 1057911a29bacSmrg for oldlib in $oldlibs; do 1058041b2f0bdSmrg 105816b526288Smrg case $build_libtool_libs in 105826b526288Smrg convenience) 105836b526288Smrg oldobjs="$libobjs_save $symfileobj" 105846b526288Smrg addlibs=$convenience 1058511a29bacSmrg build_libtool_libs=no 105866b526288Smrg ;; 105876b526288Smrg module) 105886b526288Smrg oldobjs=$libobjs_save 105896b526288Smrg addlibs=$old_convenience 105906b526288Smrg build_libtool_libs=no 105916b526288Smrg ;; 105926b526288Smrg *) 1059311a29bacSmrg oldobjs="$old_deplibs $non_pic_objects" 105946b526288Smrg $preload && test -f "$symfileobj" \ 105956b526288Smrg && func_append oldobjs " $symfileobj" 105966b526288Smrg addlibs=$old_convenience 105976b526288Smrg ;; 105986b526288Smrg esac 1059941b2f0bdSmrg 1060011a29bacSmrg if test -n "$addlibs"; then 106016b526288Smrg gentop=$output_objdir/${outputname}x 106026b526288Smrg func_append generated " $gentop" 1060341b2f0bdSmrg 1060411a29bacSmrg func_extract_archives $gentop $addlibs 106056b526288Smrg func_append oldobjs " $func_extract_archives_result" 1060611a29bacSmrg fi 1060741b2f0bdSmrg 1060811a29bacSmrg # Do each command in the archive commands. 106096b526288Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1061011a29bacSmrg cmds=$old_archive_from_new_cmds 1061111a29bacSmrg else 1061241b2f0bdSmrg 1061311a29bacSmrg # Add any objects from preloaded convenience libraries 1061411a29bacSmrg if test -n "$dlprefiles"; then 106156b526288Smrg gentop=$output_objdir/${outputname}x 106166b526288Smrg func_append generated " $gentop" 1061741b2f0bdSmrg 1061811a29bacSmrg func_extract_archives $gentop $dlprefiles 106196b526288Smrg func_append oldobjs " $func_extract_archives_result" 1062011a29bacSmrg fi 1062141b2f0bdSmrg 1062211a29bacSmrg # POSIX demands no paths to be encoded in archives. We have 1062311a29bacSmrg # to avoid creating archives with duplicate basenames if we 1062411a29bacSmrg # might have to extract them afterwards, e.g., when creating a 1062511a29bacSmrg # static archive out of a convenience library, or when linking 1062611a29bacSmrg # the entirety of a libtool archive into another (currently 1062711a29bacSmrg # not supported by libtool). 1062811a29bacSmrg if (for obj in $oldobjs 1062911a29bacSmrg do 1063011a29bacSmrg func_basename "$obj" 1063111a29bacSmrg $ECHO "$func_basename_result" 1063211a29bacSmrg done | sort | sort -uc >/dev/null 2>&1); then 1063311a29bacSmrg : 1063411a29bacSmrg else 1063511a29bacSmrg echo "copying selected object files to avoid basename conflicts..." 106366b526288Smrg gentop=$output_objdir/${outputname}x 106376b526288Smrg func_append generated " $gentop" 1063811a29bacSmrg func_mkdir_p "$gentop" 1063911a29bacSmrg save_oldobjs=$oldobjs 1064011a29bacSmrg oldobjs= 1064111a29bacSmrg counter=1 1064211a29bacSmrg for obj in $save_oldobjs 1064311a29bacSmrg do 1064411a29bacSmrg func_basename "$obj" 106456b526288Smrg objbase=$func_basename_result 1064611a29bacSmrg case " $oldobjs " in 1064711a29bacSmrg " ") oldobjs=$obj ;; 1064811a29bacSmrg *[\ /]"$objbase "*) 1064911a29bacSmrg while :; do 1065011a29bacSmrg # Make sure we don't pick an alternate name that also 1065111a29bacSmrg # overlaps. 1065211a29bacSmrg newobj=lt$counter-$objbase 1065311a29bacSmrg func_arith $counter + 1 1065411a29bacSmrg counter=$func_arith_result 1065511a29bacSmrg case " $oldobjs " in 1065611a29bacSmrg *[\ /]"$newobj "*) ;; 1065711a29bacSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1065811a29bacSmrg esac 1065911a29bacSmrg done 1066011a29bacSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 106616b526288Smrg func_append oldobjs " $gentop/$newobj" 1066211a29bacSmrg ;; 106636b526288Smrg *) func_append oldobjs " $obj" ;; 1066411a29bacSmrg esac 1066541b2f0bdSmrg done 1066641b2f0bdSmrg fi 106676b526288Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 106686b526288Smrg tool_oldlib=$func_to_tool_file_result 1066911a29bacSmrg eval cmds=\"$old_archive_cmds\" 1067041b2f0bdSmrg 1067111a29bacSmrg func_len " $cmds" 1067211a29bacSmrg len=$func_len_result 1067311a29bacSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1067411a29bacSmrg cmds=$old_archive_cmds 106756b526288Smrg elif test -n "$archiver_list_spec"; then 106766b526288Smrg func_verbose "using command file archive linking..." 106776b526288Smrg for obj in $oldobjs 106786b526288Smrg do 106796b526288Smrg func_to_tool_file "$obj" 106806b526288Smrg $ECHO "$func_to_tool_file_result" 106816b526288Smrg done > $output_objdir/$libname.libcmd 106826b526288Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 106836b526288Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 106846b526288Smrg cmds=$old_archive_cmds 1068511a29bacSmrg else 1068611a29bacSmrg # the command line is too long to link in one step, link in parts 1068711a29bacSmrg func_verbose "using piecewise archive linking..." 1068811a29bacSmrg save_RANLIB=$RANLIB 1068911a29bacSmrg RANLIB=: 1069011a29bacSmrg objlist= 1069111a29bacSmrg concat_cmds= 1069211a29bacSmrg save_oldobjs=$oldobjs 1069311a29bacSmrg oldobjs= 1069411a29bacSmrg # Is there a better way of finding the last object in the list? 1069511a29bacSmrg for obj in $save_oldobjs 1069611a29bacSmrg do 1069711a29bacSmrg last_oldobj=$obj 1069811a29bacSmrg done 1069911a29bacSmrg eval test_cmds=\"$old_archive_cmds\" 1070011a29bacSmrg func_len " $test_cmds" 1070111a29bacSmrg len0=$func_len_result 1070211a29bacSmrg len=$len0 1070311a29bacSmrg for obj in $save_oldobjs 1070411a29bacSmrg do 1070511a29bacSmrg func_len " $obj" 1070611a29bacSmrg func_arith $len + $func_len_result 1070711a29bacSmrg len=$func_arith_result 1070811a29bacSmrg func_append objlist " $obj" 1070911a29bacSmrg if test "$len" -lt "$max_cmd_len"; then 1071011a29bacSmrg : 1071111a29bacSmrg else 1071211a29bacSmrg # the above command should be used before it gets too long 1071311a29bacSmrg oldobjs=$objlist 107146b526288Smrg if test "$obj" = "$last_oldobj"; then 1071511a29bacSmrg RANLIB=$save_RANLIB 1071611a29bacSmrg fi 1071711a29bacSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 107186b526288Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1071911a29bacSmrg objlist= 1072011a29bacSmrg len=$len0 1072111a29bacSmrg fi 1072211a29bacSmrg done 1072311a29bacSmrg RANLIB=$save_RANLIB 1072411a29bacSmrg oldobjs=$objlist 107256b526288Smrg if test -z "$oldobjs"; then 1072611a29bacSmrg eval cmds=\"\$concat_cmds\" 1072711a29bacSmrg else 1072811a29bacSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1072911a29bacSmrg fi 1073011a29bacSmrg fi 1073111a29bacSmrg fi 1073211a29bacSmrg func_execute_cmds "$cmds" 'exit $?' 1073341b2f0bdSmrg done 1073441b2f0bdSmrg 1073511a29bacSmrg test -n "$generated" && \ 1073611a29bacSmrg func_show_eval "${RM}r$generated" 1073741b2f0bdSmrg 1073811a29bacSmrg # Now create the libtool archive. 1073911a29bacSmrg case $output in 1074011a29bacSmrg *.la) 1074111a29bacSmrg old_library= 107426b526288Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 1074311a29bacSmrg func_verbose "creating $output" 1074441b2f0bdSmrg 1074511a29bacSmrg # Preserve any variables that may affect compiler behavior 1074611a29bacSmrg for var in $variables_saved_for_relink; do 1074711a29bacSmrg if eval test -z \"\${$var+set}\"; then 1074811a29bacSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1074911a29bacSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1075011a29bacSmrg relink_command="$var=; export $var; $relink_command" 1075141b2f0bdSmrg else 1075211a29bacSmrg func_quote_for_eval "$var_value" 1075311a29bacSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1075441b2f0bdSmrg fi 1075511a29bacSmrg done 1075611a29bacSmrg # Quote the link command for shipping. 107576b526288Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1075811a29bacSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 107596b526288Smrg if test yes = "$hardcode_automatic"; then 1076011a29bacSmrg relink_command= 1076111a29bacSmrg fi 1076241b2f0bdSmrg 1076311a29bacSmrg # Only create the output if not a dry run. 1076411a29bacSmrg $opt_dry_run || { 1076511a29bacSmrg for installed in no yes; do 107666b526288Smrg if test yes = "$installed"; then 1076711a29bacSmrg if test -z "$install_libdir"; then 1076811a29bacSmrg break 1076911a29bacSmrg fi 107706b526288Smrg output=$output_objdir/${outputname}i 1077111a29bacSmrg # Replace all uninstalled libtool libraries with the installed ones 1077211a29bacSmrg newdependency_libs= 1077311a29bacSmrg for deplib in $dependency_libs; do 1077411a29bacSmrg case $deplib in 1077511a29bacSmrg *.la) 1077611a29bacSmrg func_basename "$deplib" 107776b526288Smrg name=$func_basename_result 107786b526288Smrg func_resolve_sysroot "$deplib" 107796b526288Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1078011a29bacSmrg test -z "$libdir" && \ 107816b526288Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 107826b526288Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 107836b526288Smrg ;; 107846b526288Smrg -L*) 107856b526288Smrg func_stripname -L '' "$deplib" 107866b526288Smrg func_replace_sysroot "$func_stripname_result" 107876b526288Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1078811a29bacSmrg ;; 107896b526288Smrg -R*) 107906b526288Smrg func_stripname -R '' "$deplib" 107916b526288Smrg func_replace_sysroot "$func_stripname_result" 107926b526288Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 107936b526288Smrg ;; 107946b526288Smrg *) func_append newdependency_libs " $deplib" ;; 1079511a29bacSmrg esac 1079611a29bacSmrg done 107976b526288Smrg dependency_libs=$newdependency_libs 1079811a29bacSmrg newdlfiles= 1079911a29bacSmrg 1080011a29bacSmrg for lib in $dlfiles; do 1080111a29bacSmrg case $lib in 1080211a29bacSmrg *.la) 1080311a29bacSmrg func_basename "$lib" 108046b526288Smrg name=$func_basename_result 108056b526288Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1080611a29bacSmrg test -z "$libdir" && \ 108076b526288Smrg func_fatal_error "'$lib' is not a valid libtool archive" 108086b526288Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1080911a29bacSmrg ;; 108106b526288Smrg *) func_append newdlfiles " $lib" ;; 1081111a29bacSmrg esac 1081211a29bacSmrg done 108136b526288Smrg dlfiles=$newdlfiles 1081411a29bacSmrg newdlprefiles= 1081511a29bacSmrg for lib in $dlprefiles; do 1081611a29bacSmrg case $lib in 1081711a29bacSmrg *.la) 1081811a29bacSmrg # Only pass preopened files to the pseudo-archive (for 1081911a29bacSmrg # eventual linking with the app. that links it) if we 1082011a29bacSmrg # didn't already link the preopened objects directly into 1082111a29bacSmrg # the library: 1082211a29bacSmrg func_basename "$lib" 108236b526288Smrg name=$func_basename_result 108246b526288Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1082511a29bacSmrg test -z "$libdir" && \ 108266b526288Smrg func_fatal_error "'$lib' is not a valid libtool archive" 108276b526288Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1082811a29bacSmrg ;; 1082911a29bacSmrg esac 1083011a29bacSmrg done 108316b526288Smrg dlprefiles=$newdlprefiles 1083211a29bacSmrg else 1083311a29bacSmrg newdlfiles= 1083411a29bacSmrg for lib in $dlfiles; do 1083511a29bacSmrg case $lib in 108366b526288Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1083711a29bacSmrg *) abs=`pwd`"/$lib" ;; 1083811a29bacSmrg esac 108396b526288Smrg func_append newdlfiles " $abs" 1084011a29bacSmrg done 108416b526288Smrg dlfiles=$newdlfiles 1084211a29bacSmrg newdlprefiles= 1084311a29bacSmrg for lib in $dlprefiles; do 1084411a29bacSmrg case $lib in 108456b526288Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1084611a29bacSmrg *) abs=`pwd`"/$lib" ;; 1084711a29bacSmrg esac 108486b526288Smrg func_append newdlprefiles " $abs" 1084911a29bacSmrg done 108506b526288Smrg dlprefiles=$newdlprefiles 1085111a29bacSmrg fi 1085211a29bacSmrg $RM $output 1085311a29bacSmrg # place dlname in correct position for cygwin 1085411a29bacSmrg # In fact, it would be nice if we could use this code for all target 1085511a29bacSmrg # systems that can't hard-code library paths into their executables 1085611a29bacSmrg # and that have no shared library path variable independent of PATH, 1085711a29bacSmrg # but it turns out we can't easily determine that from inspecting 1085811a29bacSmrg # libtool variables, so we have to hard-code the OSs to which it 1085911a29bacSmrg # applies here; at the moment, that means platforms that use the PE 1086011a29bacSmrg # object format with DLL files. See the long comment at the top of 1086111a29bacSmrg # tests/bindir.at for full details. 1086211a29bacSmrg tdlname=$dlname 1086311a29bacSmrg case $host,$output,$installed,$module,$dlname in 1086411a29bacSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1086511a29bacSmrg # If a -bindir argument was supplied, place the dll there. 108666b526288Smrg if test -n "$bindir"; then 1086711a29bacSmrg func_relative_path "$install_libdir" "$bindir" 108686b526288Smrg tdlname=$func_relative_path_result/$dlname 1086911a29bacSmrg else 1087011a29bacSmrg # Otherwise fall back on heuristic. 1087111a29bacSmrg tdlname=../bin/$dlname 1087211a29bacSmrg fi 1087311a29bacSmrg ;; 1087411a29bacSmrg esac 1087511a29bacSmrg $ECHO > $output "\ 1087611a29bacSmrg# $outputname - a libtool library file 108776b526288Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1087811a29bacSmrg# 1087911a29bacSmrg# Please DO NOT delete this file! 1088011a29bacSmrg# It is necessary for linking the library. 1088141b2f0bdSmrg 1088211a29bacSmrg# The name that we can dlopen(3). 1088311a29bacSmrgdlname='$tdlname' 1088441b2f0bdSmrg 1088511a29bacSmrg# Names of this library. 1088611a29bacSmrglibrary_names='$library_names' 1088741b2f0bdSmrg 1088811a29bacSmrg# The name of the static archive. 1088911a29bacSmrgold_library='$old_library' 1089041b2f0bdSmrg 108916b526288Smrg# Linker flags that cannot go in dependency_libs. 1089211a29bacSmrginherited_linker_flags='$new_inherited_linker_flags' 1089341b2f0bdSmrg 1089411a29bacSmrg# Libraries that this one depends upon. 1089511a29bacSmrgdependency_libs='$dependency_libs' 1089641b2f0bdSmrg 1089711a29bacSmrg# Names of additional weak libraries provided by this library 1089811a29bacSmrgweak_library_names='$weak_libs' 1089941b2f0bdSmrg 1090011a29bacSmrg# Version information for $libname. 1090111a29bacSmrgcurrent=$current 1090211a29bacSmrgage=$age 1090311a29bacSmrgrevision=$revision 1090441b2f0bdSmrg 1090511a29bacSmrg# Is this an already installed library? 1090611a29bacSmrginstalled=$installed 1090741b2f0bdSmrg 1090811a29bacSmrg# Should we warn about portability when linking against -modules? 1090911a29bacSmrgshouldnotlink=$module 1091041b2f0bdSmrg 1091111a29bacSmrg# Files to dlopen/dlpreopen 1091211a29bacSmrgdlopen='$dlfiles' 1091311a29bacSmrgdlpreopen='$dlprefiles' 1091441b2f0bdSmrg 1091511a29bacSmrg# Directory that this library needs to be installed in: 1091611a29bacSmrglibdir='$install_libdir'" 109176b526288Smrg if test no,yes = "$installed,$need_relink"; then 1091811a29bacSmrg $ECHO >> $output "\ 1091911a29bacSmrgrelink_command=\"$relink_command\"" 1092011a29bacSmrg fi 1092111a29bacSmrg done 1092211a29bacSmrg } 1092341b2f0bdSmrg 1092411a29bacSmrg # Do a symbolic link so that the libtool archive can be found in 1092511a29bacSmrg # LD_LIBRARY_PATH before the program is installed. 1092611a29bacSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1092711a29bacSmrg ;; 1092811a29bacSmrg esac 1092911a29bacSmrg exit $EXIT_SUCCESS 1093011a29bacSmrg} 1093141b2f0bdSmrg 109326b526288Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 109336b526288Smrg func_mode_link ${1+"$@"} 109346b526288Smrgfi 1093541b2f0bdSmrg 1093641b2f0bdSmrg 1093711a29bacSmrg# func_mode_uninstall arg... 1093811a29bacSmrgfunc_mode_uninstall () 1093911a29bacSmrg{ 109406b526288Smrg $debug_cmd 109416b526288Smrg 109426b526288Smrg RM=$nonopt 1094341b2f0bdSmrg files= 109446b526288Smrg rmforce=false 1094541b2f0bdSmrg exit_status=0 1094641b2f0bdSmrg 1094741b2f0bdSmrg # This variable tells wrapper scripts just to set variables rather 1094841b2f0bdSmrg # than running their programs. 109496b526288Smrg libtool_install_magic=$magic 1095041b2f0bdSmrg 1095141b2f0bdSmrg for arg 1095241b2f0bdSmrg do 1095341b2f0bdSmrg case $arg in 109546b526288Smrg -f) func_append RM " $arg"; rmforce=: ;; 109556b526288Smrg -*) func_append RM " $arg" ;; 109566b526288Smrg *) func_append files " $arg" ;; 1095741b2f0bdSmrg esac 1095841b2f0bdSmrg done 1095941b2f0bdSmrg 1096011a29bacSmrg test -z "$RM" && \ 1096111a29bacSmrg func_fatal_help "you must specify an RM program" 1096241b2f0bdSmrg 1096341b2f0bdSmrg rmdirs= 1096441b2f0bdSmrg 1096541b2f0bdSmrg for file in $files; do 1096611a29bacSmrg func_dirname "$file" "" "." 109676b526288Smrg dir=$func_dirname_result 109686b526288Smrg if test . = "$dir"; then 109696b526288Smrg odir=$objdir 1097041b2f0bdSmrg else 109716b526288Smrg odir=$dir/$objdir 1097241b2f0bdSmrg fi 1097311a29bacSmrg func_basename "$file" 109746b526288Smrg name=$func_basename_result 109756b526288Smrg test uninstall = "$opt_mode" && odir=$dir 1097641b2f0bdSmrg 109776b526288Smrg # Remember odir for removal later, being careful to avoid duplicates 109786b526288Smrg if test clean = "$opt_mode"; then 1097941b2f0bdSmrg case " $rmdirs " in 109806b526288Smrg *" $odir "*) ;; 109816b526288Smrg *) func_append rmdirs " $odir" ;; 1098241b2f0bdSmrg esac 1098341b2f0bdSmrg fi 1098441b2f0bdSmrg 1098541b2f0bdSmrg # Don't error if the file doesn't exist and rm -f was used. 1098611a29bacSmrg if { test -L "$file"; } >/dev/null 2>&1 || 1098711a29bacSmrg { test -h "$file"; } >/dev/null 2>&1 || 1098811a29bacSmrg test -f "$file"; then 1098941b2f0bdSmrg : 1099041b2f0bdSmrg elif test -d "$file"; then 1099141b2f0bdSmrg exit_status=1 1099241b2f0bdSmrg continue 109936b526288Smrg elif $rmforce; then 1099441b2f0bdSmrg continue 1099541b2f0bdSmrg fi 1099641b2f0bdSmrg 109976b526288Smrg rmfiles=$file 1099841b2f0bdSmrg 1099941b2f0bdSmrg case $name in 1100041b2f0bdSmrg *.la) 1100141b2f0bdSmrg # Possibly a libtool archive, so verify it. 1100211a29bacSmrg if func_lalib_p "$file"; then 1100311a29bacSmrg func_source $dir/$name 1100441b2f0bdSmrg 1100541b2f0bdSmrg # Delete the libtool libraries and symlinks. 1100641b2f0bdSmrg for n in $library_names; do 110076b526288Smrg func_append rmfiles " $odir/$n" 1100841b2f0bdSmrg done 110096b526288Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1101041b2f0bdSmrg 110116b526288Smrg case $opt_mode in 1101241b2f0bdSmrg clean) 110136b526288Smrg case " $library_names " in 1101441b2f0bdSmrg *" $dlname "*) ;; 110156b526288Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1101641b2f0bdSmrg esac 110176b526288Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1101841b2f0bdSmrg ;; 1101941b2f0bdSmrg uninstall) 1102041b2f0bdSmrg if test -n "$library_names"; then 1102141b2f0bdSmrg # Do each command in the postuninstall commands. 110226b526288Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1102341b2f0bdSmrg fi 1102441b2f0bdSmrg 1102541b2f0bdSmrg if test -n "$old_library"; then 1102641b2f0bdSmrg # Do each command in the old_postuninstall commands. 110276b526288Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1102841b2f0bdSmrg fi 1102941b2f0bdSmrg # FIXME: should reinstall the best remaining shared library. 1103041b2f0bdSmrg ;; 1103141b2f0bdSmrg esac 1103241b2f0bdSmrg fi 1103341b2f0bdSmrg ;; 1103441b2f0bdSmrg 1103541b2f0bdSmrg *.lo) 1103641b2f0bdSmrg # Possibly a libtool object, so verify it. 1103711a29bacSmrg if func_lalib_p "$file"; then 1103841b2f0bdSmrg 1103941b2f0bdSmrg # Read the .lo file 1104011a29bacSmrg func_source $dir/$name 1104141b2f0bdSmrg 1104241b2f0bdSmrg # Add PIC object to the list of files to remove. 110436b526288Smrg if test -n "$pic_object" && test none != "$pic_object"; then 110446b526288Smrg func_append rmfiles " $dir/$pic_object" 1104541b2f0bdSmrg fi 1104641b2f0bdSmrg 1104741b2f0bdSmrg # Add non-PIC object to the list of files to remove. 110486b526288Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 110496b526288Smrg func_append rmfiles " $dir/$non_pic_object" 1105041b2f0bdSmrg fi 1105141b2f0bdSmrg fi 1105241b2f0bdSmrg ;; 1105341b2f0bdSmrg 1105441b2f0bdSmrg *) 110556b526288Smrg if test clean = "$opt_mode"; then 1105641b2f0bdSmrg noexename=$name 1105741b2f0bdSmrg case $file in 1105841b2f0bdSmrg *.exe) 1105911a29bacSmrg func_stripname '' '.exe' "$file" 1106011a29bacSmrg file=$func_stripname_result 1106111a29bacSmrg func_stripname '' '.exe' "$name" 1106211a29bacSmrg noexename=$func_stripname_result 1106341b2f0bdSmrg # $file with .exe has already been added to rmfiles, 1106441b2f0bdSmrg # add $file without .exe 110656b526288Smrg func_append rmfiles " $file" 1106641b2f0bdSmrg ;; 1106741b2f0bdSmrg esac 1106841b2f0bdSmrg # Do a test to see if this is a libtool program. 1106911a29bacSmrg if func_ltwrapper_p "$file"; then 1107011a29bacSmrg if func_ltwrapper_executable_p "$file"; then 1107111a29bacSmrg func_ltwrapper_scriptname "$file" 1107211a29bacSmrg relink_command= 1107311a29bacSmrg func_source $func_ltwrapper_scriptname_result 110746b526288Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1107511a29bacSmrg else 1107611a29bacSmrg relink_command= 1107711a29bacSmrg func_source $dir/$noexename 1107811a29bacSmrg fi 1107941b2f0bdSmrg 1108041b2f0bdSmrg # note $name still contains .exe if it was in $file originally 1108141b2f0bdSmrg # as does the version of $file that was added into $rmfiles 110826b526288Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 110836b526288Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 110846b526288Smrg func_append rmfiles " $odir/lt-$name" 1108541b2f0bdSmrg fi 110866b526288Smrg if test "X$noexename" != "X$name"; then 110876b526288Smrg func_append rmfiles " $odir/lt-$noexename.c" 1108841b2f0bdSmrg fi 1108941b2f0bdSmrg fi 1109041b2f0bdSmrg fi 1109141b2f0bdSmrg ;; 1109241b2f0bdSmrg esac 1109311a29bacSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1109441b2f0bdSmrg done 1109541b2f0bdSmrg 110966b526288Smrg # Try to remove the $objdir's in the directories where we deleted files 1109741b2f0bdSmrg for dir in $rmdirs; do 1109841b2f0bdSmrg if test -d "$dir"; then 1109911a29bacSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1110041b2f0bdSmrg fi 1110141b2f0bdSmrg done 1110241b2f0bdSmrg 1110341b2f0bdSmrg exit $exit_status 1110411a29bacSmrg} 1110541b2f0bdSmrg 111066b526288Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 111076b526288Smrg func_mode_uninstall ${1+"$@"} 111086b526288Smrgfi 1110941b2f0bdSmrg 111106b526288Smrgtest -z "$opt_mode" && { 111116b526288Smrg help=$generic_help 1111211a29bacSmrg func_fatal_help "you must specify a MODE" 1111311a29bacSmrg} 1111411a29bacSmrg 1111511a29bacSmrgtest -z "$exec_cmd" && \ 111166b526288Smrg func_fatal_help "invalid operation mode '$opt_mode'" 1111741b2f0bdSmrg 1111841b2f0bdSmrgif test -n "$exec_cmd"; then 1111911a29bacSmrg eval exec "$exec_cmd" 1112041b2f0bdSmrg exit $EXIT_FAILURE 1112141b2f0bdSmrgfi 1112241b2f0bdSmrg 1112311a29bacSmrgexit $exit_status 1112441b2f0bdSmrg 1112541b2f0bdSmrg 1112641b2f0bdSmrg# The TAGs below are defined such that we never get into a situation 111276b526288Smrg# where we disable both kinds of libraries. Given conflicting 1112841b2f0bdSmrg# choices, we go for a static library, that is the most portable, 1112941b2f0bdSmrg# since we can't tell whether shared libraries were disabled because 1113041b2f0bdSmrg# the user asked for that or because the platform doesn't support 1113141b2f0bdSmrg# them. This is particularly important on AIX, because we don't 1113241b2f0bdSmrg# support having both static and shared libraries enabled at the same 1113341b2f0bdSmrg# time on that platform, so we default to a shared-only configuration. 1113441b2f0bdSmrg# If a disable-shared tag is given, we'll fallback to a static-only 1113541b2f0bdSmrg# configuration. But we'll never go from static-only to shared-only. 1113641b2f0bdSmrg 1113741b2f0bdSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1113811a29bacSmrgbuild_libtool_libs=no 1113911a29bacSmrgbuild_old_libs=yes 1114041b2f0bdSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 1114141b2f0bdSmrg 1114241b2f0bdSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1114311a29bacSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1114441b2f0bdSmrg# ### END LIBTOOL TAG CONFIG: disable-static 1114541b2f0bdSmrg 1114641b2f0bdSmrg# Local Variables: 1114741b2f0bdSmrg# mode:shell-script 1114841b2f0bdSmrg# sh-indentation:2 1114941b2f0bdSmrg# End: 11150