ltmain.sh revision 8292847c
18292847cSmrg#! /bin/sh 28292847cSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 38292847cSmrg## by inline-source v2014-01-03.01 4c2939121Smrg 58292847cSmrg# libtool (GNU libtool) 2.4.6 68292847cSmrg# Provide generalized library-building support services. 7c2939121Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8c2939121Smrg 98292847cSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10c2939121Smrg# This is free software; see the source for copying conditions. There is NO 11c2939121Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12c2939121Smrg 13c2939121Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14c76ae52dSmrg# it under the terms of the GNU General Public License as published by 15c76ae52dSmrg# the Free Software Foundation; either version 2 of the License, or 16c76ae52dSmrg# (at your option) any later version. 17c76ae52dSmrg# 18c2939121Smrg# As a special exception to the GNU General Public License, 19c2939121Smrg# if you distribute this file as part of a program or library that 20c2939121Smrg# is built using GNU Libtool, you may include this file under the 21c2939121Smrg# same distribution terms that you use for the rest of that program. 22c2939121Smrg# 23c2939121Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24c76ae52dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25c76ae52dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26c76ae52dSmrg# General Public License for more details. 27c76ae52dSmrg# 28c76ae52dSmrg# You should have received a copy of the GNU General Public License 298292847cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30c76ae52dSmrg 31c76ae52dSmrg 32c2939121SmrgPROGRAM=libtool 33c76ae52dSmrgPACKAGE=libtool 348292847cSmrgVERSION=2.4.6 358292847cSmrgpackage_revision=2.4.6 360d590c07Smrg 378292847cSmrg 388292847cSmrg## ------ ## 398292847cSmrg## Usage. ## 408292847cSmrg## ------ ## 418292847cSmrg 428292847cSmrg# Run './libtool --help' for help with using this script from the 438292847cSmrg# command line. 448292847cSmrg 458292847cSmrg 468292847cSmrg## ------------------------------- ## 478292847cSmrg## User overridable command paths. ## 488292847cSmrg## ------------------------------- ## 498292847cSmrg 508292847cSmrg# After configure completes, it has a better idea of some of the 518292847cSmrg# shell tools we need than the defaults used by the functions shared 528292847cSmrg# with bootstrap, so set those here where they can still be over- 538292847cSmrg# ridden by the user, but otherwise take precedence. 548292847cSmrg 558292847cSmrg: ${AUTOCONF="autoconf"} 568292847cSmrg: ${AUTOMAKE="automake"} 578292847cSmrg 588292847cSmrg 598292847cSmrg## -------------------------- ## 608292847cSmrg## Source external libraries. ## 618292847cSmrg## -------------------------- ## 628292847cSmrg 638292847cSmrg# Much of our low-level functionality needs to be sourced from external 648292847cSmrg# libraries, which are installed to $pkgauxdir. 658292847cSmrg 668292847cSmrg# Set a version string for this script. 678292847cSmrgscriptversion=2015-01-20.17; # UTC 688292847cSmrg 698292847cSmrg# General shell script boiler plate, and helper functions. 708292847cSmrg# Written by Gary V. Vaughan, 2004 718292847cSmrg 728292847cSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 738292847cSmrg# This is free software; see the source for copying conditions. There is NO 748292847cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 758292847cSmrg 768292847cSmrg# This program is free software; you can redistribute it and/or modify 778292847cSmrg# it under the terms of the GNU General Public License as published by 788292847cSmrg# the Free Software Foundation; either version 3 of the License, or 798292847cSmrg# (at your option) any later version. 808292847cSmrg 818292847cSmrg# As a special exception to the GNU General Public License, if you distribute 828292847cSmrg# this file as part of a program or library that is built using GNU Libtool, 838292847cSmrg# you may include this file under the same distribution terms that you use 848292847cSmrg# for the rest of that program. 858292847cSmrg 868292847cSmrg# This program is distributed in the hope that it will be useful, 878292847cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 888292847cSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 898292847cSmrg# General Public License for more details. 908292847cSmrg 918292847cSmrg# You should have received a copy of the GNU General Public License 928292847cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 938292847cSmrg 948292847cSmrg# Please report bugs or propose patches to gary@gnu.org. 958292847cSmrg 968292847cSmrg 978292847cSmrg## ------ ## 988292847cSmrg## Usage. ## 998292847cSmrg## ------ ## 1008292847cSmrg 1018292847cSmrg# Evaluate this file near the top of your script to gain access to 1028292847cSmrg# the functions and variables defined here: 1038292847cSmrg# 1048292847cSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 1058292847cSmrg# 1068292847cSmrg# If you need to override any of the default environment variable 1078292847cSmrg# settings, do that before evaluating this file. 1088292847cSmrg 1098292847cSmrg 1108292847cSmrg## -------------------- ## 1118292847cSmrg## Shell normalisation. ## 1128292847cSmrg## -------------------- ## 1138292847cSmrg 1148292847cSmrg# Some shells need a little help to be as Bourne compatible as possible. 1158292847cSmrg# Before doing anything else, make sure all that help has been provided! 1168292847cSmrg 1178292847cSmrgDUALCASE=1; export DUALCASE # for MKS sh 1188292847cSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1190d590c07Smrg emulate sh 1200d590c07Smrg NULLCMD=: 1218292847cSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1220d590c07Smrg # is contrary to our usage. Disable this feature. 1230d590c07Smrg alias -g '${1+"$@"}'='"$@"' 124c76ae52dSmrg setopt NO_GLOB_SUBST 1250d590c07Smrgelse 1268292847cSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127c76ae52dSmrgfi 128c76ae52dSmrg 1298292847cSmrg# NLS nuisances: We save the old values in case they are required later. 1308292847cSmrg_G_user_locale= 1318292847cSmrg_G_safe_locale= 1328292847cSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1330d590c07Smrgdo 1348292847cSmrg eval "if test set = \"\${$_G_var+set}\"; then 1358292847cSmrg save_$_G_var=\$$_G_var 1368292847cSmrg $_G_var=C 1378292847cSmrg export $_G_var 1388292847cSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1398292847cSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1400d590c07Smrg fi" 1410d590c07Smrgdone 1420d590c07Smrg 1438292847cSmrg# CDPATH. 1448292847cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145c2939121Smrg 1468292847cSmrg# Make sure IFS has a sensible default 1478292847cSmrgsp=' ' 1488292847cSmrgnl=' 1498292847cSmrg' 1508292847cSmrgIFS="$sp $nl" 1518292847cSmrg 1528292847cSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1538292847cSmrgif test "${PATH_SEPARATOR+set}" != set; then 1548292847cSmrg PATH_SEPARATOR=: 1558292847cSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1568292847cSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1578292847cSmrg PATH_SEPARATOR=';' 1588292847cSmrg } 1598292847cSmrgfi 160c2939121Smrg 161c2939121Smrg 162c2939121Smrg 1638292847cSmrg## ------------------------- ## 1648292847cSmrg## Locate command utilities. ## 1658292847cSmrg## ------------------------- ## 1668292847cSmrg 1678292847cSmrg 1688292847cSmrg# func_executable_p FILE 1698292847cSmrg# ---------------------- 1708292847cSmrg# Check that FILE is an executable regular file. 1718292847cSmrgfunc_executable_p () 1728292847cSmrg{ 1738292847cSmrg test -f "$1" && test -x "$1" 1748292847cSmrg} 1758292847cSmrg 1768292847cSmrg 1778292847cSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1788292847cSmrg# -------------------------------------------- 1798292847cSmrg# Search for either a program that responds to --version with output 1808292847cSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1818292847cSmrg# trying all the directories in PATH with each of the elements of 1828292847cSmrg# PROGS_LIST. 1838292847cSmrg# 1848292847cSmrg# CHECK_FUNC should accept the path to a candidate program, and 1858292847cSmrg# set $func_check_prog_result if it truncates its output less than 1868292847cSmrg# $_G_path_prog_max characters. 1878292847cSmrgfunc_path_progs () 1888292847cSmrg{ 1898292847cSmrg _G_progs_list=$1 1908292847cSmrg _G_check_func=$2 1918292847cSmrg _G_PATH=${3-"$PATH"} 1928292847cSmrg 1938292847cSmrg _G_path_prog_max=0 1948292847cSmrg _G_path_prog_found=false 1958292847cSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 1968292847cSmrg for _G_dir in $_G_PATH; do 1978292847cSmrg IFS=$_G_save_IFS 1988292847cSmrg test -z "$_G_dir" && _G_dir=. 1998292847cSmrg for _G_prog_name in $_G_progs_list; do 2008292847cSmrg for _exeext in '' .EXE; do 2018292847cSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2028292847cSmrg func_executable_p "$_G_path_prog" || continue 2038292847cSmrg case `"$_G_path_prog" --version 2>&1` in 2048292847cSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2058292847cSmrg *) $_G_check_func $_G_path_prog 2068292847cSmrg func_path_progs_result=$func_check_prog_result 2078292847cSmrg ;; 2088292847cSmrg esac 2098292847cSmrg $_G_path_prog_found && break 3 2108292847cSmrg done 2118292847cSmrg done 2128292847cSmrg done 2138292847cSmrg IFS=$_G_save_IFS 2148292847cSmrg test -z "$func_path_progs_result" && { 2158292847cSmrg echo "no acceptable sed could be found in \$PATH" >&2 2168292847cSmrg exit 1 2178292847cSmrg } 2188292847cSmrg} 2198292847cSmrg 2208292847cSmrg 2218292847cSmrg# We want to be able to use the functions in this file before configure 2228292847cSmrg# has figured out where the best binaries are kept, which means we have 2238292847cSmrg# to search for them ourselves - except when the results are already set 2248292847cSmrg# where we skip the searches. 2258292847cSmrg 2268292847cSmrg# Unless the user overrides by setting SED, search the path for either GNU 2278292847cSmrg# sed, or the sed that truncates its output the least. 2288292847cSmrgtest -z "$SED" && { 2298292847cSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2308292847cSmrg for _G_i in 1 2 3 4 5 6 7; do 2318292847cSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2328292847cSmrg done 2338292847cSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2348292847cSmrg _G_sed_script= 2358292847cSmrg 2368292847cSmrg func_check_prog_sed () 2378292847cSmrg { 2388292847cSmrg _G_path_prog=$1 2398292847cSmrg 2408292847cSmrg _G_count=0 2418292847cSmrg printf 0123456789 >conftest.in 2428292847cSmrg while : 2438292847cSmrg do 2448292847cSmrg cat conftest.in conftest.in >conftest.tmp 2458292847cSmrg mv conftest.tmp conftest.in 2468292847cSmrg cp conftest.in conftest.nl 2478292847cSmrg echo '' >> conftest.nl 2488292847cSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2498292847cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2508292847cSmrg _G_count=`expr $_G_count + 1` 2518292847cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2528292847cSmrg # Best one so far, save it but keep looking for a better one 2538292847cSmrg func_check_prog_result=$_G_path_prog 2548292847cSmrg _G_path_prog_max=$_G_count 2558292847cSmrg fi 2568292847cSmrg # 10*(2^10) chars as input seems more than enough 2578292847cSmrg test 10 -lt "$_G_count" && break 2588292847cSmrg done 2598292847cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2608292847cSmrg } 2618292847cSmrg 2628292847cSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 2638292847cSmrg rm -f conftest.sed 2648292847cSmrg SED=$func_path_progs_result 2658292847cSmrg} 2668292847cSmrg 2678292847cSmrg 2688292847cSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2698292847cSmrg# grep, or the grep that truncates its output the least. 2708292847cSmrgtest -z "$GREP" && { 2718292847cSmrg func_check_prog_grep () 2728292847cSmrg { 2738292847cSmrg _G_path_prog=$1 2748292847cSmrg 2758292847cSmrg _G_count=0 2768292847cSmrg _G_path_prog_max=0 2778292847cSmrg printf 0123456789 >conftest.in 2788292847cSmrg while : 2798292847cSmrg do 2808292847cSmrg cat conftest.in conftest.in >conftest.tmp 2818292847cSmrg mv conftest.tmp conftest.in 2828292847cSmrg cp conftest.in conftest.nl 2838292847cSmrg echo 'GREP' >> conftest.nl 2848292847cSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2858292847cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2868292847cSmrg _G_count=`expr $_G_count + 1` 2878292847cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2888292847cSmrg # Best one so far, save it but keep looking for a better one 2898292847cSmrg func_check_prog_result=$_G_path_prog 2908292847cSmrg _G_path_prog_max=$_G_count 2918292847cSmrg fi 2928292847cSmrg # 10*(2^10) chars as input seems more than enough 2938292847cSmrg test 10 -lt "$_G_count" && break 2948292847cSmrg done 2958292847cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2968292847cSmrg } 2978292847cSmrg 2988292847cSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 2998292847cSmrg GREP=$func_path_progs_result 3008292847cSmrg} 3018292847cSmrg 3028292847cSmrg 3038292847cSmrg## ------------------------------- ## 3048292847cSmrg## User overridable command paths. ## 3058292847cSmrg## ------------------------------- ## 3068292847cSmrg 3078292847cSmrg# All uppercase variable names are used for environment variables. These 3088292847cSmrg# variables can be overridden by the user before calling a script that 3098292847cSmrg# uses them if a suitable command of that name is not already available 3108292847cSmrg# in the command search PATH. 311c2939121Smrg 312c2939121Smrg: ${CP="cp -f"} 3138292847cSmrg: ${ECHO="printf %s\n"} 3148292847cSmrg: ${EGREP="$GREP -E"} 3158292847cSmrg: ${FGREP="$GREP -F"} 3168292847cSmrg: ${LN_S="ln -s"} 317c2939121Smrg: ${MAKE="make"} 318c2939121Smrg: ${MKDIR="mkdir"} 319c2939121Smrg: ${MV="mv -f"} 320c2939121Smrg: ${RM="rm -f"} 321c2939121Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322c76ae52dSmrg 323c2939121Smrg 3248292847cSmrg## -------------------- ## 3258292847cSmrg## Useful sed snippets. ## 3268292847cSmrg## -------------------- ## 3272836776bSmrg 3288292847cSmrgsed_dirname='s|/[^/]*$||' 3298292847cSmrgsed_basename='s|^.*/||' 3302836776bSmrg 3318292847cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3328292847cSmrg# metacharacters that are still active within double-quoted strings. 3338292847cSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3342836776bSmrg 3358292847cSmrg# Same as above, but do not quote variable references. 3368292847cSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3372836776bSmrg 3388292847cSmrg# Sed substitution that turns a string into a regex matching for the 3398292847cSmrg# string literally. 3408292847cSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3412836776bSmrg 3428292847cSmrg# Sed substitution that converts a w32 file name or path 3438292847cSmrg# that contains forward slashes, into one that contains 3448292847cSmrg# (escaped) backslashes. A very naive implementation. 3458292847cSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3468292847cSmrg 3478292847cSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3488292847cSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3498292847cSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3508292847cSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3518292847cSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3528292847cSmrg_G_bs='\\' 3538292847cSmrg_G_bs2='\\\\' 3548292847cSmrg_G_bs4='\\\\\\\\' 3558292847cSmrg_G_dollar='\$' 3568292847cSmrgsed_double_backslash="\ 3578292847cSmrg s/$_G_bs4/&\\ 3588292847cSmrg/g 3598292847cSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3608292847cSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3618292847cSmrg s/\n//g" 3622836776bSmrg 363c76ae52dSmrg 3648292847cSmrg## ----------------- ## 3658292847cSmrg## Global variables. ## 3668292847cSmrg## ----------------- ## 367c2939121Smrg 3688292847cSmrg# Except for the global variables explicitly listed below, the following 3698292847cSmrg# functions in the '^func_' namespace, and the '^require_' namespace 3708292847cSmrg# variables initialised in the 'Resource management' section, sourcing 3718292847cSmrg# this file will not pollute your global namespace with anything 3728292847cSmrg# else. There's no portable way to scope variables in Bourne shell 3738292847cSmrg# though, so actually running these functions will sometimes place 3748292847cSmrg# results into a variable named after the function, and often use 3758292847cSmrg# temporary variables in the '^_G_' namespace. If you are careful to 3768292847cSmrg# avoid using those namespaces casually in your sourcing script, things 3778292847cSmrg# should continue to work as you expect. And, of course, you can freely 3788292847cSmrg# overwrite any of the functions or variables defined here before 3798292847cSmrg# calling anything to customize them. 380c2939121Smrg 3818292847cSmrgEXIT_SUCCESS=0 3828292847cSmrgEXIT_FAILURE=1 3838292847cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 3848292847cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385c2939121Smrg 3868292847cSmrg# Allow overriding, eg assuming that you follow the convention of 3878292847cSmrg# putting '$debug_cmd' at the start of all your functions, you can get 3888292847cSmrg# bash to show function call trace with: 3898292847cSmrg# 3908292847cSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 3918292847cSmrgdebug_cmd=${debug_cmd-":"} 3928292847cSmrgexit_cmd=: 393c2939121Smrg 3948292847cSmrg# By convention, finish your script with: 3958292847cSmrg# 3968292847cSmrg# exit $exit_status 3978292847cSmrg# 3988292847cSmrg# so that you can set exit_status to non-zero if you want to indicate 3998292847cSmrg# something went wrong during execution without actually bailing out at 4008292847cSmrg# the point of failure. 4018292847cSmrgexit_status=$EXIT_SUCCESS 402c2939121Smrg 4038292847cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4048292847cSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4058292847cSmrg# the _XPG environment variable is not equal to 1 (one), the special 4068292847cSmrg# positional parameter $0, within a function call, is the name of the 4078292847cSmrg# function. 4088292847cSmrgprogpath=$0 409c2939121Smrg 4108292847cSmrg# The name of this program. 4118292847cSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412c2939121Smrg 4138292847cSmrg# Make sure we have an absolute progpath for reexecution: 414c2939121Smrgcase $progpath in 415c2939121Smrg [\\/]*|[A-Za-z]:\\*) ;; 416c2939121Smrg *[\\/]*) 4178292847cSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418c2939121Smrg progdir=`cd "$progdir" && pwd` 4198292847cSmrg progpath=$progdir/$progname 420c2939121Smrg ;; 421c2939121Smrg *) 4228292847cSmrg _G_IFS=$IFS 4232836776bSmrg IFS=${PATH_SEPARATOR-:} 424c2939121Smrg for progdir in $PATH; do 4258292847cSmrg IFS=$_G_IFS 426c2939121Smrg test -x "$progdir/$progname" && break 427c2939121Smrg done 4288292847cSmrg IFS=$_G_IFS 429c2939121Smrg test -n "$progdir" || progdir=`pwd` 4308292847cSmrg progpath=$progdir/$progname 431c2939121Smrg ;; 432c2939121Smrgesac 433c2939121Smrg 434c2939121Smrg 4358292847cSmrg## ----------------- ## 4368292847cSmrg## Standard options. ## 4378292847cSmrg## ----------------- ## 4382836776bSmrg 4398292847cSmrg# The following options affect the operation of the functions defined 4408292847cSmrg# below, and should be set appropriately depending on run-time para- 4418292847cSmrg# meters passed on the command line. 442c2939121Smrg 443c2939121Smrgopt_dry_run=false 444c2939121Smrgopt_quiet=false 445c2939121Smrgopt_verbose=false 446c2939121Smrg 4478292847cSmrg# Categories 'all' and 'none' are always available. Append any others 4488292847cSmrg# you will pass as the first argument to func_warning from your own 4498292847cSmrg# code. 4508292847cSmrgwarning_categories= 451c2939121Smrg 4528292847cSmrg# By default, display warnings according to 'opt_warning_types'. Set 4538292847cSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4548292847cSmrg# treat the next displayed warning as a fatal error. 4558292847cSmrgwarning_func=func_warn_and_continue 456c2939121Smrg 4578292847cSmrg# Set to 'all' to display all warnings, 'none' to suppress all 4588292847cSmrg# warnings, or a space delimited list of some subset of 4598292847cSmrg# 'warning_categories' to display only the listed warnings. 4608292847cSmrgopt_warning_types=all 461c2939121Smrg 462c2939121Smrg 4638292847cSmrg## -------------------- ## 4648292847cSmrg## Resource management. ## 4658292847cSmrg## -------------------- ## 466c2939121Smrg 4678292847cSmrg# This section contains definitions for functions that each ensure a 4688292847cSmrg# particular resource (a file, or a non-empty configuration variable for 4698292847cSmrg# example) is available, and if appropriate to extract default values 4708292847cSmrg# from pertinent package files. Call them using their associated 4718292847cSmrg# 'require_*' variable to ensure that they are executed, at most, once. 4728292847cSmrg# 4738292847cSmrg# It's entirely deliberate that calling these functions can set 4748292847cSmrg# variables that don't obey the namespace limitations obeyed by the rest 4758292847cSmrg# of this file, in order that that they be as useful as possible to 4768292847cSmrg# callers. 477c2939121Smrg 478c2939121Smrg 4798292847cSmrg# require_term_colors 4808292847cSmrg# ------------------- 4818292847cSmrg# Allow display of bold text on terminals that support it. 4828292847cSmrgrequire_term_colors=func_require_term_colors 4838292847cSmrgfunc_require_term_colors () 484c2939121Smrg{ 4858292847cSmrg $debug_cmd 4868292847cSmrg 4878292847cSmrg test -t 1 && { 4888292847cSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 4898292847cSmrg # precedence, because most terminfo databases neglect to describe 4908292847cSmrg # whether color sequences are supported. 4918292847cSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 4928292847cSmrg 4938292847cSmrg if test 1 = "$USE_ANSI_COLORS"; then 4948292847cSmrg # Standard ANSI escape sequences 4958292847cSmrg tc_reset='[0m' 4968292847cSmrg tc_bold='[1m'; tc_standout='[7m' 4978292847cSmrg tc_red='[31m'; tc_green='[32m' 4988292847cSmrg tc_blue='[34m'; tc_cyan='[36m' 4998292847cSmrg else 5008292847cSmrg # Otherwise trust the terminfo database after all. 5018292847cSmrg test -n "`tput sgr0 2>/dev/null`" && { 5028292847cSmrg tc_reset=`tput sgr0` 5038292847cSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5048292847cSmrg tc_standout=$tc_bold 5058292847cSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5068292847cSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5078292847cSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5088292847cSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5098292847cSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5108292847cSmrg } 5118292847cSmrg fi 5128292847cSmrg } 513c2939121Smrg 5148292847cSmrg require_term_colors=: 515c2939121Smrg} 516c2939121Smrg 517c2939121Smrg 5188292847cSmrg## ----------------- ## 5198292847cSmrg## Function library. ## 5208292847cSmrg## ----------------- ## 5218292847cSmrg 5228292847cSmrg# This section contains a variety of useful functions to call in your 5238292847cSmrg# scripts. Take note of the portable wrappers for features provided by 5248292847cSmrg# some modern shells, which will fall back to slower equivalents on 5258292847cSmrg# less featureful shells. 5268292847cSmrg 5278292847cSmrg 5288292847cSmrg# func_append VAR VALUE 5298292847cSmrg# --------------------- 5308292847cSmrg# Append VALUE onto the existing contents of VAR. 5318292847cSmrg 5328292847cSmrg # We should try to minimise forks, especially on Windows where they are 5338292847cSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5348292847cSmrg # being used: 5358292847cSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5368292847cSmrg : ${_G_HAVE_ARITH_OP="yes"} 5378292847cSmrg : ${_G_HAVE_XSI_OPS="yes"} 5388292847cSmrg # The += operator was introduced in bash 3.1 5398292847cSmrg case $BASH_VERSION in 5408292847cSmrg [12].* | 3.0 | 3.0*) ;; 5418292847cSmrg *) 5428292847cSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5438292847cSmrg ;; 5448292847cSmrg esac 5458292847cSmrg fi 5468292847cSmrg 5478292847cSmrg # _G_HAVE_PLUSEQ_OP 5488292847cSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5498292847cSmrg # useable or anything else if it does not work. 5508292847cSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5518292847cSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5528292847cSmrg && _G_HAVE_PLUSEQ_OP=yes 5538292847cSmrg 5548292847cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5558292847cSmrgthen 5568292847cSmrg # This is an XSI compatible shell, allowing a faster implementation... 5578292847cSmrg eval 'func_append () 5588292847cSmrg { 5598292847cSmrg $debug_cmd 5608292847cSmrg 5618292847cSmrg eval "$1+=\$2" 5628292847cSmrg }' 5638292847cSmrgelse 5648292847cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 5658292847cSmrg func_append () 5668292847cSmrg { 5678292847cSmrg $debug_cmd 5688292847cSmrg 5698292847cSmrg eval "$1=\$$1\$2" 5708292847cSmrg } 5718292847cSmrgfi 5728292847cSmrg 5738292847cSmrg 5748292847cSmrg# func_append_quoted VAR VALUE 5758292847cSmrg# ---------------------------- 5768292847cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 5778292847cSmrg# by a space. 5788292847cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 5798292847cSmrg eval 'func_append_quoted () 5808292847cSmrg { 5818292847cSmrg $debug_cmd 5828292847cSmrg 5838292847cSmrg func_quote_for_eval "$2" 5848292847cSmrg eval "$1+=\\ \$func_quote_for_eval_result" 5858292847cSmrg }' 5868292847cSmrgelse 5878292847cSmrg func_append_quoted () 5888292847cSmrg { 5898292847cSmrg $debug_cmd 5908292847cSmrg 5918292847cSmrg func_quote_for_eval "$2" 5928292847cSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 5938292847cSmrg } 5948292847cSmrgfi 5958292847cSmrg 5968292847cSmrg 5978292847cSmrg# func_append_uniq VAR VALUE 5988292847cSmrg# -------------------------- 5998292847cSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6008292847cSmrg# entries are delimited by the first character of VALUE. For example: 6018292847cSmrg# 6028292847cSmrg# func_append_uniq options " --another-option option-argument" 6038292847cSmrg# 6048292847cSmrg# will only append to $options if " --another-option option-argument " 6058292847cSmrg# is not already present somewhere in $options already (note spaces at 6068292847cSmrg# each end implied by leading space in second argument). 6078292847cSmrgfunc_append_uniq () 6088292847cSmrg{ 6098292847cSmrg $debug_cmd 6108292847cSmrg 6118292847cSmrg eval _G_current_value='`$ECHO $'$1'`' 6128292847cSmrg _G_delim=`expr "$2" : '\(.\)'` 6138292847cSmrg 6148292847cSmrg case $_G_delim$_G_current_value$_G_delim in 6158292847cSmrg *"$2$_G_delim"*) ;; 6168292847cSmrg *) func_append "$@" ;; 6178292847cSmrg esac 6188292847cSmrg} 6198292847cSmrg 6208292847cSmrg 6218292847cSmrg# func_arith TERM... 6228292847cSmrg# ------------------ 6238292847cSmrg# Set func_arith_result to the result of evaluating TERMs. 6248292847cSmrg test -z "$_G_HAVE_ARITH_OP" \ 6258292847cSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6268292847cSmrg && _G_HAVE_ARITH_OP=yes 6278292847cSmrg 6288292847cSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6298292847cSmrg eval 'func_arith () 6308292847cSmrg { 6318292847cSmrg $debug_cmd 6328292847cSmrg 6338292847cSmrg func_arith_result=$(( $* )) 6348292847cSmrg }' 6358292847cSmrgelse 6368292847cSmrg func_arith () 6378292847cSmrg { 6388292847cSmrg $debug_cmd 6398292847cSmrg 6408292847cSmrg func_arith_result=`expr "$@"` 6418292847cSmrg } 6428292847cSmrgfi 6438292847cSmrg 6448292847cSmrg 6458292847cSmrg# func_basename FILE 6468292847cSmrg# ------------------ 6478292847cSmrg# Set func_basename_result to FILE with everything up to and including 6488292847cSmrg# the last / stripped. 6498292847cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6508292847cSmrg # If this shell supports suffix pattern removal, then use it to avoid 6518292847cSmrg # forking. Hide the definitions single quotes in case the shell chokes 6528292847cSmrg # on unsupported syntax... 6538292847cSmrg _b='func_basename_result=${1##*/}' 6548292847cSmrg _d='case $1 in 6558292847cSmrg */*) func_dirname_result=${1%/*}$2 ;; 6568292847cSmrg * ) func_dirname_result=$3 ;; 6578292847cSmrg esac' 6588292847cSmrg 6598292847cSmrgelse 6608292847cSmrg # ...otherwise fall back to using sed. 6618292847cSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 6628292847cSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 6638292847cSmrg if test "X$func_dirname_result" = "X$1"; then 6648292847cSmrg func_dirname_result=$3 6658292847cSmrg else 6668292847cSmrg func_append func_dirname_result "$2" 6678292847cSmrg fi' 6688292847cSmrgfi 6698292847cSmrg 6708292847cSmrgeval 'func_basename () 6718292847cSmrg{ 6728292847cSmrg $debug_cmd 6738292847cSmrg 6748292847cSmrg '"$_b"' 6758292847cSmrg}' 6768292847cSmrg 6778292847cSmrg 6788292847cSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 6798292847cSmrg# ------------------------------------------- 6808292847cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 6818292847cSmrg# otherwise set result to NONDIR_REPLACEMENT. 6828292847cSmrgeval 'func_dirname () 6838292847cSmrg{ 6848292847cSmrg $debug_cmd 6858292847cSmrg 6868292847cSmrg '"$_d"' 6878292847cSmrg}' 6888292847cSmrg 6898292847cSmrg 6908292847cSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 6918292847cSmrg# -------------------------------------------------------- 6928292847cSmrg# Perform func_basename and func_dirname in a single function 6938292847cSmrg# call: 6948292847cSmrg# dirname: Compute the dirname of FILE. If nonempty, 6958292847cSmrg# add APPEND to the result, otherwise set result 6968292847cSmrg# to NONDIR_REPLACEMENT. 6978292847cSmrg# value returned in "$func_dirname_result" 6988292847cSmrg# basename: Compute filename of FILE. 6998292847cSmrg# value retuned in "$func_basename_result" 7008292847cSmrg# For efficiency, we do not delegate to the functions above but instead 7018292847cSmrg# duplicate the functionality here. 7028292847cSmrgeval 'func_dirname_and_basename () 7038292847cSmrg{ 7048292847cSmrg $debug_cmd 7058292847cSmrg 7068292847cSmrg '"$_b"' 7078292847cSmrg '"$_d"' 7088292847cSmrg}' 7098292847cSmrg 7108292847cSmrg 7118292847cSmrg# func_echo ARG... 7128292847cSmrg# ---------------- 7138292847cSmrg# Echo program name prefixed message. 7148292847cSmrgfunc_echo () 7158292847cSmrg{ 7168292847cSmrg $debug_cmd 7178292847cSmrg 7188292847cSmrg _G_message=$* 7198292847cSmrg 7208292847cSmrg func_echo_IFS=$IFS 7218292847cSmrg IFS=$nl 7228292847cSmrg for _G_line in $_G_message; do 7238292847cSmrg IFS=$func_echo_IFS 7248292847cSmrg $ECHO "$progname: $_G_line" 7258292847cSmrg done 7268292847cSmrg IFS=$func_echo_IFS 7278292847cSmrg} 7288292847cSmrg 7298292847cSmrg 7308292847cSmrg# func_echo_all ARG... 7318292847cSmrg# -------------------- 7328292847cSmrg# Invoke $ECHO with all args, space-separated. 7338292847cSmrgfunc_echo_all () 7348292847cSmrg{ 7358292847cSmrg $ECHO "$*" 7368292847cSmrg} 7378292847cSmrg 7388292847cSmrg 7398292847cSmrg# func_echo_infix_1 INFIX ARG... 7408292847cSmrg# ------------------------------ 7418292847cSmrg# Echo program name, followed by INFIX on the first line, with any 7428292847cSmrg# additional lines not showing INFIX. 7438292847cSmrgfunc_echo_infix_1 () 7448292847cSmrg{ 7458292847cSmrg $debug_cmd 7468292847cSmrg 7478292847cSmrg $require_term_colors 7488292847cSmrg 7498292847cSmrg _G_infix=$1; shift 7508292847cSmrg _G_indent=$_G_infix 7518292847cSmrg _G_prefix="$progname: $_G_infix: " 7528292847cSmrg _G_message=$* 7538292847cSmrg 7548292847cSmrg # Strip color escape sequences before counting printable length 7558292847cSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7568292847cSmrg do 7578292847cSmrg test -n "$_G_tc" && { 7588292847cSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 7598292847cSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 7608292847cSmrg } 7618292847cSmrg done 7628292847cSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 7638292847cSmrg 7648292847cSmrg func_echo_infix_1_IFS=$IFS 7658292847cSmrg IFS=$nl 7668292847cSmrg for _G_line in $_G_message; do 7678292847cSmrg IFS=$func_echo_infix_1_IFS 7688292847cSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 7698292847cSmrg _G_prefix=$_G_indent 7708292847cSmrg done 7718292847cSmrg IFS=$func_echo_infix_1_IFS 7728292847cSmrg} 7738292847cSmrg 7748292847cSmrg 7758292847cSmrg# func_error ARG... 7768292847cSmrg# ----------------- 7778292847cSmrg# Echo program name prefixed message to standard error. 7788292847cSmrgfunc_error () 7798292847cSmrg{ 7808292847cSmrg $debug_cmd 7818292847cSmrg 7828292847cSmrg $require_term_colors 7838292847cSmrg 7848292847cSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 7858292847cSmrg} 7868292847cSmrg 7878292847cSmrg 7888292847cSmrg# func_fatal_error ARG... 7898292847cSmrg# ----------------------- 7908292847cSmrg# Echo program name prefixed message to standard error, and exit. 7918292847cSmrgfunc_fatal_error () 7928292847cSmrg{ 7938292847cSmrg $debug_cmd 7948292847cSmrg 7958292847cSmrg func_error "$*" 7968292847cSmrg exit $EXIT_FAILURE 7978292847cSmrg} 7988292847cSmrg 7998292847cSmrg 8008292847cSmrg# func_grep EXPRESSION FILENAME 8018292847cSmrg# ----------------------------- 802c2939121Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803c2939121Smrgfunc_grep () 804c2939121Smrg{ 8058292847cSmrg $debug_cmd 8068292847cSmrg 807c2939121Smrg $GREP "$1" "$2" >/dev/null 2>&1 808c2939121Smrg} 809c2939121Smrg 810c2939121Smrg 8118292847cSmrg# func_len STRING 8128292847cSmrg# --------------- 8138292847cSmrg# Set func_len_result to the length of STRING. STRING may not 8148292847cSmrg# start with a hyphen. 8158292847cSmrg test -z "$_G_HAVE_XSI_OPS" \ 8168292847cSmrg && (eval 'x=a/b/c; 8178292847cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8188292847cSmrg && _G_HAVE_XSI_OPS=yes 8198292847cSmrg 8208292847cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8218292847cSmrg eval 'func_len () 8228292847cSmrg { 8238292847cSmrg $debug_cmd 8248292847cSmrg 8258292847cSmrg func_len_result=${#1} 8268292847cSmrg }' 8278292847cSmrgelse 8288292847cSmrg func_len () 8298292847cSmrg { 8308292847cSmrg $debug_cmd 8318292847cSmrg 8328292847cSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8338292847cSmrg } 8348292847cSmrgfi 8358292847cSmrg 8368292847cSmrg 8378292847cSmrg# func_mkdir_p DIRECTORY-PATH 8388292847cSmrg# --------------------------- 839c2939121Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840c2939121Smrgfunc_mkdir_p () 841c2939121Smrg{ 8428292847cSmrg $debug_cmd 843c2939121Smrg 8448292847cSmrg _G_directory_path=$1 8458292847cSmrg _G_dir_list= 846c2939121Smrg 8478292847cSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8488292847cSmrg 8498292847cSmrg # Protect directory names starting with '-' 8508292847cSmrg case $_G_directory_path in 8518292847cSmrg -*) _G_directory_path=./$_G_directory_path ;; 852c2939121Smrg esac 853c2939121Smrg 854c2939121Smrg # While some portion of DIR does not yet exist... 8558292847cSmrg while test ! -d "$_G_directory_path"; do 856c2939121Smrg # ...make a list in topmost first order. Use a colon delimited 857c2939121Smrg # list incase some portion of path contains whitespace. 8588292847cSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 859c2939121Smrg 860c2939121Smrg # If the last portion added has no slash in it, the list is done 8618292847cSmrg case $_G_directory_path in */*) ;; *) break ;; esac 862c2939121Smrg 863c2939121Smrg # ...otherwise throw away the child directory and loop 8648292847cSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865c2939121Smrg done 8668292847cSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867c2939121Smrg 8688292847cSmrg func_mkdir_p_IFS=$IFS; IFS=: 8698292847cSmrg for _G_dir in $_G_dir_list; do 8708292847cSmrg IFS=$func_mkdir_p_IFS 8718292847cSmrg # mkdir can fail with a 'File exist' error if two processes 872c2939121Smrg # try to create one of the directories concurrently. Don't 873c2939121Smrg # stop in that case! 8748292847cSmrg $MKDIR "$_G_dir" 2>/dev/null || : 875c2939121Smrg done 8768292847cSmrg IFS=$func_mkdir_p_IFS 877c2939121Smrg 878c2939121Smrg # Bail out if we (or some other process) failed to create a directory. 8798292847cSmrg test -d "$_G_directory_path" || \ 8808292847cSmrg func_fatal_error "Failed to create '$1'" 881c2939121Smrg fi 882c2939121Smrg} 883c76ae52dSmrg 884c76ae52dSmrg 8858292847cSmrg# func_mktempdir [BASENAME] 8868292847cSmrg# ------------------------- 887c76ae52dSmrg# Make a temporary directory that won't clash with other running 888c76ae52dSmrg# libtool processes, and avoids race conditions if possible. If 8898292847cSmrg# given, BASENAME is the basename for that directory. 890c76ae52dSmrgfunc_mktempdir () 891c76ae52dSmrg{ 8928292847cSmrg $debug_cmd 8938292847cSmrg 8948292847cSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895c76ae52dSmrg 8968292847cSmrg if test : = "$opt_dry_run"; then 897c76ae52dSmrg # Return a directory name, but don't create it in dry-run mode 8988292847cSmrg _G_tmpdir=$_G_template-$$ 899c76ae52dSmrg else 900c76ae52dSmrg 901c76ae52dSmrg # If mktemp works, use that first and foremost 9028292847cSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903c76ae52dSmrg 9048292847cSmrg if test ! -d "$_G_tmpdir"; then 905c2939121Smrg # Failing that, at least try and use $RANDOM to avoid a race 9068292847cSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907c76ae52dSmrg 9088292847cSmrg func_mktempdir_umask=`umask` 909c2939121Smrg umask 0077 9108292847cSmrg $MKDIR "$_G_tmpdir" 9118292847cSmrg umask $func_mktempdir_umask 912c76ae52dSmrg fi 913c76ae52dSmrg 914c76ae52dSmrg # If we're not in dry-run mode, bomb out on failure 9158292847cSmrg test -d "$_G_tmpdir" || \ 9168292847cSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9178292847cSmrg fi 9188292847cSmrg 9198292847cSmrg $ECHO "$_G_tmpdir" 9208292847cSmrg} 9218292847cSmrg 9228292847cSmrg 9238292847cSmrg# func_normal_abspath PATH 9248292847cSmrg# ------------------------ 9258292847cSmrg# Remove doubled-up and trailing slashes, "." path components, 9268292847cSmrg# and cancel out any ".." path components in PATH after making 9278292847cSmrg# it an absolute path. 9288292847cSmrgfunc_normal_abspath () 9298292847cSmrg{ 9308292847cSmrg $debug_cmd 9318292847cSmrg 9328292847cSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9338292847cSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9348292847cSmrg _G_pathcdr='s|^/[^/]*||' 9358292847cSmrg _G_removedotparts=':dotsl 9368292847cSmrg s|/\./|/|g 9378292847cSmrg t dotsl 9388292847cSmrg s|/\.$|/|' 9398292847cSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9408292847cSmrg _G_finalslash='s|/*$|/|' 9418292847cSmrg 9428292847cSmrg # Start from root dir and reassemble the path. 9438292847cSmrg func_normal_abspath_result= 9448292847cSmrg func_normal_abspath_tpath=$1 9458292847cSmrg func_normal_abspath_altnamespace= 9468292847cSmrg case $func_normal_abspath_tpath in 9478292847cSmrg "") 9488292847cSmrg # Empty path, that just means $cwd. 9498292847cSmrg func_stripname '' '/' "`pwd`" 9508292847cSmrg func_normal_abspath_result=$func_stripname_result 9518292847cSmrg return 9528292847cSmrg ;; 9538292847cSmrg # The next three entries are used to spot a run of precisely 9548292847cSmrg # two leading slashes without using negated character classes; 9558292847cSmrg # we take advantage of case's first-match behaviour. 9568292847cSmrg ///*) 9578292847cSmrg # Unusual form of absolute path, do nothing. 9588292847cSmrg ;; 9598292847cSmrg //*) 9608292847cSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 9618292847cSmrg # and for example Cygwin uses it to access remote file shares 9628292847cSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 9638292847cSmrg func_normal_abspath_altnamespace=/ 9648292847cSmrg ;; 9658292847cSmrg /*) 9668292847cSmrg # Absolute path, do nothing. 9678292847cSmrg ;; 9688292847cSmrg *) 9698292847cSmrg # Relative path, prepend $cwd. 9708292847cSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 9718292847cSmrg ;; 9728292847cSmrg esac 9738292847cSmrg 9748292847cSmrg # Cancel out all the simple stuff to save iterations. We also want 9758292847cSmrg # the path to end with a slash for ease of parsing, so make sure 9768292847cSmrg # there is one (and only one) here. 9778292847cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9788292847cSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 9798292847cSmrg while :; do 9808292847cSmrg # Processed it all yet? 9818292847cSmrg if test / = "$func_normal_abspath_tpath"; then 9828292847cSmrg # If we ascended to the root using ".." the result may be empty now. 9838292847cSmrg if test -z "$func_normal_abspath_result"; then 9848292847cSmrg func_normal_abspath_result=/ 9858292847cSmrg fi 9868292847cSmrg break 9878292847cSmrg fi 9888292847cSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9898292847cSmrg -e "$_G_pathcar"` 9908292847cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9918292847cSmrg -e "$_G_pathcdr"` 9928292847cSmrg # Figure out what to do with it 9938292847cSmrg case $func_normal_abspath_tcomponent in 9948292847cSmrg "") 9958292847cSmrg # Trailing empty path component, ignore it. 9968292847cSmrg ;; 9978292847cSmrg ..) 9988292847cSmrg # Parent dir; strip last assembled component from result. 9998292847cSmrg func_dirname "$func_normal_abspath_result" 10008292847cSmrg func_normal_abspath_result=$func_dirname_result 10018292847cSmrg ;; 10028292847cSmrg *) 10038292847cSmrg # Actual path component, append it. 10048292847cSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10058292847cSmrg ;; 10068292847cSmrg esac 10078292847cSmrg done 10088292847cSmrg # Restore leading double-slash if one was found on entry. 10098292847cSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10108292847cSmrg} 10118292847cSmrg 10128292847cSmrg 10138292847cSmrg# func_notquiet ARG... 10148292847cSmrg# -------------------- 10158292847cSmrg# Echo program name prefixed message only when not in quiet mode. 10168292847cSmrgfunc_notquiet () 10178292847cSmrg{ 10188292847cSmrg $debug_cmd 10198292847cSmrg 10208292847cSmrg $opt_quiet || func_echo ${1+"$@"} 10218292847cSmrg 10228292847cSmrg # A bug in bash halts the script if the last line of a function 10238292847cSmrg # fails when set -e is in force, so we need another command to 10248292847cSmrg # work around that: 10258292847cSmrg : 10268292847cSmrg} 10278292847cSmrg 10288292847cSmrg 10298292847cSmrg# func_relative_path SRCDIR DSTDIR 10308292847cSmrg# -------------------------------- 10318292847cSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10328292847cSmrgfunc_relative_path () 10338292847cSmrg{ 10348292847cSmrg $debug_cmd 10358292847cSmrg 10368292847cSmrg func_relative_path_result= 10378292847cSmrg func_normal_abspath "$1" 10388292847cSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10398292847cSmrg func_normal_abspath "$2" 10408292847cSmrg func_relative_path_tbindir=$func_normal_abspath_result 10418292847cSmrg 10428292847cSmrg # Ascend the tree starting from libdir 10438292847cSmrg while :; do 10448292847cSmrg # check if we have found a prefix of bindir 10458292847cSmrg case $func_relative_path_tbindir in 10468292847cSmrg $func_relative_path_tlibdir) 10478292847cSmrg # found an exact match 10488292847cSmrg func_relative_path_tcancelled= 10498292847cSmrg break 10508292847cSmrg ;; 10518292847cSmrg $func_relative_path_tlibdir*) 10528292847cSmrg # found a matching prefix 10538292847cSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10548292847cSmrg func_relative_path_tcancelled=$func_stripname_result 10558292847cSmrg if test -z "$func_relative_path_result"; then 10568292847cSmrg func_relative_path_result=. 10578292847cSmrg fi 10588292847cSmrg break 10598292847cSmrg ;; 10608292847cSmrg *) 10618292847cSmrg func_dirname $func_relative_path_tlibdir 10628292847cSmrg func_relative_path_tlibdir=$func_dirname_result 10638292847cSmrg if test -z "$func_relative_path_tlibdir"; then 10648292847cSmrg # Have to descend all the way to the root! 10658292847cSmrg func_relative_path_result=../$func_relative_path_result 10668292847cSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 10678292847cSmrg break 10688292847cSmrg fi 10698292847cSmrg func_relative_path_result=../$func_relative_path_result 10708292847cSmrg ;; 10718292847cSmrg esac 10728292847cSmrg done 10738292847cSmrg 10748292847cSmrg # Now calculate path; take care to avoid doubling-up slashes. 10758292847cSmrg func_stripname '' '/' "$func_relative_path_result" 10768292847cSmrg func_relative_path_result=$func_stripname_result 10778292847cSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 10788292847cSmrg if test -n "$func_stripname_result"; then 10798292847cSmrg func_append func_relative_path_result "/$func_stripname_result" 10808292847cSmrg fi 10818292847cSmrg 10828292847cSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 10838292847cSmrg if test -n "$func_relative_path_result"; then 10848292847cSmrg func_stripname './' '' "$func_relative_path_result" 10858292847cSmrg func_relative_path_result=$func_stripname_result 1086c76ae52dSmrg fi 1087c76ae52dSmrg 10888292847cSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 10898292847cSmrg 10908292847cSmrg : 10918292847cSmrg} 10928292847cSmrg 10938292847cSmrg 10948292847cSmrg# func_quote_for_eval ARG... 10958292847cSmrg# -------------------------- 10968292847cSmrg# Aesthetically quote ARGs to be evaled later. 10978292847cSmrg# This function returns two values: 10988292847cSmrg# i) func_quote_for_eval_result 10998292847cSmrg# double-quoted, suitable for a subsequent eval 11008292847cSmrg# ii) func_quote_for_eval_unquoted_result 11018292847cSmrg# has all characters that are still active within double 11028292847cSmrg# quotes backslashified. 11038292847cSmrgfunc_quote_for_eval () 11048292847cSmrg{ 11058292847cSmrg $debug_cmd 11068292847cSmrg 11078292847cSmrg func_quote_for_eval_unquoted_result= 11088292847cSmrg func_quote_for_eval_result= 11098292847cSmrg while test 0 -lt $#; do 11108292847cSmrg case $1 in 11118292847cSmrg *[\\\`\"\$]*) 11128292847cSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 11138292847cSmrg *) 11148292847cSmrg _G_unquoted_arg=$1 ;; 11158292847cSmrg esac 11168292847cSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 11178292847cSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 11188292847cSmrg else 11198292847cSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 11208292847cSmrg fi 11218292847cSmrg 11228292847cSmrg case $_G_unquoted_arg in 11238292847cSmrg # Double-quote args containing shell metacharacters to delay 11248292847cSmrg # word splitting, command substitution and variable expansion 11258292847cSmrg # for a subsequent eval. 11268292847cSmrg # Many Bourne shells cannot handle close brackets correctly 11278292847cSmrg # in scan sets, so we specify it separately. 11288292847cSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11298292847cSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 11308292847cSmrg ;; 11318292847cSmrg *) 11328292847cSmrg _G_quoted_arg=$_G_unquoted_arg 11338292847cSmrg ;; 11348292847cSmrg esac 11358292847cSmrg 11368292847cSmrg if test -n "$func_quote_for_eval_result"; then 11378292847cSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 11388292847cSmrg else 11398292847cSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 11408292847cSmrg fi 11418292847cSmrg shift 11428292847cSmrg done 11438292847cSmrg} 11448292847cSmrg 11458292847cSmrg 11468292847cSmrg# func_quote_for_expand ARG 11478292847cSmrg# ------------------------- 11488292847cSmrg# Aesthetically quote ARG to be evaled later; same as above, 11498292847cSmrg# but do not quote variable references. 11508292847cSmrgfunc_quote_for_expand () 11518292847cSmrg{ 11528292847cSmrg $debug_cmd 11538292847cSmrg 11548292847cSmrg case $1 in 11558292847cSmrg *[\\\`\"]*) 11568292847cSmrg _G_arg=`$ECHO "$1" | $SED \ 11578292847cSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 11588292847cSmrg *) 11598292847cSmrg _G_arg=$1 ;; 11608292847cSmrg esac 11618292847cSmrg 11628292847cSmrg case $_G_arg in 11638292847cSmrg # Double-quote args containing shell metacharacters to delay 11648292847cSmrg # word splitting and command substitution for a subsequent eval. 11658292847cSmrg # Many Bourne shells cannot handle close brackets correctly 11668292847cSmrg # in scan sets, so we specify it separately. 11678292847cSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11688292847cSmrg _G_arg=\"$_G_arg\" 11698292847cSmrg ;; 11708292847cSmrg esac 11718292847cSmrg 11728292847cSmrg func_quote_for_expand_result=$_G_arg 11738292847cSmrg} 11748292847cSmrg 11758292847cSmrg 11768292847cSmrg# func_stripname PREFIX SUFFIX NAME 11778292847cSmrg# --------------------------------- 11788292847cSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 11798292847cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 11808292847cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 11818292847cSmrg# dot (in which case that matches only a dot). 11828292847cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 11838292847cSmrg eval 'func_stripname () 11848292847cSmrg { 11858292847cSmrg $debug_cmd 11868292847cSmrg 11878292847cSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 11888292847cSmrg # positional parameters, so assign one to ordinary variable first. 11898292847cSmrg func_stripname_result=$3 11908292847cSmrg func_stripname_result=${func_stripname_result#"$1"} 11918292847cSmrg func_stripname_result=${func_stripname_result%"$2"} 11928292847cSmrg }' 11938292847cSmrgelse 11948292847cSmrg func_stripname () 11958292847cSmrg { 11968292847cSmrg $debug_cmd 11978292847cSmrg 11988292847cSmrg case $2 in 11998292847cSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 12008292847cSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 12018292847cSmrg esac 12028292847cSmrg } 12038292847cSmrgfi 12048292847cSmrg 12058292847cSmrg 12068292847cSmrg# func_show_eval CMD [FAIL_EXP] 12078292847cSmrg# ----------------------------- 12088292847cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 12098292847cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 12108292847cSmrg# is given, then evaluate it. 12118292847cSmrgfunc_show_eval () 12128292847cSmrg{ 12138292847cSmrg $debug_cmd 12148292847cSmrg 12158292847cSmrg _G_cmd=$1 12168292847cSmrg _G_fail_exp=${2-':'} 12178292847cSmrg 12188292847cSmrg func_quote_for_expand "$_G_cmd" 12198292847cSmrg eval "func_notquiet $func_quote_for_expand_result" 12208292847cSmrg 12218292847cSmrg $opt_dry_run || { 12228292847cSmrg eval "$_G_cmd" 12238292847cSmrg _G_status=$? 12248292847cSmrg if test 0 -ne "$_G_status"; then 12258292847cSmrg eval "(exit $_G_status); $_G_fail_exp" 12268292847cSmrg fi 12278292847cSmrg } 12288292847cSmrg} 12298292847cSmrg 12308292847cSmrg 12318292847cSmrg# func_show_eval_locale CMD [FAIL_EXP] 12328292847cSmrg# ------------------------------------ 12338292847cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 12348292847cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 12358292847cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 12368292847cSmrgfunc_show_eval_locale () 12378292847cSmrg{ 12388292847cSmrg $debug_cmd 12398292847cSmrg 12408292847cSmrg _G_cmd=$1 12418292847cSmrg _G_fail_exp=${2-':'} 12428292847cSmrg 12438292847cSmrg $opt_quiet || { 12448292847cSmrg func_quote_for_expand "$_G_cmd" 12458292847cSmrg eval "func_echo $func_quote_for_expand_result" 12468292847cSmrg } 12478292847cSmrg 12488292847cSmrg $opt_dry_run || { 12498292847cSmrg eval "$_G_user_locale 12508292847cSmrg $_G_cmd" 12518292847cSmrg _G_status=$? 12528292847cSmrg eval "$_G_safe_locale" 12538292847cSmrg if test 0 -ne "$_G_status"; then 12548292847cSmrg eval "(exit $_G_status); $_G_fail_exp" 12558292847cSmrg fi 12568292847cSmrg } 12578292847cSmrg} 12588292847cSmrg 12598292847cSmrg 12608292847cSmrg# func_tr_sh 12618292847cSmrg# ---------- 12628292847cSmrg# Turn $1 into a string suitable for a shell variable name. 12638292847cSmrg# Result is stored in $func_tr_sh_result. All characters 12648292847cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 12658292847cSmrg# if $1 begins with a digit, a '_' is prepended as well. 12668292847cSmrgfunc_tr_sh () 12678292847cSmrg{ 12688292847cSmrg $debug_cmd 12698292847cSmrg 12708292847cSmrg case $1 in 12718292847cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 12728292847cSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 12738292847cSmrg ;; 12748292847cSmrg * ) 12758292847cSmrg func_tr_sh_result=$1 12768292847cSmrg ;; 12778292847cSmrg esac 12788292847cSmrg} 12798292847cSmrg 12808292847cSmrg 12818292847cSmrg# func_verbose ARG... 12828292847cSmrg# ------------------- 12838292847cSmrg# Echo program name prefixed message in verbose mode only. 12848292847cSmrgfunc_verbose () 12858292847cSmrg{ 12868292847cSmrg $debug_cmd 12878292847cSmrg 12888292847cSmrg $opt_verbose && func_echo "$*" 12898292847cSmrg 12908292847cSmrg : 12918292847cSmrg} 12928292847cSmrg 12938292847cSmrg 12948292847cSmrg# func_warn_and_continue ARG... 12958292847cSmrg# ----------------------------- 12968292847cSmrg# Echo program name prefixed warning message to standard error. 12978292847cSmrgfunc_warn_and_continue () 12988292847cSmrg{ 12998292847cSmrg $debug_cmd 13008292847cSmrg 13018292847cSmrg $require_term_colors 13028292847cSmrg 13038292847cSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 13048292847cSmrg} 13058292847cSmrg 13068292847cSmrg 13078292847cSmrg# func_warning CATEGORY ARG... 13088292847cSmrg# ---------------------------- 13098292847cSmrg# Echo program name prefixed warning message to standard error. Warning 13108292847cSmrg# messages can be filtered according to CATEGORY, where this function 13118292847cSmrg# elides messages where CATEGORY is not listed in the global variable 13128292847cSmrg# 'opt_warning_types'. 13138292847cSmrgfunc_warning () 13148292847cSmrg{ 13158292847cSmrg $debug_cmd 13168292847cSmrg 13178292847cSmrg # CATEGORY must be in the warning_categories list! 13188292847cSmrg case " $warning_categories " in 13198292847cSmrg *" $1 "*) ;; 13208292847cSmrg *) func_internal_error "invalid warning category '$1'" ;; 13218292847cSmrg esac 13228292847cSmrg 13238292847cSmrg _G_category=$1 13248292847cSmrg shift 13258292847cSmrg 13268292847cSmrg case " $opt_warning_types " in 13278292847cSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 13288292847cSmrg esac 13298292847cSmrg} 13308292847cSmrg 13318292847cSmrg 13328292847cSmrg# func_sort_ver VER1 VER2 13338292847cSmrg# ----------------------- 13348292847cSmrg# 'sort -V' is not generally available. 13358292847cSmrg# Note this deviates from the version comparison in automake 13368292847cSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 13378292847cSmrg# but this should suffice as we won't be specifying old 13388292847cSmrg# version formats or redundant trailing .0 in bootstrap.conf. 13398292847cSmrg# If we did want full compatibility then we should probably 13408292847cSmrg# use m4_version_compare from autoconf. 13418292847cSmrgfunc_sort_ver () 13428292847cSmrg{ 13438292847cSmrg $debug_cmd 13448292847cSmrg 13458292847cSmrg printf '%s\n%s\n' "$1" "$2" \ 13468292847cSmrg | 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 13478292847cSmrg} 13488292847cSmrg 13498292847cSmrg# func_lt_ver PREV CURR 13508292847cSmrg# --------------------- 13518292847cSmrg# Return true if PREV and CURR are in the correct order according to 13528292847cSmrg# func_sort_ver, otherwise false. Use it like this: 13538292847cSmrg# 13548292847cSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 13558292847cSmrgfunc_lt_ver () 13568292847cSmrg{ 13578292847cSmrg $debug_cmd 13588292847cSmrg 13598292847cSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 13608292847cSmrg} 13618292847cSmrg 13628292847cSmrg 13638292847cSmrg# Local variables: 13648292847cSmrg# mode: shell-script 13658292847cSmrg# sh-indentation: 2 13668292847cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 13678292847cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 13688292847cSmrg# time-stamp-time-zone: "UTC" 13698292847cSmrg# End: 13708292847cSmrg#! /bin/sh 13718292847cSmrg 13728292847cSmrg# Set a version string for this script. 13738292847cSmrgscriptversion=2014-01-07.03; # UTC 13748292847cSmrg 13758292847cSmrg# A portable, pluggable option parser for Bourne shell. 13768292847cSmrg# Written by Gary V. Vaughan, 2010 13778292847cSmrg 13788292847cSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 13798292847cSmrg# This is free software; see the source for copying conditions. There is NO 13808292847cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13818292847cSmrg 13828292847cSmrg# This program is free software: you can redistribute it and/or modify 13838292847cSmrg# it under the terms of the GNU General Public License as published by 13848292847cSmrg# the Free Software Foundation, either version 3 of the License, or 13858292847cSmrg# (at your option) any later version. 13868292847cSmrg 13878292847cSmrg# This program is distributed in the hope that it will be useful, 13888292847cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 13898292847cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13908292847cSmrg# GNU General Public License for more details. 13918292847cSmrg 13928292847cSmrg# You should have received a copy of the GNU General Public License 13938292847cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 13948292847cSmrg 13958292847cSmrg# Please report bugs or propose patches to gary@gnu.org. 13968292847cSmrg 13978292847cSmrg 13988292847cSmrg## ------ ## 13998292847cSmrg## Usage. ## 14008292847cSmrg## ------ ## 14018292847cSmrg 14028292847cSmrg# This file is a library for parsing options in your shell scripts along 14038292847cSmrg# with assorted other useful supporting features that you can make use 14048292847cSmrg# of too. 14058292847cSmrg# 14068292847cSmrg# For the simplest scripts you might need only: 14078292847cSmrg# 14088292847cSmrg# #!/bin/sh 14098292847cSmrg# . relative/path/to/funclib.sh 14108292847cSmrg# . relative/path/to/options-parser 14118292847cSmrg# scriptversion=1.0 14128292847cSmrg# func_options ${1+"$@"} 14138292847cSmrg# eval set dummy "$func_options_result"; shift 14148292847cSmrg# ...rest of your script... 14158292847cSmrg# 14168292847cSmrg# In order for the '--version' option to work, you will need to have a 14178292847cSmrg# suitably formatted comment like the one at the top of this file 14188292847cSmrg# starting with '# Written by ' and ending with '# warranty; '. 14198292847cSmrg# 14208292847cSmrg# For '-h' and '--help' to work, you will also need a one line 14218292847cSmrg# description of your script's purpose in a comment directly above the 14228292847cSmrg# '# Written by ' line, like the one at the top of this file. 14238292847cSmrg# 14248292847cSmrg# The default options also support '--debug', which will turn on shell 14258292847cSmrg# execution tracing (see the comment above debug_cmd below for another 14268292847cSmrg# use), and '--verbose' and the func_verbose function to allow your script 14278292847cSmrg# to display verbose messages only when your user has specified 14288292847cSmrg# '--verbose'. 14298292847cSmrg# 14308292847cSmrg# After sourcing this file, you can plug processing for additional 14318292847cSmrg# options by amending the variables from the 'Configuration' section 14328292847cSmrg# below, and following the instructions in the 'Option parsing' 14338292847cSmrg# section further down. 14348292847cSmrg 14358292847cSmrg## -------------- ## 14368292847cSmrg## Configuration. ## 14378292847cSmrg## -------------- ## 14388292847cSmrg 14398292847cSmrg# You should override these variables in your script after sourcing this 14408292847cSmrg# file so that they reflect the customisations you have added to the 14418292847cSmrg# option parser. 14428292847cSmrg 14438292847cSmrg# The usage line for option parsing errors and the start of '-h' and 14448292847cSmrg# '--help' output messages. You can embed shell variables for delayed 14458292847cSmrg# expansion at the time the message is displayed, but you will need to 14468292847cSmrg# quote other shell meta-characters carefully to prevent them being 14478292847cSmrg# expanded when the contents are evaled. 14488292847cSmrgusage='$progpath [OPTION]...' 14498292847cSmrg 14508292847cSmrg# Short help message in response to '-h' and '--help'. Add to this or 14518292847cSmrg# override it after sourcing this library to reflect the full set of 14528292847cSmrg# options your script accepts. 14538292847cSmrgusage_message="\ 14548292847cSmrg --debug enable verbose shell tracing 14558292847cSmrg -W, --warnings=CATEGORY 14568292847cSmrg report the warnings falling in CATEGORY [all] 14578292847cSmrg -v, --verbose verbosely report processing 14588292847cSmrg --version print version information and exit 14598292847cSmrg -h, --help print short or long help message and exit 14608292847cSmrg" 14618292847cSmrg 14628292847cSmrg# Additional text appended to 'usage_message' in response to '--help'. 14638292847cSmrglong_help_message=" 14648292847cSmrgWarning categories include: 14658292847cSmrg 'all' show all warnings 14668292847cSmrg 'none' turn off all the warnings 14678292847cSmrg 'error' warnings are treated as fatal errors" 14688292847cSmrg 14698292847cSmrg# Help message printed before fatal option parsing errors. 14708292847cSmrgfatal_help="Try '\$progname --help' for more information." 14718292847cSmrg 14728292847cSmrg 14738292847cSmrg 14748292847cSmrg## ------------------------- ## 14758292847cSmrg## Hook function management. ## 14768292847cSmrg## ------------------------- ## 14778292847cSmrg 14788292847cSmrg# This section contains functions for adding, removing, and running hooks 14798292847cSmrg# to the main code. A hook is just a named list of of function, that can 14808292847cSmrg# be run in order later on. 14818292847cSmrg 14828292847cSmrg# func_hookable FUNC_NAME 14838292847cSmrg# ----------------------- 14848292847cSmrg# Declare that FUNC_NAME will run hooks added with 14858292847cSmrg# 'func_add_hook FUNC_NAME ...'. 14868292847cSmrgfunc_hookable () 14878292847cSmrg{ 14888292847cSmrg $debug_cmd 14898292847cSmrg 14908292847cSmrg func_append hookable_fns " $1" 14918292847cSmrg} 14928292847cSmrg 14938292847cSmrg 14948292847cSmrg# func_add_hook FUNC_NAME HOOK_FUNC 14958292847cSmrg# --------------------------------- 14968292847cSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 14978292847cSmrg# first have been declared "hookable" by a call to 'func_hookable'. 14988292847cSmrgfunc_add_hook () 14998292847cSmrg{ 15008292847cSmrg $debug_cmd 15018292847cSmrg 15028292847cSmrg case " $hookable_fns " in 15038292847cSmrg *" $1 "*) ;; 15048292847cSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 15058292847cSmrg esac 15068292847cSmrg 15078292847cSmrg eval func_append ${1}_hooks '" $2"' 15088292847cSmrg} 15098292847cSmrg 15108292847cSmrg 15118292847cSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 15128292847cSmrg# ------------------------------------ 15138292847cSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 15148292847cSmrgfunc_remove_hook () 15158292847cSmrg{ 15168292847cSmrg $debug_cmd 15178292847cSmrg 15188292847cSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 15198292847cSmrg} 15208292847cSmrg 15218292847cSmrg 15228292847cSmrg# func_run_hooks FUNC_NAME [ARG]... 15238292847cSmrg# --------------------------------- 15248292847cSmrg# Run all hook functions registered to FUNC_NAME. 15258292847cSmrg# It is assumed that the list of hook functions contains nothing more 15268292847cSmrg# than a whitespace-delimited list of legal shell function names, and 15278292847cSmrg# no effort is wasted trying to catch shell meta-characters or preserve 15288292847cSmrg# whitespace. 15298292847cSmrgfunc_run_hooks () 15308292847cSmrg{ 15318292847cSmrg $debug_cmd 15328292847cSmrg 15338292847cSmrg case " $hookable_fns " in 15348292847cSmrg *" $1 "*) ;; 15358292847cSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 15368292847cSmrg esac 15378292847cSmrg 15388292847cSmrg eval _G_hook_fns=\$$1_hooks; shift 15398292847cSmrg 15408292847cSmrg for _G_hook in $_G_hook_fns; do 15418292847cSmrg eval $_G_hook '"$@"' 15428292847cSmrg 15438292847cSmrg # store returned options list back into positional 15448292847cSmrg # parameters for next 'cmd' execution. 15458292847cSmrg eval _G_hook_result=\$${_G_hook}_result 15468292847cSmrg eval set dummy "$_G_hook_result"; shift 15478292847cSmrg done 15488292847cSmrg 15498292847cSmrg func_quote_for_eval ${1+"$@"} 15508292847cSmrg func_run_hooks_result=$func_quote_for_eval_result 15518292847cSmrg} 15528292847cSmrg 15538292847cSmrg 15548292847cSmrg 15558292847cSmrg## --------------- ## 15568292847cSmrg## Option parsing. ## 15578292847cSmrg## --------------- ## 15588292847cSmrg 15598292847cSmrg# In order to add your own option parsing hooks, you must accept the 15608292847cSmrg# full positional parameter list in your hook function, remove any 15618292847cSmrg# options that you action, and then pass back the remaining unprocessed 15628292847cSmrg# options in '<hooked_function_name>_result', escaped suitably for 15638292847cSmrg# 'eval'. Like this: 15648292847cSmrg# 15658292847cSmrg# my_options_prep () 15668292847cSmrg# { 15678292847cSmrg# $debug_cmd 15688292847cSmrg# 15698292847cSmrg# # Extend the existing usage message. 15708292847cSmrg# usage_message=$usage_message' 15718292847cSmrg# -s, --silent don'\''t print informational messages 15728292847cSmrg# ' 15738292847cSmrg# 15748292847cSmrg# func_quote_for_eval ${1+"$@"} 15758292847cSmrg# my_options_prep_result=$func_quote_for_eval_result 15768292847cSmrg# } 15778292847cSmrg# func_add_hook func_options_prep my_options_prep 15788292847cSmrg# 15798292847cSmrg# 15808292847cSmrg# my_silent_option () 15818292847cSmrg# { 15828292847cSmrg# $debug_cmd 15838292847cSmrg# 15848292847cSmrg# # Note that for efficiency, we parse as many options as we can 15858292847cSmrg# # recognise in a loop before passing the remainder back to the 15868292847cSmrg# # caller on the first unrecognised argument we encounter. 15878292847cSmrg# while test $# -gt 0; do 15888292847cSmrg# opt=$1; shift 15898292847cSmrg# case $opt in 15908292847cSmrg# --silent|-s) opt_silent=: ;; 15918292847cSmrg# # Separate non-argument short options: 15928292847cSmrg# -s*) func_split_short_opt "$_G_opt" 15938292847cSmrg# set dummy "$func_split_short_opt_name" \ 15948292847cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 15958292847cSmrg# shift 15968292847cSmrg# ;; 15978292847cSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 15988292847cSmrg# esac 15998292847cSmrg# done 16008292847cSmrg# 16018292847cSmrg# func_quote_for_eval ${1+"$@"} 16028292847cSmrg# my_silent_option_result=$func_quote_for_eval_result 16038292847cSmrg# } 16048292847cSmrg# func_add_hook func_parse_options my_silent_option 16058292847cSmrg# 16068292847cSmrg# 16078292847cSmrg# my_option_validation () 16088292847cSmrg# { 16098292847cSmrg# $debug_cmd 16108292847cSmrg# 16118292847cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 16128292847cSmrg# '--silent' and '--verbose' options are mutually exclusive." 16138292847cSmrg# 16148292847cSmrg# func_quote_for_eval ${1+"$@"} 16158292847cSmrg# my_option_validation_result=$func_quote_for_eval_result 16168292847cSmrg# } 16178292847cSmrg# func_add_hook func_validate_options my_option_validation 16188292847cSmrg# 16198292847cSmrg# You'll alse need to manually amend $usage_message to reflect the extra 16208292847cSmrg# options you parse. It's preferable to append if you can, so that 16218292847cSmrg# multiple option parsing hooks can be added safely. 16228292847cSmrg 16238292847cSmrg 16248292847cSmrg# func_options [ARG]... 16258292847cSmrg# --------------------- 16268292847cSmrg# All the functions called inside func_options are hookable. See the 16278292847cSmrg# individual implementations for details. 16288292847cSmrgfunc_hookable func_options 16298292847cSmrgfunc_options () 16308292847cSmrg{ 16318292847cSmrg $debug_cmd 16328292847cSmrg 16338292847cSmrg func_options_prep ${1+"$@"} 16348292847cSmrg eval func_parse_options \ 16358292847cSmrg ${func_options_prep_result+"$func_options_prep_result"} 16368292847cSmrg eval func_validate_options \ 16378292847cSmrg ${func_parse_options_result+"$func_parse_options_result"} 16388292847cSmrg 16398292847cSmrg eval func_run_hooks func_options \ 16408292847cSmrg ${func_validate_options_result+"$func_validate_options_result"} 16418292847cSmrg 16428292847cSmrg # save modified positional parameters for caller 16438292847cSmrg func_options_result=$func_run_hooks_result 1644c76ae52dSmrg} 1645c76ae52dSmrg 1646c76ae52dSmrg 16478292847cSmrg# func_options_prep [ARG]... 16488292847cSmrg# -------------------------- 16498292847cSmrg# All initialisations required before starting the option parse loop. 16508292847cSmrg# Note that when calling hook functions, we pass through the list of 16518292847cSmrg# positional parameters. If a hook function modifies that list, and 16528292847cSmrg# needs to propogate that back to rest of this script, then the complete 16538292847cSmrg# modified list must be put in 'func_run_hooks_result' before 16548292847cSmrg# returning. 16558292847cSmrgfunc_hookable func_options_prep 16568292847cSmrgfunc_options_prep () 1657c76ae52dSmrg{ 16588292847cSmrg $debug_cmd 1659c2939121Smrg 16608292847cSmrg # Option defaults: 16618292847cSmrg opt_verbose=false 16628292847cSmrg opt_warning_types= 16638292847cSmrg 16648292847cSmrg func_run_hooks func_options_prep ${1+"$@"} 16658292847cSmrg 16668292847cSmrg # save modified positional parameters for caller 16678292847cSmrg func_options_prep_result=$func_run_hooks_result 1668c76ae52dSmrg} 1669c76ae52dSmrg 1670c76ae52dSmrg 16718292847cSmrg# func_parse_options [ARG]... 16728292847cSmrg# --------------------------- 16738292847cSmrg# The main option parsing loop. 16748292847cSmrgfunc_hookable func_parse_options 16758292847cSmrgfunc_parse_options () 1676c76ae52dSmrg{ 16778292847cSmrg $debug_cmd 1678c2939121Smrg 16798292847cSmrg func_parse_options_result= 1680c2939121Smrg 16818292847cSmrg # this just eases exit handling 16828292847cSmrg while test $# -gt 0; do 16838292847cSmrg # Defer to hook functions for initial option parsing, so they 16848292847cSmrg # get priority in the event of reusing an option name. 16858292847cSmrg func_run_hooks func_parse_options ${1+"$@"} 1686c76ae52dSmrg 16878292847cSmrg # Adjust func_parse_options positional parameters to match 16888292847cSmrg eval set dummy "$func_run_hooks_result"; shift 1689c76ae52dSmrg 16908292847cSmrg # Break out of the loop if we already parsed every option. 16918292847cSmrg test $# -gt 0 || break 1692c76ae52dSmrg 16938292847cSmrg _G_opt=$1 16948292847cSmrg shift 16958292847cSmrg case $_G_opt in 16968292847cSmrg --debug|-x) debug_cmd='set -x' 16978292847cSmrg func_echo "enabling shell trace mode" 16988292847cSmrg $debug_cmd 16998292847cSmrg ;; 17008292847cSmrg 17018292847cSmrg --no-warnings|--no-warning|--no-warn) 17028292847cSmrg set dummy --warnings none ${1+"$@"} 17038292847cSmrg shift 17048292847cSmrg ;; 1705c2939121Smrg 17068292847cSmrg --warnings|--warning|-W) 17078292847cSmrg test $# = 0 && func_missing_arg $_G_opt && break 17088292847cSmrg case " $warning_categories $1" in 17098292847cSmrg *" $1 "*) 17108292847cSmrg # trailing space prevents matching last $1 above 17118292847cSmrg func_append_uniq opt_warning_types " $1" 17128292847cSmrg ;; 17138292847cSmrg *all) 17148292847cSmrg opt_warning_types=$warning_categories 17158292847cSmrg ;; 17168292847cSmrg *none) 17178292847cSmrg opt_warning_types=none 17188292847cSmrg warning_func=: 17198292847cSmrg ;; 17208292847cSmrg *error) 17218292847cSmrg opt_warning_types=$warning_categories 17228292847cSmrg warning_func=func_fatal_error 17238292847cSmrg ;; 17248292847cSmrg *) 17258292847cSmrg func_fatal_error \ 17268292847cSmrg "unsupported warning category: '$1'" 17278292847cSmrg ;; 17288292847cSmrg esac 17298292847cSmrg shift 17308292847cSmrg ;; 17318292847cSmrg 17328292847cSmrg --verbose|-v) opt_verbose=: ;; 17338292847cSmrg --version) func_version ;; 17348292847cSmrg -\?|-h) func_usage ;; 17358292847cSmrg --help) func_help ;; 17368292847cSmrg 17378292847cSmrg # Separate optargs to long options (plugins may need this): 17388292847cSmrg --*=*) func_split_equals "$_G_opt" 17398292847cSmrg set dummy "$func_split_equals_lhs" \ 17408292847cSmrg "$func_split_equals_rhs" ${1+"$@"} 17418292847cSmrg shift 17428292847cSmrg ;; 17438292847cSmrg 17448292847cSmrg # Separate optargs to short options: 17458292847cSmrg -W*) 17468292847cSmrg func_split_short_opt "$_G_opt" 17478292847cSmrg set dummy "$func_split_short_opt_name" \ 17488292847cSmrg "$func_split_short_opt_arg" ${1+"$@"} 17498292847cSmrg shift 17508292847cSmrg ;; 17518292847cSmrg 17528292847cSmrg # Separate non-argument short options: 17538292847cSmrg -\?*|-h*|-v*|-x*) 17548292847cSmrg func_split_short_opt "$_G_opt" 17558292847cSmrg set dummy "$func_split_short_opt_name" \ 17568292847cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 17578292847cSmrg shift 17588292847cSmrg ;; 17598292847cSmrg 17608292847cSmrg --) break ;; 17618292847cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 17628292847cSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17638292847cSmrg esac 17648292847cSmrg done 17658292847cSmrg 17668292847cSmrg # save modified positional parameters for caller 17678292847cSmrg func_quote_for_eval ${1+"$@"} 17688292847cSmrg func_parse_options_result=$func_quote_for_eval_result 1769c76ae52dSmrg} 1770c76ae52dSmrg 1771c2939121Smrg 17728292847cSmrg# func_validate_options [ARG]... 17738292847cSmrg# ------------------------------ 17748292847cSmrg# Perform any sanity checks on option settings and/or unconsumed 17758292847cSmrg# arguments. 17768292847cSmrgfunc_hookable func_validate_options 17778292847cSmrgfunc_validate_options () 1778c76ae52dSmrg{ 17798292847cSmrg $debug_cmd 1780c76ae52dSmrg 17818292847cSmrg # Display all warnings if -W was not given. 17828292847cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783c76ae52dSmrg 17848292847cSmrg func_run_hooks func_validate_options ${1+"$@"} 1785c76ae52dSmrg 17868292847cSmrg # Bail if the options were screwed! 17878292847cSmrg $exit_cmd $EXIT_FAILURE 17888292847cSmrg 17898292847cSmrg # save modified positional parameters for caller 17908292847cSmrg func_validate_options_result=$func_run_hooks_result 17912836776bSmrg} 17922836776bSmrg 1793c76ae52dSmrg 17942836776bSmrg 17958292847cSmrg## ----------------- ## 17968292847cSmrg## Helper functions. ## 17978292847cSmrg## ----------------- ## 1798c76ae52dSmrg 17998292847cSmrg# This section contains the helper functions used by the rest of the 18008292847cSmrg# hookable option parser framework in ascii-betical order. 18018292847cSmrg 18028292847cSmrg 18038292847cSmrg# func_fatal_help ARG... 18048292847cSmrg# ---------------------- 18058292847cSmrg# Echo program name prefixed message to standard error, followed by 18068292847cSmrg# a help hint, and exit. 18078292847cSmrgfunc_fatal_help () 1808c2939121Smrg{ 18098292847cSmrg $debug_cmd 18102836776bSmrg 18118292847cSmrg eval \$ECHO \""Usage: $usage"\" 18128292847cSmrg eval \$ECHO \""$fatal_help"\" 18138292847cSmrg func_error ${1+"$@"} 18148292847cSmrg exit $EXIT_FAILURE 1815c2939121Smrg} 1816c76ae52dSmrg 18178292847cSmrg 18188292847cSmrg# func_help 18198292847cSmrg# --------- 18208292847cSmrg# Echo long help message to standard output and exit. 1821c2939121Smrgfunc_help () 1822c2939121Smrg{ 18238292847cSmrg $debug_cmd 18248292847cSmrg 18258292847cSmrg func_usage_message 18268292847cSmrg $ECHO "$long_help_message" 18278292847cSmrg exit 0 1828c2939121Smrg} 1829c76ae52dSmrg 18308292847cSmrg 18318292847cSmrg# func_missing_arg ARGNAME 18328292847cSmrg# ------------------------ 1833c2939121Smrg# Echo program name prefixed message to standard error and set global 1834c2939121Smrg# exit_cmd. 1835c2939121Smrgfunc_missing_arg () 1836c2939121Smrg{ 18378292847cSmrg $debug_cmd 18382836776bSmrg 18398292847cSmrg func_error "Missing argument for '$1'." 1840c2939121Smrg exit_cmd=exit 1841c2939121Smrg} 1842c76ae52dSmrg 1843c76ae52dSmrg 18448292847cSmrg# func_split_equals STRING 18458292847cSmrg# ------------------------ 18468292847cSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 18478292847cSmrg# splitting STRING at the '=' sign. 18488292847cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 18498292847cSmrg && (eval 'x=a/b/c; 18508292847cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 18518292847cSmrg && _G_HAVE_XSI_OPS=yes 18528292847cSmrg 18538292847cSmrgif test yes = "$_G_HAVE_XSI_OPS" 18548292847cSmrgthen 18558292847cSmrg # This is an XSI compatible shell, allowing a faster implementation... 18568292847cSmrg eval 'func_split_equals () 18578292847cSmrg { 18588292847cSmrg $debug_cmd 18598292847cSmrg 18608292847cSmrg func_split_equals_lhs=${1%%=*} 18618292847cSmrg func_split_equals_rhs=${1#*=} 18628292847cSmrg test "x$func_split_equals_lhs" = "x$1" \ 18638292847cSmrg && func_split_equals_rhs= 18648292847cSmrg }' 18658292847cSmrgelse 18668292847cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 18678292847cSmrg func_split_equals () 18688292847cSmrg { 18698292847cSmrg $debug_cmd 18708292847cSmrg 18718292847cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 18728292847cSmrg func_split_equals_rhs= 18738292847cSmrg test "x$func_split_equals_lhs" = "x$1" \ 18748292847cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 18758292847cSmrg } 18768292847cSmrgfi #func_split_equals 18778292847cSmrg 18788292847cSmrg 18798292847cSmrg# func_split_short_opt SHORTOPT 18808292847cSmrg# ----------------------------- 18812836776bSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 18822836776bSmrg# variables after splitting SHORTOPT after the 2nd character. 18838292847cSmrgif test yes = "$_G_HAVE_XSI_OPS" 18848292847cSmrgthen 18858292847cSmrg # This is an XSI compatible shell, allowing a faster implementation... 18868292847cSmrg eval 'func_split_short_opt () 18878292847cSmrg { 18888292847cSmrg $debug_cmd 18898292847cSmrg 18908292847cSmrg func_split_short_opt_arg=${1#??} 18918292847cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 18928292847cSmrg }' 18938292847cSmrgelse 18948292847cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 18958292847cSmrg func_split_short_opt () 18968292847cSmrg { 18978292847cSmrg $debug_cmd 18988292847cSmrg 18998292847cSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 19008292847cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 19018292847cSmrg } 19028292847cSmrgfi #func_split_short_opt 19038292847cSmrg 19048292847cSmrg 19058292847cSmrg# func_usage 19068292847cSmrg# ---------- 19078292847cSmrg# Echo short help message to standard output and exit. 19088292847cSmrgfunc_usage () 19092836776bSmrg{ 19108292847cSmrg $debug_cmd 19112836776bSmrg 19128292847cSmrg func_usage_message 19138292847cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 19148292847cSmrg exit 0 19158292847cSmrg} 19162836776bSmrg 19172836776bSmrg 19188292847cSmrg# func_usage_message 19198292847cSmrg# ------------------ 19208292847cSmrg# Echo short help message to standard output. 19218292847cSmrgfunc_usage_message () 19222836776bSmrg{ 19238292847cSmrg $debug_cmd 19242836776bSmrg 19258292847cSmrg eval \$ECHO \""Usage: $usage"\" 19268292847cSmrg echo 19278292847cSmrg $SED -n 's|^# || 19288292847cSmrg /^Written by/{ 19298292847cSmrg x;p;x 19308292847cSmrg } 19318292847cSmrg h 19328292847cSmrg /^Written by/q' < "$progpath" 19338292847cSmrg echo 19348292847cSmrg eval \$ECHO \""$usage_message"\" 19358292847cSmrg} 19362836776bSmrg 1937c76ae52dSmrg 19388292847cSmrg# func_version 19398292847cSmrg# ------------ 19408292847cSmrg# Echo version message to standard output and exit. 19418292847cSmrgfunc_version () 19428292847cSmrg{ 19438292847cSmrg $debug_cmd 1944c76ae52dSmrg 19458292847cSmrg printf '%s\n' "$progname $scriptversion" 19468292847cSmrg $SED -n ' 19478292847cSmrg /(C)/!b go 19488292847cSmrg :more 19498292847cSmrg /\./!{ 19508292847cSmrg N 19518292847cSmrg s|\n# | | 19528292847cSmrg b more 19538292847cSmrg } 19548292847cSmrg :go 19558292847cSmrg /^# Written by /,/# warranty; / { 19568292847cSmrg s|^# || 19578292847cSmrg s|^# *$|| 19588292847cSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 19598292847cSmrg p 19608292847cSmrg } 19618292847cSmrg /^# Written by / { 19628292847cSmrg s|^# || 19638292847cSmrg p 19648292847cSmrg } 19658292847cSmrg /^warranty; /q' < "$progpath" 19660d590c07Smrg 19678292847cSmrg exit $? 19688292847cSmrg} 1969c76ae52dSmrg 1970c2939121Smrg 19718292847cSmrg# Local variables: 19728292847cSmrg# mode: shell-script 19738292847cSmrg# sh-indentation: 2 19748292847cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 19758292847cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 19768292847cSmrg# time-stamp-time-zone: "UTC" 19778292847cSmrg# End: 1978c2939121Smrg 19798292847cSmrg# Set a version string. 19808292847cSmrgscriptversion='(GNU libtool) 2.4.6' 1981c2939121Smrg 1982c2939121Smrg 19838292847cSmrg# func_echo ARG... 19848292847cSmrg# ---------------- 19858292847cSmrg# Libtool also displays the current mode in messages, so override 19868292847cSmrg# funclib.sh func_echo with this custom definition. 19878292847cSmrgfunc_echo () 19882836776bSmrg{ 19898292847cSmrg $debug_cmd 19902836776bSmrg 19918292847cSmrg _G_message=$* 19922836776bSmrg 19938292847cSmrg func_echo_IFS=$IFS 19948292847cSmrg IFS=$nl 19958292847cSmrg for _G_line in $_G_message; do 19968292847cSmrg IFS=$func_echo_IFS 19978292847cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 19988292847cSmrg done 19998292847cSmrg IFS=$func_echo_IFS 20008292847cSmrg} 20012836776bSmrg 20028292847cSmrg 20038292847cSmrg# func_warning ARG... 20048292847cSmrg# ------------------- 20058292847cSmrg# Libtool warnings are not categorized, so override funclib.sh 20068292847cSmrg# func_warning with this simpler definition. 20078292847cSmrgfunc_warning () 20082836776bSmrg{ 20098292847cSmrg $debug_cmd 20102836776bSmrg 20118292847cSmrg $warning_func ${1+"$@"} 20128292847cSmrg} 20132836776bSmrg 20142836776bSmrg 20158292847cSmrg## ---------------- ## 20168292847cSmrg## Options parsing. ## 20178292847cSmrg## ---------------- ## 20188292847cSmrg 20198292847cSmrg# Hook in the functions to make sure our own options are parsed during 20208292847cSmrg# the option parsing loop. 20218292847cSmrg 20228292847cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 20238292847cSmrg 20248292847cSmrg# Short help message in response to '-h'. 20258292847cSmrgusage_message="Options: 20268292847cSmrg --config show all configuration variables 20278292847cSmrg --debug enable verbose shell tracing 20288292847cSmrg -n, --dry-run display commands without modifying any files 20298292847cSmrg --features display basic configuration information and exit 20308292847cSmrg --mode=MODE use operation mode MODE 20318292847cSmrg --no-warnings equivalent to '-Wnone' 20328292847cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 20338292847cSmrg --quiet, --silent don't print informational messages 20348292847cSmrg --tag=TAG use configuration variables from tag TAG 20358292847cSmrg -v, --verbose print more informational messages than default 20368292847cSmrg --version print version information 20378292847cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 20388292847cSmrg -h, --help, --help-all print short, long, or detailed help message 20398292847cSmrg" 20402836776bSmrg 20418292847cSmrg# Additional text appended to 'usage_message' in response to '--help'. 20428292847cSmrgfunc_help () 20432836776bSmrg{ 20448292847cSmrg $debug_cmd 20458292847cSmrg 20468292847cSmrg func_usage_message 20478292847cSmrg $ECHO "$long_help_message 20488292847cSmrg 20498292847cSmrgMODE must be one of the following: 20508292847cSmrg 20518292847cSmrg clean remove files from the build directory 20528292847cSmrg compile compile a source file into a libtool object 20538292847cSmrg execute automatically set library path, then run a program 20548292847cSmrg finish complete the installation of libtool libraries 20558292847cSmrg install install libraries or executables 20568292847cSmrg link create a library or an executable 20578292847cSmrg uninstall remove libraries from an installed directory 20588292847cSmrg 20598292847cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 20608292847cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 20618292847cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 20628292847cSmrg 20638292847cSmrgWhen reporting a bug, please describe a test case to reproduce it and 20648292847cSmrginclude the following information: 20658292847cSmrg 20668292847cSmrg host-triplet: $host 20678292847cSmrg shell: $SHELL 20688292847cSmrg compiler: $LTCC 20698292847cSmrg compiler flags: $LTCFLAGS 20708292847cSmrg linker: $LD (gnu? $with_gnu_ld) 20718292847cSmrg version: $progname (GNU libtool) 2.4.6 20728292847cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 20738292847cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 20748292847cSmrg 20758292847cSmrgReport bugs to <bug-libtool@gnu.org>. 20768292847cSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 20778292847cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 20788292847cSmrg exit 0 20798292847cSmrg} 20802836776bSmrg 20812836776bSmrg 20828292847cSmrg# func_lo2o OBJECT-NAME 20838292847cSmrg# --------------------- 20848292847cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 20858292847cSmrg# object suffix. 20868292847cSmrg 20878292847cSmrglo2o=s/\\.lo\$/.$objext/ 20888292847cSmrgo2lo=s/\\.$objext\$/.lo/ 20898292847cSmrg 20908292847cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 20918292847cSmrg eval 'func_lo2o () 20928292847cSmrg { 20938292847cSmrg case $1 in 20948292847cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 20958292847cSmrg * ) func_lo2o_result=$1 ;; 20968292847cSmrg esac 20978292847cSmrg }' 20988292847cSmrg 20998292847cSmrg # func_xform LIBOBJ-OR-SOURCE 21008292847cSmrg # --------------------------- 21018292847cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 21028292847cSmrg # suffix to a '.lo' libtool-object suffix. 21038292847cSmrg eval 'func_xform () 21048292847cSmrg { 21058292847cSmrg func_xform_result=${1%.*}.lo 21068292847cSmrg }' 21078292847cSmrgelse 21088292847cSmrg # ...otherwise fall back to using sed. 21098292847cSmrg func_lo2o () 21108292847cSmrg { 21118292847cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 21128292847cSmrg } 21138292847cSmrg 21148292847cSmrg func_xform () 21158292847cSmrg { 21168292847cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 21178292847cSmrg } 21188292847cSmrgfi 21192836776bSmrg 21202836776bSmrg 21218292847cSmrg# func_fatal_configuration ARG... 21228292847cSmrg# ------------------------------- 2123c2939121Smrg# Echo program name prefixed message to standard error, followed by 2124c2939121Smrg# a configuration failure hint, and exit. 2125c2939121Smrgfunc_fatal_configuration () 2126c2939121Smrg{ 21278292847cSmrg func__fatal_error ${1+"$@"} \ 21288292847cSmrg "See the $PACKAGE documentation for more information." \ 21298292847cSmrg "Fatal configuration error." 2130c2939121Smrg} 2131c2939121Smrg 2132c2939121Smrg 2133c2939121Smrg# func_config 21348292847cSmrg# ----------- 2135c2939121Smrg# Display the configuration for all the tags in this script. 2136c2939121Smrgfunc_config () 2137c2939121Smrg{ 2138c2939121Smrg re_begincf='^# ### BEGIN LIBTOOL' 2139c2939121Smrg re_endcf='^# ### END LIBTOOL' 2140c2939121Smrg 2141c2939121Smrg # Default configuration. 2142c2939121Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143c2939121Smrg 2144c76ae52dSmrg # Now print the configurations for the tags. 2145c76ae52dSmrg for tagname in $taglist; do 2146c2939121Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147c76ae52dSmrg done 2148c76ae52dSmrg 2149c2939121Smrg exit $? 2150c2939121Smrg} 2151c76ae52dSmrg 21528292847cSmrg 2153c2939121Smrg# func_features 21548292847cSmrg# ------------- 2155c2939121Smrg# Display the features supported by this script. 2156c2939121Smrgfunc_features () 2157c2939121Smrg{ 2158c2939121Smrg echo "host: $host" 21598292847cSmrg if test yes = "$build_libtool_libs"; then 2160c2939121Smrg echo "enable shared libraries" 2161c76ae52dSmrg else 2162c2939121Smrg echo "disable shared libraries" 2163c76ae52dSmrg fi 21648292847cSmrg if test yes = "$build_old_libs"; then 2165c2939121Smrg echo "enable static libraries" 2166c76ae52dSmrg else 2167c2939121Smrg echo "disable static libraries" 2168c76ae52dSmrg fi 2169c2939121Smrg 2170c76ae52dSmrg exit $? 2171c2939121Smrg} 2172c76ae52dSmrg 21738292847cSmrg 21748292847cSmrg# func_enable_tag TAGNAME 21758292847cSmrg# ----------------------- 2176c2939121Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177c2939121Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178c2939121Smrg# variable here. 2179c2939121Smrgfunc_enable_tag () 2180c2939121Smrg{ 21818292847cSmrg # Global variable: 21828292847cSmrg tagname=$1 2183c76ae52dSmrg 21848292847cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 21858292847cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 21868292847cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187c76ae52dSmrg 21888292847cSmrg # Validate tagname. 21898292847cSmrg case $tagname in 21908292847cSmrg *[!-_A-Za-z0-9,/]*) 21918292847cSmrg func_fatal_error "invalid tag name: $tagname" 21928292847cSmrg ;; 21938292847cSmrg esac 2194c76ae52dSmrg 21958292847cSmrg # Don't test for the "default" C tag, as we know it's 21968292847cSmrg # there but not specially marked. 21978292847cSmrg case $tagname in 21988292847cSmrg CC) ;; 2199c2939121Smrg *) 22008292847cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 22018292847cSmrg taglist="$taglist $tagname" 22028292847cSmrg 22038292847cSmrg # Evaluate the configuration. Be careful to quote the path 22048292847cSmrg # and the sed script, to avoid splitting on whitespace, but 22058292847cSmrg # also don't use non-portable quotes within backquotes within 22068292847cSmrg # quotes we have to do it in 2 steps: 22078292847cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 22088292847cSmrg eval "$extractedcf" 22098292847cSmrg else 22108292847cSmrg func_error "ignoring unknown tag $tagname" 22118292847cSmrg fi 22128292847cSmrg ;; 22138292847cSmrg esac 2214c2939121Smrg} 2215c2939121Smrg 22168292847cSmrg 22172836776bSmrg# func_check_version_match 22188292847cSmrg# ------------------------ 22192836776bSmrg# Ensure that we are using m4 macros, and libtool script from the same 22202836776bSmrg# release of libtool. 22212836776bSmrgfunc_check_version_match () 2222c2939121Smrg{ 22238292847cSmrg if test "$package_revision" != "$macro_revision"; then 22248292847cSmrg if test "$VERSION" != "$macro_version"; then 22258292847cSmrg if test -z "$macro_version"; then 22268292847cSmrg cat >&2 <<_LT_EOF 22272836776bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22282836776bSmrg$progname: definition of this LT_INIT comes from an older release. 22292836776bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22302836776bSmrg$progname: and run autoconf again. 22312836776bSmrg_LT_EOF 22328292847cSmrg else 22338292847cSmrg cat >&2 <<_LT_EOF 22342836776bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 22352836776bSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 22362836776bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 22372836776bSmrg$progname: and run autoconf again. 22382836776bSmrg_LT_EOF 22398292847cSmrg fi 22408292847cSmrg else 22418292847cSmrg cat >&2 <<_LT_EOF 22422836776bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 22432836776bSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 22442836776bSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 22452836776bSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 22462836776bSmrg_LT_EOF 22478292847cSmrg fi 22482836776bSmrg 22498292847cSmrg exit $EXIT_MISMATCH 22508292847cSmrg fi 22512836776bSmrg} 22522836776bSmrg 22532836776bSmrg 22548292847cSmrg# libtool_options_prep [ARG]... 22558292847cSmrg# ----------------------------- 22568292847cSmrg# Preparation for options parsed by libtool. 22578292847cSmrglibtool_options_prep () 22588292847cSmrg{ 22598292847cSmrg $debug_mode 22602836776bSmrg 22618292847cSmrg # Option defaults: 22628292847cSmrg opt_config=false 22638292847cSmrg opt_dlopen= 22648292847cSmrg opt_dry_run=false 22658292847cSmrg opt_help=false 22668292847cSmrg opt_mode= 22678292847cSmrg opt_preserve_dup_deps=false 22688292847cSmrg opt_quiet=false 22692836776bSmrg 22708292847cSmrg nonopt= 22718292847cSmrg preserve_args= 22722836776bSmrg 22738292847cSmrg # Shorthand for --mode=foo, only valid as the first argument 22748292847cSmrg case $1 in 22758292847cSmrg clean|clea|cle|cl) 22768292847cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 22778292847cSmrg ;; 22788292847cSmrg compile|compil|compi|comp|com|co|c) 22798292847cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 22808292847cSmrg ;; 22818292847cSmrg execute|execut|execu|exec|exe|ex|e) 22828292847cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 22838292847cSmrg ;; 22848292847cSmrg finish|finis|fini|fin|fi|f) 22858292847cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 22868292847cSmrg ;; 22878292847cSmrg install|instal|insta|inst|ins|in|i) 22888292847cSmrg shift; set dummy --mode install ${1+"$@"}; shift 22898292847cSmrg ;; 22908292847cSmrg link|lin|li|l) 22918292847cSmrg shift; set dummy --mode link ${1+"$@"}; shift 22928292847cSmrg ;; 22938292847cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 22948292847cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 22958292847cSmrg ;; 22968292847cSmrg esac 22978292847cSmrg 22988292847cSmrg # Pass back the list of options. 22998292847cSmrg func_quote_for_eval ${1+"$@"} 23008292847cSmrg libtool_options_prep_result=$func_quote_for_eval_result 23018292847cSmrg} 23028292847cSmrgfunc_add_hook func_options_prep libtool_options_prep 2303c76ae52dSmrg 2304c76ae52dSmrg 23058292847cSmrg# libtool_parse_options [ARG]... 23068292847cSmrg# --------------------------------- 23078292847cSmrg# Provide handling for libtool specific options. 23088292847cSmrglibtool_parse_options () 23092836776bSmrg{ 23108292847cSmrg $debug_cmd 2311c2939121Smrg 23128292847cSmrg # Perform our own loop to consume as many options as possible in 23138292847cSmrg # each iteration. 23148292847cSmrg while test $# -gt 0; do 23158292847cSmrg _G_opt=$1 23168292847cSmrg shift 23178292847cSmrg case $_G_opt in 23188292847cSmrg --dry-run|--dryrun|-n) 23198292847cSmrg opt_dry_run=: 23208292847cSmrg ;; 23218292847cSmrg 23228292847cSmrg --config) func_config ;; 23238292847cSmrg 23248292847cSmrg --dlopen|-dlopen) 23258292847cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 23268292847cSmrg}$1" 23278292847cSmrg shift 23288292847cSmrg ;; 23298292847cSmrg 23308292847cSmrg --preserve-dup-deps) 23318292847cSmrg opt_preserve_dup_deps=: ;; 23328292847cSmrg 23338292847cSmrg --features) func_features ;; 23348292847cSmrg 23358292847cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 23368292847cSmrg 23378292847cSmrg --help) opt_help=: ;; 23388292847cSmrg 23398292847cSmrg --help-all) opt_help=': help-all' ;; 23408292847cSmrg 23418292847cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 23428292847cSmrg opt_mode=$1 23438292847cSmrg case $1 in 23448292847cSmrg # Valid mode arguments: 23458292847cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 23468292847cSmrg 23478292847cSmrg # Catch anything else as an error 23488292847cSmrg *) func_error "invalid argument for $_G_opt" 23498292847cSmrg exit_cmd=exit 23508292847cSmrg break 23518292847cSmrg ;; 23528292847cSmrg esac 23538292847cSmrg shift 23548292847cSmrg ;; 23558292847cSmrg 23568292847cSmrg --no-silent|--no-quiet) 23578292847cSmrg opt_quiet=false 23588292847cSmrg func_append preserve_args " $_G_opt" 23598292847cSmrg ;; 23608292847cSmrg 23618292847cSmrg --no-warnings|--no-warning|--no-warn) 23628292847cSmrg opt_warning=false 23638292847cSmrg func_append preserve_args " $_G_opt" 23648292847cSmrg ;; 23658292847cSmrg 23668292847cSmrg --no-verbose) 23678292847cSmrg opt_verbose=false 23688292847cSmrg func_append preserve_args " $_G_opt" 23698292847cSmrg ;; 23708292847cSmrg 23718292847cSmrg --silent|--quiet) 23728292847cSmrg opt_quiet=: 23738292847cSmrg opt_verbose=false 23748292847cSmrg func_append preserve_args " $_G_opt" 23758292847cSmrg ;; 23768292847cSmrg 23778292847cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 23788292847cSmrg opt_tag=$1 23798292847cSmrg func_append preserve_args " $_G_opt $1" 23808292847cSmrg func_enable_tag "$1" 23818292847cSmrg shift 23828292847cSmrg ;; 23838292847cSmrg 23848292847cSmrg --verbose|-v) opt_quiet=false 23858292847cSmrg opt_verbose=: 23868292847cSmrg func_append preserve_args " $_G_opt" 23878292847cSmrg ;; 23888292847cSmrg 23898292847cSmrg # An option not handled by this hook function: 23908292847cSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 23918292847cSmrg esac 23928292847cSmrg done 23932836776bSmrg 23942836776bSmrg 23958292847cSmrg # save modified positional parameters for caller 23968292847cSmrg func_quote_for_eval ${1+"$@"} 23978292847cSmrg libtool_parse_options_result=$func_quote_for_eval_result 23988292847cSmrg} 23998292847cSmrgfunc_add_hook func_parse_options libtool_parse_options 2400c2939121Smrg 2401c76ae52dSmrg 2402c2939121Smrg 24038292847cSmrg# libtool_validate_options [ARG]... 24048292847cSmrg# --------------------------------- 24058292847cSmrg# Perform any sanity checks on option settings and/or unconsumed 24068292847cSmrg# arguments. 24078292847cSmrglibtool_validate_options () 24088292847cSmrg{ 24098292847cSmrg # save first non-option argument 24108292847cSmrg if test 0 -lt $#; then 24118292847cSmrg nonopt=$1 24128292847cSmrg shift 2413c2939121Smrg fi 2414c2939121Smrg 24158292847cSmrg # preserve --debug 24168292847cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417c2939121Smrg 24188292847cSmrg case $host in 24198292847cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 24208292847cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 24218292847cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 24228292847cSmrg # don't eliminate duplications in $postdeps and $predeps 24238292847cSmrg opt_duplicate_compiler_generated_deps=: 24248292847cSmrg ;; 24258292847cSmrg *) 24268292847cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 24278292847cSmrg ;; 24288292847cSmrg esac 2429c2939121Smrg 24308292847cSmrg $opt_help || { 24318292847cSmrg # Sanity checks first: 24328292847cSmrg func_check_version_match 24338292847cSmrg 24348292847cSmrg test yes != "$build_libtool_libs" \ 24358292847cSmrg && test yes != "$build_old_libs" \ 24368292847cSmrg && func_fatal_configuration "not configured to build any kind of library" 24378292847cSmrg 24388292847cSmrg # Darwin sucks 24398292847cSmrg eval std_shrext=\"$shrext_cmds\" 24408292847cSmrg 24418292847cSmrg # Only execute mode is allowed to have -dlopen flags. 24428292847cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 24438292847cSmrg func_error "unrecognized option '-dlopen'" 24448292847cSmrg $ECHO "$help" 1>&2 24458292847cSmrg exit $EXIT_FAILURE 24468292847cSmrg fi 2447c2939121Smrg 24488292847cSmrg # Change the help message to a mode-specific one. 24498292847cSmrg generic_help=$help 24508292847cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 24518292847cSmrg } 2452c2939121Smrg 24538292847cSmrg # Pass back the unparsed argument list 24548292847cSmrg func_quote_for_eval ${1+"$@"} 24558292847cSmrg libtool_validate_options_result=$func_quote_for_eval_result 24562836776bSmrg} 24578292847cSmrgfunc_add_hook func_validate_options libtool_validate_options 2458c2939121Smrg 2459c2939121Smrg 24608292847cSmrg# Process options as early as possible so that --help and --version 24618292847cSmrg# can return quickly. 24628292847cSmrgfunc_options ${1+"$@"} 24638292847cSmrgeval set dummy "$func_options_result"; shift 24648292847cSmrg 2465c76ae52dSmrg 2466c76ae52dSmrg 24672836776bSmrg## ----------- ## 24682836776bSmrg## Main. ## 24692836776bSmrg## ----------- ## 2470c76ae52dSmrg 24718292847cSmrgmagic='%%%MAGIC variable%%%' 24728292847cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 24738292847cSmrg 24748292847cSmrg# Global variables. 24758292847cSmrgextracted_archives= 24768292847cSmrgextracted_serial=0 24778292847cSmrg 24788292847cSmrg# If this variable is set in any of the actions, the command in it 24798292847cSmrg# will be execed at the end. This prevents here-documents from being 24808292847cSmrg# left over by shells. 24818292847cSmrgexec_cmd= 24828292847cSmrg 24838292847cSmrg 24848292847cSmrg# A function that is used when there is no print builtin or printf. 24858292847cSmrgfunc_fallback_echo () 24868292847cSmrg{ 24878292847cSmrg eval 'cat <<_LTECHO_EOF 24888292847cSmrg$1 24898292847cSmrg_LTECHO_EOF' 24908292847cSmrg} 24918292847cSmrg 24928292847cSmrg# func_generated_by_libtool 24938292847cSmrg# True iff stdin has been generated by Libtool. This function is only 24948292847cSmrg# a basic sanity check; it will hardly flush out determined imposters. 24958292847cSmrgfunc_generated_by_libtool_p () 24968292847cSmrg{ 24978292847cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 24988292847cSmrg} 24998292847cSmrg 2500c2939121Smrg# func_lalib_p file 25018292847cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2503c2939121Smrg# determined imposters. 2504c2939121Smrgfunc_lalib_p () 2505c2939121Smrg{ 2506c2939121Smrg test -f "$1" && 25078292847cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508c2939121Smrg} 2509c76ae52dSmrg 2510c2939121Smrg# func_lalib_unsafe_p file 25118292847cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512c2939121Smrg# This function implements the same check as func_lalib_p without 2513c2939121Smrg# resorting to external programs. To this end, it redirects stdin and 2514c2939121Smrg# closes it afterwards, without saving the original file descriptor. 2515c2939121Smrg# As a safety measure, use it only where a negative result would be 25168292847cSmrg# fatal anyway. Works if 'file' does not exist. 2517c2939121Smrgfunc_lalib_unsafe_p () 2518c2939121Smrg{ 2519c2939121Smrg lalib_p=no 2520c2939121Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521c2939121Smrg for lalib_p_l in 1 2 3 4 2522c2939121Smrg do 2523c2939121Smrg read lalib_p_line 25248292847cSmrg case $lalib_p_line in 2525c2939121Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526c2939121Smrg esac 2527c2939121Smrg done 2528c2939121Smrg exec 0<&5 5<&- 2529c2939121Smrg fi 25308292847cSmrg test yes = "$lalib_p" 2531c2939121Smrg} 2532c76ae52dSmrg 2533c2939121Smrg# func_ltwrapper_script_p file 2534c2939121Smrg# True iff FILE is a libtool wrapper script 2535c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2536c2939121Smrg# determined imposters. 2537c2939121Smrgfunc_ltwrapper_script_p () 2538c2939121Smrg{ 25398292847cSmrg test -f "$1" && 25408292847cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541c2939121Smrg} 2542c76ae52dSmrg 2543c2939121Smrg# func_ltwrapper_executable_p file 2544c2939121Smrg# True iff FILE is a libtool wrapper executable 2545c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2546c2939121Smrg# determined imposters. 2547c2939121Smrgfunc_ltwrapper_executable_p () 2548c2939121Smrg{ 2549c2939121Smrg func_ltwrapper_exec_suffix= 2550c2939121Smrg case $1 in 2551c2939121Smrg *.exe) ;; 2552c2939121Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553c2939121Smrg esac 2554c2939121Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555c2939121Smrg} 2556c2939121Smrg 2557c2939121Smrg# func_ltwrapper_scriptname file 2558c2939121Smrg# Assumes file is an ltwrapper_executable 2559c2939121Smrg# uses $file to determine the appropriate filename for a 2560c2939121Smrg# temporary ltwrapper_script. 2561c2939121Smrgfunc_ltwrapper_scriptname () 2562c2939121Smrg{ 25632836776bSmrg func_dirname_and_basename "$1" "" "." 25642836776bSmrg func_stripname '' '.exe' "$func_basename_result" 25658292847cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566c2939121Smrg} 2567c2939121Smrg 2568c2939121Smrg# func_ltwrapper_p file 2569c2939121Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2570c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2571c2939121Smrg# determined imposters. 2572c2939121Smrgfunc_ltwrapper_p () 2573c2939121Smrg{ 2574c2939121Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575c2939121Smrg} 2576c2939121Smrg 2577c2939121Smrg 2578c2939121Smrg# func_execute_cmds commands fail_cmd 2579c2939121Smrg# Execute tilde-delimited COMMANDS. 2580c2939121Smrg# If FAIL_CMD is given, eval that upon failure. 2581c2939121Smrg# FAIL_CMD may read-access the current command in variable CMD! 2582c2939121Smrgfunc_execute_cmds () 2583c2939121Smrg{ 25848292847cSmrg $debug_cmd 25858292847cSmrg 2586c2939121Smrg save_ifs=$IFS; IFS='~' 2587c2939121Smrg for cmd in $1; do 25888292847cSmrg IFS=$sp$nl 2589c2939121Smrg eval cmd=\"$cmd\" 25908292847cSmrg IFS=$save_ifs 2591c2939121Smrg func_show_eval "$cmd" "${2-:}" 2592c2939121Smrg done 2593c2939121Smrg IFS=$save_ifs 2594c2939121Smrg} 2595c2939121Smrg 2596c2939121Smrg 2597c2939121Smrg# func_source file 2598c2939121Smrg# Source FILE, adding directory component if necessary. 2599c2939121Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600c2939121Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601c2939121Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 26028292847cSmrg# 'FILE.' does not work on cygwin managed mounts. 2603c2939121Smrgfunc_source () 2604c2939121Smrg{ 26058292847cSmrg $debug_cmd 26068292847cSmrg 2607c2939121Smrg case $1 in 2608c2939121Smrg */* | *\\*) . "$1" ;; 2609c2939121Smrg *) . "./$1" ;; 2610c2939121Smrg esac 2611c2939121Smrg} 2612c2939121Smrg 2613c2939121Smrg 26142836776bSmrg# func_resolve_sysroot PATH 26152836776bSmrg# Replace a leading = in PATH with a sysroot. Store the result into 26162836776bSmrg# func_resolve_sysroot_result 26172836776bSmrgfunc_resolve_sysroot () 26182836776bSmrg{ 26192836776bSmrg func_resolve_sysroot_result=$1 26202836776bSmrg case $func_resolve_sysroot_result in 26212836776bSmrg =*) 26222836776bSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 26232836776bSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 26242836776bSmrg ;; 26252836776bSmrg esac 26262836776bSmrg} 26272836776bSmrg 26282836776bSmrg# func_replace_sysroot PATH 26292836776bSmrg# If PATH begins with the sysroot, replace it with = and 26302836776bSmrg# store the result into func_replace_sysroot_result. 26312836776bSmrgfunc_replace_sysroot () 26322836776bSmrg{ 26338292847cSmrg case $lt_sysroot:$1 in 26342836776bSmrg ?*:"$lt_sysroot"*) 26352836776bSmrg func_stripname "$lt_sysroot" '' "$1" 26368292847cSmrg func_replace_sysroot_result='='$func_stripname_result 26372836776bSmrg ;; 26382836776bSmrg *) 26392836776bSmrg # Including no sysroot. 26402836776bSmrg func_replace_sysroot_result=$1 26412836776bSmrg ;; 26422836776bSmrg esac 26432836776bSmrg} 26442836776bSmrg 2645c2939121Smrg# func_infer_tag arg 2646c2939121Smrg# Infer tagged configuration to use if any are available and 2647c2939121Smrg# if one wasn't chosen via the "--tag" command line option. 2648c2939121Smrg# Only attempt this if the compiler in the base compile 2649c2939121Smrg# command doesn't match the default compiler. 2650c2939121Smrg# arg is usually of the form 'gcc ...' 2651c2939121Smrgfunc_infer_tag () 2652c2939121Smrg{ 26538292847cSmrg $debug_cmd 26548292847cSmrg 2655c2939121Smrg if test -n "$available_tags" && test -z "$tagname"; then 2656c2939121Smrg CC_quoted= 2657c2939121Smrg for arg in $CC; do 26582836776bSmrg func_append_quoted CC_quoted "$arg" 2659c2939121Smrg done 2660c2939121Smrg CC_expanded=`func_echo_all $CC` 2661c2939121Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662c2939121Smrg case $@ in 2663c2939121Smrg # Blanks in the command may have been stripped by the calling shell, 2664c2939121Smrg # but not from the CC environment variable when configure was run. 2665c2939121Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666c2939121Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667c2939121Smrg # Blanks at the start of $base_compile will cause this to fail 2668c2939121Smrg # if we don't check for them as well. 2669c2939121Smrg *) 2670c2939121Smrg for z in $available_tags; do 2671c2939121Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672c2939121Smrg # Evaluate the configuration. 26738292847cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674c2939121Smrg CC_quoted= 2675c2939121Smrg for arg in $CC; do 2676c2939121Smrg # Double-quote args containing other shell metacharacters. 26772836776bSmrg func_append_quoted CC_quoted "$arg" 2678c2939121Smrg done 2679c2939121Smrg CC_expanded=`func_echo_all $CC` 2680c2939121Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681c2939121Smrg case "$@ " in 2682c2939121Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683c2939121Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684c2939121Smrg # The compiler in the base compile command matches 2685c2939121Smrg # the one in the tagged configuration. 2686c2939121Smrg # Assume this is the tagged configuration we want. 2687c2939121Smrg tagname=$z 2688c2939121Smrg break 2689c2939121Smrg ;; 2690c2939121Smrg esac 2691c2939121Smrg fi 2692c2939121Smrg done 2693c2939121Smrg # If $tagname still isn't set, then no tagged configuration 2694c2939121Smrg # was found and let the user know that the "--tag" command 2695c2939121Smrg # line option must be used. 2696c2939121Smrg if test -z "$tagname"; then 2697c2939121Smrg func_echo "unable to infer tagged configuration" 26988292847cSmrg func_fatal_error "specify a tag with '--tag'" 2699c2939121Smrg# else 2700c2939121Smrg# func_verbose "using $tagname tagged configuration" 2701c2939121Smrg fi 2702c2939121Smrg ;; 2703c2939121Smrg esac 2704c2939121Smrg fi 2705c2939121Smrg} 2706c2939121Smrg 2707c2939121Smrg 27082836776bSmrg 27092836776bSmrg# func_write_libtool_object output_name pic_name nonpic_name 27102836776bSmrg# Create a libtool object file (analogous to a ".la" file), 27112836776bSmrg# but don't create it if we're doing a dry run. 27122836776bSmrgfunc_write_libtool_object () 27132836776bSmrg{ 27148292847cSmrg write_libobj=$1 27158292847cSmrg if test yes = "$build_libtool_libs"; then 27168292847cSmrg write_lobj=\'$2\' 27172836776bSmrg else 27182836776bSmrg write_lobj=none 27192836776bSmrg fi 27202836776bSmrg 27218292847cSmrg if test yes = "$build_old_libs"; then 27228292847cSmrg write_oldobj=\'$3\' 27232836776bSmrg else 27242836776bSmrg write_oldobj=none 27252836776bSmrg fi 27262836776bSmrg 27272836776bSmrg $opt_dry_run || { 27282836776bSmrg cat >${write_libobj}T <<EOF 27292836776bSmrg# $write_libobj - a libtool object file 27308292847cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 27312836776bSmrg# 27322836776bSmrg# Please DO NOT delete this file! 27332836776bSmrg# It is necessary for linking the library. 27342836776bSmrg 27352836776bSmrg# Name of the PIC object. 27362836776bSmrgpic_object=$write_lobj 27372836776bSmrg 27382836776bSmrg# Name of the non-PIC object 27392836776bSmrgnon_pic_object=$write_oldobj 27402836776bSmrg 27412836776bSmrgEOF 27428292847cSmrg $MV "${write_libobj}T" "$write_libobj" 27432836776bSmrg } 27442836776bSmrg} 27452836776bSmrg 27462836776bSmrg 27472836776bSmrg################################################## 27482836776bSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 27492836776bSmrg################################################## 27502836776bSmrg 27512836776bSmrg# func_convert_core_file_wine_to_w32 ARG 27522836776bSmrg# Helper function used by file name conversion functions when $build is *nix, 27532836776bSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 27542836776bSmrg# correctly configured wine environment available, with the winepath program 27552836776bSmrg# in $build's $PATH. 27562836776bSmrg# 27572836776bSmrg# ARG is the $build file name to be converted to w32 format. 27582836776bSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 27592836776bSmrg# be empty on error (or when ARG is empty) 27602836776bSmrgfunc_convert_core_file_wine_to_w32 () 27612836776bSmrg{ 27628292847cSmrg $debug_cmd 27638292847cSmrg 27648292847cSmrg func_convert_core_file_wine_to_w32_result=$1 27652836776bSmrg if test -n "$1"; then 27662836776bSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 27672836776bSmrg # are forced to check the contents of stdout. On the other hand, if the 27682836776bSmrg # command is not found, the shell will set an exit code of 127 and print 27692836776bSmrg # *an error message* to stdout. So we must check for both error code of 27702836776bSmrg # zero AND non-empty stdout, which explains the odd construction: 27712836776bSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 27728292847cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 27732836776bSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 27748292847cSmrg $SED -e "$sed_naive_backslashify"` 27752836776bSmrg else 27762836776bSmrg func_convert_core_file_wine_to_w32_result= 27772836776bSmrg fi 27782836776bSmrg fi 27792836776bSmrg} 27802836776bSmrg# end: func_convert_core_file_wine_to_w32 27812836776bSmrg 27822836776bSmrg 27832836776bSmrg# func_convert_core_path_wine_to_w32 ARG 27842836776bSmrg# Helper function used by path conversion functions when $build is *nix, and 27852836776bSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 27862836776bSmrg# configured wine environment available, with the winepath program in $build's 27872836776bSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 27882836776bSmrg# 27892836776bSmrg# ARG is path to be converted from $build format to win32. 27902836776bSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 27912836776bSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 27922836776bSmrg# are convertible, then the result may be empty. 27932836776bSmrgfunc_convert_core_path_wine_to_w32 () 27942836776bSmrg{ 27958292847cSmrg $debug_cmd 27968292847cSmrg 27972836776bSmrg # unfortunately, winepath doesn't convert paths, only file names 27988292847cSmrg func_convert_core_path_wine_to_w32_result= 27992836776bSmrg if test -n "$1"; then 28002836776bSmrg oldIFS=$IFS 28012836776bSmrg IFS=: 28022836776bSmrg for func_convert_core_path_wine_to_w32_f in $1; do 28032836776bSmrg IFS=$oldIFS 28042836776bSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 28058292847cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 28062836776bSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 28078292847cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 28082836776bSmrg else 28092836776bSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 28102836776bSmrg fi 28112836776bSmrg fi 28122836776bSmrg done 28132836776bSmrg IFS=$oldIFS 28142836776bSmrg fi 28152836776bSmrg} 28162836776bSmrg# end: func_convert_core_path_wine_to_w32 28172836776bSmrg 28182836776bSmrg 28192836776bSmrg# func_cygpath ARGS... 28202836776bSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 28212836776bSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 28222836776bSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 28232836776bSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 28242836776bSmrg# file name or path is assumed to be in w32 format, as previously converted 28252836776bSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 28262836776bSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 28272836776bSmrg# Cygwin format). Returns an empty string on error. 28282836776bSmrg# 28292836776bSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 28302836776bSmrg# be converted. 28312836776bSmrg# 28322836776bSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 28332836776bSmrg# environment variable; do not put it in $PATH. 28342836776bSmrgfunc_cygpath () 28352836776bSmrg{ 28368292847cSmrg $debug_cmd 28378292847cSmrg 28382836776bSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 28392836776bSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 28402836776bSmrg if test "$?" -ne 0; then 28412836776bSmrg # on failure, ensure result is empty 28422836776bSmrg func_cygpath_result= 28432836776bSmrg fi 28442836776bSmrg else 28452836776bSmrg func_cygpath_result= 28468292847cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 28472836776bSmrg fi 28482836776bSmrg} 28492836776bSmrg#end: func_cygpath 28502836776bSmrg 28512836776bSmrg 28522836776bSmrg# func_convert_core_msys_to_w32 ARG 28532836776bSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 28542836776bSmrg# result in func_convert_core_msys_to_w32_result. 28552836776bSmrgfunc_convert_core_msys_to_w32 () 28562836776bSmrg{ 28578292847cSmrg $debug_cmd 28588292847cSmrg 28592836776bSmrg # awkward: cmd appends spaces to result 28602836776bSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 28618292847cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 28622836776bSmrg} 28632836776bSmrg#end: func_convert_core_msys_to_w32 28642836776bSmrg 28652836776bSmrg 28662836776bSmrg# func_convert_file_check ARG1 ARG2 28672836776bSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 28682836776bSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 28692836776bSmrg# func_to_host_file_result to ARG1). 28702836776bSmrgfunc_convert_file_check () 28712836776bSmrg{ 28728292847cSmrg $debug_cmd 28738292847cSmrg 28748292847cSmrg if test -z "$2" && test -n "$1"; then 28752836776bSmrg func_error "Could not determine host file name corresponding to" 28768292847cSmrg func_error " '$1'" 28772836776bSmrg func_error "Continuing, but uninstalled executables may not work." 28782836776bSmrg # Fallback: 28798292847cSmrg func_to_host_file_result=$1 28802836776bSmrg fi 28812836776bSmrg} 28822836776bSmrg# end func_convert_file_check 28832836776bSmrg 28842836776bSmrg 28852836776bSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 28862836776bSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 28872836776bSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 28882836776bSmrg# func_to_host_file_result to a simplistic fallback value (see below). 28892836776bSmrgfunc_convert_path_check () 28902836776bSmrg{ 28918292847cSmrg $debug_cmd 28928292847cSmrg 28932836776bSmrg if test -z "$4" && test -n "$3"; then 28942836776bSmrg func_error "Could not determine the host path corresponding to" 28958292847cSmrg func_error " '$3'" 28962836776bSmrg func_error "Continuing, but uninstalled executables may not work." 28972836776bSmrg # Fallback. This is a deliberately simplistic "conversion" and 28982836776bSmrg # should not be "improved". See libtool.info. 28992836776bSmrg if test "x$1" != "x$2"; then 29002836776bSmrg lt_replace_pathsep_chars="s|$1|$2|g" 29012836776bSmrg func_to_host_path_result=`echo "$3" | 29022836776bSmrg $SED -e "$lt_replace_pathsep_chars"` 29032836776bSmrg else 29048292847cSmrg func_to_host_path_result=$3 29052836776bSmrg fi 29062836776bSmrg fi 29072836776bSmrg} 29082836776bSmrg# end func_convert_path_check 29092836776bSmrg 29102836776bSmrg 29112836776bSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 29122836776bSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 29132836776bSmrg# and appending REPL if ORIG matches BACKPAT. 29142836776bSmrgfunc_convert_path_front_back_pathsep () 29152836776bSmrg{ 29168292847cSmrg $debug_cmd 29178292847cSmrg 29182836776bSmrg case $4 in 29198292847cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 29202836776bSmrg ;; 29212836776bSmrg esac 29222836776bSmrg case $4 in 29232836776bSmrg $2 ) func_append func_to_host_path_result "$3" 29242836776bSmrg ;; 29252836776bSmrg esac 29262836776bSmrg} 29272836776bSmrg# end func_convert_path_front_back_pathsep 29282836776bSmrg 29292836776bSmrg 29302836776bSmrg################################################## 29312836776bSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 29322836776bSmrg################################################## 29338292847cSmrg# invoked via '$to_host_file_cmd ARG' 29342836776bSmrg# 29352836776bSmrg# In each case, ARG is the path to be converted from $build to $host format. 29362836776bSmrg# Result will be available in $func_to_host_file_result. 29372836776bSmrg 29382836776bSmrg 29392836776bSmrg# func_to_host_file ARG 29402836776bSmrg# Converts the file name ARG from $build format to $host format. Return result 29412836776bSmrg# in func_to_host_file_result. 29422836776bSmrgfunc_to_host_file () 29432836776bSmrg{ 29448292847cSmrg $debug_cmd 29458292847cSmrg 29462836776bSmrg $to_host_file_cmd "$1" 29472836776bSmrg} 29482836776bSmrg# end func_to_host_file 29492836776bSmrg 29502836776bSmrg 29512836776bSmrg# func_to_tool_file ARG LAZY 29522836776bSmrg# converts the file name ARG from $build format to toolchain format. Return 29532836776bSmrg# result in func_to_tool_file_result. If the conversion in use is listed 29542836776bSmrg# in (the comma separated) LAZY, no conversion takes place. 29552836776bSmrgfunc_to_tool_file () 29562836776bSmrg{ 29578292847cSmrg $debug_cmd 29588292847cSmrg 29592836776bSmrg case ,$2, in 29602836776bSmrg *,"$to_tool_file_cmd",*) 29612836776bSmrg func_to_tool_file_result=$1 29622836776bSmrg ;; 29632836776bSmrg *) 29642836776bSmrg $to_tool_file_cmd "$1" 29652836776bSmrg func_to_tool_file_result=$func_to_host_file_result 29662836776bSmrg ;; 29672836776bSmrg esac 29682836776bSmrg} 29692836776bSmrg# end func_to_tool_file 29702836776bSmrg 29712836776bSmrg 29722836776bSmrg# func_convert_file_noop ARG 29732836776bSmrg# Copy ARG to func_to_host_file_result. 29742836776bSmrgfunc_convert_file_noop () 29752836776bSmrg{ 29768292847cSmrg func_to_host_file_result=$1 29772836776bSmrg} 29782836776bSmrg# end func_convert_file_noop 29792836776bSmrg 29802836776bSmrg 29812836776bSmrg# func_convert_file_msys_to_w32 ARG 29822836776bSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 29832836776bSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 29842836776bSmrg# func_to_host_file_result. 29852836776bSmrgfunc_convert_file_msys_to_w32 () 29862836776bSmrg{ 29878292847cSmrg $debug_cmd 29888292847cSmrg 29898292847cSmrg func_to_host_file_result=$1 29902836776bSmrg if test -n "$1"; then 29912836776bSmrg func_convert_core_msys_to_w32 "$1" 29928292847cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 29932836776bSmrg fi 29942836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 29952836776bSmrg} 29962836776bSmrg# end func_convert_file_msys_to_w32 29972836776bSmrg 29982836776bSmrg 29992836776bSmrg# func_convert_file_cygwin_to_w32 ARG 30002836776bSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 30012836776bSmrg# func_to_host_file_result. 30022836776bSmrgfunc_convert_file_cygwin_to_w32 () 30032836776bSmrg{ 30048292847cSmrg $debug_cmd 30058292847cSmrg 30068292847cSmrg func_to_host_file_result=$1 30072836776bSmrg if test -n "$1"; then 30082836776bSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 30092836776bSmrg # LT_CYGPATH in this case. 30102836776bSmrg func_to_host_file_result=`cygpath -m "$1"` 30112836776bSmrg fi 30122836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30132836776bSmrg} 30142836776bSmrg# end func_convert_file_cygwin_to_w32 30152836776bSmrg 30162836776bSmrg 30172836776bSmrg# func_convert_file_nix_to_w32 ARG 30182836776bSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 30192836776bSmrg# and a working winepath. Returns result in func_to_host_file_result. 30202836776bSmrgfunc_convert_file_nix_to_w32 () 30212836776bSmrg{ 30228292847cSmrg $debug_cmd 30238292847cSmrg 30248292847cSmrg func_to_host_file_result=$1 30252836776bSmrg if test -n "$1"; then 30262836776bSmrg func_convert_core_file_wine_to_w32 "$1" 30278292847cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 30282836776bSmrg fi 30292836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30302836776bSmrg} 30312836776bSmrg# end func_convert_file_nix_to_w32 30322836776bSmrg 30332836776bSmrg 30342836776bSmrg# func_convert_file_msys_to_cygwin ARG 30352836776bSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 30362836776bSmrg# Returns result in func_to_host_file_result. 30372836776bSmrgfunc_convert_file_msys_to_cygwin () 30382836776bSmrg{ 30398292847cSmrg $debug_cmd 30408292847cSmrg 30418292847cSmrg func_to_host_file_result=$1 30422836776bSmrg if test -n "$1"; then 30432836776bSmrg func_convert_core_msys_to_w32 "$1" 30442836776bSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 30458292847cSmrg func_to_host_file_result=$func_cygpath_result 30462836776bSmrg fi 30472836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30482836776bSmrg} 30492836776bSmrg# end func_convert_file_msys_to_cygwin 30502836776bSmrg 30512836776bSmrg 30522836776bSmrg# func_convert_file_nix_to_cygwin ARG 30532836776bSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 30542836776bSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 30552836776bSmrg# in func_to_host_file_result. 30562836776bSmrgfunc_convert_file_nix_to_cygwin () 30572836776bSmrg{ 30588292847cSmrg $debug_cmd 30598292847cSmrg 30608292847cSmrg func_to_host_file_result=$1 30612836776bSmrg if test -n "$1"; then 30622836776bSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 30632836776bSmrg func_convert_core_file_wine_to_w32 "$1" 30642836776bSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 30658292847cSmrg func_to_host_file_result=$func_cygpath_result 30662836776bSmrg fi 30672836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30682836776bSmrg} 30692836776bSmrg# end func_convert_file_nix_to_cygwin 30702836776bSmrg 30712836776bSmrg 30722836776bSmrg############################################# 30732836776bSmrg# $build to $host PATH CONVERSION FUNCTIONS # 30742836776bSmrg############################################# 30758292847cSmrg# invoked via '$to_host_path_cmd ARG' 30762836776bSmrg# 30772836776bSmrg# In each case, ARG is the path to be converted from $build to $host format. 30782836776bSmrg# The result will be available in $func_to_host_path_result. 30792836776bSmrg# 30802836776bSmrg# Path separators are also converted from $build format to $host format. If 30812836776bSmrg# ARG begins or ends with a path separator character, it is preserved (but 30822836776bSmrg# converted to $host format) on output. 30832836776bSmrg# 30842836776bSmrg# All path conversion functions are named using the following convention: 30852836776bSmrg# file name conversion function : func_convert_file_X_to_Y () 30862836776bSmrg# path conversion function : func_convert_path_X_to_Y () 30872836776bSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 30882836776bSmrg# same. If conversion functions are added for new $build/$host combinations, 30892836776bSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 30902836776bSmrg# will break. 30912836776bSmrg 30922836776bSmrg 30932836776bSmrg# func_init_to_host_path_cmd 30942836776bSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 30952836776bSmrg# appropriate value, based on the value of $to_host_file_cmd. 30962836776bSmrgto_host_path_cmd= 30972836776bSmrgfunc_init_to_host_path_cmd () 30982836776bSmrg{ 30998292847cSmrg $debug_cmd 31008292847cSmrg 31012836776bSmrg if test -z "$to_host_path_cmd"; then 31022836776bSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 31038292847cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 31042836776bSmrg fi 31052836776bSmrg} 31062836776bSmrg 31072836776bSmrg 31082836776bSmrg# func_to_host_path ARG 31092836776bSmrg# Converts the path ARG from $build format to $host format. Return result 31102836776bSmrg# in func_to_host_path_result. 31112836776bSmrgfunc_to_host_path () 31122836776bSmrg{ 31138292847cSmrg $debug_cmd 31148292847cSmrg 31152836776bSmrg func_init_to_host_path_cmd 31162836776bSmrg $to_host_path_cmd "$1" 31172836776bSmrg} 31182836776bSmrg# end func_to_host_path 31192836776bSmrg 31202836776bSmrg 31212836776bSmrg# func_convert_path_noop ARG 31222836776bSmrg# Copy ARG to func_to_host_path_result. 31232836776bSmrgfunc_convert_path_noop () 31242836776bSmrg{ 31258292847cSmrg func_to_host_path_result=$1 31262836776bSmrg} 31272836776bSmrg# end func_convert_path_noop 31282836776bSmrg 31292836776bSmrg 31302836776bSmrg# func_convert_path_msys_to_w32 ARG 31312836776bSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 31322836776bSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 31332836776bSmrg# func_to_host_path_result. 31342836776bSmrgfunc_convert_path_msys_to_w32 () 31352836776bSmrg{ 31368292847cSmrg $debug_cmd 31378292847cSmrg 31388292847cSmrg func_to_host_path_result=$1 31392836776bSmrg if test -n "$1"; then 31402836776bSmrg # Remove leading and trailing path separator characters from ARG. MSYS 31412836776bSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 31422836776bSmrg # and winepath ignores them completely. 31432836776bSmrg func_stripname : : "$1" 31442836776bSmrg func_to_host_path_tmp1=$func_stripname_result 31452836776bSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 31468292847cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 31472836776bSmrg func_convert_path_check : ";" \ 31482836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31492836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31502836776bSmrg fi 31512836776bSmrg} 31522836776bSmrg# end func_convert_path_msys_to_w32 31532836776bSmrg 31542836776bSmrg 31552836776bSmrg# func_convert_path_cygwin_to_w32 ARG 31562836776bSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 31572836776bSmrg# func_to_host_file_result. 31582836776bSmrgfunc_convert_path_cygwin_to_w32 () 31592836776bSmrg{ 31608292847cSmrg $debug_cmd 31618292847cSmrg 31628292847cSmrg func_to_host_path_result=$1 31632836776bSmrg if test -n "$1"; then 31642836776bSmrg # See func_convert_path_msys_to_w32: 31652836776bSmrg func_stripname : : "$1" 31662836776bSmrg func_to_host_path_tmp1=$func_stripname_result 31672836776bSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 31682836776bSmrg func_convert_path_check : ";" \ 31692836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31702836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31712836776bSmrg fi 31722836776bSmrg} 31732836776bSmrg# end func_convert_path_cygwin_to_w32 31742836776bSmrg 31752836776bSmrg 31762836776bSmrg# func_convert_path_nix_to_w32 ARG 31772836776bSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 31782836776bSmrg# a working winepath. Returns result in func_to_host_file_result. 31792836776bSmrgfunc_convert_path_nix_to_w32 () 3180c2939121Smrg{ 31818292847cSmrg $debug_cmd 31828292847cSmrg 31838292847cSmrg func_to_host_path_result=$1 31842836776bSmrg if test -n "$1"; then 31852836776bSmrg # See func_convert_path_msys_to_w32: 31862836776bSmrg func_stripname : : "$1" 31872836776bSmrg func_to_host_path_tmp1=$func_stripname_result 31882836776bSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 31898292847cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 31902836776bSmrg func_convert_path_check : ";" \ 31912836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 31922836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 31932836776bSmrg fi 31942836776bSmrg} 31952836776bSmrg# end func_convert_path_nix_to_w32 3196c2939121Smrg 3197c2939121Smrg 31982836776bSmrg# func_convert_path_msys_to_cygwin ARG 31992836776bSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32002836776bSmrg# Returns result in func_to_host_file_result. 32012836776bSmrgfunc_convert_path_msys_to_cygwin () 32022836776bSmrg{ 32038292847cSmrg $debug_cmd 32048292847cSmrg 32058292847cSmrg func_to_host_path_result=$1 32062836776bSmrg if test -n "$1"; then 32072836776bSmrg # See func_convert_path_msys_to_w32: 32082836776bSmrg func_stripname : : "$1" 32092836776bSmrg func_to_host_path_tmp1=$func_stripname_result 32102836776bSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 32112836776bSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 32128292847cSmrg func_to_host_path_result=$func_cygpath_result 32132836776bSmrg func_convert_path_check : : \ 32142836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32152836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32162836776bSmrg fi 32172836776bSmrg} 32182836776bSmrg# end func_convert_path_msys_to_cygwin 3219c2939121Smrg 3220c2939121Smrg 32212836776bSmrg# func_convert_path_nix_to_cygwin ARG 32222836776bSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 32232836776bSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 32242836776bSmrg# func_to_host_file_result. 32252836776bSmrgfunc_convert_path_nix_to_cygwin () 32262836776bSmrg{ 32278292847cSmrg $debug_cmd 32288292847cSmrg 32298292847cSmrg func_to_host_path_result=$1 32302836776bSmrg if test -n "$1"; then 32312836776bSmrg # Remove leading and trailing path separator characters from 32322836776bSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 32332836776bSmrg # into '.;' and ';.', and winepath ignores them completely. 32342836776bSmrg func_stripname : : "$1" 32352836776bSmrg func_to_host_path_tmp1=$func_stripname_result 32362836776bSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 32372836776bSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 32388292847cSmrg func_to_host_path_result=$func_cygpath_result 32392836776bSmrg func_convert_path_check : : \ 32402836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32412836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 32422836776bSmrg fi 3243c2939121Smrg} 32442836776bSmrg# end func_convert_path_nix_to_cygwin 32452836776bSmrg 3246c2939121Smrg 32478292847cSmrg# func_dll_def_p FILE 32488292847cSmrg# True iff FILE is a Windows DLL '.def' file. 32498292847cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 32508292847cSmrgfunc_dll_def_p () 32518292847cSmrg{ 32528292847cSmrg $debug_cmd 32538292847cSmrg 32548292847cSmrg func_dll_def_p_tmp=`$SED -n \ 32558292847cSmrg -e 's/^[ ]*//' \ 32568292847cSmrg -e '/^\(;.*\)*$/d' \ 32578292847cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 32588292847cSmrg -e q \ 32598292847cSmrg "$1"` 32608292847cSmrg test DEF = "$func_dll_def_p_tmp" 32618292847cSmrg} 32628292847cSmrg 32638292847cSmrg 3264c2939121Smrg# func_mode_compile arg... 3265c2939121Smrgfunc_mode_compile () 3266c2939121Smrg{ 32678292847cSmrg $debug_cmd 32688292847cSmrg 3269c2939121Smrg # Get the compilation command and the source file. 3270c2939121Smrg base_compile= 32718292847cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272c2939121Smrg suppress_opt=yes 3273c2939121Smrg suppress_output= 3274c2939121Smrg arg_mode=normal 3275c2939121Smrg libobj= 3276c2939121Smrg later= 3277c2939121Smrg pie_flag= 3278c2939121Smrg 3279c2939121Smrg for arg 3280c2939121Smrg do 3281c2939121Smrg case $arg_mode in 3282c2939121Smrg arg ) 3283c2939121Smrg # do not "continue". Instead, add this to base_compile 32848292847cSmrg lastarg=$arg 3285c2939121Smrg arg_mode=normal 3286c2939121Smrg ;; 3287c2939121Smrg 3288c2939121Smrg target ) 32898292847cSmrg libobj=$arg 3290c2939121Smrg arg_mode=normal 3291c2939121Smrg continue 3292c2939121Smrg ;; 3293c2939121Smrg 3294c2939121Smrg normal ) 3295c2939121Smrg # Accept any command-line options. 3296c2939121Smrg case $arg in 3297c2939121Smrg -o) 3298c2939121Smrg test -n "$libobj" && \ 32998292847cSmrg func_fatal_error "you cannot specify '-o' more than once" 3300c2939121Smrg arg_mode=target 3301c2939121Smrg continue 3302c2939121Smrg ;; 3303c2939121Smrg 3304c2939121Smrg -pie | -fpie | -fPIE) 33052836776bSmrg func_append pie_flag " $arg" 3306c2939121Smrg continue 3307c2939121Smrg ;; 3308c2939121Smrg 3309c2939121Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 33102836776bSmrg func_append later " $arg" 3311c2939121Smrg continue 3312c2939121Smrg ;; 3313c76ae52dSmrg 3314c76ae52dSmrg -no-suppress) 3315c76ae52dSmrg suppress_opt=no 3316c76ae52dSmrg continue 3317c76ae52dSmrg ;; 3318c76ae52dSmrg 3319c76ae52dSmrg -Xcompiler) 3320c76ae52dSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321c76ae52dSmrg continue # The current "srcfile" will either be retained or 3322c76ae52dSmrg ;; # replaced later. I would guess that would be a bug. 3323c76ae52dSmrg 3324c76ae52dSmrg -Wc,*) 3325c2939121Smrg func_stripname '-Wc,' '' "$arg" 3326c2939121Smrg args=$func_stripname_result 3327c76ae52dSmrg lastarg= 33288292847cSmrg save_ifs=$IFS; IFS=, 3329c2939121Smrg for arg in $args; do 33308292847cSmrg IFS=$save_ifs 33312836776bSmrg func_append_quoted lastarg "$arg" 3332c76ae52dSmrg done 33338292847cSmrg IFS=$save_ifs 3334c2939121Smrg func_stripname ' ' '' "$lastarg" 3335c2939121Smrg lastarg=$func_stripname_result 3336c76ae52dSmrg 3337c76ae52dSmrg # Add the arguments to base_compile. 33382836776bSmrg func_append base_compile " $lastarg" 3339c76ae52dSmrg continue 3340c76ae52dSmrg ;; 3341c76ae52dSmrg 3342c2939121Smrg *) 3343c76ae52dSmrg # Accept the current argument as the source file. 3344c76ae52dSmrg # The previous "srcfile" becomes the current argument. 3345c76ae52dSmrg # 33468292847cSmrg lastarg=$srcfile 33478292847cSmrg srcfile=$arg 3348c76ae52dSmrg ;; 3349c76ae52dSmrg esac # case $arg 3350c76ae52dSmrg ;; 3351c76ae52dSmrg esac # case $arg_mode 3352c76ae52dSmrg 3353c76ae52dSmrg # Aesthetically quote the previous argument. 33542836776bSmrg func_append_quoted base_compile "$lastarg" 3355c76ae52dSmrg done # for arg 3356c76ae52dSmrg 3357c76ae52dSmrg case $arg_mode in 3358c76ae52dSmrg arg) 3359c2939121Smrg func_fatal_error "you must specify an argument for -Xcompile" 3360c76ae52dSmrg ;; 3361c76ae52dSmrg target) 33628292847cSmrg func_fatal_error "you must specify a target with '-o'" 3363c76ae52dSmrg ;; 3364c76ae52dSmrg *) 3365c76ae52dSmrg # Get the name of the library object. 3366c2939121Smrg test -z "$libobj" && { 3367c2939121Smrg func_basename "$srcfile" 33688292847cSmrg libobj=$func_basename_result 3369c2939121Smrg } 3370c76ae52dSmrg ;; 3371c76ae52dSmrg esac 3372c76ae52dSmrg 3373c76ae52dSmrg # Recognize several different file suffixes. 3374c76ae52dSmrg # If the user specifies -o file.o, it is replaced with file.lo 3375c76ae52dSmrg case $libobj in 3376c2939121Smrg *.[cCFSifmso] | \ 3377c2939121Smrg *.ada | *.adb | *.ads | *.asm | \ 3378c2939121Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 33792836776bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380c2939121Smrg func_xform "$libobj" 3381c2939121Smrg libobj=$func_xform_result 3382c2939121Smrg ;; 3383c76ae52dSmrg esac 3384c76ae52dSmrg 3385c76ae52dSmrg case $libobj in 3386c2939121Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387c76ae52dSmrg *) 33888292847cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389c76ae52dSmrg ;; 3390c76ae52dSmrg esac 3391c76ae52dSmrg 3392c76ae52dSmrg func_infer_tag $base_compile 3393c76ae52dSmrg 3394c76ae52dSmrg for arg in $later; do 3395c76ae52dSmrg case $arg in 3396c2939121Smrg -shared) 33978292847cSmrg test yes = "$build_libtool_libs" \ 33988292847cSmrg || func_fatal_configuration "cannot build a shared library" 3399c2939121Smrg build_old_libs=no 3400c2939121Smrg continue 3401c2939121Smrg ;; 3402c2939121Smrg 3403c76ae52dSmrg -static) 3404c2939121Smrg build_libtool_libs=no 3405c76ae52dSmrg build_old_libs=yes 3406c76ae52dSmrg continue 3407c76ae52dSmrg ;; 3408c76ae52dSmrg 3409c76ae52dSmrg -prefer-pic) 3410c76ae52dSmrg pic_mode=yes 3411c76ae52dSmrg continue 3412c76ae52dSmrg ;; 3413c76ae52dSmrg 3414c76ae52dSmrg -prefer-non-pic) 3415c76ae52dSmrg pic_mode=no 3416c76ae52dSmrg continue 3417c76ae52dSmrg ;; 3418c76ae52dSmrg esac 3419c76ae52dSmrg done 3420c76ae52dSmrg 3421c2939121Smrg func_quote_for_eval "$libobj" 3422c2939121Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423c2939121Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 34248292847cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425c2939121Smrg func_dirname_and_basename "$obj" "/" "" 34268292847cSmrg objname=$func_basename_result 34278292847cSmrg xdir=$func_dirname_result 34288292847cSmrg lobj=$xdir$objdir/$objname 3429c76ae52dSmrg 3430c2939121Smrg test -z "$base_compile" && \ 3431c2939121Smrg func_fatal_help "you must specify a compilation command" 3432c76ae52dSmrg 3433c76ae52dSmrg # Delete any leftover library objects. 34348292847cSmrg if test yes = "$build_old_libs"; then 3435c76ae52dSmrg removelist="$obj $lobj $libobj ${libobj}T" 3436c76ae52dSmrg else 3437c76ae52dSmrg removelist="$lobj $libobj ${libobj}T" 3438c76ae52dSmrg fi 3439c76ae52dSmrg 3440c76ae52dSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441c76ae52dSmrg case $host_os in 3442c2939121Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443c76ae52dSmrg pic_mode=default 3444c76ae52dSmrg ;; 3445c76ae52dSmrg esac 34468292847cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447c76ae52dSmrg # non-PIC code in shared libraries is not supported 3448c76ae52dSmrg pic_mode=default 3449c76ae52dSmrg fi 3450c76ae52dSmrg 3451c76ae52dSmrg # Calculate the filename of the output object if compiler does 3452c76ae52dSmrg # not support -o with -c 34538292847cSmrg if test no = "$compiler_c_o"; then 34548292847cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 34558292847cSmrg lockfile=$output_obj.lock 3456c76ae52dSmrg else 3457c76ae52dSmrg output_obj= 3458c76ae52dSmrg need_locks=no 3459c76ae52dSmrg lockfile= 3460c76ae52dSmrg fi 3461c76ae52dSmrg 3462c76ae52dSmrg # Lock this critical section if it is needed 3463c76ae52dSmrg # We use this script file to make the link, it avoids creating a new file 34648292847cSmrg if test yes = "$need_locks"; then 3465c2939121Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466c2939121Smrg func_echo "Waiting for $lockfile to be removed" 3467c76ae52dSmrg sleep 2 3468c76ae52dSmrg done 34698292847cSmrg elif test warn = "$need_locks"; then 3470c76ae52dSmrg if test -f "$lockfile"; then 3471c2939121Smrg $ECHO "\ 3472c76ae52dSmrg*** ERROR, $lockfile exists and contains: 3473c76ae52dSmrg`cat $lockfile 2>/dev/null` 3474c76ae52dSmrg 3475c76ae52dSmrgThis indicates that another process is trying to use the same 3476c76ae52dSmrgtemporary object file, and libtool could not work around it because 34778292847cSmrgyour compiler does not support '-c' and '-o' together. If you 3478c76ae52dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3479c76ae52dSmrgavoid parallel builds (make -j) in this platform, or get a better 3480c76ae52dSmrgcompiler." 3481c76ae52dSmrg 3482c2939121Smrg $opt_dry_run || $RM $removelist 3483c76ae52dSmrg exit $EXIT_FAILURE 3484c76ae52dSmrg fi 34852836776bSmrg func_append removelist " $output_obj" 3486c2939121Smrg $ECHO "$srcfile" > "$lockfile" 3487c76ae52dSmrg fi 3488c76ae52dSmrg 3489c2939121Smrg $opt_dry_run || $RM $removelist 34902836776bSmrg func_append removelist " $lockfile" 3491c2939121Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492c2939121Smrg 34932836776bSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 34942836776bSmrg srcfile=$func_to_tool_file_result 3495c2939121Smrg func_quote_for_eval "$srcfile" 3496c2939121Smrg qsrcfile=$func_quote_for_eval_result 3497c76ae52dSmrg 3498c76ae52dSmrg # Only build a PIC object if we are building libtool libraries. 34998292847cSmrg if test yes = "$build_libtool_libs"; then 3500c76ae52dSmrg # Without this assignment, base_compile gets emptied. 3501c76ae52dSmrg fbsd_hideous_sh_bug=$base_compile 3502c76ae52dSmrg 35038292847cSmrg if test no != "$pic_mode"; then 3504c76ae52dSmrg command="$base_compile $qsrcfile $pic_flag" 3505c76ae52dSmrg else 3506c76ae52dSmrg # Don't build PIC code 3507c76ae52dSmrg command="$base_compile $qsrcfile" 3508c76ae52dSmrg fi 3509c76ae52dSmrg 3510c2939121Smrg func_mkdir_p "$xdir$objdir" 3511c76ae52dSmrg 3512c76ae52dSmrg if test -z "$output_obj"; then 3513c76ae52dSmrg # Place PIC objects in $objdir 35142836776bSmrg func_append command " -o $lobj" 3515c76ae52dSmrg fi 3516c76ae52dSmrg 3517c2939121Smrg func_show_eval_locale "$command" \ 3518c2939121Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519c76ae52dSmrg 35208292847cSmrg if test warn = "$need_locks" && 3521c76ae52dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522c2939121Smrg $ECHO "\ 3523c76ae52dSmrg*** ERROR, $lockfile contains: 3524c76ae52dSmrg`cat $lockfile 2>/dev/null` 3525c76ae52dSmrg 3526c76ae52dSmrgbut it should contain: 3527c76ae52dSmrg$srcfile 3528c76ae52dSmrg 3529c76ae52dSmrgThis indicates that another process is trying to use the same 3530c76ae52dSmrgtemporary object file, and libtool could not work around it because 35318292847cSmrgyour compiler does not support '-c' and '-o' together. If you 3532c76ae52dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3533c76ae52dSmrgavoid parallel builds (make -j) in this platform, or get a better 3534c76ae52dSmrgcompiler." 3535c76ae52dSmrg 3536c2939121Smrg $opt_dry_run || $RM $removelist 3537c76ae52dSmrg exit $EXIT_FAILURE 3538c76ae52dSmrg fi 3539c76ae52dSmrg 3540c76ae52dSmrg # Just move the object if needed, then go on to compile the next one 3541c76ae52dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542c2939121Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543c2939121Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544c76ae52dSmrg fi 3545c76ae52dSmrg 3546c76ae52dSmrg # Allow error messages only from the first compilation. 35478292847cSmrg if test yes = "$suppress_opt"; then 3548c2939121Smrg suppress_output=' >/dev/null 2>&1' 3549c76ae52dSmrg fi 3550c76ae52dSmrg fi 3551c76ae52dSmrg 3552c76ae52dSmrg # Only build a position-dependent object if we build old libraries. 35538292847cSmrg if test yes = "$build_old_libs"; then 35548292847cSmrg if test yes != "$pic_mode"; then 3555c76ae52dSmrg # Don't build PIC code 3556c2939121Smrg command="$base_compile $qsrcfile$pie_flag" 3557c76ae52dSmrg else 3558c76ae52dSmrg command="$base_compile $qsrcfile $pic_flag" 3559c76ae52dSmrg fi 35608292847cSmrg if test yes = "$compiler_c_o"; then 35612836776bSmrg func_append command " -o $obj" 3562c76ae52dSmrg fi 3563c76ae52dSmrg 3564c76ae52dSmrg # Suppress compiler output if we already did a PIC compilation. 35652836776bSmrg func_append command "$suppress_output" 3566c2939121Smrg func_show_eval_locale "$command" \ 3567c2939121Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568c76ae52dSmrg 35698292847cSmrg if test warn = "$need_locks" && 3570c76ae52dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571c2939121Smrg $ECHO "\ 3572c76ae52dSmrg*** ERROR, $lockfile contains: 3573c76ae52dSmrg`cat $lockfile 2>/dev/null` 3574c76ae52dSmrg 3575c76ae52dSmrgbut it should contain: 3576c76ae52dSmrg$srcfile 3577c76ae52dSmrg 3578c76ae52dSmrgThis indicates that another process is trying to use the same 3579c76ae52dSmrgtemporary object file, and libtool could not work around it because 35808292847cSmrgyour compiler does not support '-c' and '-o' together. If you 3581c76ae52dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3582c76ae52dSmrgavoid parallel builds (make -j) in this platform, or get a better 3583c76ae52dSmrgcompiler." 3584c76ae52dSmrg 3585c2939121Smrg $opt_dry_run || $RM $removelist 3586c76ae52dSmrg exit $EXIT_FAILURE 3587c76ae52dSmrg fi 3588c76ae52dSmrg 3589c76ae52dSmrg # Just move the object if needed 3590c76ae52dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591c2939121Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592c2939121Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593c76ae52dSmrg fi 3594c76ae52dSmrg fi 3595c76ae52dSmrg 3596c2939121Smrg $opt_dry_run || { 3597c2939121Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598c76ae52dSmrg 3599c2939121Smrg # Unlock the critical section if it was locked 36008292847cSmrg if test no != "$need_locks"; then 3601c2939121Smrg removelist=$lockfile 3602c2939121Smrg $RM "$lockfile" 3603c2939121Smrg fi 3604c2939121Smrg } 3605c76ae52dSmrg 3606c76ae52dSmrg exit $EXIT_SUCCESS 3607c2939121Smrg} 3608c76ae52dSmrg 3609c2939121Smrg$opt_help || { 36108292847cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611c2939121Smrg} 3612c76ae52dSmrg 3613c2939121Smrgfunc_mode_help () 3614c2939121Smrg{ 3615c2939121Smrg # We need to display help for each of the modes. 36162836776bSmrg case $opt_mode in 3617c2939121Smrg "") 3618c2939121Smrg # Generic help is extracted from the usage comments 3619c2939121Smrg # at the start of this file. 3620c2939121Smrg func_help 3621c2939121Smrg ;; 3622c76ae52dSmrg 3623c2939121Smrg clean) 3624c2939121Smrg $ECHO \ 3625c2939121Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626c76ae52dSmrg 3627c2939121SmrgRemove files from the build directory. 3628c76ae52dSmrg 3629c2939121SmrgRM is the name of the program to use to delete files associated with each FILE 36308292847cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631c2939121Smrgto RM. 3632c76ae52dSmrg 3633c2939121SmrgIf FILE is a libtool library, object or program, all the files associated 3634c2939121Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635c2939121Smrg ;; 3636c76ae52dSmrg 3637c2939121Smrg compile) 3638c2939121Smrg $ECHO \ 3639c2939121Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640c76ae52dSmrg 3641c2939121SmrgCompile a source file into a libtool library object. 3642c76ae52dSmrg 3643c2939121SmrgThis mode accepts the following additional options: 3644c76ae52dSmrg 3645c2939121Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646c2939121Smrg -no-suppress do not suppress compiler output for multiple passes 3647c2939121Smrg -prefer-pic try to build PIC objects only 3648c2939121Smrg -prefer-non-pic try to build non-PIC objects only 36498292847cSmrg -shared do not build a '.o' file suitable for static linking 36508292847cSmrg -static only build a '.o' file suitable for static linking 3651c2939121Smrg -Wc,FLAG pass FLAG directly to the compiler 3652c76ae52dSmrg 36538292847cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654c2939121Smrgfrom the given SOURCEFILE. 3655c76ae52dSmrg 3656c2939121SmrgThe output file name is determined by removing the directory component from 36578292847cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 36588292847cSmrglibrary object suffix, '.lo'." 3659c2939121Smrg ;; 3660c76ae52dSmrg 3661c2939121Smrg execute) 3662c2939121Smrg $ECHO \ 3663c2939121Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664c76ae52dSmrg 3665c2939121SmrgAutomatically set library path, then run a program. 3666c76ae52dSmrg 3667c2939121SmrgThis mode accepts the following additional options: 3668c76ae52dSmrg 3669c2939121Smrg -dlopen FILE add the directory containing FILE to the library path 3670c76ae52dSmrg 36718292847cSmrgThis mode sets the library path environment variable according to '-dlopen' 3672c2939121Smrgflags. 3673c76ae52dSmrg 3674c2939121SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675c2939121Smrginto their corresponding uninstalled binary, and any of their required library 3676c2939121Smrgdirectories are added to the library path. 3677c76ae52dSmrg 3678c2939121SmrgThen, COMMAND is executed, with ARGS as arguments." 3679c2939121Smrg ;; 3680c76ae52dSmrg 3681c2939121Smrg finish) 3682c2939121Smrg $ECHO \ 3683c2939121Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684c76ae52dSmrg 3685c2939121SmrgComplete the installation of libtool libraries. 3686c76ae52dSmrg 3687c2939121SmrgEach LIBDIR is a directory that contains libtool libraries. 3688c76ae52dSmrg 3689c2939121SmrgThe commands that this mode executes may require superuser privileges. Use 36908292847cSmrgthe '--dry-run' option if you just want to see what would be executed." 3691c2939121Smrg ;; 3692c76ae52dSmrg 3693c2939121Smrg install) 3694c2939121Smrg $ECHO \ 3695c2939121Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696c76ae52dSmrg 3697c2939121SmrgInstall executables or libraries. 3698c76ae52dSmrg 3699c2939121SmrgINSTALL-COMMAND is the installation command. The first component should be 37008292847cSmrgeither the 'install' or 'cp' program. 3701c76ae52dSmrg 3702c2939121SmrgThe following components of INSTALL-COMMAND are treated specially: 3703c76ae52dSmrg 3704c2939121Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705c76ae52dSmrg 3706c2939121SmrgThe rest of the components are interpreted as arguments to that command (only 3707c2939121SmrgBSD-compatible install options are recognized)." 3708c2939121Smrg ;; 3709c76ae52dSmrg 3710c2939121Smrg link) 3711c2939121Smrg $ECHO \ 3712c2939121Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713c76ae52dSmrg 3714c2939121SmrgLink object files or libraries together to form another library, or to 3715c2939121Smrgcreate an executable program. 3716c76ae52dSmrg 3717c2939121SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718c2939121Smrga program from several object files. 3719c76ae52dSmrg 3720c2939121SmrgThe following components of LINK-COMMAND are treated specially: 3721c76ae52dSmrg 3722c2939121Smrg -all-static do not do any dynamic linking at all 3723c2939121Smrg -avoid-version do not add a version suffix if possible 3724c2939121Smrg -bindir BINDIR specify path to binaries directory (for systems where 3725c2939121Smrg libraries must be found in the PATH setting at runtime) 37268292847cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727c2939121Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728c2939121Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729c2939121Smrg -export-symbols SYMFILE 3730c2939121Smrg try to export only the symbols listed in SYMFILE 3731c2939121Smrg -export-symbols-regex REGEX 3732c2939121Smrg try to export only the symbols matching REGEX 3733c2939121Smrg -LLIBDIR search LIBDIR for required installed libraries 3734c2939121Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735c2939121Smrg -module build a library that can dlopened 3736c2939121Smrg -no-fast-install disable the fast-install mode 3737c2939121Smrg -no-install link a not-installable executable 3738c2939121Smrg -no-undefined declare that a library does not refer to external symbols 3739c2939121Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 37408292847cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 37418292847cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742c2939121Smrg -precious-files-regex REGEX 3743c2939121Smrg don't remove output files matching REGEX 3744c2939121Smrg -release RELEASE specify package release information 3745c2939121Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746c2939121Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747c2939121Smrg -shared only do dynamic linking of libtool libraries 3748c2939121Smrg -shrext SUFFIX override the standard shared library file extension 3749c2939121Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3750c2939121Smrg -static-libtool-libs 3751c2939121Smrg do not do any dynamic linking of libtool libraries 3752c2939121Smrg -version-info CURRENT[:REVISION[:AGE]] 3753c2939121Smrg specify library version info [each variable defaults to 0] 3754c2939121Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 3755c2939121Smrg -Wc,FLAG 3756c2939121Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757c2939121Smrg -Wl,FLAG 3758c2939121Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759c2939121Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760c76ae52dSmrg 37618292847cSmrgAll other options (arguments beginning with '-') are ignored. 3762c76ae52dSmrg 37638292847cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764c2939121Smrgtreated as uninstalled libtool libraries, other files are standard or library 3765c2939121Smrgobject files. 3766c76ae52dSmrg 37678292847cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 37688292847cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769c2939121Smrgrequired, except when creating a convenience library. 3770c76ae52dSmrg 37718292847cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 37728292847cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 37730d590c07Smrg 37748292847cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775c2939121Smrgis created, otherwise an executable program is created." 3776c2939121Smrg ;; 3777c76ae52dSmrg 3778c2939121Smrg uninstall) 3779c2939121Smrg $ECHO \ 3780c2939121Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781c76ae52dSmrg 3782c2939121SmrgRemove libraries from an installation directory. 3783c76ae52dSmrg 3784c2939121SmrgRM is the name of the program to use to delete files associated with each FILE 37858292847cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786c2939121Smrgto RM. 3787c76ae52dSmrg 3788c2939121SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789c2939121SmrgOtherwise, only FILE itself is deleted using RM." 3790c2939121Smrg ;; 3791c76ae52dSmrg 3792c2939121Smrg *) 37938292847cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3794c2939121Smrg ;; 3795c2939121Smrg esac 3796c76ae52dSmrg 3797c2939121Smrg echo 37988292847cSmrg $ECHO "Try '$progname --help' for more information about other modes." 3799c2939121Smrg} 3800c76ae52dSmrg 3801c2939121Smrg# Now that we've collected a possible --mode arg, show help if necessary 3802c2939121Smrgif $opt_help; then 38038292847cSmrg if test : = "$opt_help"; then 3804c2939121Smrg func_mode_help 3805c2939121Smrg else 3806c2939121Smrg { 3807c2939121Smrg func_help noexit 38082836776bSmrg for opt_mode in compile link execute install finish uninstall clean; do 3809c2939121Smrg func_mode_help 3810c2939121Smrg done 38118292847cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812c2939121Smrg { 3813c2939121Smrg func_help noexit 38142836776bSmrg for opt_mode in compile link execute install finish uninstall clean; do 3815c2939121Smrg echo 3816c2939121Smrg func_mode_help 3817c2939121Smrg done 3818c2939121Smrg } | 38198292847cSmrg $SED '1d 3820c2939121Smrg /^When reporting/,/^Report/{ 3821c2939121Smrg H 3822c2939121Smrg d 3823c2939121Smrg } 3824c2939121Smrg $x 3825c2939121Smrg /information about other modes/d 3826c2939121Smrg /more detailed .*MODE/d 3827c2939121Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828c2939121Smrg fi 3829c2939121Smrg exit $? 3830c2939121Smrgfi 3831c76ae52dSmrg 3832c76ae52dSmrg 3833c2939121Smrg# func_mode_execute arg... 3834c2939121Smrgfunc_mode_execute () 3835c2939121Smrg{ 38368292847cSmrg $debug_cmd 38378292847cSmrg 3838c2939121Smrg # The first argument is the command name. 38398292847cSmrg cmd=$nonopt 3840c2939121Smrg test -z "$cmd" && \ 3841c2939121Smrg func_fatal_help "you must specify a COMMAND" 3842c76ae52dSmrg 3843c2939121Smrg # Handle -dlopen flags immediately. 38442836776bSmrg for file in $opt_dlopen; do 3845c2939121Smrg test -f "$file" \ 38468292847cSmrg || func_fatal_help "'$file' is not a file" 3847c76ae52dSmrg 3848c2939121Smrg dir= 3849c2939121Smrg case $file in 3850c2939121Smrg *.la) 38512836776bSmrg func_resolve_sysroot "$file" 38522836776bSmrg file=$func_resolve_sysroot_result 38532836776bSmrg 3854c2939121Smrg # Check to see that this really is a libtool archive. 3855c2939121Smrg func_lalib_unsafe_p "$file" \ 38568292847cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857c76ae52dSmrg 3858c2939121Smrg # Read the libtool library. 3859c2939121Smrg dlname= 3860c2939121Smrg library_names= 3861c2939121Smrg func_source "$file" 3862c76ae52dSmrg 3863c2939121Smrg # Skip this library if it cannot be dlopened. 3864c2939121Smrg if test -z "$dlname"; then 3865c2939121Smrg # Warn if it was a shared library. 3866c2939121Smrg test -n "$library_names" && \ 38678292847cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3868c2939121Smrg continue 3869c2939121Smrg fi 3870c76ae52dSmrg 3871c2939121Smrg func_dirname "$file" "" "." 38728292847cSmrg dir=$func_dirname_result 3873c76ae52dSmrg 3874c2939121Smrg if test -f "$dir/$objdir/$dlname"; then 38752836776bSmrg func_append dir "/$objdir" 3876c2939121Smrg else 3877c2939121Smrg if test ! -f "$dir/$dlname"; then 38788292847cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879c2939121Smrg fi 3880c2939121Smrg fi 3881c76ae52dSmrg ;; 3882c76ae52dSmrg 3883c2939121Smrg *.lo) 3884c2939121Smrg # Just add the directory containing the .lo file. 3885c2939121Smrg func_dirname "$file" "" "." 38868292847cSmrg dir=$func_dirname_result 3887c76ae52dSmrg ;; 3888c2939121Smrg 3889c2939121Smrg *) 38908292847cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891c76ae52dSmrg continue 3892c76ae52dSmrg ;; 3893c2939121Smrg esac 3894c76ae52dSmrg 3895c2939121Smrg # Get the absolute pathname. 3896c2939121Smrg absdir=`cd "$dir" && pwd` 38978292847cSmrg test -n "$absdir" && dir=$absdir 3898c76ae52dSmrg 3899c2939121Smrg # Now add the directory to shlibpath_var. 3900c2939121Smrg if eval "test -z \"\$$shlibpath_var\""; then 3901c2939121Smrg eval "$shlibpath_var=\"\$dir\"" 3902c2939121Smrg else 3903c2939121Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904c2939121Smrg fi 3905c2939121Smrg done 3906c76ae52dSmrg 3907c2939121Smrg # This variable tells wrapper scripts just to set shlibpath_var 3908c2939121Smrg # rather than running their programs. 39098292847cSmrg libtool_execute_magic=$magic 3910c76ae52dSmrg 3911c2939121Smrg # Check if any of the arguments is a wrapper script. 3912c2939121Smrg args= 3913c2939121Smrg for file 3914c2939121Smrg do 3915c2939121Smrg case $file in 3916c2939121Smrg -* | *.la | *.lo ) ;; 3917c2939121Smrg *) 3918c2939121Smrg # Do a test to see if this is really a libtool program. 3919c2939121Smrg if func_ltwrapper_script_p "$file"; then 3920c2939121Smrg func_source "$file" 3921c2939121Smrg # Transform arg to wrapped name. 39228292847cSmrg file=$progdir/$program 3923c2939121Smrg elif func_ltwrapper_executable_p "$file"; then 3924c2939121Smrg func_ltwrapper_scriptname "$file" 3925c2939121Smrg func_source "$func_ltwrapper_scriptname_result" 3926c2939121Smrg # Transform arg to wrapped name. 39278292847cSmrg file=$progdir/$program 3928c2939121Smrg fi 3929c76ae52dSmrg ;; 3930c2939121Smrg esac 3931c2939121Smrg # Quote arguments (to preserve shell metacharacters). 39322836776bSmrg func_append_quoted args "$file" 3933c2939121Smrg done 3934c76ae52dSmrg 39358292847cSmrg if $opt_dry_run; then 39368292847cSmrg # Display what would be done. 39378292847cSmrg if test -n "$shlibpath_var"; then 39388292847cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 39398292847cSmrg echo "export $shlibpath_var" 39408292847cSmrg fi 39418292847cSmrg $ECHO "$cmd$args" 39428292847cSmrg exit $EXIT_SUCCESS 39438292847cSmrg else 3944c2939121Smrg if test -n "$shlibpath_var"; then 3945c2939121Smrg # Export the shlibpath_var. 3946c2939121Smrg eval "export $shlibpath_var" 3947c2939121Smrg fi 3948c76ae52dSmrg 3949c2939121Smrg # Restore saved environment variables 3950c2939121Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951c2939121Smrg do 3952c2939121Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953c2939121Smrg $lt_var=\$save_$lt_var; export $lt_var 3954c2939121Smrg else 3955c2939121Smrg $lt_unset $lt_var 3956c2939121Smrg fi" 3957c2939121Smrg done 3958c76ae52dSmrg 3959c2939121Smrg # Now prepare to actually exec the command. 39608292847cSmrg exec_cmd=\$cmd$args 3961c2939121Smrg fi 3962c2939121Smrg} 3963c76ae52dSmrg 39648292847cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965c76ae52dSmrg 3966c76ae52dSmrg 3967c2939121Smrg# func_mode_finish arg... 3968c2939121Smrgfunc_mode_finish () 3969c2939121Smrg{ 39708292847cSmrg $debug_cmd 39718292847cSmrg 39722836776bSmrg libs= 39732836776bSmrg libdirs= 3974c2939121Smrg admincmds= 3975c76ae52dSmrg 39762836776bSmrg for opt in "$nonopt" ${1+"$@"} 39772836776bSmrg do 39782836776bSmrg if test -d "$opt"; then 39792836776bSmrg func_append libdirs " $opt" 39802836776bSmrg 39812836776bSmrg elif test -f "$opt"; then 39822836776bSmrg if func_lalib_unsafe_p "$opt"; then 39832836776bSmrg func_append libs " $opt" 39842836776bSmrg else 39858292847cSmrg func_warning "'$opt' is not a valid libtool archive" 39862836776bSmrg fi 39872836776bSmrg 39882836776bSmrg else 39898292847cSmrg func_fatal_error "invalid argument '$opt'" 39902836776bSmrg fi 39912836776bSmrg done 39922836776bSmrg 39932836776bSmrg if test -n "$libs"; then 39942836776bSmrg if test -n "$lt_sysroot"; then 39952836776bSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 39962836776bSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 39972836776bSmrg else 39982836776bSmrg sysroot_cmd= 39992836776bSmrg fi 40002836776bSmrg 40012836776bSmrg # Remove sysroot references 40022836776bSmrg if $opt_dry_run; then 40032836776bSmrg for lib in $libs; do 40048292847cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 40052836776bSmrg done 40062836776bSmrg else 40072836776bSmrg tmpdir=`func_mktempdir` 40082836776bSmrg for lib in $libs; do 40098292847cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 40102836776bSmrg > $tmpdir/tmp-la 40112836776bSmrg mv -f $tmpdir/tmp-la $lib 40122836776bSmrg done 40132836776bSmrg ${RM}r "$tmpdir" 40142836776bSmrg fi 40152836776bSmrg fi 4016c76ae52dSmrg 40172836776bSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018c2939121Smrg for libdir in $libdirs; do 4019c2939121Smrg if test -n "$finish_cmds"; then 4020c2939121Smrg # Do each command in the finish commands. 4021c2939121Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022c2939121Smrg'"$cmd"'"' 4023c2939121Smrg fi 4024c2939121Smrg if test -n "$finish_eval"; then 4025c2939121Smrg # Do the single finish_eval. 4026c2939121Smrg eval cmds=\"$finish_eval\" 40272836776bSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028c2939121Smrg $cmds" 4029c2939121Smrg fi 4030c2939121Smrg done 4031c2939121Smrg fi 4032c76ae52dSmrg 4033c2939121Smrg # Exit here if they wanted silent mode. 40348292847cSmrg $opt_quiet && exit $EXIT_SUCCESS 4035c76ae52dSmrg 40362836776bSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40372836776bSmrg echo "----------------------------------------------------------------------" 40382836776bSmrg echo "Libraries have been installed in:" 40392836776bSmrg for libdir in $libdirs; do 40402836776bSmrg $ECHO " $libdir" 40412836776bSmrg done 40422836776bSmrg echo 40432836776bSmrg echo "If you ever happen to want to link against installed libraries" 40442836776bSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 40458292847cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 40462836776bSmrg echo "flag during linking and do at least one of the following:" 40472836776bSmrg if test -n "$shlibpath_var"; then 40488292847cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 40492836776bSmrg echo " during execution" 40502836776bSmrg fi 40512836776bSmrg if test -n "$runpath_var"; then 40528292847cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 40532836776bSmrg echo " during linking" 40542836776bSmrg fi 40552836776bSmrg if test -n "$hardcode_libdir_flag_spec"; then 40562836776bSmrg libdir=LIBDIR 40572836776bSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4058c76ae52dSmrg 40598292847cSmrg $ECHO " - use the '$flag' linker flag" 40602836776bSmrg fi 40612836776bSmrg if test -n "$admincmds"; then 40622836776bSmrg $ECHO " - have your system administrator run these commands:$admincmds" 40632836776bSmrg fi 40642836776bSmrg if test -f /etc/ld.so.conf; then 40658292847cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 40662836776bSmrg fi 40672836776bSmrg echo 4068c76ae52dSmrg 40692836776bSmrg echo "See any operating system documentation about shared libraries for" 40702836776bSmrg case $host in 40712836776bSmrg solaris2.[6789]|solaris2.1[0-9]) 40722836776bSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 40732836776bSmrg echo "pages." 40742836776bSmrg ;; 40752836776bSmrg *) 40762836776bSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 40772836776bSmrg ;; 40782836776bSmrg esac 40792836776bSmrg echo "----------------------------------------------------------------------" 40802836776bSmrg fi 4081c2939121Smrg exit $EXIT_SUCCESS 4082c2939121Smrg} 4083c76ae52dSmrg 40848292847cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085c76ae52dSmrg 4086c76ae52dSmrg 4087c2939121Smrg# func_mode_install arg... 4088c2939121Smrgfunc_mode_install () 4089c2939121Smrg{ 40908292847cSmrg $debug_cmd 40918292847cSmrg 4092c2939121Smrg # There may be an optional sh(1) argument at the beginning of 4093c2939121Smrg # install_prog (especially on Windows NT). 40948292847cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095c2939121Smrg # Allow the use of GNU shtool's install command. 40968292847cSmrg case $nonopt in *shtool*) :;; *) false;; esac 40978292847cSmrg then 4098c2939121Smrg # Aesthetically quote it. 4099c2939121Smrg func_quote_for_eval "$nonopt" 4100c2939121Smrg install_prog="$func_quote_for_eval_result " 4101c2939121Smrg arg=$1 4102c2939121Smrg shift 4103c2939121Smrg else 4104c2939121Smrg install_prog= 4105c2939121Smrg arg=$nonopt 4106c2939121Smrg fi 4107c76ae52dSmrg 4108c2939121Smrg # The real first argument should be the name of the installation program. 4109c2939121Smrg # Aesthetically quote it. 4110c2939121Smrg func_quote_for_eval "$arg" 41112836776bSmrg func_append install_prog "$func_quote_for_eval_result" 4112c2939121Smrg install_shared_prog=$install_prog 4113c2939121Smrg case " $install_prog " in 4114c2939121Smrg *[\\\ /]cp\ *) install_cp=: ;; 4115c2939121Smrg *) install_cp=false ;; 4116c2939121Smrg esac 4117c76ae52dSmrg 4118c2939121Smrg # We need to accept at least all the BSD install flags. 4119c2939121Smrg dest= 4120c2939121Smrg files= 4121c2939121Smrg opts= 4122c2939121Smrg prev= 4123c2939121Smrg install_type= 41248292847cSmrg isdir=false 4125c2939121Smrg stripme= 4126c2939121Smrg no_mode=: 4127c2939121Smrg for arg 4128c2939121Smrg do 4129c2939121Smrg arg2= 4130c2939121Smrg if test -n "$dest"; then 41312836776bSmrg func_append files " $dest" 4132c2939121Smrg dest=$arg 4133c76ae52dSmrg continue 4134c2939121Smrg fi 4135c76ae52dSmrg 4136c2939121Smrg case $arg in 41378292847cSmrg -d) isdir=: ;; 4138c2939121Smrg -f) 4139c2939121Smrg if $install_cp; then :; else 4140c2939121Smrg prev=$arg 4141c76ae52dSmrg fi 4142c2939121Smrg ;; 4143c2939121Smrg -g | -m | -o) 4144c2939121Smrg prev=$arg 4145c2939121Smrg ;; 4146c2939121Smrg -s) 4147c2939121Smrg stripme=" -s" 4148c76ae52dSmrg continue 4149c76ae52dSmrg ;; 4150c2939121Smrg -*) 4151c2939121Smrg ;; 4152c76ae52dSmrg *) 4153c2939121Smrg # If the previous option needed an argument, then skip it. 4154c2939121Smrg if test -n "$prev"; then 41558292847cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156c2939121Smrg arg2=$install_override_mode 4157c2939121Smrg no_mode=false 4158c2939121Smrg fi 4159c2939121Smrg prev= 4160c2939121Smrg else 4161c2939121Smrg dest=$arg 4162c2939121Smrg continue 4163c2939121Smrg fi 4164c76ae52dSmrg ;; 4165c2939121Smrg esac 4166c76ae52dSmrg 4167c2939121Smrg # Aesthetically quote the argument. 4168c2939121Smrg func_quote_for_eval "$arg" 41692836776bSmrg func_append install_prog " $func_quote_for_eval_result" 4170c2939121Smrg if test -n "$arg2"; then 4171c2939121Smrg func_quote_for_eval "$arg2" 4172c76ae52dSmrg fi 41732836776bSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4174c2939121Smrg done 4175c76ae52dSmrg 4176c2939121Smrg test -z "$install_prog" && \ 4177c2939121Smrg func_fatal_help "you must specify an install program" 4178c76ae52dSmrg 4179c2939121Smrg test -n "$prev" && \ 41808292847cSmrg func_fatal_help "the '$prev' option requires an argument" 4181c76ae52dSmrg 4182c2939121Smrg if test -n "$install_override_mode" && $no_mode; then 4183c2939121Smrg if $install_cp; then :; else 4184c2939121Smrg func_quote_for_eval "$install_override_mode" 41852836776bSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4186c2939121Smrg fi 4187c76ae52dSmrg fi 4188c76ae52dSmrg 4189c2939121Smrg if test -z "$files"; then 4190c2939121Smrg if test -z "$dest"; then 4191c2939121Smrg func_fatal_help "no file or destination specified" 4192c2939121Smrg else 4193c2939121Smrg func_fatal_help "you must specify a destination" 4194c76ae52dSmrg fi 4195c76ae52dSmrg fi 4196c76ae52dSmrg 4197c2939121Smrg # Strip any trailing slash from the destination. 4198c2939121Smrg func_stripname '' '/' "$dest" 4199c2939121Smrg dest=$func_stripname_result 4200c76ae52dSmrg 4201c2939121Smrg # Check to see that the destination is a directory. 42028292847cSmrg test -d "$dest" && isdir=: 42038292847cSmrg if $isdir; then 42048292847cSmrg destdir=$dest 4205c2939121Smrg destname= 4206c2939121Smrg else 4207c2939121Smrg func_dirname_and_basename "$dest" "" "." 42088292847cSmrg destdir=$func_dirname_result 42098292847cSmrg destname=$func_basename_result 4210c2939121Smrg 4211c2939121Smrg # Not a directory, so check to see that there is only one file specified. 4212c2939121Smrg set dummy $files; shift 4213c2939121Smrg test "$#" -gt 1 && \ 42148292847cSmrg func_fatal_help "'$dest' is not a directory" 4215c2939121Smrg fi 4216c2939121Smrg case $destdir in 4217c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218c76ae52dSmrg *) 4219c2939121Smrg for file in $files; do 4220c2939121Smrg case $file in 4221c2939121Smrg *.lo) ;; 4222c2939121Smrg *) 42238292847cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4224c2939121Smrg ;; 4225c2939121Smrg esac 4226c2939121Smrg done 4227c76ae52dSmrg ;; 4228c76ae52dSmrg esac 4229c76ae52dSmrg 4230c2939121Smrg # This variable tells wrapper scripts just to set variables rather 4231c2939121Smrg # than running their programs. 42328292847cSmrg libtool_install_magic=$magic 4233c76ae52dSmrg 4234c2939121Smrg staticlibs= 4235c2939121Smrg future_libdirs= 4236c2939121Smrg current_libdirs= 4237c2939121Smrg for file in $files; do 4238c76ae52dSmrg 4239c2939121Smrg # Do each installation. 4240c2939121Smrg case $file in 4241c2939121Smrg *.$libext) 4242c2939121Smrg # Do the static libraries later. 42432836776bSmrg func_append staticlibs " $file" 4244c2939121Smrg ;; 4245c2939121Smrg 4246c2939121Smrg *.la) 42472836776bSmrg func_resolve_sysroot "$file" 42482836776bSmrg file=$func_resolve_sysroot_result 42492836776bSmrg 4250c2939121Smrg # Check to see that this really is a libtool archive. 4251c2939121Smrg func_lalib_unsafe_p "$file" \ 42528292847cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4253c2939121Smrg 4254c2939121Smrg library_names= 4255c2939121Smrg old_library= 4256c2939121Smrg relink_command= 4257c2939121Smrg func_source "$file" 4258c2939121Smrg 4259c2939121Smrg # Add the libdir to current_libdirs if it is the destination. 4260c2939121Smrg if test "X$destdir" = "X$libdir"; then 4261c2939121Smrg case "$current_libdirs " in 4262c2939121Smrg *" $libdir "*) ;; 42632836776bSmrg *) func_append current_libdirs " $libdir" ;; 4264c76ae52dSmrg esac 4265c2939121Smrg else 4266c2939121Smrg # Note the libdir as a future libdir. 4267c2939121Smrg case "$future_libdirs " in 4268c2939121Smrg *" $libdir "*) ;; 42692836776bSmrg *) func_append future_libdirs " $libdir" ;; 4270c2939121Smrg esac 4271c2939121Smrg fi 4272c76ae52dSmrg 4273c2939121Smrg func_dirname "$file" "/" "" 42748292847cSmrg dir=$func_dirname_result 42752836776bSmrg func_append dir "$objdir" 4276c2939121Smrg 4277c2939121Smrg if test -n "$relink_command"; then 4278c2939121Smrg # Determine the prefix the user has applied to our future dir. 4279c2939121Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280c2939121Smrg 4281c2939121Smrg # Don't allow the user to place us outside of our expected 4282c2939121Smrg # location b/c this prevents finding dependent libraries that 4283c2939121Smrg # are installed to the same prefix. 4284c2939121Smrg # At present, this check doesn't affect windows .dll's that 4285c2939121Smrg # are installed into $libdir/../bin (currently, that works fine) 4286c2939121Smrg # but it's something to keep an eye on. 4287c2939121Smrg test "$inst_prefix_dir" = "$destdir" && \ 42888292847cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289c2939121Smrg 4290c2939121Smrg if test -n "$inst_prefix_dir"; then 4291c2939121Smrg # Stick the inst_prefix_dir data into the link command. 4292c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293c2939121Smrg else 4294c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295c2939121Smrg fi 4296c2939121Smrg 42978292847cSmrg func_warning "relinking '$file'" 4298c2939121Smrg func_show_eval "$relink_command" \ 42998292847cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300c2939121Smrg fi 4301c2939121Smrg 4302c2939121Smrg # See the names of the shared library. 4303c2939121Smrg set dummy $library_names; shift 4304c2939121Smrg if test -n "$1"; then 43058292847cSmrg realname=$1 4306c2939121Smrg shift 4307c2939121Smrg 43088292847cSmrg srcname=$realname 43098292847cSmrg test -n "$relink_command" && srcname=${realname}T 4310c2939121Smrg 4311c2939121Smrg # Install the shared library and build the symlinks. 4312c2939121Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313c2939121Smrg 'exit $?' 43148292847cSmrg tstripme=$stripme 4315c2939121Smrg case $host_os in 4316c2939121Smrg cygwin* | mingw* | pw32* | cegcc*) 4317c2939121Smrg case $realname in 4318c2939121Smrg *.dll.a) 43198292847cSmrg tstripme= 43208292847cSmrg ;; 43218292847cSmrg esac 43228292847cSmrg ;; 43238292847cSmrg os2*) 43248292847cSmrg case $realname in 43258292847cSmrg *_dll.a) 43268292847cSmrg tstripme= 4327c2939121Smrg ;; 4328c2939121Smrg esac 4329c76ae52dSmrg ;; 4330c76ae52dSmrg esac 4331c2939121Smrg if test -n "$tstripme" && test -n "$striplib"; then 4332c2939121Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333c2939121Smrg fi 4334c2939121Smrg 4335c2939121Smrg if test "$#" -gt 0; then 4336c2939121Smrg # Delete the old symlinks, and create new ones. 43378292847cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338c2939121Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339c2939121Smrg # so we also need to try rm && ln -s. 4340c2939121Smrg for linkname 4341c2939121Smrg do 4342c2939121Smrg test "$linkname" != "$realname" \ 4343c2939121Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344c2939121Smrg done 4345c2939121Smrg fi 4346c2939121Smrg 4347c2939121Smrg # Do each command in the postinstall commands. 43488292847cSmrg lib=$destdir/$realname 4349c2939121Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350c2939121Smrg fi 4351c2939121Smrg 4352c2939121Smrg # Install the pseudo-library for information purposes. 4353c2939121Smrg func_basename "$file" 43548292847cSmrg name=$func_basename_result 43558292847cSmrg instname=$dir/${name}i 4356c2939121Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357c2939121Smrg 4358c2939121Smrg # Maybe install the static library, too. 43592836776bSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360c76ae52dSmrg ;; 4361c2939121Smrg 4362c2939121Smrg *.lo) 4363c2939121Smrg # Install (i.e. copy) a libtool object. 4364c2939121Smrg 4365c2939121Smrg # Figure out destination file name, if it wasn't already specified. 4366c2939121Smrg if test -n "$destname"; then 43678292847cSmrg destfile=$destdir/$destname 4368c2939121Smrg else 4369c2939121Smrg func_basename "$file" 43708292847cSmrg destfile=$func_basename_result 43718292847cSmrg destfile=$destdir/$destfile 4372c2939121Smrg fi 4373c2939121Smrg 4374c2939121Smrg # Deduce the name of the destination old-style object file. 4375c2939121Smrg case $destfile in 4376c2939121Smrg *.lo) 4377c2939121Smrg func_lo2o "$destfile" 4378c2939121Smrg staticdest=$func_lo2o_result 4379c76ae52dSmrg ;; 4380c2939121Smrg *.$objext) 43818292847cSmrg staticdest=$destfile 4382c2939121Smrg destfile= 4383c76ae52dSmrg ;; 4384c2939121Smrg *) 43858292847cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386c76ae52dSmrg ;; 4387c2939121Smrg esac 4388c2939121Smrg 4389c2939121Smrg # Install the libtool object if requested. 4390c2939121Smrg test -n "$destfile" && \ 4391c2939121Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392c2939121Smrg 4393c2939121Smrg # Install the old object if enabled. 43948292847cSmrg if test yes = "$build_old_libs"; then 4395c2939121Smrg # Deduce the name of the old-style object file. 4396c2939121Smrg func_lo2o "$file" 4397c2939121Smrg staticobj=$func_lo2o_result 4398c2939121Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399c76ae52dSmrg fi 4400c2939121Smrg exit $EXIT_SUCCESS 4401c2939121Smrg ;; 4402c76ae52dSmrg 4403c2939121Smrg *) 4404c2939121Smrg # Figure out destination file name, if it wasn't already specified. 4405c2939121Smrg if test -n "$destname"; then 44068292847cSmrg destfile=$destdir/$destname 4407c76ae52dSmrg else 4408c2939121Smrg func_basename "$file" 44098292847cSmrg destfile=$func_basename_result 44108292847cSmrg destfile=$destdir/$destfile 4411c76ae52dSmrg fi 4412c76ae52dSmrg 4413c2939121Smrg # If the file is missing, and there is a .exe on the end, strip it 4414c2939121Smrg # because it is most likely a libtool script we actually want to 4415c2939121Smrg # install 44168292847cSmrg stripped_ext= 4417c2939121Smrg case $file in 4418c2939121Smrg *.exe) 4419c2939121Smrg if test ! -f "$file"; then 4420c2939121Smrg func_stripname '' '.exe' "$file" 4421c2939121Smrg file=$func_stripname_result 44228292847cSmrg stripped_ext=.exe 4423c2939121Smrg fi 4424c2939121Smrg ;; 4425c2939121Smrg esac 4426c76ae52dSmrg 4427c2939121Smrg # Do a test to see if this is really a libtool program. 4428c2939121Smrg case $host in 4429c2939121Smrg *cygwin* | *mingw*) 4430c2939121Smrg if func_ltwrapper_executable_p "$file"; then 4431c2939121Smrg func_ltwrapper_scriptname "$file" 4432c2939121Smrg wrapper=$func_ltwrapper_scriptname_result 4433c2939121Smrg else 4434c2939121Smrg func_stripname '' '.exe' "$file" 4435c2939121Smrg wrapper=$func_stripname_result 4436c2939121Smrg fi 4437c2939121Smrg ;; 4438c2939121Smrg *) 4439c2939121Smrg wrapper=$file 4440c2939121Smrg ;; 4441c2939121Smrg esac 4442c2939121Smrg if func_ltwrapper_script_p "$wrapper"; then 4443c2939121Smrg notinst_deplibs= 4444c2939121Smrg relink_command= 4445c76ae52dSmrg 4446c2939121Smrg func_source "$wrapper" 4447c76ae52dSmrg 4448c2939121Smrg # Check the variables that should have been set. 4449c2939121Smrg test -z "$generated_by_libtool_version" && \ 44508292847cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451c76ae52dSmrg 44528292847cSmrg finalize=: 4453c2939121Smrg for lib in $notinst_deplibs; do 4454c2939121Smrg # Check to see that each library is installed. 4455c2939121Smrg libdir= 4456c2939121Smrg if test -f "$lib"; then 4457c2939121Smrg func_source "$lib" 4458c76ae52dSmrg fi 44598292847cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460c2939121Smrg if test -n "$libdir" && test ! -f "$libfile"; then 44618292847cSmrg func_warning "'$lib' has not been installed in '$libdir'" 44628292847cSmrg finalize=false 4463c2939121Smrg fi 4464c2939121Smrg done 4465c76ae52dSmrg 4466c2939121Smrg relink_command= 4467c2939121Smrg func_source "$wrapper" 4468c76ae52dSmrg 4469c2939121Smrg outputname= 44708292847cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4471c2939121Smrg $opt_dry_run || { 44728292847cSmrg if $finalize; then 4473c2939121Smrg tmpdir=`func_mktempdir` 4474c2939121Smrg func_basename "$file$stripped_ext" 44758292847cSmrg file=$func_basename_result 44768292847cSmrg outputname=$tmpdir/$file 4477c2939121Smrg # Replace the output file specification. 4478c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479c2939121Smrg 44808292847cSmrg $opt_quiet || { 4481c2939121Smrg func_quote_for_expand "$relink_command" 4482c2939121Smrg eval "func_echo $func_quote_for_expand_result" 4483c2939121Smrg } 4484c2939121Smrg if eval "$relink_command"; then : 4485c2939121Smrg else 44868292847cSmrg func_error "error: relink '$file' with the above command before installing it" 4487c2939121Smrg $opt_dry_run || ${RM}r "$tmpdir" 4488c2939121Smrg continue 4489c2939121Smrg fi 44908292847cSmrg file=$outputname 4491c2939121Smrg else 44928292847cSmrg func_warning "cannot relink '$file'" 4493c2939121Smrg fi 4494c2939121Smrg } 4495c76ae52dSmrg else 4496c2939121Smrg # Install the binary that we compiled earlier. 4497c2939121Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498c76ae52dSmrg fi 4499c2939121Smrg fi 4500c76ae52dSmrg 4501c2939121Smrg # remove .exe since cygwin /usr/bin/install will append another 4502c2939121Smrg # one anyway 4503c2939121Smrg case $install_prog,$host in 4504c2939121Smrg */usr/bin/install*,*cygwin*) 4505c2939121Smrg case $file:$destfile in 4506c2939121Smrg *.exe:*.exe) 4507c2939121Smrg # this is ok 4508c2939121Smrg ;; 4509c2939121Smrg *.exe:*) 4510c2939121Smrg destfile=$destfile.exe 4511c2939121Smrg ;; 4512c2939121Smrg *:*.exe) 4513c2939121Smrg func_stripname '' '.exe' "$destfile" 4514c2939121Smrg destfile=$func_stripname_result 4515c2939121Smrg ;; 4516c2939121Smrg esac 4517c76ae52dSmrg ;; 4518c76ae52dSmrg esac 4519c2939121Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520c2939121Smrg $opt_dry_run || if test -n "$outputname"; then 4521c2939121Smrg ${RM}r "$tmpdir" 4522c2939121Smrg fi 4523c2939121Smrg ;; 4524c2939121Smrg esac 4525c2939121Smrg done 4526c76ae52dSmrg 4527c2939121Smrg for file in $staticlibs; do 4528c2939121Smrg func_basename "$file" 45298292847cSmrg name=$func_basename_result 4530c2939121Smrg 4531c2939121Smrg # Set up the ranlib parameters. 45328292847cSmrg oldlib=$destdir/$name 45332836776bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 45342836776bSmrg tool_oldlib=$func_to_tool_file_result 4535c2939121Smrg 4536c2939121Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537c2939121Smrg 4538c2939121Smrg if test -n "$stripme" && test -n "$old_striplib"; then 45392836776bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540c2939121Smrg fi 4541c2939121Smrg 4542c2939121Smrg # Do each command in the postinstall commands. 4543c2939121Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544c2939121Smrg done 4545c2939121Smrg 4546c2939121Smrg test -n "$future_libdirs" && \ 45478292847cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548c2939121Smrg 4549c2939121Smrg if test -n "$current_libdirs"; then 4550c2939121Smrg # Maybe just do a dry run. 4551c2939121Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 45528292847cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553c2939121Smrg else 4554c2939121Smrg exit $EXIT_SUCCESS 4555c2939121Smrg fi 4556c2939121Smrg} 4557c2939121Smrg 45588292847cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559c2939121Smrg 4560c2939121Smrg 4561c2939121Smrg# func_generate_dlsyms outputname originator pic_p 4562c2939121Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563c2939121Smrg# a dlpreopen symbol table. 4564c2939121Smrgfunc_generate_dlsyms () 4565c2939121Smrg{ 45668292847cSmrg $debug_cmd 45678292847cSmrg 45688292847cSmrg my_outputname=$1 45698292847cSmrg my_originator=$2 45708292847cSmrg my_pic_p=${3-false} 45718292847cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572c2939121Smrg my_dlsyms= 4573c2939121Smrg 45748292847cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575c2939121Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 45768292847cSmrg my_dlsyms=${my_outputname}S.c 4577c2939121Smrg else 4578c2939121Smrg func_error "not configured to extract global symbols from dlpreopened files" 4579c2939121Smrg fi 4580c2939121Smrg fi 4581c2939121Smrg 4582c2939121Smrg if test -n "$my_dlsyms"; then 4583c2939121Smrg case $my_dlsyms in 4584c2939121Smrg "") ;; 4585c2939121Smrg *.c) 4586c2939121Smrg # Discover the nlist of each of the dlfiles. 45878292847cSmrg nlist=$output_objdir/$my_outputname.nm 4588c2939121Smrg 4589c2939121Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590c2939121Smrg 4591c2939121Smrg # Parse the name list into a source file. 4592c2939121Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593c2939121Smrg 4594c2939121Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 45958292847cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 45968292847cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597c2939121Smrg 4598c2939121Smrg#ifdef __cplusplus 4599c2939121Smrgextern \"C\" { 4600c2939121Smrg#endif 4601c2939121Smrg 46028292847cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603c2939121Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604c2939121Smrg#endif 4605c2939121Smrg 46062836776bSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 46078292847cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 46088292847cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 46092836776bSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 46102836776bSmrg# define LT_DLSYM_CONST 46118292847cSmrg#elif defined __osf__ 46122836776bSmrg/* This system does not cope well with relocations in const data. */ 46132836776bSmrg# define LT_DLSYM_CONST 46142836776bSmrg#else 46152836776bSmrg# define LT_DLSYM_CONST const 46162836776bSmrg#endif 46172836776bSmrg 46188292847cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 46198292847cSmrg 4620c2939121Smrg/* External symbol declarations for the compiler. */\ 4621c2939121Smrg" 4622c2939121Smrg 46238292847cSmrg if test yes = "$dlself"; then 46248292847cSmrg func_verbose "generating symbol list for '$output'" 4625c2939121Smrg 4626c2939121Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627c2939121Smrg 4628c2939121Smrg # Add our own program objects to the symbol list. 4629c2939121Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630c2939121Smrg for progfile in $progfiles; do 46312836776bSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 46328292847cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 46332836776bSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634c2939121Smrg done 4635c2939121Smrg 4636c2939121Smrg if test -n "$exclude_expsyms"; then 4637c2939121Smrg $opt_dry_run || { 4638c2939121Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639c2939121Smrg eval '$MV "$nlist"T "$nlist"' 4640c2939121Smrg } 4641c76ae52dSmrg fi 4642c2939121Smrg 4643c2939121Smrg if test -n "$export_symbols_regex"; then 4644c2939121Smrg $opt_dry_run || { 4645c2939121Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646c2939121Smrg eval '$MV "$nlist"T "$nlist"' 4647c2939121Smrg } 4648c2939121Smrg fi 4649c2939121Smrg 4650c2939121Smrg # Prepare the list of exported symbols 4651c2939121Smrg if test -z "$export_symbols"; then 46528292847cSmrg export_symbols=$output_objdir/$outputname.exp 4653c2939121Smrg $opt_dry_run || { 4654c2939121Smrg $RM $export_symbols 46558292847cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656c2939121Smrg case $host in 4657c2939121Smrg *cygwin* | *mingw* | *cegcc* ) 4658c2939121Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659c2939121Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660c2939121Smrg ;; 4661c2939121Smrg esac 4662c2939121Smrg } 4663c76ae52dSmrg else 4664c2939121Smrg $opt_dry_run || { 46658292847cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666c2939121Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667c2939121Smrg eval '$MV "$nlist"T "$nlist"' 4668c2939121Smrg case $host in 4669c2939121Smrg *cygwin* | *mingw* | *cegcc* ) 4670c2939121Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671c2939121Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672c2939121Smrg ;; 4673c2939121Smrg esac 4674c2939121Smrg } 4675c76ae52dSmrg fi 4676c2939121Smrg fi 4677c76ae52dSmrg 4678c2939121Smrg for dlprefile in $dlprefiles; do 46798292847cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4680c2939121Smrg func_basename "$dlprefile" 46818292847cSmrg name=$func_basename_result 46822836776bSmrg case $host in 46832836776bSmrg *cygwin* | *mingw* | *cegcc* ) 46842836776bSmrg # if an import library, we need to obtain dlname 46852836776bSmrg if func_win32_import_lib_p "$dlprefile"; then 46862836776bSmrg func_tr_sh "$dlprefile" 46872836776bSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 46888292847cSmrg dlprefile_dlbasename= 46892836776bSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 46902836776bSmrg # Use subshell, to avoid clobbering current variable values 46912836776bSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 46928292847cSmrg if test -n "$dlprefile_dlname"; then 46932836776bSmrg func_basename "$dlprefile_dlname" 46948292847cSmrg dlprefile_dlbasename=$func_basename_result 46952836776bSmrg else 46962836776bSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 46972836776bSmrg $sharedlib_from_linklib_cmd "$dlprefile" 46982836776bSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 46992836776bSmrg fi 47002836776bSmrg fi 47012836776bSmrg $opt_dry_run || { 47028292847cSmrg if test -n "$dlprefile_dlbasename"; then 47032836776bSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 47042836776bSmrg else 47052836776bSmrg func_warning "Could not compute DLL name from $name" 47062836776bSmrg eval '$ECHO ": $name " >> "$nlist"' 47072836776bSmrg fi 47082836776bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47092836776bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 47102836776bSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 47112836776bSmrg } 47122836776bSmrg else # not an import lib 47132836776bSmrg $opt_dry_run || { 47142836776bSmrg eval '$ECHO ": $name " >> "$nlist"' 47152836776bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47162836776bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47172836776bSmrg } 47182836776bSmrg fi 47192836776bSmrg ;; 47202836776bSmrg *) 47212836776bSmrg $opt_dry_run || { 47222836776bSmrg eval '$ECHO ": $name " >> "$nlist"' 47232836776bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 47242836776bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 47252836776bSmrg } 47262836776bSmrg ;; 47272836776bSmrg esac 4728c2939121Smrg done 4729c2939121Smrg 4730c2939121Smrg $opt_dry_run || { 4731c2939121Smrg # Make sure we have at least an empty file. 4732c2939121Smrg test -f "$nlist" || : > "$nlist" 4733c2939121Smrg 4734c2939121Smrg if test -n "$exclude_expsyms"; then 4735c2939121Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736c2939121Smrg $MV "$nlist"T "$nlist" 4737c76ae52dSmrg fi 4738c2939121Smrg 4739c2939121Smrg # Try sorting and uniquifying the output. 4740c2939121Smrg if $GREP -v "^: " < "$nlist" | 4741c2939121Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742c2939121Smrg sort -k 3 4743c2939121Smrg else 4744c2939121Smrg sort +2 4745c2939121Smrg fi | 4746c2939121Smrg uniq > "$nlist"S; then 4747c2939121Smrg : 4748c76ae52dSmrg else 4749c2939121Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750c76ae52dSmrg fi 4751c76ae52dSmrg 4752c2939121Smrg if test -f "$nlist"S; then 4753c2939121Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754c76ae52dSmrg else 4755c2939121Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756c76ae52dSmrg fi 4757c76ae52dSmrg 47588292847cSmrg func_show_eval '$RM "${nlist}I"' 47598292847cSmrg if test -n "$global_symbol_to_import"; then 47608292847cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 47618292847cSmrg fi 47628292847cSmrg 4763c2939121Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4764c76ae52dSmrg 4765c2939121Smrg/* The mapping between symbol names and symbols. */ 4766c2939121Smrgtypedef struct { 4767c2939121Smrg const char *name; 4768c2939121Smrg void *address; 4769c2939121Smrg} lt_dlsymlist; 47702836776bSmrgextern LT_DLSYM_CONST lt_dlsymlist 47718292847cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 47728292847cSmrg" 47738292847cSmrg 47748292847cSmrg if test -s "$nlist"I; then 47758292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47768292847cSmrgstatic void lt_syminit(void) 47778292847cSmrg{ 47788292847cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 47798292847cSmrg for (; symbol->name; ++symbol) 47808292847cSmrg {" 47818292847cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 47828292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47838292847cSmrg } 47848292847cSmrg}" 47858292847cSmrg fi 47868292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47872836776bSmrgLT_DLSYM_CONST lt_dlsymlist 4788c2939121Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 47898292847cSmrg{ {\"$my_originator\", (void *) 0}," 47908292847cSmrg 47918292847cSmrg if test -s "$nlist"I; then 47928292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47938292847cSmrg {\"@INIT@\", (void *) <_syminit}," 47948292847cSmrg fi 4795c76ae52dSmrg 4796c2939121Smrg case $need_lib_prefix in 4797c2939121Smrg no) 4798c2939121Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799c2939121Smrg ;; 4800c2939121Smrg *) 4801c2939121Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802c2939121Smrg ;; 4803c2939121Smrg esac 4804c2939121Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4805c2939121Smrg {0, (void *) 0} 4806c2939121Smrg}; 4807c76ae52dSmrg 4808c2939121Smrg/* This works around a problem in FreeBSD linker */ 4809c2939121Smrg#ifdef FREEBSD_WORKAROUND 4810c2939121Smrgstatic const void *lt_preloaded_setup() { 4811c2939121Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812c2939121Smrg} 4813c2939121Smrg#endif 4814c76ae52dSmrg 4815c2939121Smrg#ifdef __cplusplus 4816c2939121Smrg} 4817c2939121Smrg#endif\ 4818c2939121Smrg" 4819c2939121Smrg } # !$opt_dry_run 4820c76ae52dSmrg 4821c2939121Smrg pic_flag_for_symtable= 4822c2939121Smrg case "$compile_command " in 4823c2939121Smrg *" -static "*) ;; 4824c2939121Smrg *) 4825c2939121Smrg case $host in 4826c2939121Smrg # compiling the symbol table file with pic_flag works around 4827c2939121Smrg # a FreeBSD bug that causes programs to crash when -lm is 4828c2939121Smrg # linked before any other PIC object. But we must not use 4829c2939121Smrg # pic_flag when linking with -static. The problem exists in 4830c2939121Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 48312836776bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832c2939121Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833c2939121Smrg *-*-hpux*) 4834c2939121Smrg pic_flag_for_symtable=" $pic_flag" ;; 4835c2939121Smrg *) 48368292847cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837c2939121Smrg ;; 4838c2939121Smrg esac 4839c2939121Smrg ;; 4840c2939121Smrg esac 4841c2939121Smrg symtab_cflags= 4842c2939121Smrg for arg in $LTCFLAGS; do 4843c2939121Smrg case $arg in 4844c2939121Smrg -pie | -fpie | -fPIE) ;; 48452836776bSmrg *) func_append symtab_cflags " $arg" ;; 4846c2939121Smrg esac 4847c2939121Smrg done 4848c76ae52dSmrg 4849c2939121Smrg # Now compile the dynamic symbol file. 4850c2939121Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851c76ae52dSmrg 4852c2939121Smrg # Clean up the generated files. 48538292847cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854c76ae52dSmrg 4855c2939121Smrg # Transform the symbol file into the correct name. 48568292847cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857c2939121Smrg case $host in 4858c2939121Smrg *cygwin* | *mingw* | *cegcc* ) 4859c2939121Smrg if test -f "$output_objdir/$my_outputname.def"; then 4860c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862c2939121Smrg else 4863c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865c2939121Smrg fi 4866c2939121Smrg ;; 4867c2939121Smrg *) 4868c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870c2939121Smrg ;; 4871c2939121Smrg esac 4872c2939121Smrg ;; 4873c2939121Smrg *) 48748292847cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875c2939121Smrg ;; 4876c2939121Smrg esac 4877c2939121Smrg else 4878c2939121Smrg # We keep going just in case the user didn't refer to 4879c2939121Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880c2939121Smrg # really was required. 4881c76ae52dSmrg 4882c2939121Smrg # Nullify the symbol file. 4883c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885c2939121Smrg fi 4886c2939121Smrg} 4887c76ae52dSmrg 48888292847cSmrg# func_cygming_gnu_implib_p ARG 48898292847cSmrg# This predicate returns with zero status (TRUE) if 48908292847cSmrg# ARG is a GNU/binutils-style import library. Returns 48918292847cSmrg# with nonzero status (FALSE) otherwise. 48928292847cSmrgfunc_cygming_gnu_implib_p () 48938292847cSmrg{ 48948292847cSmrg $debug_cmd 48958292847cSmrg 48968292847cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 48978292847cSmrg 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)$'` 48988292847cSmrg test -n "$func_cygming_gnu_implib_tmp" 48998292847cSmrg} 49008292847cSmrg 49018292847cSmrg# func_cygming_ms_implib_p ARG 49028292847cSmrg# This predicate returns with zero status (TRUE) if 49038292847cSmrg# ARG is an MS-style import library. Returns 49048292847cSmrg# with nonzero status (FALSE) otherwise. 49058292847cSmrgfunc_cygming_ms_implib_p () 49068292847cSmrg{ 49078292847cSmrg $debug_cmd 49088292847cSmrg 49098292847cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49108292847cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 49118292847cSmrg test -n "$func_cygming_ms_implib_tmp" 49128292847cSmrg} 49138292847cSmrg 4914c2939121Smrg# func_win32_libid arg 4915c2939121Smrg# return the library type of file 'arg' 4916c2939121Smrg# 4917c2939121Smrg# Need a lot of goo to handle *both* DLLs and import libs 4918c2939121Smrg# Has to be a shell function in order to 'eat' the argument 4919c2939121Smrg# that is supplied when $file_magic_command is called. 4920c2939121Smrg# Despite the name, also deal with 64 bit binaries. 4921c2939121Smrgfunc_win32_libid () 4922c2939121Smrg{ 49238292847cSmrg $debug_cmd 49248292847cSmrg 49258292847cSmrg win32_libid_type=unknown 4926c2939121Smrg win32_fileres=`file -L $1 2>/dev/null` 4927c2939121Smrg case $win32_fileres in 4928c2939121Smrg *ar\ archive\ import\ library*) # definitely import 4929c2939121Smrg win32_libid_type="x86 archive import" 4930c2939121Smrg ;; 4931c2939121Smrg *ar\ archive*) # could be an import, or static 4932c2939121Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933c2939121Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934c2939121Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 49358292847cSmrg case $nm_interface in 49368292847cSmrg "MS dumpbin") 49378292847cSmrg if func_cygming_ms_implib_p "$1" || 49388292847cSmrg func_cygming_gnu_implib_p "$1" 49398292847cSmrg then 49408292847cSmrg win32_nmres=import 49418292847cSmrg else 49428292847cSmrg win32_nmres= 49438292847cSmrg fi 49448292847cSmrg ;; 49458292847cSmrg *) 49468292847cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49478292847cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 49488292847cSmrg $SED -n -e ' 4949c2939121Smrg 1,100{ 4950c2939121Smrg / I /{ 49518292847cSmrg s|.*|import| 4952c2939121Smrg p 4953c2939121Smrg q 4954c2939121Smrg } 4955c2939121Smrg }'` 49568292847cSmrg ;; 49578292847cSmrg esac 4958c2939121Smrg case $win32_nmres in 4959c2939121Smrg import*) win32_libid_type="x86 archive import";; 4960c2939121Smrg *) win32_libid_type="x86 archive static";; 4961c2939121Smrg esac 4962c2939121Smrg fi 4963c2939121Smrg ;; 4964c2939121Smrg *DLL*) 4965c2939121Smrg win32_libid_type="x86 DLL" 4966c2939121Smrg ;; 4967c2939121Smrg *executable*) # but shell scripts are "executable" too... 4968c2939121Smrg case $win32_fileres in 4969c2939121Smrg *MS\ Windows\ PE\ Intel*) 4970c2939121Smrg win32_libid_type="x86 DLL" 4971c2939121Smrg ;; 4972c2939121Smrg esac 4973c2939121Smrg ;; 4974c2939121Smrg esac 4975c2939121Smrg $ECHO "$win32_libid_type" 4976c2939121Smrg} 4977c76ae52dSmrg 49782836776bSmrg# func_cygming_dll_for_implib ARG 49792836776bSmrg# 49802836776bSmrg# Platform-specific function to extract the 49812836776bSmrg# name of the DLL associated with the specified 49822836776bSmrg# import library ARG. 49832836776bSmrg# Invoked by eval'ing the libtool variable 49842836776bSmrg# $sharedlib_from_linklib_cmd 49852836776bSmrg# Result is available in the variable 49862836776bSmrg# $sharedlib_from_linklib_result 49872836776bSmrgfunc_cygming_dll_for_implib () 49882836776bSmrg{ 49898292847cSmrg $debug_cmd 49908292847cSmrg 49912836776bSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 49922836776bSmrg} 49932836776bSmrg 49942836776bSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 49952836776bSmrg# 49962836776bSmrg# The is the core of a fallback implementation of a 49972836776bSmrg# platform-specific function to extract the name of the 49982836776bSmrg# DLL associated with the specified import library LIBNAME. 49992836776bSmrg# 50002836776bSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 50012836776bSmrg# on the platform and compiler that created the implib. 50022836776bSmrg# 50032836776bSmrg# Echos the name of the DLL associated with the 50042836776bSmrg# specified import library. 50052836776bSmrgfunc_cygming_dll_for_implib_fallback_core () 50062836776bSmrg{ 50078292847cSmrg $debug_cmd 50088292847cSmrg 50092836776bSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 50102836776bSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 50112836776bSmrg $SED '/^Contents of section '"$match_literal"':/{ 50122836776bSmrg # Place marker at beginning of archive member dllname section 50132836776bSmrg s/.*/====MARK====/ 50142836776bSmrg p 50152836776bSmrg d 50162836776bSmrg } 50172836776bSmrg # These lines can sometimes be longer than 43 characters, but 50182836776bSmrg # are always uninteresting 50192836776bSmrg /:[ ]*file format pe[i]\{,1\}-/d 50202836776bSmrg /^In archive [^:]*:/d 50212836776bSmrg # Ensure marker is printed 50222836776bSmrg /^====MARK====/p 50232836776bSmrg # Remove all lines with less than 43 characters 50242836776bSmrg /^.\{43\}/!d 50252836776bSmrg # From remaining lines, remove first 43 characters 50262836776bSmrg s/^.\{43\}//' | 50272836776bSmrg $SED -n ' 50282836776bSmrg # Join marker and all lines until next marker into a single line 50292836776bSmrg /^====MARK====/ b para 50302836776bSmrg H 50312836776bSmrg $ b para 50322836776bSmrg b 50332836776bSmrg :para 50342836776bSmrg x 50352836776bSmrg s/\n//g 50362836776bSmrg # Remove the marker 50372836776bSmrg s/^====MARK====// 50382836776bSmrg # Remove trailing dots and whitespace 50392836776bSmrg s/[\. \t]*$// 50402836776bSmrg # Print 50412836776bSmrg /./p' | 50422836776bSmrg # we now have a list, one entry per line, of the stringified 50432836776bSmrg # contents of the appropriate section of all members of the 50448292847cSmrg # archive that possess that section. Heuristic: eliminate 50458292847cSmrg # all those that have a first or second character that is 50462836776bSmrg # a '.' (that is, objdump's representation of an unprintable 50472836776bSmrg # character.) This should work for all archives with less than 50482836776bSmrg # 0x302f exports -- but will fail for DLLs whose name actually 50492836776bSmrg # begins with a literal '.' or a single character followed by 50502836776bSmrg # a '.'. 50512836776bSmrg # 50522836776bSmrg # Of those that remain, print the first one. 50532836776bSmrg $SED -e '/^\./d;/^.\./d;q' 50542836776bSmrg} 50552836776bSmrg 50562836776bSmrg# func_cygming_dll_for_implib_fallback ARG 50572836776bSmrg# Platform-specific function to extract the 50582836776bSmrg# name of the DLL associated with the specified 50592836776bSmrg# import library ARG. 50602836776bSmrg# 50612836776bSmrg# This fallback implementation is for use when $DLLTOOL 50622836776bSmrg# does not support the --identify-strict option. 50632836776bSmrg# Invoked by eval'ing the libtool variable 50642836776bSmrg# $sharedlib_from_linklib_cmd 50652836776bSmrg# Result is available in the variable 50662836776bSmrg# $sharedlib_from_linklib_result 50672836776bSmrgfunc_cygming_dll_for_implib_fallback () 50682836776bSmrg{ 50698292847cSmrg $debug_cmd 50708292847cSmrg 50718292847cSmrg if func_cygming_gnu_implib_p "$1"; then 50722836776bSmrg # binutils import library 50732836776bSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 50748292847cSmrg elif func_cygming_ms_implib_p "$1"; then 50752836776bSmrg # ms-generated import library 50762836776bSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 50772836776bSmrg else 50782836776bSmrg # unknown 50798292847cSmrg sharedlib_from_linklib_result= 50802836776bSmrg fi 50812836776bSmrg} 5082c76ae52dSmrg 5083c76ae52dSmrg 5084c2939121Smrg# func_extract_an_archive dir oldlib 5085c2939121Smrgfunc_extract_an_archive () 5086c2939121Smrg{ 50878292847cSmrg $debug_cmd 50888292847cSmrg 50898292847cSmrg f_ex_an_ar_dir=$1; shift 50908292847cSmrg f_ex_an_ar_oldlib=$1 50918292847cSmrg if test yes = "$lock_old_archive_extraction"; then 5092c2939121Smrg lockfile=$f_ex_an_ar_oldlib.lock 5093c2939121Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094c2939121Smrg func_echo "Waiting for $lockfile to be removed" 5095c2939121Smrg sleep 2 5096c2939121Smrg done 5097c2939121Smrg fi 5098c2939121Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099c2939121Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 51008292847cSmrg if test yes = "$lock_old_archive_extraction"; then 5101c2939121Smrg $opt_dry_run || rm -f "$lockfile" 5102c2939121Smrg fi 5103c2939121Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104c2939121Smrg : 5105c2939121Smrg else 5106c2939121Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107c2939121Smrg fi 5108c2939121Smrg} 5109c76ae52dSmrg 5110c76ae52dSmrg 5111c2939121Smrg# func_extract_archives gentop oldlib ... 5112c2939121Smrgfunc_extract_archives () 5113c2939121Smrg{ 51148292847cSmrg $debug_cmd 51158292847cSmrg 51168292847cSmrg my_gentop=$1; shift 5117c2939121Smrg my_oldlibs=${1+"$@"} 51188292847cSmrg my_oldobjs= 51198292847cSmrg my_xlib= 51208292847cSmrg my_xabs= 51218292847cSmrg my_xdir= 5122c76ae52dSmrg 5123c2939121Smrg for my_xlib in $my_oldlibs; do 5124c2939121Smrg # Extract the objects. 5125c2939121Smrg case $my_xlib in 51268292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127c2939121Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128c2939121Smrg esac 5129c2939121Smrg func_basename "$my_xlib" 51308292847cSmrg my_xlib=$func_basename_result 5131c2939121Smrg my_xlib_u=$my_xlib 5132c2939121Smrg while :; do 5133c2939121Smrg case " $extracted_archives " in 5134c2939121Smrg *" $my_xlib_u "*) 5135c2939121Smrg func_arith $extracted_serial + 1 5136c2939121Smrg extracted_serial=$func_arith_result 5137c2939121Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138c2939121Smrg *) break ;; 5139c2939121Smrg esac 5140c2939121Smrg done 5141c2939121Smrg extracted_archives="$extracted_archives $my_xlib_u" 51428292847cSmrg my_xdir=$my_gentop/$my_xlib_u 5143c76ae52dSmrg 5144c2939121Smrg func_mkdir_p "$my_xdir" 5145c2939121Smrg 5146c2939121Smrg case $host in 5147c2939121Smrg *-darwin*) 5148c2939121Smrg func_verbose "Extracting $my_xabs" 5149c2939121Smrg # Do not bother doing anything if just a dry run 5150c2939121Smrg $opt_dry_run || { 5151c2939121Smrg darwin_orig_dir=`pwd` 5152c2939121Smrg cd $my_xdir || exit $? 5153c2939121Smrg darwin_archive=$my_xabs 5154c2939121Smrg darwin_curdir=`pwd` 51558292847cSmrg func_basename "$darwin_archive" 51568292847cSmrg darwin_base_archive=$func_basename_result 5157c2939121Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158c2939121Smrg if test -n "$darwin_arches"; then 5159c2939121Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160c2939121Smrg darwin_arch= 5161c2939121Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 51628292847cSmrg for darwin_arch in $darwin_arches; do 51638292847cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 51648292847cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 51658292847cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 51668292847cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167c2939121Smrg cd "$darwin_curdir" 51688292847cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169c2939121Smrg done # $darwin_arches 5170c2939121Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 51718292847cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172c2939121Smrg darwin_file= 5173c2939121Smrg darwin_files= 5174c2939121Smrg for darwin_file in $darwin_filelist; do 5175c2939121Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176c2939121Smrg $LIPO -create -output "$darwin_file" $darwin_files 5177c2939121Smrg done # $darwin_filelist 5178c2939121Smrg $RM -rf unfat-$$ 5179c2939121Smrg cd "$darwin_orig_dir" 5180c76ae52dSmrg else 5181c2939121Smrg cd $darwin_orig_dir 5182c2939121Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183c2939121Smrg fi # $darwin_arches 5184c2939121Smrg } # !$opt_dry_run 5185c2939121Smrg ;; 5186c2939121Smrg *) 5187c2939121Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188c2939121Smrg ;; 5189c2939121Smrg esac 5190c2939121Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191c2939121Smrg done 5192c76ae52dSmrg 51938292847cSmrg func_extract_archives_result=$my_oldobjs 5194c2939121Smrg} 5195c76ae52dSmrg 5196c76ae52dSmrg 5197c2939121Smrg# func_emit_wrapper [arg=no] 5198c2939121Smrg# 5199c2939121Smrg# Emit a libtool wrapper script on stdout. 5200c2939121Smrg# Don't directly open a file because we may want to 5201c2939121Smrg# incorporate the script contents within a cygwin/mingw 5202c2939121Smrg# wrapper executable. Must ONLY be called from within 5203c2939121Smrg# func_mode_link because it depends on a number of variables 5204c2939121Smrg# set therein. 5205c2939121Smrg# 5206c2939121Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207c2939121Smrg# variable will take. If 'yes', then the emitted script 52088292847cSmrg# will assume that the directory where it is stored is 5209c2939121Smrg# the $objdir directory. This is a cygwin/mingw-specific 5210c2939121Smrg# behavior. 5211c2939121Smrgfunc_emit_wrapper () 5212c2939121Smrg{ 5213c2939121Smrg func_emit_wrapper_arg1=${1-no} 5214c76ae52dSmrg 5215c2939121Smrg $ECHO "\ 5216c2939121Smrg#! $SHELL 5217c76ae52dSmrg 5218c2939121Smrg# $output - temporary wrapper script for $objdir/$outputname 52198292847cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220c2939121Smrg# 5221c2939121Smrg# The $output program cannot be directly executed until all the libtool 5222c2939121Smrg# libraries that it depends on are installed. 5223c2939121Smrg# 5224c2939121Smrg# This wrapper script should never be moved out of the build directory. 5225c2939121Smrg# If it is, it will not operate correctly. 5226c76ae52dSmrg 5227c2939121Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5228c2939121Smrg# metacharacters that are still active within double-quoted strings. 5229c2939121Smrgsed_quote_subst='$sed_quote_subst' 5230c76ae52dSmrg 5231c2939121Smrg# Be Bourne compatible 5232c2939121Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233c2939121Smrg emulate sh 5234c2939121Smrg NULLCMD=: 5235c2939121Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236c2939121Smrg # is contrary to our usage. Disable this feature. 5237c2939121Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238c2939121Smrg setopt NO_GLOB_SUBST 5239c2939121Smrgelse 5240c2939121Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241c2939121Smrgfi 5242c2939121SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243c2939121SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244c76ae52dSmrg 5245c2939121Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246c2939121Smrg# if CDPATH is set. 5247c2939121Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248c76ae52dSmrg 5249c2939121Smrgrelink_command=\"$relink_command\" 5250c76ae52dSmrg 5251c2939121Smrg# This environment variable determines our operation mode. 5252c2939121Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253c2939121Smrg # install mode needs the following variables: 5254c2939121Smrg generated_by_libtool_version='$macro_version' 5255c2939121Smrg notinst_deplibs='$notinst_deplibs' 5256c2939121Smrgelse 5257c2939121Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258c2939121Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259c2939121Smrg file=\"\$0\"" 5260c76ae52dSmrg 5261c2939121Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262c2939121Smrg $ECHO "\ 5263c76ae52dSmrg 5264c2939121Smrg# A function that is used when there is no print builtin or printf. 5265c2939121Smrgfunc_fallback_echo () 5266c2939121Smrg{ 5267c2939121Smrg eval 'cat <<_LTECHO_EOF 5268c2939121Smrg\$1 5269c2939121Smrg_LTECHO_EOF' 5270c2939121Smrg} 5271c2939121Smrg ECHO=\"$qECHO\" 5272c2939121Smrg fi 5273c2939121Smrg 5274c2939121Smrg# Very basic option parsing. These options are (a) specific to 5275c2939121Smrg# the libtool wrapper, (b) are identical between the wrapper 52768292847cSmrg# /script/ and the wrapper /executable/ that is used only on 5277c2939121Smrg# windows platforms, and (c) all begin with the string "--lt-" 52788292847cSmrg# (application programs are unlikely to have options that match 5279c2939121Smrg# this pattern). 5280c2939121Smrg# 5281c2939121Smrg# There are only two supported options: --lt-debug and 5282c2939121Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5283c2939121Smrg# 5284c2939121Smrg# The first argument to this parsing function should be the 5285c2939121Smrg# script's $0 value, followed by "$@". 5286c2939121Smrglt_option_debug= 5287c2939121Smrgfunc_parse_lt_options () 5288c2939121Smrg{ 5289c2939121Smrg lt_script_arg0=\$0 5290c2939121Smrg shift 5291c2939121Smrg for lt_opt 5292c2939121Smrg do 5293c2939121Smrg case \"\$lt_opt\" in 5294c2939121Smrg --lt-debug) lt_option_debug=1 ;; 5295c2939121Smrg --lt-dump-script) 5296c2939121Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297c2939121Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298c2939121Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299c2939121Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5300c2939121Smrg exit 0 5301c2939121Smrg ;; 5302c2939121Smrg --lt-*) 5303c2939121Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304c2939121Smrg exit 1 5305c76ae52dSmrg ;; 5306c2939121Smrg esac 5307c2939121Smrg done 5308c76ae52dSmrg 5309c2939121Smrg # Print the debug banner immediately: 5310c2939121Smrg if test -n \"\$lt_option_debug\"; then 53118292847cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312c2939121Smrg fi 5313c2939121Smrg} 5314c76ae52dSmrg 5315c2939121Smrg# Used when --lt-debug. Prints its arguments to stdout 5316c2939121Smrg# (redirection is the responsibility of the caller) 5317c2939121Smrgfunc_lt_dump_args () 5318c2939121Smrg{ 5319c2939121Smrg lt_dump_args_N=1; 5320c2939121Smrg for lt_arg 5321c2939121Smrg do 53228292847cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323c2939121Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324c2939121Smrg done 5325c2939121Smrg} 5326c76ae52dSmrg 5327c2939121Smrg# Core function for launching the target application 5328c2939121Smrgfunc_exec_program_core () 5329c2939121Smrg{ 5330c2939121Smrg" 5331c2939121Smrg case $host in 5332c2939121Smrg # Backslashes separate directories on plain windows 5333c2939121Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5334c2939121Smrg $ECHO "\ 5335c2939121Smrg if test -n \"\$lt_option_debug\"; then 53368292847cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337c2939121Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338c76ae52dSmrg fi 5339c2939121Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340c2939121Smrg" 5341c2939121Smrg ;; 5342c76ae52dSmrg 5343c2939121Smrg *) 5344c2939121Smrg $ECHO "\ 5345c2939121Smrg if test -n \"\$lt_option_debug\"; then 53468292847cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347c2939121Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348c76ae52dSmrg fi 5349c2939121Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350c2939121Smrg" 5351c2939121Smrg ;; 5352c2939121Smrg esac 5353c2939121Smrg $ECHO "\ 5354c2939121Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355c2939121Smrg exit 1 5356c2939121Smrg} 5357c76ae52dSmrg 5358c2939121Smrg# A function to encapsulate launching the target application 5359c2939121Smrg# Strips options in the --lt-* namespace from \$@ and 5360c2939121Smrg# launches target application with the remaining arguments. 5361c2939121Smrgfunc_exec_program () 5362c2939121Smrg{ 53632836776bSmrg case \" \$* \" in 53642836776bSmrg *\\ --lt-*) 53652836776bSmrg for lt_wr_arg 53662836776bSmrg do 53672836776bSmrg case \$lt_wr_arg in 53682836776bSmrg --lt-*) ;; 53692836776bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 53702836776bSmrg esac 53712836776bSmrg shift 53722836776bSmrg done ;; 53732836776bSmrg esac 5374c2939121Smrg func_exec_program_core \${1+\"\$@\"} 5375c2939121Smrg} 5376c76ae52dSmrg 5377c2939121Smrg # Parse options 5378c2939121Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379c76ae52dSmrg 5380c2939121Smrg # Find the directory that this script lives in. 5381c2939121Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382c2939121Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383c76ae52dSmrg 5384c2939121Smrg # Follow symbolic links until we get to the real thisdir. 5385c2939121Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386c2939121Smrg while test -n \"\$file\"; do 5387c2939121Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388c76ae52dSmrg 5389c2939121Smrg # If there was a directory component, then change thisdir. 5390c2939121Smrg if test \"x\$destdir\" != \"x\$file\"; then 5391c2939121Smrg case \"\$destdir\" in 5392c2939121Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393c2939121Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394c2939121Smrg esac 5395c2939121Smrg fi 5396c76ae52dSmrg 5397c2939121Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398c2939121Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399c2939121Smrg done 5400c76ae52dSmrg 5401c2939121Smrg # Usually 'no', except on cygwin/mingw when embedded into 5402c2939121Smrg # the cwrapper. 5403c2939121Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404c2939121Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405c2939121Smrg # special case for '.' 5406c2939121Smrg if test \"\$thisdir\" = \".\"; then 5407c2939121Smrg thisdir=\`pwd\` 5408c2939121Smrg fi 5409c2939121Smrg # remove .libs from thisdir 5410c2939121Smrg case \"\$thisdir\" in 5411c2939121Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412c2939121Smrg $objdir ) thisdir=. ;; 5413c2939121Smrg esac 5414c2939121Smrg fi 5415c76ae52dSmrg 5416c2939121Smrg # Try to get the absolute directory name. 5417c2939121Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5418c2939121Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419c2939121Smrg" 5420c76ae52dSmrg 54218292847cSmrg if test yes = "$fast_install"; then 5422c2939121Smrg $ECHO "\ 5423c2939121Smrg program=lt-'$outputname'$exeext 5424c2939121Smrg progdir=\"\$thisdir/$objdir\" 5425c76ae52dSmrg 5426c2939121Smrg if test ! -f \"\$progdir/\$program\" || 54278292847cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428c2939121Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429c76ae52dSmrg 5430c2939121Smrg file=\"\$\$-\$program\" 5431c76ae52dSmrg 5432c2939121Smrg if test ! -d \"\$progdir\"; then 5433c2939121Smrg $MKDIR \"\$progdir\" 5434c2939121Smrg else 5435c2939121Smrg $RM \"\$progdir/\$file\" 5436c2939121Smrg fi" 5437c76ae52dSmrg 5438c2939121Smrg $ECHO "\ 5439c76ae52dSmrg 5440c2939121Smrg # relink executable if necessary 5441c2939121Smrg if test -n \"\$relink_command\"; then 5442c2939121Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443c2939121Smrg else 54448292847cSmrg \$ECHO \"\$relink_command_output\" >&2 5445c2939121Smrg $RM \"\$progdir/\$file\" 5446c2939121Smrg exit 1 5447c2939121Smrg fi 5448c2939121Smrg fi 5449c76ae52dSmrg 5450c2939121Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451c2939121Smrg { $RM \"\$progdir/\$program\"; 5452c2939121Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453c2939121Smrg $RM \"\$progdir/\$file\" 5454c2939121Smrg fi" 5455c2939121Smrg else 5456c2939121Smrg $ECHO "\ 5457c2939121Smrg program='$outputname' 5458c2939121Smrg progdir=\"\$thisdir/$objdir\" 5459c2939121Smrg" 5460c2939121Smrg fi 5461c76ae52dSmrg 5462c2939121Smrg $ECHO "\ 5463c76ae52dSmrg 5464c2939121Smrg if test -f \"\$progdir/\$program\"; then" 5465c76ae52dSmrg 54662836776bSmrg # fixup the dll searchpath if we need to. 54672836776bSmrg # 54682836776bSmrg # Fix the DLL searchpath if we need to. Do this before prepending 54692836776bSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 54702836776bSmrg # libraries must come first. 54712836776bSmrg if test -n "$dllsearchpath"; then 54722836776bSmrg $ECHO "\ 54732836776bSmrg # Add the dll search path components to the executable PATH 54742836776bSmrg PATH=$dllsearchpath:\$PATH 54752836776bSmrg" 54762836776bSmrg fi 54772836776bSmrg 5478c2939121Smrg # Export our shlibpath_var if we have one. 54798292847cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480c2939121Smrg $ECHO "\ 5481c2939121Smrg # Add our own library path to $shlibpath_var 5482c2939121Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483c76ae52dSmrg 5484c2939121Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485c2939121Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5486c2939121Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487c76ae52dSmrg 5488c2939121Smrg export $shlibpath_var 5489c2939121Smrg" 5490c2939121Smrg fi 5491c76ae52dSmrg 5492c2939121Smrg $ECHO "\ 5493c2939121Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494c2939121Smrg # Run the actual program with our arguments. 5495c2939121Smrg func_exec_program \${1+\"\$@\"} 5496c2939121Smrg fi 5497c2939121Smrg else 5498c2939121Smrg # The program doesn't exist. 54998292847cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500c2939121Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501c2939121Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502c2939121Smrg exit 1 5503c2939121Smrg fi 5504c2939121Smrgfi\ 5505c2939121Smrg" 5506c2939121Smrg} 5507c76ae52dSmrg 5508c76ae52dSmrg 5509c2939121Smrg# func_emit_cwrapperexe_src 5510c2939121Smrg# emit the source code for a wrapper executable on stdout 5511c2939121Smrg# Must ONLY be called from within func_mode_link because 5512c2939121Smrg# it depends on a number of variable set therein. 5513c2939121Smrgfunc_emit_cwrapperexe_src () 5514c2939121Smrg{ 5515c2939121Smrg cat <<EOF 5516c76ae52dSmrg 5517c2939121Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 55188292847cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519c76ae52dSmrg 5520c2939121Smrg The $output program cannot be directly executed until all the libtool 5521c2939121Smrg libraries that it depends on are installed. 5522c76ae52dSmrg 5523c2939121Smrg This wrapper executable should never be moved out of the build directory. 5524c2939121Smrg If it is, it will not operate correctly. 5525c2939121Smrg*/ 5526c2939121SmrgEOF 5527c2939121Smrg cat <<"EOF" 5528c2939121Smrg#ifdef _MSC_VER 5529c2939121Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5530c2939121Smrg#endif 5531c2939121Smrg#include <stdio.h> 5532c2939121Smrg#include <stdlib.h> 5533c2939121Smrg#ifdef _MSC_VER 5534c2939121Smrg# include <direct.h> 5535c2939121Smrg# include <process.h> 5536c2939121Smrg# include <io.h> 5537c2939121Smrg#else 5538c2939121Smrg# include <unistd.h> 5539c2939121Smrg# include <stdint.h> 5540c2939121Smrg# ifdef __CYGWIN__ 5541c2939121Smrg# include <io.h> 5542c2939121Smrg# endif 5543c2939121Smrg#endif 5544c2939121Smrg#include <malloc.h> 5545c2939121Smrg#include <stdarg.h> 5546c2939121Smrg#include <assert.h> 5547c2939121Smrg#include <string.h> 5548c2939121Smrg#include <ctype.h> 5549c2939121Smrg#include <errno.h> 5550c2939121Smrg#include <fcntl.h> 5551c2939121Smrg#include <sys/stat.h> 5552c76ae52dSmrg 55538292847cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 55548292847cSmrg 5555c2939121Smrg/* declarations of non-ANSI functions */ 55568292847cSmrg#if defined __MINGW32__ 5557c2939121Smrg# ifdef __STRICT_ANSI__ 5558c2939121Smrgint _putenv (const char *); 5559c2939121Smrg# endif 55608292847cSmrg#elif defined __CYGWIN__ 5561c2939121Smrg# ifdef __STRICT_ANSI__ 5562c2939121Smrgchar *realpath (const char *, char *); 5563c2939121Smrgint putenv (char *); 5564c2939121Smrgint setenv (const char *, const char *, int); 5565c2939121Smrg# endif 55668292847cSmrg/* #elif defined other_platform || defined ... */ 5567c2939121Smrg#endif 5568c76ae52dSmrg 5569c2939121Smrg/* portability defines, excluding path handling macros */ 55708292847cSmrg#if defined _MSC_VER 5571c2939121Smrg# define setmode _setmode 5572c2939121Smrg# define stat _stat 5573c2939121Smrg# define chmod _chmod 5574c2939121Smrg# define getcwd _getcwd 5575c2939121Smrg# define putenv _putenv 5576c2939121Smrg# define S_IXUSR _S_IEXEC 55778292847cSmrg#elif defined __MINGW32__ 5578c2939121Smrg# define setmode _setmode 5579c2939121Smrg# define stat _stat 5580c2939121Smrg# define chmod _chmod 5581c2939121Smrg# define getcwd _getcwd 5582c2939121Smrg# define putenv _putenv 55838292847cSmrg#elif defined __CYGWIN__ 5584c2939121Smrg# define HAVE_SETENV 5585c2939121Smrg# define FOPEN_WB "wb" 55868292847cSmrg/* #elif defined other platforms ... */ 5587c2939121Smrg#endif 5588c76ae52dSmrg 55898292847cSmrg#if defined PATH_MAX 5590c2939121Smrg# define LT_PATHMAX PATH_MAX 55918292847cSmrg#elif defined MAXPATHLEN 5592c2939121Smrg# define LT_PATHMAX MAXPATHLEN 5593c2939121Smrg#else 5594c2939121Smrg# define LT_PATHMAX 1024 5595c2939121Smrg#endif 5596c76ae52dSmrg 5597c2939121Smrg#ifndef S_IXOTH 5598c2939121Smrg# define S_IXOTH 0 5599c2939121Smrg#endif 5600c2939121Smrg#ifndef S_IXGRP 5601c2939121Smrg# define S_IXGRP 0 5602c2939121Smrg#endif 5603c76ae52dSmrg 5604c2939121Smrg/* path handling portability macros */ 5605c2939121Smrg#ifndef DIR_SEPARATOR 5606c2939121Smrg# define DIR_SEPARATOR '/' 5607c2939121Smrg# define PATH_SEPARATOR ':' 5608c2939121Smrg#endif 5609c76ae52dSmrg 56108292847cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 56118292847cSmrg defined __OS2__ 5612c2939121Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613c2939121Smrg# define FOPEN_WB "wb" 5614c2939121Smrg# ifndef DIR_SEPARATOR_2 5615c2939121Smrg# define DIR_SEPARATOR_2 '\\' 5616c2939121Smrg# endif 5617c2939121Smrg# ifndef PATH_SEPARATOR_2 5618c2939121Smrg# define PATH_SEPARATOR_2 ';' 5619c2939121Smrg# endif 5620c2939121Smrg#endif 5621c76ae52dSmrg 5622c2939121Smrg#ifndef DIR_SEPARATOR_2 5623c2939121Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624c2939121Smrg#else /* DIR_SEPARATOR_2 */ 5625c2939121Smrg# define IS_DIR_SEPARATOR(ch) \ 5626c2939121Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627c2939121Smrg#endif /* DIR_SEPARATOR_2 */ 5628c76ae52dSmrg 5629c2939121Smrg#ifndef PATH_SEPARATOR_2 5630c2939121Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631c2939121Smrg#else /* PATH_SEPARATOR_2 */ 5632c2939121Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633c2939121Smrg#endif /* PATH_SEPARATOR_2 */ 5634c2939121Smrg 5635c2939121Smrg#ifndef FOPEN_WB 5636c2939121Smrg# define FOPEN_WB "w" 5637c2939121Smrg#endif 5638c2939121Smrg#ifndef _O_BINARY 5639c2939121Smrg# define _O_BINARY 0 5640c2939121Smrg#endif 5641c2939121Smrg 5642c2939121Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643c2939121Smrg#define XFREE(stale) do { \ 56448292847cSmrg if (stale) { free (stale); stale = 0; } \ 5645c2939121Smrg} while (0) 5646c2939121Smrg 56478292847cSmrg#if defined LT_DEBUGWRAPPER 5648c2939121Smrgstatic int lt_debug = 1; 5649c2939121Smrg#else 5650c2939121Smrgstatic int lt_debug = 0; 5651c2939121Smrg#endif 5652c2939121Smrg 5653c2939121Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654c2939121Smrg 5655c2939121Smrgvoid *xmalloc (size_t num); 5656c2939121Smrgchar *xstrdup (const char *string); 5657c2939121Smrgconst char *base_name (const char *name); 5658c2939121Smrgchar *find_executable (const char *wrapper); 5659c2939121Smrgchar *chase_symlinks (const char *pathspec); 5660c2939121Smrgint make_executable (const char *path); 5661c2939121Smrgint check_executable (const char *path); 5662c2939121Smrgchar *strendzap (char *str, const char *pat); 5663c2939121Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664c2939121Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5665c2939121Smrgstatic const char *nonnull (const char *s); 5666c2939121Smrgstatic const char *nonempty (const char *s); 5667c2939121Smrgvoid lt_setenv (const char *name, const char *value); 5668c2939121Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669c2939121Smrgvoid lt_update_exe_path (const char *name, const char *value); 5670c2939121Smrgvoid lt_update_lib_path (const char *name, const char *value); 5671c2939121Smrgchar **prepare_spawn (char **argv); 5672c2939121Smrgvoid lt_dump_script (FILE *f); 5673c2939121SmrgEOF 5674c2939121Smrg 5675c2939121Smrg cat <<EOF 56768292847cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 56778292847cSmrg# define externally_visible volatile 56788292847cSmrg#else 56798292847cSmrg# define externally_visible __attribute__((externally_visible)) volatile 56808292847cSmrg#endif 56818292847cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682c2939121Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683c2939121SmrgEOF 5684c2939121Smrg 56858292847cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 56862836776bSmrg func_to_host_path "$temp_rpath" 5687c2939121Smrg cat <<EOF 56882836776bSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689c76ae52dSmrgEOF 5690c76ae52dSmrg else 5691c2939121Smrg cat <<"EOF" 5692c2939121Smrgconst char * LIB_PATH_VALUE = ""; 5693c2939121SmrgEOF 5694c76ae52dSmrg fi 5695c2939121Smrg 5696c2939121Smrg if test -n "$dllsearchpath"; then 56972836776bSmrg func_to_host_path "$dllsearchpath:" 5698c2939121Smrg cat <<EOF 5699c2939121Smrgconst char * EXE_PATH_VARNAME = "PATH"; 57002836776bSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701c2939121SmrgEOF 5702c76ae52dSmrg else 5703c2939121Smrg cat <<"EOF" 5704c2939121Smrgconst char * EXE_PATH_VARNAME = ""; 5705c2939121Smrgconst char * EXE_PATH_VALUE = ""; 5706c2939121SmrgEOF 5707c76ae52dSmrg fi 5708c2939121Smrg 57098292847cSmrg if test yes = "$fast_install"; then 5710c2939121Smrg cat <<EOF 5711c2939121Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712c2939121SmrgEOF 5713c76ae52dSmrg else 5714c2939121Smrg cat <<EOF 5715c2939121Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716c2939121SmrgEOF 5717c76ae52dSmrg fi 5718c76ae52dSmrg 5719c76ae52dSmrg 5720c2939121Smrg cat <<"EOF" 5721c76ae52dSmrg 5722c2939121Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723c76ae52dSmrg 5724c2939121Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725c2939121Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726c2939121Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727c76ae52dSmrg 5728c2939121Smrgint 5729c2939121Smrgmain (int argc, char *argv[]) 5730c2939121Smrg{ 5731c2939121Smrg char **newargz; 5732c2939121Smrg int newargc; 5733c2939121Smrg char *tmp_pathspec; 5734c2939121Smrg char *actual_cwrapper_path; 5735c2939121Smrg char *actual_cwrapper_name; 5736c2939121Smrg char *target_name; 5737c2939121Smrg char *lt_argv_zero; 57388292847cSmrg int rval = 127; 5739c76ae52dSmrg 5740c2939121Smrg int i; 5741c76ae52dSmrg 5742c2939121Smrg program_name = (char *) xstrdup (base_name (argv[0])); 57438292847cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744c76ae52dSmrg 5745c2939121Smrg /* very simple arg parsing; don't want to rely on getopt 5746c2939121Smrg * also, copy all non cwrapper options to newargz, except 5747c2939121Smrg * argz[0], which is handled differently 5748c2939121Smrg */ 5749c2939121Smrg newargc=0; 5750c2939121Smrg for (i = 1; i < argc; i++) 5751c2939121Smrg { 57528292847cSmrg if (STREQ (argv[i], dumpscript_opt)) 5753c2939121Smrg { 5754c2939121SmrgEOF 57558292847cSmrg case $host in 5756c2939121Smrg *mingw* | *cygwin* ) 5757c2939121Smrg # make stdout use "unix" line endings 5758c2939121Smrg echo " setmode(1,_O_BINARY);" 5759c2939121Smrg ;; 57600d590c07Smrg esac 5761c76ae52dSmrg 5762c2939121Smrg cat <<"EOF" 5763c2939121Smrg lt_dump_script (stdout); 5764c2939121Smrg return 0; 5765c2939121Smrg } 57668292847cSmrg if (STREQ (argv[i], debug_opt)) 5767c2939121Smrg { 5768c2939121Smrg lt_debug = 1; 5769c2939121Smrg continue; 5770c2939121Smrg } 57718292847cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5772c2939121Smrg { 5773c2939121Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774c2939121Smrg namespace, but it is not one of the ones we know about and 5775c2939121Smrg have already dealt with, above (inluding dump-script), then 5776c2939121Smrg report an error. Otherwise, targets might begin to believe 5777c2939121Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778c2939121Smrg namespace. The first time any user complains about this, we'll 5779c2939121Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780c2939121Smrg or a configure.ac-settable value. 5781c2939121Smrg */ 5782c2939121Smrg lt_fatal (__FILE__, __LINE__, 5783c2939121Smrg "unrecognized %s option: '%s'", 5784c2939121Smrg ltwrapper_option_prefix, argv[i]); 5785c2939121Smrg } 5786c2939121Smrg /* otherwise ... */ 5787c2939121Smrg newargz[++newargc] = xstrdup (argv[i]); 5788c2939121Smrg } 5789c2939121Smrg newargz[++newargc] = NULL; 5790c76ae52dSmrg 5791c2939121SmrgEOF 5792c2939121Smrg cat <<EOF 5793c2939121Smrg /* The GNU banner must be the first non-error debug message */ 57948292847cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795c2939121SmrgEOF 5796c2939121Smrg cat <<"EOF" 5797c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799c2939121Smrg 5800c2939121Smrg tmp_pathspec = find_executable (argv[0]); 5801c2939121Smrg if (tmp_pathspec == NULL) 5802c2939121Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5804c2939121Smrg "(main) found exe (before symlink chase) at: %s\n", 5805c2939121Smrg tmp_pathspec); 5806c2939121Smrg 5807c2939121Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5809c2939121Smrg "(main) found exe (after symlink chase) at: %s\n", 5810c2939121Smrg actual_cwrapper_path); 5811c2939121Smrg XFREE (tmp_pathspec); 5812c2939121Smrg 5813c2939121Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814c2939121Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815c2939121Smrg 5816c2939121Smrg /* wrapper name transforms */ 5817c2939121Smrg strendzap (actual_cwrapper_name, ".exe"); 5818c2939121Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819c2939121Smrg XFREE (actual_cwrapper_name); 5820c2939121Smrg actual_cwrapper_name = tmp_pathspec; 5821c2939121Smrg tmp_pathspec = 0; 5822c2939121Smrg 5823c2939121Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824c2939121Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825c2939121Smrg strendzap (target_name, ".exe"); 5826c2939121Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827c2939121Smrg XFREE (target_name); 5828c2939121Smrg target_name = tmp_pathspec; 5829c2939121Smrg tmp_pathspec = 0; 5830c2939121Smrg 5831c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5832c2939121Smrg "(main) libtool target name: %s\n", 5833c2939121Smrg target_name); 5834c2939121SmrgEOF 5835c76ae52dSmrg 5836c2939121Smrg cat <<EOF 5837c2939121Smrg newargz[0] = 5838c2939121Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839c2939121Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840c2939121Smrg strcpy (newargz[0], actual_cwrapper_path); 5841c2939121Smrg strcat (newargz[0], "$objdir"); 5842c2939121Smrg strcat (newargz[0], "/"); 5843c2939121SmrgEOF 5844c76ae52dSmrg 5845c2939121Smrg cat <<"EOF" 5846c2939121Smrg /* stop here, and copy so we don't have to do this twice */ 5847c2939121Smrg tmp_pathspec = xstrdup (newargz[0]); 5848c76ae52dSmrg 5849c2939121Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850c2939121Smrg strcat (newargz[0], actual_cwrapper_name); 5851c76ae52dSmrg 5852c2939121Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853c2939121Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854c2939121Smrg XFREE (tmp_pathspec); 5855c2939121Smrg tmp_pathspec = NULL; 5856c2939121SmrgEOF 5857c76ae52dSmrg 5858c2939121Smrg case $host_os in 5859c2939121Smrg mingw*) 5860c2939121Smrg cat <<"EOF" 5861c2939121Smrg { 5862c2939121Smrg char* p; 5863c2939121Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864c2939121Smrg { 5865c2939121Smrg *p = '/'; 5866c2939121Smrg } 5867c2939121Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868c2939121Smrg { 5869c2939121Smrg *p = '/'; 5870c2939121Smrg } 5871c2939121Smrg } 5872c2939121SmrgEOF 5873c2939121Smrg ;; 5874c2939121Smrg esac 5875c76ae52dSmrg 5876c2939121Smrg cat <<"EOF" 5877c2939121Smrg XFREE (target_name); 5878c2939121Smrg XFREE (actual_cwrapper_path); 5879c2939121Smrg XFREE (actual_cwrapper_name); 5880c76ae52dSmrg 5881c2939121Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882c2939121Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 58832836776bSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 58842836776bSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 58852836776bSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 58862836776bSmrg libraries must come first. */ 5887c2939121Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 58882836776bSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889c76ae52dSmrg 5890c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891c2939121Smrg nonnull (lt_argv_zero)); 5892c2939121Smrg for (i = 0; i < newargc; i++) 5893c2939121Smrg { 5894c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895c2939121Smrg i, nonnull (newargz[i])); 5896c2939121Smrg } 5897c76ae52dSmrg 5898c2939121SmrgEOF 5899c76ae52dSmrg 5900c2939121Smrg case $host_os in 5901c2939121Smrg mingw*) 5902c2939121Smrg cat <<"EOF" 5903c2939121Smrg /* execv doesn't actually work on mingw as expected on unix */ 5904c2939121Smrg newargz = prepare_spawn (newargz); 59058292847cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906c2939121Smrg if (rval == -1) 5907c2939121Smrg { 5908c2939121Smrg /* failed to start process */ 5909c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5910c2939121Smrg "(main) failed to launch target \"%s\": %s\n", 5911c2939121Smrg lt_argv_zero, nonnull (strerror (errno))); 5912c2939121Smrg return 127; 5913c2939121Smrg } 5914c2939121Smrg return rval; 5915c2939121SmrgEOF 5916c2939121Smrg ;; 5917c2939121Smrg *) 5918c2939121Smrg cat <<"EOF" 5919c2939121Smrg execv (lt_argv_zero, newargz); 5920c2939121Smrg return rval; /* =127, but avoids unused variable warning */ 5921c2939121SmrgEOF 5922c2939121Smrg ;; 5923c2939121Smrg esac 5924c76ae52dSmrg 5925c2939121Smrg cat <<"EOF" 5926c2939121Smrg} 5927c76ae52dSmrg 5928c2939121Smrgvoid * 5929c2939121Smrgxmalloc (size_t num) 5930c2939121Smrg{ 5931c2939121Smrg void *p = (void *) malloc (num); 5932c2939121Smrg if (!p) 5933c2939121Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934c76ae52dSmrg 5935c2939121Smrg return p; 5936c2939121Smrg} 5937c76ae52dSmrg 5938c2939121Smrgchar * 5939c2939121Smrgxstrdup (const char *string) 5940c2939121Smrg{ 5941c2939121Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942c2939121Smrg string) : NULL; 5943c2939121Smrg} 5944c76ae52dSmrg 5945c2939121Smrgconst char * 5946c2939121Smrgbase_name (const char *name) 5947c2939121Smrg{ 5948c2939121Smrg const char *base; 5949c76ae52dSmrg 59508292847cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951c2939121Smrg /* Skip over the disk name in MSDOS pathnames. */ 5952c2939121Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953c2939121Smrg name += 2; 5954c2939121Smrg#endif 5955c76ae52dSmrg 5956c2939121Smrg for (base = name; *name; name++) 5957c2939121Smrg if (IS_DIR_SEPARATOR (*name)) 5958c2939121Smrg base = name + 1; 5959c2939121Smrg return base; 5960c2939121Smrg} 5961c76ae52dSmrg 5962c2939121Smrgint 5963c2939121Smrgcheck_executable (const char *path) 5964c2939121Smrg{ 5965c2939121Smrg struct stat st; 5966c76ae52dSmrg 5967c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968c2939121Smrg nonempty (path)); 5969c2939121Smrg if ((!path) || (!*path)) 5970c2939121Smrg return 0; 5971c76ae52dSmrg 5972c2939121Smrg if ((stat (path, &st) >= 0) 5973c2939121Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974c2939121Smrg return 1; 5975c2939121Smrg else 5976c2939121Smrg return 0; 5977c2939121Smrg} 5978c76ae52dSmrg 5979c2939121Smrgint 5980c2939121Smrgmake_executable (const char *path) 5981c2939121Smrg{ 5982c2939121Smrg int rval = 0; 5983c2939121Smrg struct stat st; 5984c76ae52dSmrg 5985c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986c2939121Smrg nonempty (path)); 5987c2939121Smrg if ((!path) || (!*path)) 5988c2939121Smrg return 0; 5989c76ae52dSmrg 5990c2939121Smrg if (stat (path, &st) >= 0) 5991c2939121Smrg { 5992c2939121Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993c2939121Smrg } 5994c2939121Smrg return rval; 5995c2939121Smrg} 5996c76ae52dSmrg 5997c2939121Smrg/* Searches for the full path of the wrapper. Returns 5998c2939121Smrg newly allocated full path name if found, NULL otherwise 5999c2939121Smrg Does not chase symlinks, even on platforms that support them. 6000c2939121Smrg*/ 6001c2939121Smrgchar * 6002c2939121Smrgfind_executable (const char *wrapper) 6003c2939121Smrg{ 6004c2939121Smrg int has_slash = 0; 6005c2939121Smrg const char *p; 6006c2939121Smrg const char *p_next; 6007c2939121Smrg /* static buffer for getcwd */ 6008c2939121Smrg char tmp[LT_PATHMAX + 1]; 60098292847cSmrg size_t tmp_len; 6010c2939121Smrg char *concat_name; 6011c76ae52dSmrg 6012c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013c2939121Smrg nonempty (wrapper)); 6014c76ae52dSmrg 6015c2939121Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016c2939121Smrg return NULL; 6017c76ae52dSmrg 6018c2939121Smrg /* Absolute path? */ 60198292847cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020c2939121Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021c2939121Smrg { 6022c2939121Smrg concat_name = xstrdup (wrapper); 6023c2939121Smrg if (check_executable (concat_name)) 6024c2939121Smrg return concat_name; 6025c2939121Smrg XFREE (concat_name); 6026c2939121Smrg } 6027c2939121Smrg else 6028c2939121Smrg { 6029c2939121Smrg#endif 6030c2939121Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031c2939121Smrg { 6032c2939121Smrg concat_name = xstrdup (wrapper); 6033c2939121Smrg if (check_executable (concat_name)) 6034c2939121Smrg return concat_name; 6035c2939121Smrg XFREE (concat_name); 6036c2939121Smrg } 60378292847cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038c2939121Smrg } 6039c2939121Smrg#endif 6040c76ae52dSmrg 6041c2939121Smrg for (p = wrapper; *p; p++) 6042c2939121Smrg if (*p == '/') 6043c2939121Smrg { 6044c2939121Smrg has_slash = 1; 6045c2939121Smrg break; 6046c2939121Smrg } 6047c2939121Smrg if (!has_slash) 6048c2939121Smrg { 6049c2939121Smrg /* no slashes; search PATH */ 6050c2939121Smrg const char *path = getenv ("PATH"); 6051c2939121Smrg if (path != NULL) 6052c2939121Smrg { 6053c2939121Smrg for (p = path; *p; p = p_next) 6054c2939121Smrg { 6055c2939121Smrg const char *q; 6056c2939121Smrg size_t p_len; 6057c2939121Smrg for (q = p; *q; q++) 6058c2939121Smrg if (IS_PATH_SEPARATOR (*q)) 6059c2939121Smrg break; 60608292847cSmrg p_len = (size_t) (q - p); 6061c2939121Smrg p_next = (*q == '\0' ? q : q + 1); 6062c2939121Smrg if (p_len == 0) 6063c2939121Smrg { 6064c2939121Smrg /* empty path: current directory */ 6065c2939121Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6066c2939121Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067c2939121Smrg nonnull (strerror (errno))); 6068c2939121Smrg tmp_len = strlen (tmp); 6069c2939121Smrg concat_name = 6070c2939121Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071c2939121Smrg memcpy (concat_name, tmp, tmp_len); 6072c2939121Smrg concat_name[tmp_len] = '/'; 6073c2939121Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6074c2939121Smrg } 6075c2939121Smrg else 6076c2939121Smrg { 6077c2939121Smrg concat_name = 6078c2939121Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079c2939121Smrg memcpy (concat_name, p, p_len); 6080c2939121Smrg concat_name[p_len] = '/'; 6081c2939121Smrg strcpy (concat_name + p_len + 1, wrapper); 6082c2939121Smrg } 6083c2939121Smrg if (check_executable (concat_name)) 6084c2939121Smrg return concat_name; 6085c2939121Smrg XFREE (concat_name); 6086c2939121Smrg } 6087c2939121Smrg } 6088c2939121Smrg /* not found in PATH; assume curdir */ 6089c2939121Smrg } 6090c2939121Smrg /* Relative path | not found in path: prepend cwd */ 6091c2939121Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6092c2939121Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093c2939121Smrg nonnull (strerror (errno))); 6094c2939121Smrg tmp_len = strlen (tmp); 6095c2939121Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096c2939121Smrg memcpy (concat_name, tmp, tmp_len); 6097c2939121Smrg concat_name[tmp_len] = '/'; 6098c2939121Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099c76ae52dSmrg 6100c2939121Smrg if (check_executable (concat_name)) 6101c2939121Smrg return concat_name; 6102c2939121Smrg XFREE (concat_name); 6103c2939121Smrg return NULL; 6104c2939121Smrg} 6105c76ae52dSmrg 6106c2939121Smrgchar * 6107c2939121Smrgchase_symlinks (const char *pathspec) 6108c2939121Smrg{ 6109c2939121Smrg#ifndef S_ISLNK 6110c2939121Smrg return xstrdup (pathspec); 6111c2939121Smrg#else 6112c2939121Smrg char buf[LT_PATHMAX]; 6113c2939121Smrg struct stat s; 6114c2939121Smrg char *tmp_pathspec = xstrdup (pathspec); 6115c2939121Smrg char *p; 6116c2939121Smrg int has_symlinks = 0; 6117c2939121Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6118c2939121Smrg { 6119c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6120c2939121Smrg "checking path component for symlinks: %s\n", 6121c2939121Smrg tmp_pathspec); 6122c2939121Smrg if (lstat (tmp_pathspec, &s) == 0) 6123c2939121Smrg { 6124c2939121Smrg if (S_ISLNK (s.st_mode) != 0) 6125c2939121Smrg { 6126c2939121Smrg has_symlinks = 1; 6127c2939121Smrg break; 6128c2939121Smrg } 6129c76ae52dSmrg 6130c2939121Smrg /* search backwards for last DIR_SEPARATOR */ 6131c2939121Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132c2939121Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133c2939121Smrg p--; 6134c2939121Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135c2939121Smrg { 6136c2939121Smrg /* no more DIR_SEPARATORS left */ 6137c2939121Smrg break; 6138c2939121Smrg } 6139c2939121Smrg *p = '\0'; 6140c2939121Smrg } 6141c2939121Smrg else 6142c2939121Smrg { 6143c2939121Smrg lt_fatal (__FILE__, __LINE__, 6144c2939121Smrg "error accessing file \"%s\": %s", 6145c2939121Smrg tmp_pathspec, nonnull (strerror (errno))); 6146c2939121Smrg } 6147c2939121Smrg } 6148c2939121Smrg XFREE (tmp_pathspec); 6149c76ae52dSmrg 6150c2939121Smrg if (!has_symlinks) 6151c2939121Smrg { 6152c2939121Smrg return xstrdup (pathspec); 6153c2939121Smrg } 6154c76ae52dSmrg 6155c2939121Smrg tmp_pathspec = realpath (pathspec, buf); 6156c2939121Smrg if (tmp_pathspec == 0) 6157c2939121Smrg { 6158c2939121Smrg lt_fatal (__FILE__, __LINE__, 6159c2939121Smrg "could not follow symlinks for %s", pathspec); 6160c2939121Smrg } 6161c2939121Smrg return xstrdup (tmp_pathspec); 6162c2939121Smrg#endif 6163c2939121Smrg} 6164c76ae52dSmrg 6165c2939121Smrgchar * 6166c2939121Smrgstrendzap (char *str, const char *pat) 6167c2939121Smrg{ 6168c2939121Smrg size_t len, patlen; 6169c76ae52dSmrg 6170c2939121Smrg assert (str != NULL); 6171c2939121Smrg assert (pat != NULL); 6172c76ae52dSmrg 6173c2939121Smrg len = strlen (str); 6174c2939121Smrg patlen = strlen (pat); 6175c76ae52dSmrg 6176c2939121Smrg if (patlen <= len) 6177c2939121Smrg { 6178c2939121Smrg str += len - patlen; 61798292847cSmrg if (STREQ (str, pat)) 6180c2939121Smrg *str = '\0'; 6181c2939121Smrg } 6182c2939121Smrg return str; 6183c2939121Smrg} 6184c76ae52dSmrg 6185c2939121Smrgvoid 6186c2939121Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6187c2939121Smrg{ 6188c2939121Smrg va_list args; 6189c2939121Smrg if (lt_debug) 6190c2939121Smrg { 6191c2939121Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192c2939121Smrg va_start (args, fmt); 6193c2939121Smrg (void) vfprintf (stderr, fmt, args); 6194c2939121Smrg va_end (args); 6195c2939121Smrg } 6196c2939121Smrg} 6197c76ae52dSmrg 6198c2939121Smrgstatic void 6199c2939121Smrglt_error_core (int exit_status, const char *file, 6200c2939121Smrg int line, const char *mode, 6201c2939121Smrg const char *message, va_list ap) 6202c2939121Smrg{ 6203c2939121Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204c2939121Smrg vfprintf (stderr, message, ap); 6205c2939121Smrg fprintf (stderr, ".\n"); 6206c76ae52dSmrg 6207c2939121Smrg if (exit_status >= 0) 6208c2939121Smrg exit (exit_status); 6209c2939121Smrg} 6210c76ae52dSmrg 6211c2939121Smrgvoid 6212c2939121Smrglt_fatal (const char *file, int line, const char *message, ...) 6213c2939121Smrg{ 6214c2939121Smrg va_list ap; 6215c2939121Smrg va_start (ap, message); 6216c2939121Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217c2939121Smrg va_end (ap); 6218c2939121Smrg} 6219c76ae52dSmrg 6220c2939121Smrgstatic const char * 6221c2939121Smrgnonnull (const char *s) 6222c2939121Smrg{ 6223c2939121Smrg return s ? s : "(null)"; 6224c2939121Smrg} 6225c76ae52dSmrg 6226c2939121Smrgstatic const char * 6227c2939121Smrgnonempty (const char *s) 6228c2939121Smrg{ 6229c2939121Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6230c2939121Smrg} 6231c76ae52dSmrg 6232c2939121Smrgvoid 6233c2939121Smrglt_setenv (const char *name, const char *value) 6234c2939121Smrg{ 6235c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6236c2939121Smrg "(lt_setenv) setting '%s' to '%s'\n", 6237c2939121Smrg nonnull (name), nonnull (value)); 6238c2939121Smrg { 6239c2939121Smrg#ifdef HAVE_SETENV 6240c2939121Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241c2939121Smrg char *str = xstrdup (value); 6242c2939121Smrg setenv (name, str, 1); 6243c2939121Smrg#else 62448292847cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245c2939121Smrg char *str = XMALLOC (char, len); 6246c2939121Smrg sprintf (str, "%s=%s", name, value); 6247c2939121Smrg if (putenv (str) != EXIT_SUCCESS) 6248c2939121Smrg { 6249c2939121Smrg XFREE (str); 6250c2939121Smrg } 6251c2939121Smrg#endif 6252c2939121Smrg } 6253c2939121Smrg} 6254c76ae52dSmrg 6255c2939121Smrgchar * 6256c2939121Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257c2939121Smrg{ 6258c2939121Smrg char *new_value; 6259c2939121Smrg if (orig_value && *orig_value) 6260c2939121Smrg { 62618292847cSmrg size_t orig_value_len = strlen (orig_value); 62628292847cSmrg size_t add_len = strlen (add); 6263c2939121Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264c2939121Smrg if (to_end) 6265c2939121Smrg { 6266c2939121Smrg strcpy (new_value, orig_value); 6267c2939121Smrg strcpy (new_value + orig_value_len, add); 6268c2939121Smrg } 6269c2939121Smrg else 6270c2939121Smrg { 6271c2939121Smrg strcpy (new_value, add); 6272c2939121Smrg strcpy (new_value + add_len, orig_value); 6273c2939121Smrg } 6274c2939121Smrg } 6275c2939121Smrg else 6276c2939121Smrg { 6277c2939121Smrg new_value = xstrdup (add); 6278c2939121Smrg } 6279c2939121Smrg return new_value; 6280c2939121Smrg} 6281c76ae52dSmrg 6282c2939121Smrgvoid 6283c2939121Smrglt_update_exe_path (const char *name, const char *value) 6284c2939121Smrg{ 6285c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6286c2939121Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287c2939121Smrg nonnull (name), nonnull (value)); 6288c76ae52dSmrg 6289c2939121Smrg if (name && *name && value && *value) 6290c2939121Smrg { 6291c2939121Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292c2939121Smrg /* some systems can't cope with a ':'-terminated path #' */ 62938292847cSmrg size_t len = strlen (new_value); 62948292847cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295c2939121Smrg { 62968292847cSmrg new_value[--len] = '\0'; 6297c2939121Smrg } 6298c2939121Smrg lt_setenv (name, new_value); 6299c2939121Smrg XFREE (new_value); 6300c2939121Smrg } 6301c2939121Smrg} 6302c76ae52dSmrg 6303c2939121Smrgvoid 6304c2939121Smrglt_update_lib_path (const char *name, const char *value) 6305c2939121Smrg{ 6306c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6307c2939121Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308c2939121Smrg nonnull (name), nonnull (value)); 6309c76ae52dSmrg 6310c2939121Smrg if (name && *name && value && *value) 6311c2939121Smrg { 6312c2939121Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313c2939121Smrg lt_setenv (name, new_value); 6314c2939121Smrg XFREE (new_value); 6315c2939121Smrg } 6316c2939121Smrg} 6317c76ae52dSmrg 6318c2939121SmrgEOF 6319c2939121Smrg case $host_os in 6320c2939121Smrg mingw*) 6321c2939121Smrg cat <<"EOF" 6322c2939121Smrg 6323c2939121Smrg/* Prepares an argument vector before calling spawn(). 6324c2939121Smrg Note that spawn() does not by itself call the command interpreter 6325c2939121Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326c2939121Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327c2939121Smrg GetVersionEx(&v); 6328c2939121Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329c2939121Smrg }) ? "cmd.exe" : "command.com"). 6330c2939121Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6331c2939121Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332c2939121Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333c2939121Smrg special way: 6334c2939121Smrg - Space and tab are interpreted as delimiters. They are not treated as 6335c2939121Smrg delimiters if they are surrounded by double quotes: "...". 6336c2939121Smrg - Unescaped double quotes are removed from the input. Their only effect is 6337c2939121Smrg that within double quotes, space and tab are treated like normal 6338c2939121Smrg characters. 6339c2939121Smrg - Backslashes not followed by double quotes are not special. 6340c2939121Smrg - But 2*n+1 backslashes followed by a double quote become 6341c2939121Smrg n backslashes followed by a double quote (n >= 0): 6342c2939121Smrg \" -> " 6343c2939121Smrg \\\" -> \" 6344c2939121Smrg \\\\\" -> \\" 6345c2939121Smrg */ 6346c2939121Smrg#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" 6347c2939121Smrg#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" 6348c2939121Smrgchar ** 6349c2939121Smrgprepare_spawn (char **argv) 6350c2939121Smrg{ 6351c2939121Smrg size_t argc; 6352c2939121Smrg char **new_argv; 6353c2939121Smrg size_t i; 6354c76ae52dSmrg 6355c2939121Smrg /* Count number of arguments. */ 6356c2939121Smrg for (argc = 0; argv[argc] != NULL; argc++) 6357c2939121Smrg ; 6358c76ae52dSmrg 6359c2939121Smrg /* Allocate new argument vector. */ 6360c2939121Smrg new_argv = XMALLOC (char *, argc + 1); 6361c76ae52dSmrg 6362c2939121Smrg /* Put quoted arguments into the new argument vector. */ 6363c2939121Smrg for (i = 0; i < argc; i++) 6364c2939121Smrg { 6365c2939121Smrg const char *string = argv[i]; 6366c2939121Smrg 6367c2939121Smrg if (string[0] == '\0') 6368c2939121Smrg new_argv[i] = xstrdup ("\"\""); 6369c2939121Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370c2939121Smrg { 6371c2939121Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372c2939121Smrg size_t length; 6373c2939121Smrg unsigned int backslashes; 6374c2939121Smrg const char *s; 6375c2939121Smrg char *quoted_string; 6376c2939121Smrg char *p; 6377c2939121Smrg 6378c2939121Smrg length = 0; 6379c2939121Smrg backslashes = 0; 6380c2939121Smrg if (quote_around) 6381c2939121Smrg length++; 6382c2939121Smrg for (s = string; *s != '\0'; s++) 6383c2939121Smrg { 6384c2939121Smrg char c = *s; 6385c2939121Smrg if (c == '"') 6386c2939121Smrg length += backslashes + 1; 6387c2939121Smrg length++; 6388c2939121Smrg if (c == '\\') 6389c2939121Smrg backslashes++; 6390c2939121Smrg else 6391c2939121Smrg backslashes = 0; 6392c2939121Smrg } 6393c2939121Smrg if (quote_around) 6394c2939121Smrg length += backslashes + 1; 6395c2939121Smrg 6396c2939121Smrg quoted_string = XMALLOC (char, length + 1); 6397c2939121Smrg 6398c2939121Smrg p = quoted_string; 6399c2939121Smrg backslashes = 0; 6400c2939121Smrg if (quote_around) 6401c2939121Smrg *p++ = '"'; 6402c2939121Smrg for (s = string; *s != '\0'; s++) 6403c2939121Smrg { 6404c2939121Smrg char c = *s; 6405c2939121Smrg if (c == '"') 6406c2939121Smrg { 6407c2939121Smrg unsigned int j; 6408c2939121Smrg for (j = backslashes + 1; j > 0; j--) 6409c2939121Smrg *p++ = '\\'; 6410c2939121Smrg } 6411c2939121Smrg *p++ = c; 6412c2939121Smrg if (c == '\\') 6413c2939121Smrg backslashes++; 6414c2939121Smrg else 6415c2939121Smrg backslashes = 0; 6416c2939121Smrg } 6417c2939121Smrg if (quote_around) 6418c2939121Smrg { 6419c2939121Smrg unsigned int j; 6420c2939121Smrg for (j = backslashes; j > 0; j--) 6421c2939121Smrg *p++ = '\\'; 6422c2939121Smrg *p++ = '"'; 6423c2939121Smrg } 6424c2939121Smrg *p = '\0'; 6425c76ae52dSmrg 6426c2939121Smrg new_argv[i] = quoted_string; 6427c2939121Smrg } 6428c2939121Smrg else 6429c2939121Smrg new_argv[i] = (char *) string; 6430c2939121Smrg } 6431c2939121Smrg new_argv[argc] = NULL; 6432c76ae52dSmrg 6433c2939121Smrg return new_argv; 6434c2939121Smrg} 6435c2939121SmrgEOF 6436c76ae52dSmrg ;; 6437c2939121Smrg esac 6438c76ae52dSmrg 6439c2939121Smrg cat <<"EOF" 6440c2939121Smrgvoid lt_dump_script (FILE* f) 6441c2939121Smrg{ 6442c2939121SmrgEOF 6443c2939121Smrg func_emit_wrapper yes | 64442836776bSmrg $SED -n -e ' 64452836776bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 64462836776bSmrg\2/ 64472836776bSmrgh 64482836776bSmrgs/\([\\"]\)/\\\1/g 64492836776bSmrgs/$/\\n/ 64502836776bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 64512836776bSmrgg 64522836776bSmrgD' 6453c2939121Smrg cat <<"EOF" 6454c2939121Smrg} 6455c2939121SmrgEOF 6456c2939121Smrg} 6457c2939121Smrg# end: func_emit_cwrapperexe_src 6458c76ae52dSmrg 6459c2939121Smrg# func_win32_import_lib_p ARG 6460c2939121Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6461c2939121Smrgfunc_win32_import_lib_p () 6462c2939121Smrg{ 64638292847cSmrg $debug_cmd 64648292847cSmrg 6465c2939121Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466c2939121Smrg *import*) : ;; 6467c2939121Smrg *) false ;; 6468c2939121Smrg esac 6469c2939121Smrg} 6470c76ae52dSmrg 64718292847cSmrg# func_suncc_cstd_abi 64728292847cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 64738292847cSmrg# Several compiler flags select an ABI that is incompatible with the 64748292847cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 64758292847cSmrgfunc_suncc_cstd_abi () 64768292847cSmrg{ 64778292847cSmrg $debug_cmd 64788292847cSmrg 64798292847cSmrg case " $compile_command " in 64808292847cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 64818292847cSmrg suncc_use_cstd_abi=no 64828292847cSmrg ;; 64838292847cSmrg *) 64848292847cSmrg suncc_use_cstd_abi=yes 64858292847cSmrg ;; 64868292847cSmrg esac 64878292847cSmrg} 64888292847cSmrg 6489c2939121Smrg# func_mode_link arg... 6490c2939121Smrgfunc_mode_link () 6491c2939121Smrg{ 64928292847cSmrg $debug_cmd 64938292847cSmrg 6494c2939121Smrg case $host in 6495c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496c2939121Smrg # It is impossible to link a dll without this setting, and 6497c2939121Smrg # we shouldn't force the makefile maintainer to figure out 64988292847cSmrg # what system we are compiling for in order to pass an extra 6499c2939121Smrg # flag for every libtool invocation. 6500c2939121Smrg # allow_undefined=no 6501c76ae52dSmrg 6502c2939121Smrg # FIXME: Unfortunately, there are problems with the above when trying 65038292847cSmrg # to make a dll that has undefined symbols, in which case not 6504c2939121Smrg # even a static library is built. For now, we need to specify 6505c2939121Smrg # -no-undefined on the libtool link line when we can be certain 6506c2939121Smrg # that all symbols are satisfied, otherwise we get a static library. 6507c2939121Smrg allow_undefined=yes 6508c2939121Smrg ;; 6509c2939121Smrg *) 6510c2939121Smrg allow_undefined=yes 6511c2939121Smrg ;; 6512c2939121Smrg esac 6513c2939121Smrg libtool_args=$nonopt 6514c2939121Smrg base_compile="$nonopt $@" 6515c2939121Smrg compile_command=$nonopt 6516c2939121Smrg finalize_command=$nonopt 6517c76ae52dSmrg 6518c2939121Smrg compile_rpath= 6519c2939121Smrg finalize_rpath= 6520c2939121Smrg compile_shlibpath= 6521c2939121Smrg finalize_shlibpath= 6522c2939121Smrg convenience= 6523c2939121Smrg old_convenience= 6524c2939121Smrg deplibs= 6525c2939121Smrg old_deplibs= 6526c2939121Smrg compiler_flags= 6527c2939121Smrg linker_flags= 6528c2939121Smrg dllsearchpath= 6529c2939121Smrg lib_search_path=`pwd` 6530c2939121Smrg inst_prefix_dir= 6531c2939121Smrg new_inherited_linker_flags= 6532c76ae52dSmrg 6533c2939121Smrg avoid_version=no 6534c2939121Smrg bindir= 6535c2939121Smrg dlfiles= 6536c2939121Smrg dlprefiles= 6537c2939121Smrg dlself=no 6538c2939121Smrg export_dynamic=no 6539c2939121Smrg export_symbols= 6540c2939121Smrg export_symbols_regex= 6541c2939121Smrg generated= 6542c2939121Smrg libobjs= 6543c2939121Smrg ltlibs= 6544c2939121Smrg module=no 6545c2939121Smrg no_install=no 6546c2939121Smrg objs= 65478292847cSmrg os2dllname= 6548c2939121Smrg non_pic_objects= 6549c2939121Smrg precious_files_regex= 6550c2939121Smrg prefer_static_libs=no 65518292847cSmrg preload=false 6552c2939121Smrg prev= 6553c2939121Smrg prevarg= 6554c2939121Smrg release= 6555c2939121Smrg rpath= 6556c2939121Smrg xrpath= 6557c2939121Smrg perm_rpath= 6558c2939121Smrg temp_rpath= 6559c2939121Smrg thread_safe=no 6560c2939121Smrg vinfo= 6561c2939121Smrg vinfo_number=no 6562c2939121Smrg weak_libs= 65638292847cSmrg single_module=$wl-single_module 6564c2939121Smrg func_infer_tag $base_compile 6565c76ae52dSmrg 6566c2939121Smrg # We need to know -static, to get the right output filenames. 6567c2939121Smrg for arg 6568c2939121Smrg do 6569c2939121Smrg case $arg in 6570c2939121Smrg -shared) 65718292847cSmrg test yes != "$build_libtool_libs" \ 65728292847cSmrg && func_fatal_configuration "cannot build a shared library" 6573c2939121Smrg build_old_libs=no 6574c2939121Smrg break 6575c2939121Smrg ;; 6576c2939121Smrg -all-static | -static | -static-libtool-libs) 6577c2939121Smrg case $arg in 6578c2939121Smrg -all-static) 65798292847cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580c2939121Smrg func_warning "complete static linking is impossible in this configuration" 6581c2939121Smrg fi 6582c2939121Smrg if test -n "$link_static_flag"; then 6583c2939121Smrg dlopen_self=$dlopen_self_static 6584c2939121Smrg fi 6585c2939121Smrg prefer_static_libs=yes 6586c2939121Smrg ;; 6587c2939121Smrg -static) 6588c2939121Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589c2939121Smrg dlopen_self=$dlopen_self_static 6590c2939121Smrg fi 6591c2939121Smrg prefer_static_libs=built 6592c2939121Smrg ;; 6593c2939121Smrg -static-libtool-libs) 6594c2939121Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595c2939121Smrg dlopen_self=$dlopen_self_static 6596c2939121Smrg fi 6597c2939121Smrg prefer_static_libs=yes 6598c2939121Smrg ;; 6599c2939121Smrg esac 6600c2939121Smrg build_libtool_libs=no 6601c2939121Smrg build_old_libs=yes 6602c2939121Smrg break 6603c2939121Smrg ;; 6604c2939121Smrg esac 6605c2939121Smrg done 6606c76ae52dSmrg 6607c2939121Smrg # See if our shared archives depend on static archives. 6608c2939121Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609c76ae52dSmrg 6610c2939121Smrg # Go through the arguments, transforming them on the way. 6611c2939121Smrg while test "$#" -gt 0; do 66128292847cSmrg arg=$1 6613c2939121Smrg shift 6614c2939121Smrg func_quote_for_eval "$arg" 6615c2939121Smrg qarg=$func_quote_for_eval_unquoted_result 6616c2939121Smrg func_append libtool_args " $func_quote_for_eval_result" 6617c76ae52dSmrg 6618c2939121Smrg # If the previous option needs an argument, assign it. 6619c2939121Smrg if test -n "$prev"; then 6620c2939121Smrg case $prev in 6621c2939121Smrg output) 6622c2939121Smrg func_append compile_command " @OUTPUT@" 6623c2939121Smrg func_append finalize_command " @OUTPUT@" 6624c2939121Smrg ;; 6625c2939121Smrg esac 6626c76ae52dSmrg 6627c2939121Smrg case $prev in 6628c2939121Smrg bindir) 66298292847cSmrg bindir=$arg 6630c2939121Smrg prev= 6631c2939121Smrg continue 6632c2939121Smrg ;; 6633c2939121Smrg dlfiles|dlprefiles) 66348292847cSmrg $preload || { 6635c2939121Smrg # Add the symbol object into the linking commands. 6636c2939121Smrg func_append compile_command " @SYMFILE@" 6637c2939121Smrg func_append finalize_command " @SYMFILE@" 66388292847cSmrg preload=: 66398292847cSmrg } 6640c2939121Smrg case $arg in 6641c2939121Smrg *.la | *.lo) ;; # We handle these cases below. 6642c2939121Smrg force) 66438292847cSmrg if test no = "$dlself"; then 6644c2939121Smrg dlself=needless 6645c2939121Smrg export_dynamic=yes 6646c76ae52dSmrg fi 6647c2939121Smrg prev= 6648c2939121Smrg continue 6649c2939121Smrg ;; 6650c2939121Smrg self) 66518292847cSmrg if test dlprefiles = "$prev"; then 6652c2939121Smrg dlself=yes 66538292847cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654c2939121Smrg dlself=yes 6655c76ae52dSmrg else 6656c2939121Smrg dlself=needless 6657c2939121Smrg export_dynamic=yes 6658c76ae52dSmrg fi 6659c2939121Smrg prev= 6660c2939121Smrg continue 6661c2939121Smrg ;; 6662c2939121Smrg *) 66638292847cSmrg if test dlfiles = "$prev"; then 66642836776bSmrg func_append dlfiles " $arg" 6665c76ae52dSmrg else 66662836776bSmrg func_append dlprefiles " $arg" 6667c76ae52dSmrg fi 6668c2939121Smrg prev= 6669c2939121Smrg continue 6670c2939121Smrg ;; 6671c2939121Smrg esac 6672c2939121Smrg ;; 6673c2939121Smrg expsyms) 66748292847cSmrg export_symbols=$arg 6675c2939121Smrg test -f "$arg" \ 66768292847cSmrg || func_fatal_error "symbol file '$arg' does not exist" 6677c2939121Smrg prev= 6678c2939121Smrg continue 6679c2939121Smrg ;; 6680c2939121Smrg expsyms_regex) 66818292847cSmrg export_symbols_regex=$arg 6682c2939121Smrg prev= 6683c2939121Smrg continue 6684c2939121Smrg ;; 6685c2939121Smrg framework) 6686c76ae52dSmrg case $host in 6687c2939121Smrg *-*-darwin*) 6688c2939121Smrg case "$deplibs " in 6689c2939121Smrg *" $qarg.ltframework "*) ;; 66902836776bSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691c2939121Smrg ;; 6692c2939121Smrg esac 6693c2939121Smrg ;; 6694c76ae52dSmrg esac 6695c2939121Smrg prev= 6696c2939121Smrg continue 6697c76ae52dSmrg ;; 6698c2939121Smrg inst_prefix) 66998292847cSmrg inst_prefix_dir=$arg 67008292847cSmrg prev= 67018292847cSmrg continue 67028292847cSmrg ;; 67038292847cSmrg mllvm) 67048292847cSmrg # Clang does not use LLVM to link, so we can simply discard any 67058292847cSmrg # '-mllvm $arg' options when doing the link step. 6706c2939121Smrg prev= 6707c2939121Smrg continue 6708c76ae52dSmrg ;; 6709c2939121Smrg objectlist) 6710c2939121Smrg if test -f "$arg"; then 6711c2939121Smrg save_arg=$arg 6712c2939121Smrg moreargs= 6713c2939121Smrg for fil in `cat "$save_arg"` 6714c2939121Smrg do 67152836776bSmrg# func_append moreargs " $fil" 6716c2939121Smrg arg=$fil 6717c2939121Smrg # A libtool-controlled object. 6718c76ae52dSmrg 6719c2939121Smrg # Check to see that this really is a libtool object. 6720c2939121Smrg if func_lalib_unsafe_p "$arg"; then 6721c2939121Smrg pic_object= 6722c2939121Smrg non_pic_object= 6723c76ae52dSmrg 6724c2939121Smrg # Read the .lo file 6725c2939121Smrg func_source "$arg" 6726c76ae52dSmrg 6727c2939121Smrg if test -z "$pic_object" || 6728c2939121Smrg test -z "$non_pic_object" || 67298292847cSmrg test none = "$pic_object" && 67308292847cSmrg test none = "$non_pic_object"; then 67318292847cSmrg func_fatal_error "cannot find name of object for '$arg'" 6732c2939121Smrg fi 6733c76ae52dSmrg 6734c2939121Smrg # Extract subdirectory from the argument. 6735c2939121Smrg func_dirname "$arg" "/" "" 67368292847cSmrg xdir=$func_dirname_result 6737c76ae52dSmrg 67388292847cSmrg if test none != "$pic_object"; then 6739c2939121Smrg # Prepend the subdirectory the object is found in. 67408292847cSmrg pic_object=$xdir$pic_object 6741c76ae52dSmrg 67428292847cSmrg if test dlfiles = "$prev"; then 67438292847cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 67442836776bSmrg func_append dlfiles " $pic_object" 6745c2939121Smrg prev= 6746c2939121Smrg continue 6747c2939121Smrg else 6748c2939121Smrg # If libtool objects are unsupported, then we need to preload. 6749c2939121Smrg prev=dlprefiles 6750c2939121Smrg fi 6751c2939121Smrg fi 6752c76ae52dSmrg 6753c2939121Smrg # CHECK ME: I think I busted this. -Ossama 67548292847cSmrg if test dlprefiles = "$prev"; then 6755c2939121Smrg # Preload the old-style object. 67562836776bSmrg func_append dlprefiles " $pic_object" 6757c2939121Smrg prev= 6758c2939121Smrg fi 6759c76ae52dSmrg 6760c2939121Smrg # A PIC object. 6761c2939121Smrg func_append libobjs " $pic_object" 67628292847cSmrg arg=$pic_object 6763c2939121Smrg fi 6764c76ae52dSmrg 6765c2939121Smrg # Non-PIC object. 67668292847cSmrg if test none != "$non_pic_object"; then 6767c2939121Smrg # Prepend the subdirectory the object is found in. 67688292847cSmrg non_pic_object=$xdir$non_pic_object 6769c76ae52dSmrg 6770c2939121Smrg # A standard non-PIC object 6771c2939121Smrg func_append non_pic_objects " $non_pic_object" 67728292847cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 67738292847cSmrg arg=$non_pic_object 6774c2939121Smrg fi 6775c2939121Smrg else 6776c2939121Smrg # If the PIC object exists, use it instead. 6777c2939121Smrg # $xdir was prepended to $pic_object above. 67788292847cSmrg non_pic_object=$pic_object 6779c2939121Smrg func_append non_pic_objects " $non_pic_object" 6780c2939121Smrg fi 6781c2939121Smrg else 6782c2939121Smrg # Only an error if not doing a dry-run. 6783c2939121Smrg if $opt_dry_run; then 6784c2939121Smrg # Extract subdirectory from the argument. 6785c2939121Smrg func_dirname "$arg" "/" "" 67868292847cSmrg xdir=$func_dirname_result 6787c2939121Smrg 6788c2939121Smrg func_lo2o "$arg" 6789c2939121Smrg pic_object=$xdir$objdir/$func_lo2o_result 6790c2939121Smrg non_pic_object=$xdir$func_lo2o_result 6791c2939121Smrg func_append libobjs " $pic_object" 6792c2939121Smrg func_append non_pic_objects " $non_pic_object" 6793c2939121Smrg else 67948292847cSmrg func_fatal_error "'$arg' is not a valid libtool object" 6795c2939121Smrg fi 6796c2939121Smrg fi 6797c2939121Smrg done 6798c76ae52dSmrg else 67998292847cSmrg func_fatal_error "link input file '$arg' does not exist" 6800c76ae52dSmrg fi 6801c2939121Smrg arg=$save_arg 6802c2939121Smrg prev= 6803c2939121Smrg continue 6804c2939121Smrg ;; 68058292847cSmrg os2dllname) 68068292847cSmrg os2dllname=$arg 68078292847cSmrg prev= 68088292847cSmrg continue 68098292847cSmrg ;; 6810c2939121Smrg precious_regex) 68118292847cSmrg precious_files_regex=$arg 6812c2939121Smrg prev= 6813c2939121Smrg continue 6814c2939121Smrg ;; 6815c2939121Smrg release) 68168292847cSmrg release=-$arg 6817c2939121Smrg prev= 6818c2939121Smrg continue 6819c2939121Smrg ;; 6820c2939121Smrg rpath | xrpath) 6821c2939121Smrg # We need an absolute path. 6822c2939121Smrg case $arg in 6823c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824c2939121Smrg *) 6825c2939121Smrg func_fatal_error "only absolute run-paths are allowed" 6826c2939121Smrg ;; 6827c2939121Smrg esac 68288292847cSmrg if test rpath = "$prev"; then 6829c2939121Smrg case "$rpath " in 6830c2939121Smrg *" $arg "*) ;; 68312836776bSmrg *) func_append rpath " $arg" ;; 6832c2939121Smrg esac 6833c76ae52dSmrg else 6834c2939121Smrg case "$xrpath " in 6835c2939121Smrg *" $arg "*) ;; 68362836776bSmrg *) func_append xrpath " $arg" ;; 6837c2939121Smrg esac 6838c76ae52dSmrg fi 6839c2939121Smrg prev= 6840c2939121Smrg continue 6841c2939121Smrg ;; 6842c2939121Smrg shrext) 68438292847cSmrg shrext_cmds=$arg 6844c2939121Smrg prev= 6845c2939121Smrg continue 6846c2939121Smrg ;; 6847c2939121Smrg weak) 68482836776bSmrg func_append weak_libs " $arg" 6849c2939121Smrg prev= 6850c2939121Smrg continue 6851c2939121Smrg ;; 6852c2939121Smrg xcclinker) 68532836776bSmrg func_append linker_flags " $qarg" 68542836776bSmrg func_append compiler_flags " $qarg" 6855c2939121Smrg prev= 6856c2939121Smrg func_append compile_command " $qarg" 6857c2939121Smrg func_append finalize_command " $qarg" 6858c2939121Smrg continue 6859c2939121Smrg ;; 6860c2939121Smrg xcompiler) 68612836776bSmrg func_append compiler_flags " $qarg" 6862c2939121Smrg prev= 6863c2939121Smrg func_append compile_command " $qarg" 6864c2939121Smrg func_append finalize_command " $qarg" 6865c2939121Smrg continue 6866c2939121Smrg ;; 6867c2939121Smrg xlinker) 68682836776bSmrg func_append linker_flags " $qarg" 68692836776bSmrg func_append compiler_flags " $wl$qarg" 6870c2939121Smrg prev= 6871c2939121Smrg func_append compile_command " $wl$qarg" 6872c2939121Smrg func_append finalize_command " $wl$qarg" 6873c2939121Smrg continue 6874c2939121Smrg ;; 6875c2939121Smrg *) 6876c2939121Smrg eval "$prev=\"\$arg\"" 6877c2939121Smrg prev= 6878c2939121Smrg continue 6879c2939121Smrg ;; 6880c76ae52dSmrg esac 6881c2939121Smrg fi # test -n "$prev" 6882c76ae52dSmrg 68838292847cSmrg prevarg=$arg 6884c76ae52dSmrg 6885c2939121Smrg case $arg in 6886c2939121Smrg -all-static) 6887c2939121Smrg if test -n "$link_static_flag"; then 6888c2939121Smrg # See comment for -static flag below, for more details. 6889c2939121Smrg func_append compile_command " $link_static_flag" 6890c2939121Smrg func_append finalize_command " $link_static_flag" 6891c2939121Smrg fi 6892c2939121Smrg continue 6893c2939121Smrg ;; 6894c76ae52dSmrg 6895c2939121Smrg -allow-undefined) 6896c2939121Smrg # FIXME: remove this flag sometime in the future. 68978292847cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898c2939121Smrg ;; 6899c76ae52dSmrg 6900c2939121Smrg -avoid-version) 6901c2939121Smrg avoid_version=yes 6902c2939121Smrg continue 6903c2939121Smrg ;; 6904c76ae52dSmrg 6905c2939121Smrg -bindir) 6906c2939121Smrg prev=bindir 6907c2939121Smrg continue 6908c2939121Smrg ;; 6909c76ae52dSmrg 6910c2939121Smrg -dlopen) 6911c2939121Smrg prev=dlfiles 6912c2939121Smrg continue 6913c2939121Smrg ;; 6914c76ae52dSmrg 6915c2939121Smrg -dlpreopen) 6916c2939121Smrg prev=dlprefiles 6917c2939121Smrg continue 6918c2939121Smrg ;; 6919c76ae52dSmrg 6920c2939121Smrg -export-dynamic) 6921c2939121Smrg export_dynamic=yes 6922c2939121Smrg continue 6923c2939121Smrg ;; 6924c76ae52dSmrg 6925c2939121Smrg -export-symbols | -export-symbols-regex) 6926c2939121Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927c2939121Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928c2939121Smrg fi 69298292847cSmrg if test X-export-symbols = "X$arg"; then 6930c2939121Smrg prev=expsyms 6931c2939121Smrg else 6932c2939121Smrg prev=expsyms_regex 6933c2939121Smrg fi 6934c2939121Smrg continue 6935c2939121Smrg ;; 6936c76ae52dSmrg 6937c2939121Smrg -framework) 6938c2939121Smrg prev=framework 6939c2939121Smrg continue 6940c2939121Smrg ;; 6941c76ae52dSmrg 6942c2939121Smrg -inst-prefix-dir) 6943c2939121Smrg prev=inst_prefix 6944c2939121Smrg continue 6945c2939121Smrg ;; 6946c76ae52dSmrg 6947c2939121Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948c2939121Smrg # so, if we see these flags be careful not to treat them like -L 6949c2939121Smrg -L[A-Z][A-Z]*:*) 6950c2939121Smrg case $with_gcc/$host in 6951c2939121Smrg no/*-*-irix* | /*-*-irix*) 6952c2939121Smrg func_append compile_command " $arg" 6953c2939121Smrg func_append finalize_command " $arg" 6954c2939121Smrg ;; 6955c2939121Smrg esac 6956c2939121Smrg continue 6957c2939121Smrg ;; 6958c76ae52dSmrg 6959c2939121Smrg -L*) 69602836776bSmrg func_stripname "-L" '' "$arg" 69612836776bSmrg if test -z "$func_stripname_result"; then 6962c2939121Smrg if test "$#" -gt 0; then 69638292847cSmrg func_fatal_error "require no space between '-L' and '$1'" 6964c2939121Smrg else 69658292847cSmrg func_fatal_error "need path for '-L' option" 6966c2939121Smrg fi 6967c2939121Smrg fi 69682836776bSmrg func_resolve_sysroot "$func_stripname_result" 69692836776bSmrg dir=$func_resolve_sysroot_result 6970c2939121Smrg # We need an absolute path. 6971c2939121Smrg case $dir in 6972c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973c2939121Smrg *) 6974c2939121Smrg absdir=`cd "$dir" && pwd` 6975c2939121Smrg test -z "$absdir" && \ 69768292847cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 69778292847cSmrg dir=$absdir 6978c2939121Smrg ;; 6979c2939121Smrg esac 6980c2939121Smrg case "$deplibs " in 69812836776bSmrg *" -L$dir "* | *" $arg "*) 69822836776bSmrg # Will only happen for absolute or sysroot arguments 69832836776bSmrg ;; 6984c2939121Smrg *) 69852836776bSmrg # Preserve sysroot, but never include relative directories 69862836776bSmrg case $dir in 69872836776bSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 69882836776bSmrg *) func_append deplibs " -L$dir" ;; 69892836776bSmrg esac 69902836776bSmrg func_append lib_search_path " $dir" 6991c2939121Smrg ;; 6992c2939121Smrg esac 6993c2939121Smrg case $host in 6994c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995c2939121Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996c2939121Smrg case :$dllsearchpath: in 6997c2939121Smrg *":$dir:"*) ;; 6998c2939121Smrg ::) dllsearchpath=$dir;; 69992836776bSmrg *) func_append dllsearchpath ":$dir";; 7000c2939121Smrg esac 7001c2939121Smrg case :$dllsearchpath: in 7002c2939121Smrg *":$testbindir:"*) ;; 7003c2939121Smrg ::) dllsearchpath=$testbindir;; 70042836776bSmrg *) func_append dllsearchpath ":$testbindir";; 7005c2939121Smrg esac 7006c2939121Smrg ;; 7007c2939121Smrg esac 7008c2939121Smrg continue 7009c2939121Smrg ;; 7010c76ae52dSmrg 7011c2939121Smrg -l*) 70128292847cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013c2939121Smrg case $host in 7014c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015c2939121Smrg # These systems don't actually have a C or math library (as such) 7016c2939121Smrg continue 7017c2939121Smrg ;; 7018c2939121Smrg *-*-os2*) 7019c2939121Smrg # These systems don't actually have a C library (as such) 70208292847cSmrg test X-lc = "X$arg" && continue 7021c2939121Smrg ;; 70228292847cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023c2939121Smrg # Do not include libc due to us having libc/libc_r. 70248292847cSmrg test X-lc = "X$arg" && continue 7025c2939121Smrg ;; 7026c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7027c2939121Smrg # Rhapsody C and math libraries are in the System framework 70282836776bSmrg func_append deplibs " System.ltframework" 7029c2939121Smrg continue 7030c2939121Smrg ;; 7031c2939121Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7032c2939121Smrg # Causes problems with __ctype 70338292847cSmrg test X-lc = "X$arg" && continue 7034c2939121Smrg ;; 7035c2939121Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036c2939121Smrg # Compiler inserts libc in the correct place for threads to work 70378292847cSmrg test X-lc = "X$arg" && continue 7038c2939121Smrg ;; 7039c2939121Smrg esac 70408292847cSmrg elif test X-lc_r = "X$arg"; then 7041c2939121Smrg case $host in 70428292847cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043c2939121Smrg # Do not include libc_r directly, use -pthread flag. 7044c2939121Smrg continue 7045c2939121Smrg ;; 7046c2939121Smrg esac 7047c2939121Smrg fi 70482836776bSmrg func_append deplibs " $arg" 7049c2939121Smrg continue 7050c2939121Smrg ;; 7051c76ae52dSmrg 70528292847cSmrg -mllvm) 70538292847cSmrg prev=mllvm 70548292847cSmrg continue 70558292847cSmrg ;; 70568292847cSmrg 7057c2939121Smrg -module) 7058c2939121Smrg module=yes 7059c2939121Smrg continue 7060c2939121Smrg ;; 7061c76ae52dSmrg 7062c2939121Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063c2939121Smrg # classes, name mangling, and exception handling. 7064c2939121Smrg # Darwin uses the -arch flag to determine output architecture. 70652836776bSmrg -model|-arch|-isysroot|--sysroot) 70662836776bSmrg func_append compiler_flags " $arg" 7067c2939121Smrg func_append compile_command " $arg" 7068c2939121Smrg func_append finalize_command " $arg" 7069c2939121Smrg prev=xcompiler 7070c2939121Smrg continue 7071c2939121Smrg ;; 7072c76ae52dSmrg 70732836776bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 70742836776bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 70752836776bSmrg func_append compiler_flags " $arg" 7076c2939121Smrg func_append compile_command " $arg" 7077c2939121Smrg func_append finalize_command " $arg" 7078c2939121Smrg case "$new_inherited_linker_flags " in 7079c2939121Smrg *" $arg "*) ;; 70802836776bSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081c2939121Smrg esac 7082c2939121Smrg continue 7083c2939121Smrg ;; 7084c76ae52dSmrg 7085c2939121Smrg -multi_module) 70868292847cSmrg single_module=$wl-multi_module 7087c2939121Smrg continue 7088c2939121Smrg ;; 7089c76ae52dSmrg 7090c2939121Smrg -no-fast-install) 7091c2939121Smrg fast_install=no 7092c2939121Smrg continue 7093c2939121Smrg ;; 7094c76ae52dSmrg 7095c2939121Smrg -no-install) 7096c2939121Smrg case $host in 7097c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098c2939121Smrg # The PATH hackery in wrapper scripts is required on Windows 7099c2939121Smrg # and Darwin in order for the loader to find any dlls it needs. 71008292847cSmrg func_warning "'-no-install' is ignored for $host" 71018292847cSmrg func_warning "assuming '-no-fast-install' instead" 7102c2939121Smrg fast_install=no 7103c2939121Smrg ;; 7104c2939121Smrg *) no_install=yes ;; 7105c2939121Smrg esac 7106c2939121Smrg continue 7107c2939121Smrg ;; 7108c76ae52dSmrg 7109c2939121Smrg -no-undefined) 7110c2939121Smrg allow_undefined=no 7111c2939121Smrg continue 7112c2939121Smrg ;; 7113c76ae52dSmrg 7114c2939121Smrg -objectlist) 7115c2939121Smrg prev=objectlist 7116c2939121Smrg continue 7117c2939121Smrg ;; 7118c76ae52dSmrg 71198292847cSmrg -os2dllname) 71208292847cSmrg prev=os2dllname 71218292847cSmrg continue 71228292847cSmrg ;; 71238292847cSmrg 7124c2939121Smrg -o) prev=output ;; 7125c76ae52dSmrg 7126c2939121Smrg -precious-files-regex) 7127c2939121Smrg prev=precious_regex 7128c2939121Smrg continue 7129c2939121Smrg ;; 7130c76ae52dSmrg 7131c2939121Smrg -release) 7132c2939121Smrg prev=release 7133c2939121Smrg continue 7134c2939121Smrg ;; 7135c76ae52dSmrg 7136c2939121Smrg -rpath) 7137c2939121Smrg prev=rpath 7138c2939121Smrg continue 7139c2939121Smrg ;; 7140c76ae52dSmrg 7141c2939121Smrg -R) 7142c2939121Smrg prev=xrpath 7143c2939121Smrg continue 7144c2939121Smrg ;; 7145c76ae52dSmrg 7146c2939121Smrg -R*) 7147c2939121Smrg func_stripname '-R' '' "$arg" 7148c2939121Smrg dir=$func_stripname_result 7149c2939121Smrg # We need an absolute path. 7150c2939121Smrg case $dir in 7151c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 71522836776bSmrg =*) 71532836776bSmrg func_stripname '=' '' "$dir" 71542836776bSmrg dir=$lt_sysroot$func_stripname_result 71552836776bSmrg ;; 7156c2939121Smrg *) 7157c2939121Smrg func_fatal_error "only absolute run-paths are allowed" 7158c2939121Smrg ;; 7159c2939121Smrg esac 7160c2939121Smrg case "$xrpath " in 7161c2939121Smrg *" $dir "*) ;; 71622836776bSmrg *) func_append xrpath " $dir" ;; 7163c2939121Smrg esac 7164c2939121Smrg continue 7165c2939121Smrg ;; 7166c76ae52dSmrg 7167c2939121Smrg -shared) 7168c2939121Smrg # The effects of -shared are defined in a previous loop. 7169c2939121Smrg continue 7170c2939121Smrg ;; 7171c76ae52dSmrg 7172c2939121Smrg -shrext) 7173c2939121Smrg prev=shrext 7174c2939121Smrg continue 7175c2939121Smrg ;; 7176c76ae52dSmrg 7177c2939121Smrg -static | -static-libtool-libs) 7178c2939121Smrg # The effects of -static are defined in a previous loop. 7179c2939121Smrg # We used to do the same as -all-static on platforms that 7180c2939121Smrg # didn't have a PIC flag, but the assumption that the effects 7181c2939121Smrg # would be equivalent was wrong. It would break on at least 7182c2939121Smrg # Digital Unix and AIX. 7183c2939121Smrg continue 7184c2939121Smrg ;; 7185c76ae52dSmrg 7186c2939121Smrg -thread-safe) 7187c2939121Smrg thread_safe=yes 7188c2939121Smrg continue 7189c2939121Smrg ;; 7190c76ae52dSmrg 7191c2939121Smrg -version-info) 7192c2939121Smrg prev=vinfo 7193c2939121Smrg continue 7194c2939121Smrg ;; 7195c76ae52dSmrg 7196c2939121Smrg -version-number) 7197c2939121Smrg prev=vinfo 7198c2939121Smrg vinfo_number=yes 7199c2939121Smrg continue 7200c2939121Smrg ;; 7201c76ae52dSmrg 7202c2939121Smrg -weak) 7203c2939121Smrg prev=weak 7204c2939121Smrg continue 7205c2939121Smrg ;; 7206c76ae52dSmrg 7207c2939121Smrg -Wc,*) 7208c2939121Smrg func_stripname '-Wc,' '' "$arg" 7209c2939121Smrg args=$func_stripname_result 7210c2939121Smrg arg= 72118292847cSmrg save_ifs=$IFS; IFS=, 7212c2939121Smrg for flag in $args; do 72138292847cSmrg IFS=$save_ifs 7214c2939121Smrg func_quote_for_eval "$flag" 72152836776bSmrg func_append arg " $func_quote_for_eval_result" 72162836776bSmrg func_append compiler_flags " $func_quote_for_eval_result" 7217c2939121Smrg done 72188292847cSmrg IFS=$save_ifs 7219c2939121Smrg func_stripname ' ' '' "$arg" 7220c2939121Smrg arg=$func_stripname_result 7221c2939121Smrg ;; 7222c76ae52dSmrg 7223c2939121Smrg -Wl,*) 7224c2939121Smrg func_stripname '-Wl,' '' "$arg" 7225c2939121Smrg args=$func_stripname_result 7226c2939121Smrg arg= 72278292847cSmrg save_ifs=$IFS; IFS=, 7228c2939121Smrg for flag in $args; do 72298292847cSmrg IFS=$save_ifs 7230c2939121Smrg func_quote_for_eval "$flag" 72312836776bSmrg func_append arg " $wl$func_quote_for_eval_result" 72322836776bSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 72332836776bSmrg func_append linker_flags " $func_quote_for_eval_result" 7234c2939121Smrg done 72358292847cSmrg IFS=$save_ifs 7236c2939121Smrg func_stripname ' ' '' "$arg" 7237c2939121Smrg arg=$func_stripname_result 7238c2939121Smrg ;; 7239c76ae52dSmrg 7240c2939121Smrg -Xcompiler) 7241c2939121Smrg prev=xcompiler 7242c2939121Smrg continue 7243c2939121Smrg ;; 7244c76ae52dSmrg 7245c2939121Smrg -Xlinker) 7246c2939121Smrg prev=xlinker 7247c2939121Smrg continue 7248c2939121Smrg ;; 7249c76ae52dSmrg 7250c2939121Smrg -XCClinker) 7251c2939121Smrg prev=xcclinker 7252c2939121Smrg continue 7253c2939121Smrg ;; 7254c76ae52dSmrg 7255c2939121Smrg # -msg_* for osf cc 7256c2939121Smrg -msg_*) 7257c2939121Smrg func_quote_for_eval "$arg" 72588292847cSmrg arg=$func_quote_for_eval_result 7259c2939121Smrg ;; 7260c76ae52dSmrg 7261c2939121Smrg # Flags to be passed through unchanged, with rationale: 7262c2939121Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263c2939121Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7264c2939121Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265c2939121Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7266c2939121Smrg # -q* compiler args for the IBM compiler 7267c2939121Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268c2939121Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7269c2939121Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 72708292847cSmrg # -fstack-protector* stack protector flags for GCC 7271c2939121Smrg # @file GCC response files 7272c2939121Smrg # -tp=* Portland pgcc target processor selection 72732836776bSmrg # --sysroot=* for sysroot support 72748292847cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 72758292847cSmrg # -stdlib=* select c++ std lib with clang 7276c2939121Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 72772836776bSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 72788292847cSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279c2939121Smrg func_quote_for_eval "$arg" 72808292847cSmrg arg=$func_quote_for_eval_result 7281c2939121Smrg func_append compile_command " $arg" 7282c2939121Smrg func_append finalize_command " $arg" 72832836776bSmrg func_append compiler_flags " $arg" 7284c2939121Smrg continue 7285c2939121Smrg ;; 7286c76ae52dSmrg 72878292847cSmrg -Z*) 72888292847cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 72898292847cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 72908292847cSmrg compiler_flags="$compiler_flags $arg" 72918292847cSmrg func_append compile_command " $arg" 72928292847cSmrg func_append finalize_command " $arg" 72938292847cSmrg case $arg in 72948292847cSmrg -Zlinker | -Zstack) 72958292847cSmrg prev=xcompiler 72968292847cSmrg ;; 72978292847cSmrg esac 72988292847cSmrg continue 72998292847cSmrg else 73008292847cSmrg # Otherwise treat like 'Some other compiler flag' below 73018292847cSmrg func_quote_for_eval "$arg" 73028292847cSmrg arg=$func_quote_for_eval_result 73038292847cSmrg fi 73048292847cSmrg ;; 73058292847cSmrg 7306c2939121Smrg # Some other compiler flag. 7307c2939121Smrg -* | +*) 7308c2939121Smrg func_quote_for_eval "$arg" 73098292847cSmrg arg=$func_quote_for_eval_result 7310c2939121Smrg ;; 7311c76ae52dSmrg 7312c2939121Smrg *.$objext) 7313c2939121Smrg # A standard object. 73142836776bSmrg func_append objs " $arg" 7315c2939121Smrg ;; 7316c76ae52dSmrg 7317c2939121Smrg *.lo) 7318c2939121Smrg # A libtool-controlled object. 7319c76ae52dSmrg 7320c2939121Smrg # Check to see that this really is a libtool object. 7321c2939121Smrg if func_lalib_unsafe_p "$arg"; then 7322c2939121Smrg pic_object= 7323c2939121Smrg non_pic_object= 7324c76ae52dSmrg 7325c2939121Smrg # Read the .lo file 7326c2939121Smrg func_source "$arg" 7327c76ae52dSmrg 7328c2939121Smrg if test -z "$pic_object" || 7329c2939121Smrg test -z "$non_pic_object" || 73308292847cSmrg test none = "$pic_object" && 73318292847cSmrg test none = "$non_pic_object"; then 73328292847cSmrg func_fatal_error "cannot find name of object for '$arg'" 7333c2939121Smrg fi 73340d590c07Smrg 7335c2939121Smrg # Extract subdirectory from the argument. 7336c2939121Smrg func_dirname "$arg" "/" "" 73378292847cSmrg xdir=$func_dirname_result 7338c76ae52dSmrg 73398292847cSmrg test none = "$pic_object" || { 7340c2939121Smrg # Prepend the subdirectory the object is found in. 73418292847cSmrg pic_object=$xdir$pic_object 7342c76ae52dSmrg 73438292847cSmrg if test dlfiles = "$prev"; then 73448292847cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 73452836776bSmrg func_append dlfiles " $pic_object" 7346c2939121Smrg prev= 7347c2939121Smrg continue 7348c2939121Smrg else 7349c2939121Smrg # If libtool objects are unsupported, then we need to preload. 7350c2939121Smrg prev=dlprefiles 7351c2939121Smrg fi 7352c2939121Smrg fi 7353c2939121Smrg 7354c2939121Smrg # CHECK ME: I think I busted this. -Ossama 73558292847cSmrg if test dlprefiles = "$prev"; then 7356c2939121Smrg # Preload the old-style object. 73572836776bSmrg func_append dlprefiles " $pic_object" 7358c2939121Smrg prev= 7359c2939121Smrg fi 7360c2939121Smrg 7361c2939121Smrg # A PIC object. 7362c2939121Smrg func_append libobjs " $pic_object" 73638292847cSmrg arg=$pic_object 73648292847cSmrg } 7365c2939121Smrg 7366c2939121Smrg # Non-PIC object. 73678292847cSmrg if test none != "$non_pic_object"; then 7368c2939121Smrg # Prepend the subdirectory the object is found in. 73698292847cSmrg non_pic_object=$xdir$non_pic_object 7370c2939121Smrg 7371c2939121Smrg # A standard non-PIC object 7372c2939121Smrg func_append non_pic_objects " $non_pic_object" 73738292847cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 73748292847cSmrg arg=$non_pic_object 7375c2939121Smrg fi 7376c2939121Smrg else 7377c2939121Smrg # If the PIC object exists, use it instead. 7378c2939121Smrg # $xdir was prepended to $pic_object above. 73798292847cSmrg non_pic_object=$pic_object 7380c2939121Smrg func_append non_pic_objects " $non_pic_object" 7381c2939121Smrg fi 7382c2939121Smrg else 7383c2939121Smrg # Only an error if not doing a dry-run. 7384c2939121Smrg if $opt_dry_run; then 7385c2939121Smrg # Extract subdirectory from the argument. 7386c2939121Smrg func_dirname "$arg" "/" "" 73878292847cSmrg xdir=$func_dirname_result 7388c2939121Smrg 7389c2939121Smrg func_lo2o "$arg" 7390c2939121Smrg pic_object=$xdir$objdir/$func_lo2o_result 7391c2939121Smrg non_pic_object=$xdir$func_lo2o_result 7392c2939121Smrg func_append libobjs " $pic_object" 7393c2939121Smrg func_append non_pic_objects " $non_pic_object" 7394c2939121Smrg else 73958292847cSmrg func_fatal_error "'$arg' is not a valid libtool object" 7396c2939121Smrg fi 7397c2939121Smrg fi 7398c2939121Smrg ;; 7399c2939121Smrg 7400c2939121Smrg *.$libext) 7401c2939121Smrg # An archive. 74022836776bSmrg func_append deplibs " $arg" 74032836776bSmrg func_append old_deplibs " $arg" 7404c2939121Smrg continue 7405c2939121Smrg ;; 7406c2939121Smrg 7407c2939121Smrg *.la) 7408c2939121Smrg # A libtool-controlled library. 7409c2939121Smrg 74102836776bSmrg func_resolve_sysroot "$arg" 74118292847cSmrg if test dlfiles = "$prev"; then 7412c2939121Smrg # This library was specified with -dlopen. 74132836776bSmrg func_append dlfiles " $func_resolve_sysroot_result" 7414c2939121Smrg prev= 74158292847cSmrg elif test dlprefiles = "$prev"; then 7416c2939121Smrg # The library was specified with -dlpreopen. 74172836776bSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7418c2939121Smrg prev= 7419c2939121Smrg else 74202836776bSmrg func_append deplibs " $func_resolve_sysroot_result" 7421c2939121Smrg fi 7422c2939121Smrg continue 7423c2939121Smrg ;; 7424c2939121Smrg 7425c2939121Smrg # Some other compiler argument. 7426c2939121Smrg *) 7427c2939121Smrg # Unknown arguments in both finalize_command and compile_command need 7428c2939121Smrg # to be aesthetically quoted because they are evaled later. 7429c2939121Smrg func_quote_for_eval "$arg" 74308292847cSmrg arg=$func_quote_for_eval_result 7431c2939121Smrg ;; 7432c2939121Smrg esac # arg 7433c2939121Smrg 7434c2939121Smrg # Now actually substitute the argument into the commands. 7435c2939121Smrg if test -n "$arg"; then 7436c2939121Smrg func_append compile_command " $arg" 7437c2939121Smrg func_append finalize_command " $arg" 7438c2939121Smrg fi 7439c2939121Smrg done # argument parsing loop 7440c2939121Smrg 7441c2939121Smrg test -n "$prev" && \ 74428292847cSmrg func_fatal_help "the '$prevarg' option requires an argument" 7443c2939121Smrg 74448292847cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445c2939121Smrg eval arg=\"$export_dynamic_flag_spec\" 7446c2939121Smrg func_append compile_command " $arg" 7447c2939121Smrg func_append finalize_command " $arg" 7448c2939121Smrg fi 7449c2939121Smrg 7450c2939121Smrg oldlibs= 7451c2939121Smrg # calculate the name of the file, without its directory 7452c2939121Smrg func_basename "$output" 74538292847cSmrg outputname=$func_basename_result 74548292847cSmrg libobjs_save=$libobjs 7455c2939121Smrg 7456c2939121Smrg if test -n "$shlibpath_var"; then 7457c2939121Smrg # get the directories listed in $shlibpath_var 74588292847cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459c76ae52dSmrg else 7460c2939121Smrg shlib_search_path= 7461c76ae52dSmrg fi 7462c2939121Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463c2939121Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464c76ae52dSmrg 74658292847cSmrg # Definition is injected by LT_CONFIG during libtool generation. 74668292847cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 74678292847cSmrg 7468c2939121Smrg func_dirname "$output" "/" "" 74698292847cSmrg output_objdir=$func_dirname_result$objdir 74702836776bSmrg func_to_tool_file "$output_objdir/" 74712836776bSmrg tool_output_objdir=$func_to_tool_file_result 7472c2939121Smrg # Create the object directory. 7473c2939121Smrg func_mkdir_p "$output_objdir" 7474c76ae52dSmrg 7475c2939121Smrg # Determine the type of output 7476c2939121Smrg case $output in 7477c2939121Smrg "") 7478c2939121Smrg func_fatal_help "you must specify an output file" 7479c2939121Smrg ;; 7480c2939121Smrg *.$libext) linkmode=oldlib ;; 7481c2939121Smrg *.lo | *.$objext) linkmode=obj ;; 7482c2939121Smrg *.la) linkmode=lib ;; 7483c2939121Smrg *) linkmode=prog ;; # Anything else should be a program. 7484c2939121Smrg esac 7485c2939121Smrg 7486c2939121Smrg specialdeplibs= 7487c2939121Smrg 7488c2939121Smrg libs= 7489c2939121Smrg # Find all interdependent deplibs by searching for libraries 7490c2939121Smrg # that are linked more than once (e.g. -la -lb -la) 7491c2939121Smrg for deplib in $deplibs; do 74928292847cSmrg if $opt_preserve_dup_deps; then 7493c2939121Smrg case "$libs " in 74942836776bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495c2939121Smrg esac 7496c2939121Smrg fi 74972836776bSmrg func_append libs " $deplib" 7498c2939121Smrg done 7499c2939121Smrg 75008292847cSmrg if test lib = "$linkmode"; then 7501c2939121Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502c2939121Smrg 7503c2939121Smrg # Compute libraries that are listed more than once in $predeps 7504c2939121Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7505c2939121Smrg # not to be eliminated). 7506c2939121Smrg pre_post_deps= 7507c2939121Smrg if $opt_duplicate_compiler_generated_deps; then 7508c2939121Smrg for pre_post_dep in $predeps $postdeps; do 7509c2939121Smrg case "$pre_post_deps " in 75102836776bSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511c2939121Smrg esac 75122836776bSmrg func_append pre_post_deps " $pre_post_dep" 7513c2939121Smrg done 7514c2939121Smrg fi 7515c2939121Smrg pre_post_deps= 7516c2939121Smrg fi 7517c2939121Smrg 7518c2939121Smrg deplibs= 7519c2939121Smrg newdependency_libs= 7520c2939121Smrg newlib_search_path= 7521c2939121Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7522c2939121Smrg notinst_deplibs= # not-installed libtool libraries 7523c2939121Smrg notinst_path= # paths that contain not-installed libtool libraries 7524c2939121Smrg 7525c2939121Smrg case $linkmode in 7526c2939121Smrg lib) 7527c2939121Smrg passes="conv dlpreopen link" 7528c2939121Smrg for file in $dlfiles $dlprefiles; do 7529c2939121Smrg case $file in 7530c2939121Smrg *.la) ;; 7531c2939121Smrg *) 75328292847cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533c2939121Smrg ;; 7534c2939121Smrg esac 7535c2939121Smrg done 7536c2939121Smrg ;; 7537c2939121Smrg prog) 7538c2939121Smrg compile_deplibs= 7539c2939121Smrg finalize_deplibs= 75408292847cSmrg alldeplibs=false 7541c2939121Smrg newdlfiles= 7542c2939121Smrg newdlprefiles= 7543c2939121Smrg passes="conv scan dlopen dlpreopen link" 7544c2939121Smrg ;; 7545c2939121Smrg *) passes="conv" 7546c2939121Smrg ;; 7547c2939121Smrg esac 7548c2939121Smrg 7549c2939121Smrg for pass in $passes; do 7550c2939121Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7551c2939121Smrg # so that -L comes before libs that need it for instance... 75528292847cSmrg if test lib,link = "$linkmode,$pass"; then 7553c2939121Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7554c2939121Smrg ## order, and fix it there properly 7555c2939121Smrg tmp_deplibs= 7556c2939121Smrg for deplib in $deplibs; do 7557c2939121Smrg tmp_deplibs="$deplib $tmp_deplibs" 7558c2939121Smrg done 75598292847cSmrg deplibs=$tmp_deplibs 7560c2939121Smrg fi 7561c2939121Smrg 75628292847cSmrg if test lib,link = "$linkmode,$pass" || 75638292847cSmrg test prog,scan = "$linkmode,$pass"; then 75648292847cSmrg libs=$deplibs 7565c2939121Smrg deplibs= 7566c2939121Smrg fi 75678292847cSmrg if test prog = "$linkmode"; then 7568c2939121Smrg case $pass in 75698292847cSmrg dlopen) libs=$dlfiles ;; 75708292847cSmrg dlpreopen) libs=$dlprefiles ;; 7571c2939121Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572c2939121Smrg esac 7573c2939121Smrg fi 75748292847cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7575c2939121Smrg # Collect and forward deplibs of preopened libtool libs 7576c2939121Smrg for lib in $dlprefiles; do 7577c2939121Smrg # Ignore non-libtool-libs 7578c2939121Smrg dependency_libs= 75792836776bSmrg func_resolve_sysroot "$lib" 7580c2939121Smrg case $lib in 75812836776bSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7582c2939121Smrg esac 7583c2939121Smrg 7584c2939121Smrg # Collect preopened libtool deplibs, except any this library 7585c2939121Smrg # has declared as weak libs 7586c2939121Smrg for deplib in $dependency_libs; do 7587c2939121Smrg func_basename "$deplib" 7588c2939121Smrg deplib_base=$func_basename_result 7589c2939121Smrg case " $weak_libs " in 7590c2939121Smrg *" $deplib_base "*) ;; 75912836776bSmrg *) func_append deplibs " $deplib" ;; 7592c2939121Smrg esac 7593c2939121Smrg done 7594c2939121Smrg done 75958292847cSmrg libs=$dlprefiles 7596c2939121Smrg fi 75978292847cSmrg if test dlopen = "$pass"; then 7598c2939121Smrg # Collect dlpreopened libraries 75998292847cSmrg save_deplibs=$deplibs 7600c2939121Smrg deplibs= 7601c2939121Smrg fi 7602c2939121Smrg 7603c2939121Smrg for deplib in $libs; do 7604c2939121Smrg lib= 76058292847cSmrg found=false 7606c2939121Smrg case $deplib in 76072836776bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 76082836776bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 76098292847cSmrg if test prog,link = "$linkmode,$pass"; then 7610c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7611c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7612c2939121Smrg else 76132836776bSmrg func_append compiler_flags " $deplib" 76148292847cSmrg if test lib = "$linkmode"; then 7615c2939121Smrg case "$new_inherited_linker_flags " in 7616c2939121Smrg *" $deplib "*) ;; 76172836776bSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7618c2939121Smrg esac 7619c2939121Smrg fi 7620c2939121Smrg fi 7621c2939121Smrg continue 7622c2939121Smrg ;; 7623c2939121Smrg -l*) 76248292847cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 76258292847cSmrg func_warning "'-l' is ignored for archives/objects" 7626c2939121Smrg continue 7627c2939121Smrg fi 7628c2939121Smrg func_stripname '-l' '' "$deplib" 7629c2939121Smrg name=$func_stripname_result 76308292847cSmrg if test lib = "$linkmode"; then 7631c2939121Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632c2939121Smrg else 7633c2939121Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634c2939121Smrg fi 7635c2939121Smrg for searchdir in $searchdirs; do 7636c2939121Smrg for search_ext in .la $std_shrext .so .a; do 7637c2939121Smrg # Search the libtool library 76388292847cSmrg lib=$searchdir/lib$name$search_ext 7639c2939121Smrg if test -f "$lib"; then 76408292847cSmrg if test .la = "$search_ext"; then 76418292847cSmrg found=: 7642c2939121Smrg else 76438292847cSmrg found=false 7644c2939121Smrg fi 7645c2939121Smrg break 2 7646c2939121Smrg fi 7647c2939121Smrg done 7648c2939121Smrg done 76498292847cSmrg if $found; then 76508292847cSmrg # deplib is a libtool library 7651c2939121Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652c2939121Smrg # We need to do some special things here, and not later. 76538292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654c2939121Smrg case " $predeps $postdeps " in 7655c2939121Smrg *" $deplib "*) 7656c2939121Smrg if func_lalib_p "$lib"; then 7657c2939121Smrg library_names= 7658c2939121Smrg old_library= 7659c2939121Smrg func_source "$lib" 7660c2939121Smrg for l in $old_library $library_names; do 76618292847cSmrg ll=$l 7662c2939121Smrg done 76638292847cSmrg if test "X$ll" = "X$old_library"; then # only static version available 76648292847cSmrg found=false 7665c2939121Smrg func_dirname "$lib" "" "." 76668292847cSmrg ladir=$func_dirname_result 7667c2939121Smrg lib=$ladir/$old_library 76688292847cSmrg if test prog,link = "$linkmode,$pass"; then 7669c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7670c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7671c2939121Smrg else 7672c2939121Smrg deplibs="$deplib $deplibs" 76738292847cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674c2939121Smrg fi 7675c2939121Smrg continue 7676c2939121Smrg fi 7677c2939121Smrg fi 7678c2939121Smrg ;; 7679c2939121Smrg *) ;; 7680c2939121Smrg esac 7681c2939121Smrg fi 76828292847cSmrg else 76838292847cSmrg # deplib doesn't seem to be a libtool library 76848292847cSmrg if test prog,link = "$linkmode,$pass"; then 76858292847cSmrg compile_deplibs="$deplib $compile_deplibs" 76868292847cSmrg finalize_deplibs="$deplib $finalize_deplibs" 76878292847cSmrg else 76888292847cSmrg deplibs="$deplib $deplibs" 76898292847cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76908292847cSmrg fi 76918292847cSmrg continue 7692c2939121Smrg fi 7693c2939121Smrg ;; # -l 7694c2939121Smrg *.ltframework) 76958292847cSmrg if test prog,link = "$linkmode,$pass"; then 7696c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7697c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7698c2939121Smrg else 7699c2939121Smrg deplibs="$deplib $deplibs" 77008292847cSmrg if test lib = "$linkmode"; then 7701c2939121Smrg case "$new_inherited_linker_flags " in 7702c2939121Smrg *" $deplib "*) ;; 77032836776bSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7704c2939121Smrg esac 7705c2939121Smrg fi 7706c2939121Smrg fi 7707c2939121Smrg continue 7708c2939121Smrg ;; 7709c2939121Smrg -L*) 7710c2939121Smrg case $linkmode in 7711c2939121Smrg lib) 7712c2939121Smrg deplibs="$deplib $deplibs" 77138292847cSmrg test conv = "$pass" && continue 7714c2939121Smrg newdependency_libs="$deplib $newdependency_libs" 7715c2939121Smrg func_stripname '-L' '' "$deplib" 77162836776bSmrg func_resolve_sysroot "$func_stripname_result" 77172836776bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7718c2939121Smrg ;; 7719c2939121Smrg prog) 77208292847cSmrg if test conv = "$pass"; then 7721c2939121Smrg deplibs="$deplib $deplibs" 7722c2939121Smrg continue 7723c2939121Smrg fi 77248292847cSmrg if test scan = "$pass"; then 7725c2939121Smrg deplibs="$deplib $deplibs" 7726c2939121Smrg else 7727c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7728c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7729c2939121Smrg fi 7730c2939121Smrg func_stripname '-L' '' "$deplib" 77312836776bSmrg func_resolve_sysroot "$func_stripname_result" 77322836776bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7733c2939121Smrg ;; 7734c2939121Smrg *) 77358292847cSmrg func_warning "'-L' is ignored for archives/objects" 7736c2939121Smrg ;; 7737c2939121Smrg esac # linkmode 7738c2939121Smrg continue 7739c2939121Smrg ;; # -L 7740c2939121Smrg -R*) 77418292847cSmrg if test link = "$pass"; then 7742c2939121Smrg func_stripname '-R' '' "$deplib" 77432836776bSmrg func_resolve_sysroot "$func_stripname_result" 77442836776bSmrg dir=$func_resolve_sysroot_result 7745c2939121Smrg # Make sure the xrpath contains only unique directories. 7746c2939121Smrg case "$xrpath " in 7747c2939121Smrg *" $dir "*) ;; 77482836776bSmrg *) func_append xrpath " $dir" ;; 7749c2939121Smrg esac 7750c2939121Smrg fi 7751c2939121Smrg deplibs="$deplib $deplibs" 7752c2939121Smrg continue 7753c2939121Smrg ;; 77542836776bSmrg *.la) 77552836776bSmrg func_resolve_sysroot "$deplib" 77562836776bSmrg lib=$func_resolve_sysroot_result 77572836776bSmrg ;; 7758c2939121Smrg *.$libext) 77598292847cSmrg if test conv = "$pass"; then 7760c2939121Smrg deplibs="$deplib $deplibs" 7761c2939121Smrg continue 7762c2939121Smrg fi 7763c2939121Smrg case $linkmode in 7764c2939121Smrg lib) 7765c2939121Smrg # Linking convenience modules into shared libraries is allowed, 7766c2939121Smrg # but linking other static libraries is non-portable. 7767c2939121Smrg case " $dlpreconveniencelibs " in 7768c2939121Smrg *" $deplib "*) ;; 7769c2939121Smrg *) 77708292847cSmrg valid_a_lib=false 7771c2939121Smrg case $deplibs_check_method in 7772c2939121Smrg match_pattern*) 7773c2939121Smrg set dummy $deplibs_check_method; shift 7774c2939121Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775c2939121Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776c2939121Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 77778292847cSmrg valid_a_lib=: 7778c2939121Smrg fi 7779c2939121Smrg ;; 7780c2939121Smrg pass_all) 77818292847cSmrg valid_a_lib=: 7782c2939121Smrg ;; 7783c2939121Smrg esac 77848292847cSmrg if $valid_a_lib; then 77858292847cSmrg echo 77868292847cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 77878292847cSmrg $ECHO "*** static library $deplib is not portable!" 77888292847cSmrg deplibs="$deplib $deplibs" 77898292847cSmrg else 7790c2939121Smrg echo 7791c2939121Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 7793c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 7794c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 7795c2939121Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 7796c2939121Smrg echo "*** that it is just a static archive that I should not use here." 7797c2939121Smrg fi 7798c2939121Smrg ;; 7799c2939121Smrg esac 7800c2939121Smrg continue 7801c2939121Smrg ;; 7802c2939121Smrg prog) 78038292847cSmrg if test link != "$pass"; then 7804c2939121Smrg deplibs="$deplib $deplibs" 7805c2939121Smrg else 7806c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7807c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7808c2939121Smrg fi 7809c2939121Smrg continue 7810c2939121Smrg ;; 7811c2939121Smrg esac # linkmode 7812c2939121Smrg ;; # *.$libext 7813c2939121Smrg *.lo | *.$objext) 78148292847cSmrg if test conv = "$pass"; then 7815c2939121Smrg deplibs="$deplib $deplibs" 78168292847cSmrg elif test prog = "$linkmode"; then 78178292847cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818c2939121Smrg # If there is no dlopen support or we're linking statically, 7819c2939121Smrg # we need to preload. 78202836776bSmrg func_append newdlprefiles " $deplib" 7821c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7822c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7823c2939121Smrg else 78242836776bSmrg func_append newdlfiles " $deplib" 7825c2939121Smrg fi 7826c2939121Smrg fi 7827c2939121Smrg continue 7828c2939121Smrg ;; 7829c2939121Smrg %DEPLIBS%) 78308292847cSmrg alldeplibs=: 7831c2939121Smrg continue 7832c2939121Smrg ;; 7833c2939121Smrg esac # case $deplib 7834c2939121Smrg 78358292847cSmrg $found || test -f "$lib" \ 78368292847cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837c2939121Smrg 7838c2939121Smrg # Check to see that this really is a libtool archive. 7839c2939121Smrg func_lalib_unsafe_p "$lib" \ 78408292847cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7841c2939121Smrg 7842c2939121Smrg func_dirname "$lib" "" "." 78438292847cSmrg ladir=$func_dirname_result 7844c2939121Smrg 7845c2939121Smrg dlname= 7846c2939121Smrg dlopen= 7847c2939121Smrg dlpreopen= 7848c2939121Smrg libdir= 7849c2939121Smrg library_names= 7850c2939121Smrg old_library= 7851c2939121Smrg inherited_linker_flags= 7852c2939121Smrg # If the library was installed with an old release of libtool, 7853c2939121Smrg # it will not redefine variables installed, or shouldnotlink 7854c2939121Smrg installed=yes 7855c2939121Smrg shouldnotlink=no 7856c2939121Smrg avoidtemprpath= 7857c2939121Smrg 7858c2939121Smrg 7859c2939121Smrg # Read the .la file 7860c2939121Smrg func_source "$lib" 7861c2939121Smrg 7862c2939121Smrg # Convert "-framework foo" to "foo.ltframework" 7863c2939121Smrg if test -n "$inherited_linker_flags"; then 7864c2939121Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865c2939121Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866c2939121Smrg case " $new_inherited_linker_flags " in 7867c2939121Smrg *" $tmp_inherited_linker_flag "*) ;; 78682836776bSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869c2939121Smrg esac 7870c2939121Smrg done 7871c2939121Smrg fi 7872c2939121Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 78738292847cSmrg if test lib,link = "$linkmode,$pass" || 78748292847cSmrg test prog,scan = "$linkmode,$pass" || 78758292847cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 78762836776bSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 78772836776bSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878c2939121Smrg fi 7879c2939121Smrg 78808292847cSmrg if test conv = "$pass"; then 7881c2939121Smrg # Only check for convenience libraries 7882c2939121Smrg deplibs="$lib $deplibs" 7883c2939121Smrg if test -z "$libdir"; then 7884c2939121Smrg if test -z "$old_library"; then 78858292847cSmrg func_fatal_error "cannot find name of link library for '$lib'" 7886c2939121Smrg fi 7887c2939121Smrg # It is a libtool convenience library, so add in its objects. 78882836776bSmrg func_append convenience " $ladir/$objdir/$old_library" 78892836776bSmrg func_append old_convenience " $ladir/$objdir/$old_library" 78908292847cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 78918292847cSmrg func_fatal_error "'$lib' is not a convenience library" 7892c2939121Smrg fi 7893c2939121Smrg tmp_libs= 7894c2939121Smrg for deplib in $dependency_libs; do 7895c2939121Smrg deplibs="$deplib $deplibs" 78968292847cSmrg if $opt_preserve_dup_deps; then 7897c2939121Smrg case "$tmp_libs " in 78982836776bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899c2939121Smrg esac 7900c2939121Smrg fi 79012836776bSmrg func_append tmp_libs " $deplib" 7902c2939121Smrg done 7903c2939121Smrg continue 7904c2939121Smrg fi # $pass = conv 7905c2939121Smrg 7906c2939121Smrg 7907c2939121Smrg # Get the name of the library we link against. 7908c2939121Smrg linklib= 79092836776bSmrg if test -n "$old_library" && 79108292847cSmrg { test yes = "$prefer_static_libs" || 79118292847cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 79122836776bSmrg linklib=$old_library 79132836776bSmrg else 79142836776bSmrg for l in $old_library $library_names; do 79158292847cSmrg linklib=$l 79162836776bSmrg done 79172836776bSmrg fi 7918c2939121Smrg if test -z "$linklib"; then 79198292847cSmrg func_fatal_error "cannot find name of link library for '$lib'" 7920c2939121Smrg fi 7921c2939121Smrg 7922c2939121Smrg # This library was specified with -dlopen. 79238292847cSmrg if test dlopen = "$pass"; then 79248292847cSmrg test -z "$libdir" \ 79258292847cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926c2939121Smrg if test -z "$dlname" || 79278292847cSmrg test yes != "$dlopen_support" || 79288292847cSmrg test no = "$build_libtool_libs" 79298292847cSmrg then 7930c2939121Smrg # If there is no dlname, no dlopen support or we're linking 7931c2939121Smrg # statically, we need to preload. We also need to preload any 7932c2939121Smrg # dependent libraries so libltdl's deplib preloader doesn't 7933c2939121Smrg # bomb out in the load deplibs phase. 79342836776bSmrg func_append dlprefiles " $lib $dependency_libs" 7935c2939121Smrg else 79362836776bSmrg func_append newdlfiles " $lib" 7937c2939121Smrg fi 7938c2939121Smrg continue 7939c2939121Smrg fi # $pass = dlopen 7940c2939121Smrg 7941c2939121Smrg # We need an absolute path. 7942c2939121Smrg case $ladir in 79438292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944c2939121Smrg *) 7945c2939121Smrg abs_ladir=`cd "$ladir" && pwd` 7946c2939121Smrg if test -z "$abs_ladir"; then 79478292847cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 7948c2939121Smrg func_warning "passing it literally to the linker, although it might fail" 79498292847cSmrg abs_ladir=$ladir 7950c2939121Smrg fi 7951c2939121Smrg ;; 7952c2939121Smrg esac 7953c2939121Smrg func_basename "$lib" 79548292847cSmrg laname=$func_basename_result 7955c2939121Smrg 7956c2939121Smrg # Find the relevant object directory and library name. 79578292847cSmrg if test yes = "$installed"; then 79582836776bSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 79598292847cSmrg func_warning "library '$lib' was moved." 79608292847cSmrg dir=$ladir 79618292847cSmrg absdir=$abs_ladir 79628292847cSmrg libdir=$abs_ladir 7963c2939121Smrg else 79648292847cSmrg dir=$lt_sysroot$libdir 79658292847cSmrg absdir=$lt_sysroot$libdir 7966c2939121Smrg fi 79678292847cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968c2939121Smrg else 7969c2939121Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 79708292847cSmrg dir=$ladir 79718292847cSmrg absdir=$abs_ladir 7972c2939121Smrg # Remove this search path later 79732836776bSmrg func_append notinst_path " $abs_ladir" 7974c2939121Smrg else 79758292847cSmrg dir=$ladir/$objdir 79768292847cSmrg absdir=$abs_ladir/$objdir 7977c2939121Smrg # Remove this search path later 79782836776bSmrg func_append notinst_path " $abs_ladir" 7979c2939121Smrg fi 7980c2939121Smrg fi # $installed = yes 7981c2939121Smrg func_stripname 'lib' '.la' "$laname" 7982c2939121Smrg name=$func_stripname_result 7983c2939121Smrg 7984c2939121Smrg # This library was specified with -dlpreopen. 79858292847cSmrg if test dlpreopen = "$pass"; then 79868292847cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 79878292847cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988c2939121Smrg fi 79898292847cSmrg case $host in 79902836776bSmrg # special handling for platforms with PE-DLLs. 79912836776bSmrg *cygwin* | *mingw* | *cegcc* ) 79922836776bSmrg # Linker will automatically link against shared library if both 79932836776bSmrg # static and shared are present. Therefore, ensure we extract 79942836776bSmrg # symbols from the import library if a shared library is present 79952836776bSmrg # (otherwise, the dlopen module name will be incorrect). We do 79962836776bSmrg # this by putting the import library name into $newdlprefiles. 79972836776bSmrg # We recover the dlopen module name by 'saving' the la file 79982836776bSmrg # name in a special purpose variable, and (later) extracting the 79992836776bSmrg # dlname from the la file. 80002836776bSmrg if test -n "$dlname"; then 80012836776bSmrg func_tr_sh "$dir/$linklib" 80022836776bSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 80032836776bSmrg func_append newdlprefiles " $dir/$linklib" 80042836776bSmrg else 80052836776bSmrg func_append newdlprefiles " $dir/$old_library" 80062836776bSmrg # Keep a list of preopened convenience libraries to check 80072836776bSmrg # that they are being used correctly in the link pass. 80082836776bSmrg test -z "$libdir" && \ 80092836776bSmrg func_append dlpreconveniencelibs " $dir/$old_library" 80102836776bSmrg fi 80112836776bSmrg ;; 80122836776bSmrg * ) 80132836776bSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 80142836776bSmrg # are required to link). 80152836776bSmrg if test -n "$old_library"; then 80162836776bSmrg func_append newdlprefiles " $dir/$old_library" 80172836776bSmrg # Keep a list of preopened convenience libraries to check 80182836776bSmrg # that they are being used correctly in the link pass. 80192836776bSmrg test -z "$libdir" && \ 80202836776bSmrg func_append dlpreconveniencelibs " $dir/$old_library" 80212836776bSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 80222836776bSmrg elif test -n "$dlname"; then 80232836776bSmrg func_append newdlprefiles " $dir/$dlname" 80242836776bSmrg else 80252836776bSmrg func_append newdlprefiles " $dir/$linklib" 80262836776bSmrg fi 80272836776bSmrg ;; 80282836776bSmrg esac 8029c2939121Smrg fi # $pass = dlpreopen 8030c2939121Smrg 8031c2939121Smrg if test -z "$libdir"; then 8032c2939121Smrg # Link the convenience library 80338292847cSmrg if test lib = "$linkmode"; then 8034c2939121Smrg deplibs="$dir/$old_library $deplibs" 80358292847cSmrg elif test prog,link = "$linkmode,$pass"; then 8036c2939121Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8037c2939121Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038c2939121Smrg else 8039c2939121Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8040c2939121Smrg fi 8041c2939121Smrg continue 8042c2939121Smrg fi 8043c2939121Smrg 8044c2939121Smrg 80458292847cSmrg if test prog = "$linkmode" && test link != "$pass"; then 80462836776bSmrg func_append newlib_search_path " $ladir" 8047c2939121Smrg deplibs="$lib $deplibs" 8048c2939121Smrg 80498292847cSmrg linkalldeplibs=false 80508292847cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 80518292847cSmrg test no = "$build_libtool_libs"; then 80528292847cSmrg linkalldeplibs=: 8053c2939121Smrg fi 8054c2939121Smrg 8055c2939121Smrg tmp_libs= 8056c2939121Smrg for deplib in $dependency_libs; do 8057c2939121Smrg case $deplib in 8058c2939121Smrg -L*) func_stripname '-L' '' "$deplib" 80592836776bSmrg func_resolve_sysroot "$func_stripname_result" 80602836776bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8061c2939121Smrg ;; 8062c2939121Smrg esac 8063c2939121Smrg # Need to link against all dependency_libs? 80648292847cSmrg if $linkalldeplibs; then 8065c2939121Smrg deplibs="$deplib $deplibs" 8066c2939121Smrg else 8067c2939121Smrg # Need to hardcode shared library paths 8068c2939121Smrg # or/and link against static libraries 8069c2939121Smrg newdependency_libs="$deplib $newdependency_libs" 8070c2939121Smrg fi 80718292847cSmrg if $opt_preserve_dup_deps; then 8072c2939121Smrg case "$tmp_libs " in 80732836776bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074c2939121Smrg esac 8075c2939121Smrg fi 80762836776bSmrg func_append tmp_libs " $deplib" 8077c2939121Smrg done # for deplib 8078c2939121Smrg continue 8079c2939121Smrg fi # $linkmode = prog... 8080c2939121Smrg 80818292847cSmrg if test prog,link = "$linkmode,$pass"; then 8082c2939121Smrg if test -n "$library_names" && 80838292847cSmrg { { test no = "$prefer_static_libs" || 80848292847cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8085c2939121Smrg test -z "$old_library"; }; then 8086c2939121Smrg # We need to hardcode the library path 80878292847cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088c2939121Smrg # Make sure the rpath contains only unique directories. 80898292847cSmrg case $temp_rpath: in 8090c2939121Smrg *"$absdir:"*) ;; 80912836776bSmrg *) func_append temp_rpath "$absdir:" ;; 8092c2939121Smrg esac 8093c2939121Smrg fi 8094c2939121Smrg 8095c2939121Smrg # Hardcode the library path. 8096c2939121Smrg # Skip directories that are in the system default run-time 8097c2939121Smrg # search path. 8098c2939121Smrg case " $sys_lib_dlsearch_path " in 8099c2939121Smrg *" $absdir "*) ;; 8100c2939121Smrg *) 8101c2939121Smrg case "$compile_rpath " in 8102c2939121Smrg *" $absdir "*) ;; 81032836776bSmrg *) func_append compile_rpath " $absdir" ;; 8104c2939121Smrg esac 8105c2939121Smrg ;; 8106c2939121Smrg esac 8107c2939121Smrg case " $sys_lib_dlsearch_path " in 8108c2939121Smrg *" $libdir "*) ;; 8109c2939121Smrg *) 8110c2939121Smrg case "$finalize_rpath " in 8111c2939121Smrg *" $libdir "*) ;; 81122836776bSmrg *) func_append finalize_rpath " $libdir" ;; 8113c2939121Smrg esac 8114c2939121Smrg ;; 8115c2939121Smrg esac 8116c2939121Smrg fi # $linkmode,$pass = prog,link... 8117c2939121Smrg 81188292847cSmrg if $alldeplibs && 81198292847cSmrg { test pass_all = "$deplibs_check_method" || 81208292847cSmrg { test yes = "$build_libtool_libs" && 8121c2939121Smrg test -n "$library_names"; }; }; then 8122c2939121Smrg # We only need to search for static libraries 8123c2939121Smrg continue 8124c2939121Smrg fi 8125c2939121Smrg fi 8126c2939121Smrg 8127c2939121Smrg link_static=no # Whether the deplib will be linked statically 8128c2939121Smrg use_static_libs=$prefer_static_libs 81298292847cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8130c2939121Smrg use_static_libs=no 8131c2939121Smrg fi 8132c2939121Smrg if test -n "$library_names" && 81338292847cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134c2939121Smrg case $host in 81358292847cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8136c2939121Smrg # No point in relinking DLLs because paths are not encoded 81372836776bSmrg func_append notinst_deplibs " $lib" 8138c2939121Smrg need_relink=no 8139c2939121Smrg ;; 8140c2939121Smrg *) 81418292847cSmrg if test no = "$installed"; then 81422836776bSmrg func_append notinst_deplibs " $lib" 8143c2939121Smrg need_relink=yes 8144c2939121Smrg fi 8145c2939121Smrg ;; 8146c2939121Smrg esac 8147c2939121Smrg # This is a shared library 8148c2939121Smrg 8149c2939121Smrg # Warn about portability, can't link against -module's on some 8150c2939121Smrg # systems (darwin). Don't bleat about dlopened modules though! 81518292847cSmrg dlopenmodule= 8152c2939121Smrg for dlpremoduletest in $dlprefiles; do 8153c2939121Smrg if test "X$dlpremoduletest" = "X$lib"; then 81548292847cSmrg dlopenmodule=$dlpremoduletest 8155c2939121Smrg break 8156c2939121Smrg fi 8157c2939121Smrg done 81588292847cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159c2939121Smrg echo 81608292847cSmrg if test prog = "$linkmode"; then 8161c2939121Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162c2939121Smrg else 8163c2939121Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164c2939121Smrg fi 8165c2939121Smrg $ECHO "*** $linklib is not portable!" 8166c2939121Smrg fi 81678292847cSmrg if test lib = "$linkmode" && 81688292847cSmrg test yes = "$hardcode_into_libs"; then 8169c2939121Smrg # Hardcode the library path. 8170c2939121Smrg # Skip directories that are in the system default run-time 8171c2939121Smrg # search path. 8172c2939121Smrg case " $sys_lib_dlsearch_path " in 8173c2939121Smrg *" $absdir "*) ;; 8174c2939121Smrg *) 8175c2939121Smrg case "$compile_rpath " in 8176c2939121Smrg *" $absdir "*) ;; 81772836776bSmrg *) func_append compile_rpath " $absdir" ;; 8178c2939121Smrg esac 8179c2939121Smrg ;; 8180c2939121Smrg esac 8181c2939121Smrg case " $sys_lib_dlsearch_path " in 8182c2939121Smrg *" $libdir "*) ;; 8183c2939121Smrg *) 8184c2939121Smrg case "$finalize_rpath " in 8185c2939121Smrg *" $libdir "*) ;; 81862836776bSmrg *) func_append finalize_rpath " $libdir" ;; 8187c2939121Smrg esac 8188c2939121Smrg ;; 8189c2939121Smrg esac 8190c2939121Smrg fi 8191c2939121Smrg 8192c2939121Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8193c2939121Smrg # figure out the soname 8194c2939121Smrg set dummy $library_names 8195c2939121Smrg shift 81968292847cSmrg realname=$1 8197c2939121Smrg shift 8198c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8199c2939121Smrg # use dlname if we got it. it's perfectly good, no? 8200c2939121Smrg if test -n "$dlname"; then 82018292847cSmrg soname=$dlname 8202c2939121Smrg elif test -n "$soname_spec"; then 8203c2939121Smrg # bleh windows 8204c2939121Smrg case $host in 82058292847cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8206c2939121Smrg func_arith $current - $age 8207c2939121Smrg major=$func_arith_result 82088292847cSmrg versuffix=-$major 8209c2939121Smrg ;; 8210c2939121Smrg esac 8211c2939121Smrg eval soname=\"$soname_spec\" 8212c2939121Smrg else 82138292847cSmrg soname=$realname 8214c2939121Smrg fi 8215c2939121Smrg 8216c2939121Smrg # Make a new name for the extract_expsyms_cmds to use 82178292847cSmrg soroot=$soname 8218c2939121Smrg func_basename "$soroot" 82198292847cSmrg soname=$func_basename_result 8220c2939121Smrg func_stripname 'lib' '.dll' "$soname" 8221c2939121Smrg newlib=libimp-$func_stripname_result.a 8222c2939121Smrg 8223c2939121Smrg # If the library has no export list, then create one now 8224c2939121Smrg if test -f "$output_objdir/$soname-def"; then : 8225c2939121Smrg else 82268292847cSmrg func_verbose "extracting exported symbol list from '$soname'" 8227c2939121Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228c2939121Smrg fi 8229c2939121Smrg 8230c2939121Smrg # Create $newlib 8231c2939121Smrg if test -f "$output_objdir/$newlib"; then :; else 82328292847cSmrg func_verbose "generating import library for '$soname'" 8233c2939121Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234c2939121Smrg fi 8235c2939121Smrg # make sure the library variables are pointing to the new library 8236c2939121Smrg dir=$output_objdir 8237c2939121Smrg linklib=$newlib 8238c2939121Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8239c2939121Smrg 82408292847cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241c2939121Smrg add_shlibpath= 8242c2939121Smrg add_dir= 8243c2939121Smrg add= 8244c2939121Smrg lib_linked=yes 8245c2939121Smrg case $hardcode_action in 8246c2939121Smrg immediate | unsupported) 82478292847cSmrg if test no = "$hardcode_direct"; then 82488292847cSmrg add=$dir/$linklib 8249c2939121Smrg case $host in 82508292847cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 82518292847cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252c2939121Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 82538292847cSmrg *-*-unixware7*) add_dir=-L$dir ;; 8254c2939121Smrg *-*-darwin* ) 82558292847cSmrg # if the lib is a (non-dlopened) module then we cannot 8256c2939121Smrg # link against it, someone is ignoring the earlier warnings 8257c2939121Smrg if /usr/bin/file -L $add 2> /dev/null | 82588292847cSmrg $GREP ": [^:]* bundle" >/dev/null; then 8259c2939121Smrg if test "X$dlopenmodule" != "X$lib"; then 8260c2939121Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 82618292847cSmrg if test -z "$old_library"; then 8262c2939121Smrg echo 8263c2939121Smrg echo "*** And there doesn't seem to be a static archive available" 8264c2939121Smrg echo "*** The link will probably fail, sorry" 8265c2939121Smrg else 82668292847cSmrg add=$dir/$old_library 8267c2939121Smrg fi 8268c2939121Smrg elif test -n "$old_library"; then 82698292847cSmrg add=$dir/$old_library 8270c2939121Smrg fi 8271c2939121Smrg fi 8272c2939121Smrg esac 82738292847cSmrg elif test no = "$hardcode_minus_L"; then 8274c2939121Smrg case $host in 82758292847cSmrg *-*-sunos*) add_shlibpath=$dir ;; 8276c2939121Smrg esac 82778292847cSmrg add_dir=-L$dir 82788292847cSmrg add=-l$name 82798292847cSmrg elif test no = "$hardcode_shlibpath_var"; then 82808292847cSmrg add_shlibpath=$dir 82818292847cSmrg add=-l$name 8282c2939121Smrg else 8283c2939121Smrg lib_linked=no 8284c2939121Smrg fi 8285c2939121Smrg ;; 8286c2939121Smrg relink) 82878292847cSmrg if test yes = "$hardcode_direct" && 82888292847cSmrg test no = "$hardcode_direct_absolute"; then 82898292847cSmrg add=$dir/$linklib 82908292847cSmrg elif test yes = "$hardcode_minus_L"; then 82918292847cSmrg add_dir=-L$absdir 8292c2939121Smrg # Try looking first in the location we're being installed to. 8293c2939121Smrg if test -n "$inst_prefix_dir"; then 8294c2939121Smrg case $libdir in 8295c2939121Smrg [\\/]*) 82962836776bSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8297c2939121Smrg ;; 8298c2939121Smrg esac 8299c2939121Smrg fi 83008292847cSmrg add=-l$name 83018292847cSmrg elif test yes = "$hardcode_shlibpath_var"; then 83028292847cSmrg add_shlibpath=$dir 83038292847cSmrg add=-l$name 8304c2939121Smrg else 8305c2939121Smrg lib_linked=no 8306c2939121Smrg fi 8307c2939121Smrg ;; 8308c2939121Smrg *) lib_linked=no ;; 8309c2939121Smrg esac 8310c2939121Smrg 83118292847cSmrg if test yes != "$lib_linked"; then 8312c2939121Smrg func_fatal_configuration "unsupported hardcode properties" 8313c2939121Smrg fi 8314c2939121Smrg 8315c2939121Smrg if test -n "$add_shlibpath"; then 8316c2939121Smrg case :$compile_shlibpath: in 8317c2939121Smrg *":$add_shlibpath:"*) ;; 83182836776bSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319c2939121Smrg esac 8320c2939121Smrg fi 83218292847cSmrg if test prog = "$linkmode"; then 8322c2939121Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323c2939121Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324c2939121Smrg else 8325c2939121Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326c2939121Smrg test -n "$add" && deplibs="$add $deplibs" 83278292847cSmrg if test yes != "$hardcode_direct" && 83288292847cSmrg test yes != "$hardcode_minus_L" && 83298292847cSmrg test yes = "$hardcode_shlibpath_var"; then 8330c2939121Smrg case :$finalize_shlibpath: in 8331c2939121Smrg *":$libdir:"*) ;; 83322836776bSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8333c2939121Smrg esac 8334c2939121Smrg fi 8335c2939121Smrg fi 8336c2939121Smrg fi 8337c2939121Smrg 83388292847cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339c2939121Smrg add_shlibpath= 8340c2939121Smrg add_dir= 8341c2939121Smrg add= 8342c2939121Smrg # Finalize command for both is simple: just hardcode it. 83438292847cSmrg if test yes = "$hardcode_direct" && 83448292847cSmrg test no = "$hardcode_direct_absolute"; then 83458292847cSmrg add=$libdir/$linklib 83468292847cSmrg elif test yes = "$hardcode_minus_L"; then 83478292847cSmrg add_dir=-L$libdir 83488292847cSmrg add=-l$name 83498292847cSmrg elif test yes = "$hardcode_shlibpath_var"; then 8350c2939121Smrg case :$finalize_shlibpath: in 8351c2939121Smrg *":$libdir:"*) ;; 83522836776bSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8353c2939121Smrg esac 83548292847cSmrg add=-l$name 83558292847cSmrg elif test yes = "$hardcode_automatic"; then 8356c2939121Smrg if test -n "$inst_prefix_dir" && 83578292847cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 83588292847cSmrg add=$inst_prefix_dir$libdir/$linklib 8359c2939121Smrg else 83608292847cSmrg add=$libdir/$linklib 8361c2939121Smrg fi 8362c2939121Smrg else 8363c2939121Smrg # We cannot seem to hardcode it, guess we'll fake it. 83648292847cSmrg add_dir=-L$libdir 8365c2939121Smrg # Try looking first in the location we're being installed to. 8366c2939121Smrg if test -n "$inst_prefix_dir"; then 8367c2939121Smrg case $libdir in 8368c2939121Smrg [\\/]*) 83692836776bSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8370c2939121Smrg ;; 8371c2939121Smrg esac 8372c2939121Smrg fi 83738292847cSmrg add=-l$name 8374c2939121Smrg fi 8375c2939121Smrg 83768292847cSmrg if test prog = "$linkmode"; then 8377c2939121Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378c2939121Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379c2939121Smrg else 8380c2939121Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381c2939121Smrg test -n "$add" && deplibs="$add $deplibs" 8382c2939121Smrg fi 8383c2939121Smrg fi 83848292847cSmrg elif test prog = "$linkmode"; then 8385c2939121Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8386c2939121Smrg # is not unsupported. This is valid on all known static and 8387c2939121Smrg # shared platforms. 83888292847cSmrg if test unsupported != "$hardcode_direct"; then 83898292847cSmrg test -n "$old_library" && linklib=$old_library 8390c2939121Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8391c2939121Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392c2939121Smrg else 8393c2939121Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8394c2939121Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395c2939121Smrg fi 83968292847cSmrg elif test yes = "$build_libtool_libs"; then 8397c2939121Smrg # Not a shared library 83988292847cSmrg if test pass_all != "$deplibs_check_method"; then 8399c2939121Smrg # We're trying link a shared library against a static one 8400c2939121Smrg # but the system doesn't support it. 8401c2939121Smrg 8402c2939121Smrg # Just print a warning and add the library to dependency_libs so 8403c2939121Smrg # that the program can be linked against the static library. 8404c2939121Smrg echo 84058292847cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 8407c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 8408c2939121Smrg echo "*** shared version of the library, which you do not appear to have." 84098292847cSmrg if test yes = "$module"; then 8410c2939121Smrg echo "*** But as you try to build a module library, libtool will still create " 8411c2939121Smrg echo "*** a static module, that should work as long as the dlopening application" 8412c2939121Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413c2939121Smrg if test -z "$global_symbol_pipe"; then 8414c2939121Smrg echo 8415c2939121Smrg echo "*** However, this would only work if libtool was able to extract symbol" 84168292847cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417c2939121Smrg echo "*** not find such a program. So, this module is probably useless." 84188292847cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419c2939121Smrg fi 84208292847cSmrg if test no = "$build_old_libs"; then 8421c2939121Smrg build_libtool_libs=module 8422c2939121Smrg build_old_libs=yes 8423c2939121Smrg else 8424c2939121Smrg build_libtool_libs=no 8425c2939121Smrg fi 8426c2939121Smrg fi 8427c2939121Smrg else 8428c2939121Smrg deplibs="$dir/$old_library $deplibs" 8429c2939121Smrg link_static=yes 8430c2939121Smrg fi 8431c2939121Smrg fi # link shared/static library? 8432c2939121Smrg 84338292847cSmrg if test lib = "$linkmode"; then 8434c2939121Smrg if test -n "$dependency_libs" && 84358292847cSmrg { test yes != "$hardcode_into_libs" || 84368292847cSmrg test yes = "$build_old_libs" || 84378292847cSmrg test yes = "$link_static"; }; then 8438c2939121Smrg # Extract -R from dependency_libs 8439c2939121Smrg temp_deplibs= 8440c2939121Smrg for libdir in $dependency_libs; do 8441c2939121Smrg case $libdir in 8442c2939121Smrg -R*) func_stripname '-R' '' "$libdir" 8443c2939121Smrg temp_xrpath=$func_stripname_result 8444c2939121Smrg case " $xrpath " in 8445c2939121Smrg *" $temp_xrpath "*) ;; 84462836776bSmrg *) func_append xrpath " $temp_xrpath";; 8447c2939121Smrg esac;; 84482836776bSmrg *) func_append temp_deplibs " $libdir";; 8449c2939121Smrg esac 8450c2939121Smrg done 84518292847cSmrg dependency_libs=$temp_deplibs 8452c2939121Smrg fi 8453c2939121Smrg 84542836776bSmrg func_append newlib_search_path " $absdir" 8455c2939121Smrg # Link against this library 84568292847cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457c2939121Smrg # ... and its dependency_libs 8458c2939121Smrg tmp_libs= 8459c2939121Smrg for deplib in $dependency_libs; do 8460c2939121Smrg newdependency_libs="$deplib $newdependency_libs" 84612836776bSmrg case $deplib in 84622836776bSmrg -L*) func_stripname '-L' '' "$deplib" 84632836776bSmrg func_resolve_sysroot "$func_stripname_result";; 84642836776bSmrg *) func_resolve_sysroot "$deplib" ;; 84652836776bSmrg esac 84668292847cSmrg if $opt_preserve_dup_deps; then 8467c2939121Smrg case "$tmp_libs " in 84682836776bSmrg *" $func_resolve_sysroot_result "*) 84692836776bSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470c2939121Smrg esac 8471c2939121Smrg fi 84722836776bSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8473c2939121Smrg done 8474c2939121Smrg 84758292847cSmrg if test no != "$link_all_deplibs"; then 8476c2939121Smrg # Add the search paths of all dependency libraries 8477c2939121Smrg for deplib in $dependency_libs; do 8478c2939121Smrg path= 8479c2939121Smrg case $deplib in 84808292847cSmrg -L*) path=$deplib ;; 8481c2939121Smrg *.la) 84822836776bSmrg func_resolve_sysroot "$deplib" 84832836776bSmrg deplib=$func_resolve_sysroot_result 8484c2939121Smrg func_dirname "$deplib" "" "." 84852836776bSmrg dir=$func_dirname_result 8486c2939121Smrg # We need an absolute path. 8487c2939121Smrg case $dir in 84888292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489c2939121Smrg *) 8490c2939121Smrg absdir=`cd "$dir" && pwd` 8491c2939121Smrg if test -z "$absdir"; then 84928292847cSmrg func_warning "cannot determine absolute directory name of '$dir'" 84938292847cSmrg absdir=$dir 8494c2939121Smrg fi 8495c2939121Smrg ;; 8496c2939121Smrg esac 8497c2939121Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8498c2939121Smrg case $host in 8499c2939121Smrg *-*-darwin*) 8500c2939121Smrg depdepl= 85018292847cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 85028292847cSmrg if test -n "$deplibrary_names"; then 85038292847cSmrg for tmp in $deplibrary_names; do 8504c2939121Smrg depdepl=$tmp 8505c2939121Smrg done 85068292847cSmrg if test -f "$absdir/$objdir/$depdepl"; then 85078292847cSmrg depdepl=$absdir/$objdir/$depdepl 85088292847cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509c2939121Smrg if test -z "$darwin_install_name"; then 85108292847cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511c2939121Smrg fi 85128292847cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 85138292847cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514c2939121Smrg path= 8515c2939121Smrg fi 8516c2939121Smrg fi 8517c2939121Smrg ;; 8518c2939121Smrg *) 85198292847cSmrg path=-L$absdir/$objdir 8520c2939121Smrg ;; 8521c2939121Smrg esac 8522c2939121Smrg else 85238292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524c2939121Smrg test -z "$libdir" && \ 85258292847cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8526c2939121Smrg test "$absdir" != "$libdir" && \ 85278292847cSmrg func_warning "'$deplib' seems to be moved" 8528c2939121Smrg 85298292847cSmrg path=-L$absdir 8530c2939121Smrg fi 8531c2939121Smrg ;; 8532c2939121Smrg esac 8533c2939121Smrg case " $deplibs " in 8534c2939121Smrg *" $path "*) ;; 8535c2939121Smrg *) deplibs="$path $deplibs" ;; 8536c2939121Smrg esac 8537c2939121Smrg done 8538c2939121Smrg fi # link_all_deplibs != no 8539c2939121Smrg fi # linkmode = lib 8540c2939121Smrg done # for deplib in $libs 85418292847cSmrg if test link = "$pass"; then 85428292847cSmrg if test prog = "$linkmode"; then 8543c2939121Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544c2939121Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545c2939121Smrg else 8546c2939121Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547c2939121Smrg fi 8548c2939121Smrg fi 85498292847cSmrg dependency_libs=$newdependency_libs 85508292847cSmrg if test dlpreopen = "$pass"; then 8551c2939121Smrg # Link the dlpreopened libraries before other libraries 8552c2939121Smrg for deplib in $save_deplibs; do 8553c2939121Smrg deplibs="$deplib $deplibs" 8554c2939121Smrg done 8555c2939121Smrg fi 85568292847cSmrg if test dlopen != "$pass"; then 85578292847cSmrg test conv = "$pass" || { 8558c2939121Smrg # Make sure lib_search_path contains only unique directories. 8559c2939121Smrg lib_search_path= 8560c2939121Smrg for dir in $newlib_search_path; do 8561c2939121Smrg case "$lib_search_path " in 8562c2939121Smrg *" $dir "*) ;; 85632836776bSmrg *) func_append lib_search_path " $dir" ;; 8564c2939121Smrg esac 8565c2939121Smrg done 8566c2939121Smrg newlib_search_path= 85678292847cSmrg } 8568c2939121Smrg 85698292847cSmrg if test prog,link = "$linkmode,$pass"; then 8570c2939121Smrg vars="compile_deplibs finalize_deplibs" 85718292847cSmrg else 85728292847cSmrg vars=deplibs 8573c2939121Smrg fi 8574c2939121Smrg for var in $vars dependency_libs; do 8575c2939121Smrg # Add libraries to $var in reverse order 8576c2939121Smrg eval tmp_libs=\"\$$var\" 8577c2939121Smrg new_libs= 8578c2939121Smrg for deplib in $tmp_libs; do 8579c2939121Smrg # FIXME: Pedantically, this is the right thing to do, so 8580c2939121Smrg # that some nasty dependency loop isn't accidentally 8581c2939121Smrg # broken: 8582c2939121Smrg #new_libs="$deplib $new_libs" 8583c2939121Smrg # Pragmatically, this seems to cause very few problems in 8584c2939121Smrg # practice: 8585c2939121Smrg case $deplib in 8586c2939121Smrg -L*) new_libs="$deplib $new_libs" ;; 8587c2939121Smrg -R*) ;; 8588c2939121Smrg *) 8589c2939121Smrg # And here is the reason: when a library appears more 8590c2939121Smrg # than once as an explicit dependence of a library, or 8591c2939121Smrg # is implicitly linked in more than once by the 8592c2939121Smrg # compiler, it is considered special, and multiple 8593c2939121Smrg # occurrences thereof are not removed. Compare this 8594c2939121Smrg # with having the same library being listed as a 8595c2939121Smrg # dependency of multiple other libraries: in this case, 8596c2939121Smrg # we know (pedantically, we assume) the library does not 8597c2939121Smrg # need to be listed more than once, so we keep only the 8598c2939121Smrg # last copy. This is not always right, but it is rare 8599c2939121Smrg # enough that we require users that really mean to play 8600c2939121Smrg # such unportable linking tricks to link the library 8601c2939121Smrg # using -Wl,-lname, so that libtool does not consider it 8602c2939121Smrg # for duplicate removal. 8603c2939121Smrg case " $specialdeplibs " in 8604c2939121Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605c2939121Smrg *) 8606c2939121Smrg case " $new_libs " in 8607c2939121Smrg *" $deplib "*) ;; 8608c2939121Smrg *) new_libs="$deplib $new_libs" ;; 8609c2939121Smrg esac 8610c2939121Smrg ;; 8611c2939121Smrg esac 8612c2939121Smrg ;; 8613c2939121Smrg esac 8614c2939121Smrg done 8615c2939121Smrg tmp_libs= 8616c2939121Smrg for deplib in $new_libs; do 8617c2939121Smrg case $deplib in 8618c2939121Smrg -L*) 8619c2939121Smrg case " $tmp_libs " in 8620c2939121Smrg *" $deplib "*) ;; 86212836776bSmrg *) func_append tmp_libs " $deplib" ;; 8622c2939121Smrg esac 8623c2939121Smrg ;; 86242836776bSmrg *) func_append tmp_libs " $deplib" ;; 8625c2939121Smrg esac 8626c2939121Smrg done 8627c2939121Smrg eval $var=\"$tmp_libs\" 8628c2939121Smrg done # for var 8629c2939121Smrg fi 86308292847cSmrg 86318292847cSmrg # Add Sun CC postdeps if required: 86328292847cSmrg test CXX = "$tagname" && { 86338292847cSmrg case $host_os in 86348292847cSmrg linux*) 86358292847cSmrg case `$CC -V 2>&1 | sed 5q` in 86368292847cSmrg *Sun\ C*) # Sun C++ 5.9 86378292847cSmrg func_suncc_cstd_abi 86388292847cSmrg 86398292847cSmrg if test no != "$suncc_use_cstd_abi"; then 86408292847cSmrg func_append postdeps ' -library=Cstd -library=Crun' 86418292847cSmrg fi 86428292847cSmrg ;; 86438292847cSmrg esac 86448292847cSmrg ;; 86458292847cSmrg 86468292847cSmrg solaris*) 86478292847cSmrg func_cc_basename "$CC" 86488292847cSmrg case $func_cc_basename_result in 86498292847cSmrg CC* | sunCC*) 86508292847cSmrg func_suncc_cstd_abi 86518292847cSmrg 86528292847cSmrg if test no != "$suncc_use_cstd_abi"; then 86538292847cSmrg func_append postdeps ' -library=Cstd -library=Crun' 86548292847cSmrg fi 86558292847cSmrg ;; 86568292847cSmrg esac 86578292847cSmrg ;; 86588292847cSmrg esac 86598292847cSmrg } 86608292847cSmrg 8661c2939121Smrg # Last step: remove runtime libs from dependency_libs 8662c2939121Smrg # (they stay in deplibs) 8663c2939121Smrg tmp_libs= 86648292847cSmrg for i in $dependency_libs; do 8665c2939121Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8666c2939121Smrg *" $i "*) 86678292847cSmrg i= 8668c2939121Smrg ;; 8669c2939121Smrg esac 86708292847cSmrg if test -n "$i"; then 86712836776bSmrg func_append tmp_libs " $i" 8672c2939121Smrg fi 8673c2939121Smrg done 8674c2939121Smrg dependency_libs=$tmp_libs 8675c2939121Smrg done # for pass 86768292847cSmrg if test prog = "$linkmode"; then 86778292847cSmrg dlfiles=$newdlfiles 8678c2939121Smrg fi 86798292847cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 86808292847cSmrg dlprefiles=$newdlprefiles 8681c2939121Smrg fi 8682c2939121Smrg 8683c2939121Smrg case $linkmode in 8684c2939121Smrg oldlib) 86858292847cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 86868292847cSmrg func_warning "'-dlopen' is ignored for archives" 8687c2939121Smrg fi 8688c2939121Smrg 8689c2939121Smrg case " $deplibs" in 8690c2939121Smrg *\ -l* | *\ -L*) 86918292847cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8692c2939121Smrg esac 8693c2939121Smrg 8694c2939121Smrg test -n "$rpath" && \ 86958292847cSmrg func_warning "'-rpath' is ignored for archives" 8696c2939121Smrg 8697c2939121Smrg test -n "$xrpath" && \ 86988292847cSmrg func_warning "'-R' is ignored for archives" 8699c2939121Smrg 8700c2939121Smrg test -n "$vinfo" && \ 87018292847cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8702c2939121Smrg 8703c2939121Smrg test -n "$release" && \ 87048292847cSmrg func_warning "'-release' is ignored for archives" 8705c2939121Smrg 8706c2939121Smrg test -n "$export_symbols$export_symbols_regex" && \ 87078292847cSmrg func_warning "'-export-symbols' is ignored for archives" 8708c2939121Smrg 8709c2939121Smrg # Now set the variables for building old libraries. 8710c2939121Smrg build_libtool_libs=no 87118292847cSmrg oldlibs=$output 87122836776bSmrg func_append objs "$old_deplibs" 8713c2939121Smrg ;; 8714c2939121Smrg 8715c2939121Smrg lib) 87168292847cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8717c2939121Smrg case $outputname in 8718c2939121Smrg lib*) 8719c2939121Smrg func_stripname 'lib' '.la' "$outputname" 8720c2939121Smrg name=$func_stripname_result 8721c2939121Smrg eval shared_ext=\"$shrext_cmds\" 8722c2939121Smrg eval libname=\"$libname_spec\" 8723c2939121Smrg ;; 8724c2939121Smrg *) 87258292847cSmrg test no = "$module" \ 87268292847cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727c2939121Smrg 87288292847cSmrg if test no != "$need_lib_prefix"; then 8729c2939121Smrg # Add the "lib" prefix for modules if required 8730c2939121Smrg func_stripname '' '.la' "$outputname" 8731c2939121Smrg name=$func_stripname_result 8732c2939121Smrg eval shared_ext=\"$shrext_cmds\" 8733c2939121Smrg eval libname=\"$libname_spec\" 8734c2939121Smrg else 8735c2939121Smrg func_stripname '' '.la' "$outputname" 8736c2939121Smrg libname=$func_stripname_result 8737c2939121Smrg fi 8738c2939121Smrg ;; 8739c2939121Smrg esac 8740c2939121Smrg 8741c2939121Smrg if test -n "$objs"; then 87428292847cSmrg if test pass_all != "$deplibs_check_method"; then 87438292847cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744c2939121Smrg else 8745c2939121Smrg echo 8746c2939121Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747c2939121Smrg $ECHO "*** objects $objs is not portable!" 87482836776bSmrg func_append libobjs " $objs" 8749c2939121Smrg fi 8750c2939121Smrg fi 8751c2939121Smrg 87528292847cSmrg test no = "$dlself" \ 87538292847cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8754c2939121Smrg 8755c2939121Smrg set dummy $rpath 8756c2939121Smrg shift 87578292847cSmrg test 1 -lt "$#" \ 87588292847cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8759c2939121Smrg 87608292847cSmrg install_libdir=$1 8761c2939121Smrg 8762c2939121Smrg oldlibs= 8763c2939121Smrg if test -z "$rpath"; then 87648292847cSmrg if test yes = "$build_libtool_libs"; then 8765c2939121Smrg # Building a libtool convenience library. 87668292847cSmrg # Some compilers have problems with a '.al' extension so 8767c2939121Smrg # convenience libraries should have the same extension an 8768c2939121Smrg # archive normally would. 8769c2939121Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770c2939121Smrg build_libtool_libs=convenience 8771c2939121Smrg build_old_libs=yes 8772c2939121Smrg fi 8773c2939121Smrg 8774c2939121Smrg test -n "$vinfo" && \ 87758292847cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776c2939121Smrg 8777c2939121Smrg test -n "$release" && \ 87788292847cSmrg func_warning "'-release' is ignored for convenience libraries" 8779c2939121Smrg else 8780c2939121Smrg 8781c2939121Smrg # Parse the version information argument. 87828292847cSmrg save_ifs=$IFS; IFS=: 8783c2939121Smrg set dummy $vinfo 0 0 0 8784c2939121Smrg shift 87858292847cSmrg IFS=$save_ifs 8786c2939121Smrg 8787c2939121Smrg test -n "$7" && \ 87888292847cSmrg func_fatal_help "too many parameters to '-version-info'" 8789c2939121Smrg 8790c2939121Smrg # convert absolute version numbers to libtool ages 8791c2939121Smrg # this retains compatibility with .la files and attempts 8792c2939121Smrg # to make the code below a bit more comprehensible 8793c2939121Smrg 8794c2939121Smrg case $vinfo_number in 8795c2939121Smrg yes) 87968292847cSmrg number_major=$1 87978292847cSmrg number_minor=$2 87988292847cSmrg number_revision=$3 8799c2939121Smrg # 8800c2939121Smrg # There are really only two kinds -- those that 8801c2939121Smrg # use the current revision as the major version 8802c2939121Smrg # and those that subtract age and use age as 8803c2939121Smrg # a minor version. But, then there is irix 88048292847cSmrg # that has an extra 1 added just for fun 8805c2939121Smrg # 8806c2939121Smrg case $version_type in 88072836776bSmrg # correct linux to gnu/linux during the next big refactor 88088292847cSmrg darwin|freebsd-elf|linux|osf|windows|none) 8809c2939121Smrg func_arith $number_major + $number_minor 8810c2939121Smrg current=$func_arith_result 88118292847cSmrg age=$number_minor 88128292847cSmrg revision=$number_revision 8813c2939121Smrg ;; 88148292847cSmrg freebsd-aout|qnx|sunos) 88158292847cSmrg current=$number_major 88168292847cSmrg revision=$number_minor 88178292847cSmrg age=0 8818c2939121Smrg ;; 8819c2939121Smrg irix|nonstopux) 8820c2939121Smrg func_arith $number_major + $number_minor 8821c2939121Smrg current=$func_arith_result 88228292847cSmrg age=$number_minor 88238292847cSmrg revision=$number_minor 8824c2939121Smrg lt_irix_increment=no 8825c2939121Smrg ;; 8826c2939121Smrg esac 8827c2939121Smrg ;; 8828c2939121Smrg no) 88298292847cSmrg current=$1 88308292847cSmrg revision=$2 88318292847cSmrg age=$3 8832c2939121Smrg ;; 8833c2939121Smrg esac 8834c2939121Smrg 8835c2939121Smrg # Check that each of the things are valid numbers. 8836c2939121Smrg case $current in 8837c2939121Smrg 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]) ;; 8838c2939121Smrg *) 88398292847cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 88408292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8841c2939121Smrg ;; 8842c2939121Smrg esac 8843c2939121Smrg 8844c2939121Smrg case $revision in 8845c2939121Smrg 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]) ;; 8846c2939121Smrg *) 88478292847cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 88488292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8849c2939121Smrg ;; 8850c2939121Smrg esac 8851c2939121Smrg 8852c2939121Smrg case $age in 8853c2939121Smrg 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]) ;; 8854c2939121Smrg *) 88558292847cSmrg func_error "AGE '$age' must be a nonnegative integer" 88568292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8857c2939121Smrg ;; 8858c2939121Smrg esac 8859c2939121Smrg 8860c2939121Smrg if test "$age" -gt "$current"; then 88618292847cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 88628292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8863c2939121Smrg fi 8864c2939121Smrg 8865c2939121Smrg # Calculate the version variables. 8866c2939121Smrg major= 8867c2939121Smrg versuffix= 8868c2939121Smrg verstring= 8869c2939121Smrg case $version_type in 8870c2939121Smrg none) ;; 8871c2939121Smrg 8872c2939121Smrg darwin) 8873c2939121Smrg # Like Linux, but with the current version available in 8874c2939121Smrg # verstring for coding it into the library header 8875c2939121Smrg func_arith $current - $age 8876c2939121Smrg major=.$func_arith_result 88778292847cSmrg versuffix=$major.$age.$revision 8878c2939121Smrg # Darwin ld doesn't like 0 for these options... 8879c2939121Smrg func_arith $current + 1 8880c2939121Smrg minor_current=$func_arith_result 88818292847cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882c2939121Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 88838292847cSmrg # On Darwin other compilers 88848292847cSmrg case $CC in 88858292847cSmrg nagfor*) 88868292847cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88878292847cSmrg ;; 88888292847cSmrg *) 88898292847cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 88908292847cSmrg ;; 88918292847cSmrg esac 8892c2939121Smrg ;; 8893c2939121Smrg 8894c2939121Smrg freebsd-aout) 88958292847cSmrg major=.$current 88968292847cSmrg versuffix=.$current.$revision 8897c2939121Smrg ;; 8898c2939121Smrg 8899c2939121Smrg freebsd-elf) 89008292847cSmrg func_arith $current - $age 89018292847cSmrg major=.$func_arith_result 89028292847cSmrg versuffix=$major.$age.$revision 8903c2939121Smrg ;; 8904c2939121Smrg 8905c2939121Smrg irix | nonstopux) 89068292847cSmrg if test no = "$lt_irix_increment"; then 8907c2939121Smrg func_arith $current - $age 8908c2939121Smrg else 8909c2939121Smrg func_arith $current - $age + 1 8910c2939121Smrg fi 8911c2939121Smrg major=$func_arith_result 8912c2939121Smrg 8913c2939121Smrg case $version_type in 8914c2939121Smrg nonstopux) verstring_prefix=nonstopux ;; 8915c2939121Smrg *) verstring_prefix=sgi ;; 8916c2939121Smrg esac 89178292847cSmrg verstring=$verstring_prefix$major.$revision 8918c2939121Smrg 8919c2939121Smrg # Add in all the interfaces that we are compatible with. 8920c2939121Smrg loop=$revision 89218292847cSmrg while test 0 -ne "$loop"; do 8922c2939121Smrg func_arith $revision - $loop 8923c2939121Smrg iface=$func_arith_result 8924c2939121Smrg func_arith $loop - 1 8925c2939121Smrg loop=$func_arith_result 89268292847cSmrg verstring=$verstring_prefix$major.$iface:$verstring 8927c2939121Smrg done 8928c2939121Smrg 89298292847cSmrg # Before this point, $major must not contain '.'. 8930c2939121Smrg major=.$major 89318292847cSmrg versuffix=$major.$revision 8932c2939121Smrg ;; 8933c2939121Smrg 89342836776bSmrg linux) # correct to gnu/linux during the next big refactor 8935c2939121Smrg func_arith $current - $age 8936c2939121Smrg major=.$func_arith_result 89378292847cSmrg versuffix=$major.$age.$revision 8938c2939121Smrg ;; 8939c2939121Smrg 8940c2939121Smrg osf) 8941c2939121Smrg func_arith $current - $age 8942c2939121Smrg major=.$func_arith_result 89438292847cSmrg versuffix=.$current.$age.$revision 89448292847cSmrg verstring=$current.$age.$revision 8945c2939121Smrg 8946c2939121Smrg # Add in all the interfaces that we are compatible with. 8947c2939121Smrg loop=$age 89488292847cSmrg while test 0 -ne "$loop"; do 8949c2939121Smrg func_arith $current - $loop 8950c2939121Smrg iface=$func_arith_result 8951c2939121Smrg func_arith $loop - 1 8952c2939121Smrg loop=$func_arith_result 89538292847cSmrg verstring=$verstring:$iface.0 8954c2939121Smrg done 8955c2939121Smrg 8956c2939121Smrg # Make executables depend on our current version. 89578292847cSmrg func_append verstring ":$current.0" 8958c2939121Smrg ;; 8959c2939121Smrg 8960c2939121Smrg qnx) 89618292847cSmrg major=.$current 89628292847cSmrg versuffix=.$current 89638292847cSmrg ;; 89648292847cSmrg 89658292847cSmrg sco) 89668292847cSmrg major=.$current 89678292847cSmrg versuffix=.$current 8968c2939121Smrg ;; 8969c2939121Smrg 8970c2939121Smrg sunos) 89718292847cSmrg major=.$current 89728292847cSmrg versuffix=.$current.$revision 8973c2939121Smrg ;; 8974c2939121Smrg 8975c2939121Smrg windows) 8976c2939121Smrg # Use '-' rather than '.', since we only want one 89778292847cSmrg # extension on DOS 8.3 file systems. 8978c2939121Smrg func_arith $current - $age 8979c2939121Smrg major=$func_arith_result 89808292847cSmrg versuffix=-$major 8981c2939121Smrg ;; 8982c2939121Smrg 8983c2939121Smrg *) 89848292847cSmrg func_fatal_configuration "unknown library version type '$version_type'" 8985c2939121Smrg ;; 8986c2939121Smrg esac 8987c2939121Smrg 8988c2939121Smrg # Clear the version info if we defaulted, and they specified a release. 8989c2939121Smrg if test -z "$vinfo" && test -n "$release"; then 8990c2939121Smrg major= 8991c2939121Smrg case $version_type in 8992c2939121Smrg darwin) 8993c2939121Smrg # we can't check for "0.0" in archive_cmds due to quoting 8994c2939121Smrg # problems, so we reset it completely 8995c2939121Smrg verstring= 8996c2939121Smrg ;; 8997c2939121Smrg *) 89988292847cSmrg verstring=0.0 8999c2939121Smrg ;; 9000c2939121Smrg esac 90018292847cSmrg if test no = "$need_version"; then 9002c2939121Smrg versuffix= 9003c2939121Smrg else 90048292847cSmrg versuffix=.0.0 9005c2939121Smrg fi 9006c2939121Smrg fi 9007c2939121Smrg 9008c2939121Smrg # Remove version info from name if versioning should be avoided 90098292847cSmrg if test yes,no = "$avoid_version,$need_version"; then 9010c2939121Smrg major= 9011c2939121Smrg versuffix= 90128292847cSmrg verstring= 9013c2939121Smrg fi 9014c2939121Smrg 9015c2939121Smrg # Check to see if the archive will have undefined symbols. 90168292847cSmrg if test yes = "$allow_undefined"; then 90178292847cSmrg if test unsupported = "$allow_undefined_flag"; then 90188292847cSmrg if test yes = "$build_old_libs"; then 90198292847cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 90208292847cSmrg build_libtool_libs=no 90218292847cSmrg else 90228292847cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 90238292847cSmrg fi 9024c2939121Smrg fi 9025c2939121Smrg else 9026c2939121Smrg # Don't allow undefined symbols. 90278292847cSmrg allow_undefined_flag=$no_undefined_flag 9028c2939121Smrg fi 9029c2939121Smrg 9030c2939121Smrg fi 9031c2939121Smrg 90328292847cSmrg func_generate_dlsyms "$libname" "$libname" : 90332836776bSmrg func_append libobjs " $symfileobj" 90348292847cSmrg test " " = "$libobjs" && libobjs= 9035c2939121Smrg 90368292847cSmrg if test relink != "$opt_mode"; then 9037c2939121Smrg # Remove our outputs, but don't remove object files since they 9038c2939121Smrg # may have been created when compiling PIC objects. 9039c2939121Smrg removelist= 9040c2939121Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9041c2939121Smrg for p in $tempremovelist; do 9042c2939121Smrg case $p in 9043c2939121Smrg *.$objext | *.gcno) 9044c2939121Smrg ;; 90458292847cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 90468292847cSmrg if test -n "$precious_files_regex"; then 9047c2939121Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048c2939121Smrg then 9049c2939121Smrg continue 9050c2939121Smrg fi 9051c2939121Smrg fi 90522836776bSmrg func_append removelist " $p" 9053c2939121Smrg ;; 9054c2939121Smrg *) ;; 9055c2939121Smrg esac 9056c2939121Smrg done 9057c2939121Smrg test -n "$removelist" && \ 9058c2939121Smrg func_show_eval "${RM}r \$removelist" 9059c2939121Smrg fi 9060c2939121Smrg 9061c2939121Smrg # Now set the variables for building old libraries. 90628292847cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 90632836776bSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9064c2939121Smrg 9065c2939121Smrg # Transform .lo files to .o files. 90668292847cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067c2939121Smrg fi 9068c2939121Smrg 9069c2939121Smrg # Eliminate all temporary directories. 9070c2939121Smrg #for path in $notinst_path; do 9071c2939121Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072c2939121Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073c2939121Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074c2939121Smrg #done 9075c2939121Smrg 9076c2939121Smrg if test -n "$xrpath"; then 9077c2939121Smrg # If the user specified any rpath flags, then add them. 9078c2939121Smrg temp_xrpath= 9079c2939121Smrg for libdir in $xrpath; do 90802836776bSmrg func_replace_sysroot "$libdir" 90812836776bSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9082c2939121Smrg case "$finalize_rpath " in 9083c2939121Smrg *" $libdir "*) ;; 90842836776bSmrg *) func_append finalize_rpath " $libdir" ;; 9085c2939121Smrg esac 9086c2939121Smrg done 90878292847cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088c2939121Smrg dependency_libs="$temp_xrpath $dependency_libs" 9089c2939121Smrg fi 9090c2939121Smrg fi 9091c2939121Smrg 9092c2939121Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 90938292847cSmrg old_dlfiles=$dlfiles 9094c2939121Smrg dlfiles= 9095c2939121Smrg for lib in $old_dlfiles; do 9096c2939121Smrg case " $dlprefiles $dlfiles " in 9097c2939121Smrg *" $lib "*) ;; 90982836776bSmrg *) func_append dlfiles " $lib" ;; 9099c2939121Smrg esac 9100c2939121Smrg done 9101c2939121Smrg 9102c2939121Smrg # Make sure dlprefiles contains only unique files 91038292847cSmrg old_dlprefiles=$dlprefiles 9104c2939121Smrg dlprefiles= 9105c2939121Smrg for lib in $old_dlprefiles; do 9106c2939121Smrg case "$dlprefiles " in 9107c2939121Smrg *" $lib "*) ;; 91082836776bSmrg *) func_append dlprefiles " $lib" ;; 9109c2939121Smrg esac 9110c2939121Smrg done 9111c2939121Smrg 91128292847cSmrg if test yes = "$build_libtool_libs"; then 9113c2939121Smrg if test -n "$rpath"; then 9114c2939121Smrg case $host in 9115c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116c2939121Smrg # these systems don't actually have a c library (as such)! 9117c2939121Smrg ;; 9118c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9119c2939121Smrg # Rhapsody C library is in the System framework 91202836776bSmrg func_append deplibs " System.ltframework" 9121c2939121Smrg ;; 9122c2939121Smrg *-*-netbsd*) 9123c2939121Smrg # Don't link with libc until the a.out ld.so is fixed. 9124c2939121Smrg ;; 9125c2939121Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126c2939121Smrg # Do not include libc due to us having libc/libc_r. 9127c2939121Smrg ;; 9128c2939121Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9129c2939121Smrg # Causes problems with __ctype 9130c2939121Smrg ;; 9131c2939121Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132c2939121Smrg # Compiler inserts libc in the correct place for threads to work 9133c2939121Smrg ;; 9134c2939121Smrg *) 9135c2939121Smrg # Add libc to deplibs on all other systems if necessary. 91368292847cSmrg if test yes = "$build_libtool_need_lc"; then 91372836776bSmrg func_append deplibs " -lc" 9138c2939121Smrg fi 9139c2939121Smrg ;; 9140c2939121Smrg esac 9141c2939121Smrg fi 9142c2939121Smrg 9143c2939121Smrg # Transform deplibs into only deplibs that can be linked in shared. 9144c2939121Smrg name_save=$name 9145c2939121Smrg libname_save=$libname 9146c2939121Smrg release_save=$release 9147c2939121Smrg versuffix_save=$versuffix 9148c2939121Smrg major_save=$major 9149c2939121Smrg # I'm not sure if I'm treating the release correctly. I think 9150c2939121Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9151c2939121Smrg # add it in twice. Is that correct? 91528292847cSmrg release= 91538292847cSmrg versuffix= 91548292847cSmrg major= 9155c2939121Smrg newdeplibs= 9156c2939121Smrg droppeddeps=no 9157c2939121Smrg case $deplibs_check_method in 9158c2939121Smrg pass_all) 9159c2939121Smrg # Don't check for shared/static. Everything works. 9160c2939121Smrg # This might be a little naive. We might want to check 9161c2939121Smrg # whether the library exists or not. But this is on 9162c2939121Smrg # osf3 & osf4 and I'm not really sure... Just 9163c2939121Smrg # implementing what was already the behavior. 9164c2939121Smrg newdeplibs=$deplibs 9165c2939121Smrg ;; 9166c2939121Smrg test_compile) 9167c2939121Smrg # This code stresses the "libraries are programs" paradigm to its 9168c2939121Smrg # limits. Maybe even breaks it. We compile a program, linking it 9169c2939121Smrg # against the deplibs as a proxy for the library. Then we can check 9170c2939121Smrg # whether they linked in statically or dynamically with ldd. 9171c2939121Smrg $opt_dry_run || $RM conftest.c 9172c2939121Smrg cat > conftest.c <<EOF 9173c2939121Smrg int main() { return 0; } 9174c2939121SmrgEOF 9175c2939121Smrg $opt_dry_run || $RM conftest 9176c2939121Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177c2939121Smrg ldd_output=`ldd conftest` 9178c2939121Smrg for i in $deplibs; do 9179c2939121Smrg case $i in 9180c2939121Smrg -l*) 9181c2939121Smrg func_stripname -l '' "$i" 9182c2939121Smrg name=$func_stripname_result 91838292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184c2939121Smrg case " $predeps $postdeps " in 9185c2939121Smrg *" $i "*) 91862836776bSmrg func_append newdeplibs " $i" 91878292847cSmrg i= 9188c2939121Smrg ;; 9189c2939121Smrg esac 9190c2939121Smrg fi 91918292847cSmrg if test -n "$i"; then 9192c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9193c2939121Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194c2939121Smrg set dummy $deplib_matches; shift 9195c2939121Smrg deplib_match=$1 91968292847cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 91972836776bSmrg func_append newdeplibs " $i" 9198c2939121Smrg else 9199c2939121Smrg droppeddeps=yes 9200c2939121Smrg echo 9201c2939121Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9203c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9204c2939121Smrg echo "*** shared version of the library, which I believe you do not have" 9205c2939121Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9206c2939121Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207c2939121Smrg fi 9208c2939121Smrg fi 9209c2939121Smrg ;; 9210c2939121Smrg *) 92112836776bSmrg func_append newdeplibs " $i" 9212c2939121Smrg ;; 9213c2939121Smrg esac 9214c2939121Smrg done 9215c2939121Smrg else 9216c2939121Smrg # Error occurred in the first compile. Let's try to salvage 9217c2939121Smrg # the situation: Compile a separate program for each library. 9218c2939121Smrg for i in $deplibs; do 9219c2939121Smrg case $i in 9220c2939121Smrg -l*) 9221c2939121Smrg func_stripname -l '' "$i" 9222c2939121Smrg name=$func_stripname_result 9223c2939121Smrg $opt_dry_run || $RM conftest 9224c2939121Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225c2939121Smrg ldd_output=`ldd conftest` 92268292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227c2939121Smrg case " $predeps $postdeps " in 9228c2939121Smrg *" $i "*) 92292836776bSmrg func_append newdeplibs " $i" 92308292847cSmrg i= 9231c2939121Smrg ;; 9232c2939121Smrg esac 9233c2939121Smrg fi 92348292847cSmrg if test -n "$i"; then 9235c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9236c2939121Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237c2939121Smrg set dummy $deplib_matches; shift 9238c2939121Smrg deplib_match=$1 92398292847cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 92402836776bSmrg func_append newdeplibs " $i" 9241c2939121Smrg else 9242c2939121Smrg droppeddeps=yes 9243c2939121Smrg echo 9244c2939121Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9246c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9247c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 9248c2939121Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9249c2939121Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250c2939121Smrg fi 9251c2939121Smrg fi 9252c2939121Smrg else 9253c2939121Smrg droppeddeps=yes 9254c2939121Smrg echo 9255c2939121Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256c2939121Smrg echo "*** make it link in! You will probably need to install it or some" 9257c2939121Smrg echo "*** library that it depends on before this library will be fully" 9258c2939121Smrg echo "*** functional. Installing it before continuing would be even better." 9259c2939121Smrg fi 9260c2939121Smrg ;; 9261c2939121Smrg *) 92622836776bSmrg func_append newdeplibs " $i" 9263c2939121Smrg ;; 9264c2939121Smrg esac 9265c2939121Smrg done 9266c2939121Smrg fi 9267c2939121Smrg ;; 9268c2939121Smrg file_magic*) 9269c2939121Smrg set dummy $deplibs_check_method; shift 9270c2939121Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271c2939121Smrg for a_deplib in $deplibs; do 9272c2939121Smrg case $a_deplib in 9273c2939121Smrg -l*) 9274c2939121Smrg func_stripname -l '' "$a_deplib" 9275c2939121Smrg name=$func_stripname_result 92768292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277c2939121Smrg case " $predeps $postdeps " in 9278c2939121Smrg *" $a_deplib "*) 92792836776bSmrg func_append newdeplibs " $a_deplib" 92808292847cSmrg a_deplib= 9281c2939121Smrg ;; 9282c2939121Smrg esac 9283c2939121Smrg fi 92848292847cSmrg if test -n "$a_deplib"; then 9285c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 92862836776bSmrg if test -n "$file_magic_glob"; then 92872836776bSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 92882836776bSmrg else 92892836776bSmrg libnameglob=$libname 92902836776bSmrg fi 92918292847cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292c2939121Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 92938292847cSmrg if test yes = "$want_nocaseglob"; then 92942836776bSmrg shopt -s nocaseglob 92952836776bSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 92962836776bSmrg $nocaseglob 92972836776bSmrg else 92982836776bSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 92992836776bSmrg fi 9300c2939121Smrg for potent_lib in $potential_libs; do 9301c2939121Smrg # Follow soft links. 9302c2939121Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9303c2939121Smrg $GREP " -> " >/dev/null; then 9304c2939121Smrg continue 9305c2939121Smrg fi 9306c2939121Smrg # The statement above tries to avoid entering an 9307c2939121Smrg # endless loop below, in case of cyclic links. 9308c2939121Smrg # We might still enter an endless loop, since a link 9309c2939121Smrg # loop can be closed while we follow links, 9310c2939121Smrg # but so what? 93118292847cSmrg potlib=$potent_lib 9312c2939121Smrg while test -h "$potlib" 2>/dev/null; do 93138292847cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314c2939121Smrg case $potliblink in 93158292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 93168292847cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317c2939121Smrg esac 9318c2939121Smrg done 9319c2939121Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320c2939121Smrg $SED -e 10q | 9321c2939121Smrg $EGREP "$file_magic_regex" > /dev/null; then 93222836776bSmrg func_append newdeplibs " $a_deplib" 93238292847cSmrg a_deplib= 9324c2939121Smrg break 2 9325c2939121Smrg fi 9326c2939121Smrg done 9327c2939121Smrg done 9328c2939121Smrg fi 93298292847cSmrg if test -n "$a_deplib"; then 9330c2939121Smrg droppeddeps=yes 9331c2939121Smrg echo 9332c2939121Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9334c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9335c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 9336c2939121Smrg echo "*** because I did check the linker path looking for a file starting" 93378292847cSmrg if test -z "$potlib"; then 9338c2939121Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339c2939121Smrg else 9340c2939121Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9341c2939121Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9342c2939121Smrg fi 9343c2939121Smrg fi 9344c2939121Smrg ;; 9345c2939121Smrg *) 9346c2939121Smrg # Add a -L argument. 93472836776bSmrg func_append newdeplibs " $a_deplib" 9348c2939121Smrg ;; 9349c2939121Smrg esac 9350c2939121Smrg done # Gone through all deplibs. 9351c2939121Smrg ;; 9352c2939121Smrg match_pattern*) 9353c2939121Smrg set dummy $deplibs_check_method; shift 9354c2939121Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355c2939121Smrg for a_deplib in $deplibs; do 9356c2939121Smrg case $a_deplib in 9357c2939121Smrg -l*) 9358c2939121Smrg func_stripname -l '' "$a_deplib" 9359c2939121Smrg name=$func_stripname_result 93608292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361c2939121Smrg case " $predeps $postdeps " in 9362c2939121Smrg *" $a_deplib "*) 93632836776bSmrg func_append newdeplibs " $a_deplib" 93648292847cSmrg a_deplib= 9365c2939121Smrg ;; 9366c2939121Smrg esac 9367c2939121Smrg fi 93688292847cSmrg if test -n "$a_deplib"; then 9369c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9370c2939121Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371c2939121Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372c2939121Smrg for potent_lib in $potential_libs; do 93738292847cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9374c2939121Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375c2939121Smrg $EGREP "$match_pattern_regex" > /dev/null; then 93762836776bSmrg func_append newdeplibs " $a_deplib" 93778292847cSmrg a_deplib= 9378c2939121Smrg break 2 9379c2939121Smrg fi 9380c2939121Smrg done 9381c2939121Smrg done 9382c2939121Smrg fi 93838292847cSmrg if test -n "$a_deplib"; then 9384c2939121Smrg droppeddeps=yes 9385c2939121Smrg echo 9386c2939121Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9388c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9389c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 9390c2939121Smrg echo "*** because I did check the linker path looking for a file starting" 93918292847cSmrg if test -z "$potlib"; then 9392c2939121Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393c2939121Smrg else 9394c2939121Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9395c2939121Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396c2939121Smrg fi 9397c2939121Smrg fi 9398c2939121Smrg ;; 9399c2939121Smrg *) 9400c2939121Smrg # Add a -L argument. 94012836776bSmrg func_append newdeplibs " $a_deplib" 9402c2939121Smrg ;; 9403c2939121Smrg esac 9404c2939121Smrg done # Gone through all deplibs. 9405c2939121Smrg ;; 9406c2939121Smrg none | unknown | *) 94078292847cSmrg newdeplibs= 9408c2939121Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 94098292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94108292847cSmrg for i in $predeps $postdeps; do 9411c2939121Smrg # can't use Xsed below, because $i might contain '/' 94128292847cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413c2939121Smrg done 9414c2939121Smrg fi 9415c2939121Smrg case $tmp_deplibs in 9416c2939121Smrg *[!\ \ ]*) 9417c2939121Smrg echo 94188292847cSmrg if test none = "$deplibs_check_method"; then 9419c2939121Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9420c2939121Smrg else 9421c2939121Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9422c2939121Smrg fi 9423c2939121Smrg echo "*** All declared inter-library dependencies are being dropped." 9424c2939121Smrg droppeddeps=yes 9425c2939121Smrg ;; 9426c2939121Smrg esac 9427c2939121Smrg ;; 9428c2939121Smrg esac 9429c2939121Smrg versuffix=$versuffix_save 9430c2939121Smrg major=$major_save 9431c2939121Smrg release=$release_save 9432c2939121Smrg libname=$libname_save 9433c2939121Smrg name=$name_save 9434c2939121Smrg 9435c2939121Smrg case $host in 9436c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9437c2939121Smrg # On Rhapsody replace the C library with the System framework 9438c2939121Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439c2939121Smrg ;; 9440c2939121Smrg esac 9441c2939121Smrg 94428292847cSmrg if test yes = "$droppeddeps"; then 94438292847cSmrg if test yes = "$module"; then 9444c2939121Smrg echo 9445c2939121Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9446c2939121Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447c2939121Smrg echo "*** a static module, that should work as long as the dlopening" 9448c2939121Smrg echo "*** application is linked with the -dlopen flag." 9449c2939121Smrg if test -z "$global_symbol_pipe"; then 9450c2939121Smrg echo 9451c2939121Smrg echo "*** However, this would only work if libtool was able to extract symbol" 94528292847cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453c2939121Smrg echo "*** not find such a program. So, this module is probably useless." 94548292847cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455c2939121Smrg fi 94568292847cSmrg if test no = "$build_old_libs"; then 94578292847cSmrg oldlibs=$output_objdir/$libname.$libext 9458c2939121Smrg build_libtool_libs=module 9459c2939121Smrg build_old_libs=yes 9460c2939121Smrg else 9461c2939121Smrg build_libtool_libs=no 9462c2939121Smrg fi 9463c2939121Smrg else 9464c2939121Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9465c2939121Smrg echo "*** automatically added whenever a program is linked with this library" 9466c2939121Smrg echo "*** or is declared to -dlopen it." 9467c2939121Smrg 94688292847cSmrg if test no = "$allow_undefined"; then 9469c2939121Smrg echo 9470c2939121Smrg echo "*** Since this library must not contain undefined symbols," 9471c2939121Smrg echo "*** because either the platform does not support them or" 9472c2939121Smrg echo "*** it was explicitly requested with -no-undefined," 9473c2939121Smrg echo "*** libtool will only create a static version of it." 94748292847cSmrg if test no = "$build_old_libs"; then 94758292847cSmrg oldlibs=$output_objdir/$libname.$libext 9476c2939121Smrg build_libtool_libs=module 9477c2939121Smrg build_old_libs=yes 9478c2939121Smrg else 9479c2939121Smrg build_libtool_libs=no 9480c2939121Smrg fi 9481c2939121Smrg fi 9482c2939121Smrg fi 9483c2939121Smrg fi 9484c2939121Smrg # Done checking deplibs! 9485c2939121Smrg deplibs=$newdeplibs 9486c2939121Smrg fi 9487c2939121Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488c2939121Smrg case $host in 9489c2939121Smrg *-*-darwin*) 9490c2939121Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491c2939121Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492c2939121Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493c2939121Smrg ;; 9494c2939121Smrg esac 9495c2939121Smrg 9496c2939121Smrg # move library search paths that coincide with paths to not yet 9497c2939121Smrg # installed libraries to the beginning of the library search list 9498c2939121Smrg new_libs= 9499c2939121Smrg for path in $notinst_path; do 9500c2939121Smrg case " $new_libs " in 9501c2939121Smrg *" -L$path/$objdir "*) ;; 9502c2939121Smrg *) 9503c2939121Smrg case " $deplibs " in 9504c2939121Smrg *" -L$path/$objdir "*) 95052836776bSmrg func_append new_libs " -L$path/$objdir" ;; 9506c2939121Smrg esac 9507c2939121Smrg ;; 9508c2939121Smrg esac 9509c2939121Smrg done 9510c2939121Smrg for deplib in $deplibs; do 9511c2939121Smrg case $deplib in 9512c2939121Smrg -L*) 9513c2939121Smrg case " $new_libs " in 9514c2939121Smrg *" $deplib "*) ;; 95152836776bSmrg *) func_append new_libs " $deplib" ;; 9516c2939121Smrg esac 9517c2939121Smrg ;; 95182836776bSmrg *) func_append new_libs " $deplib" ;; 9519c2939121Smrg esac 9520c2939121Smrg done 95218292847cSmrg deplibs=$new_libs 9522c2939121Smrg 9523c2939121Smrg # All the library-specific variables (install_libdir is set above). 9524c2939121Smrg library_names= 9525c2939121Smrg old_library= 9526c2939121Smrg dlname= 9527c2939121Smrg 9528c2939121Smrg # Test again, we may have decided not to build it any more 95298292847cSmrg if test yes = "$build_libtool_libs"; then 95308292847cSmrg # Remove $wl instances when linking with ld. 95312836776bSmrg # FIXME: should test the right _cmds variable. 95322836776bSmrg case $archive_cmds in 95332836776bSmrg *\$LD\ *) wl= ;; 95342836776bSmrg esac 95358292847cSmrg if test yes = "$hardcode_into_libs"; then 9536c2939121Smrg # Hardcode the library paths 9537c2939121Smrg hardcode_libdirs= 9538c2939121Smrg dep_rpath= 95398292847cSmrg rpath=$finalize_rpath 95408292847cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541c2939121Smrg for libdir in $rpath; do 9542c2939121Smrg if test -n "$hardcode_libdir_flag_spec"; then 9543c2939121Smrg if test -n "$hardcode_libdir_separator"; then 95442836776bSmrg func_replace_sysroot "$libdir" 95452836776bSmrg libdir=$func_replace_sysroot_result 9546c2939121Smrg if test -z "$hardcode_libdirs"; then 95478292847cSmrg hardcode_libdirs=$libdir 9548c2939121Smrg else 9549c2939121Smrg # Just accumulate the unique libdirs. 9550c2939121Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551c2939121Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552c2939121Smrg ;; 9553c2939121Smrg *) 95542836776bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555c2939121Smrg ;; 9556c2939121Smrg esac 9557c2939121Smrg fi 9558c2939121Smrg else 9559c2939121Smrg eval flag=\"$hardcode_libdir_flag_spec\" 95602836776bSmrg func_append dep_rpath " $flag" 9561c2939121Smrg fi 9562c2939121Smrg elif test -n "$runpath_var"; then 9563c2939121Smrg case "$perm_rpath " in 9564c2939121Smrg *" $libdir "*) ;; 95652836776bSmrg *) func_append perm_rpath " $libdir" ;; 9566c2939121Smrg esac 9567c2939121Smrg fi 9568c2939121Smrg done 9569c2939121Smrg # Substitute the hardcoded libdirs into the rpath. 9570c2939121Smrg if test -n "$hardcode_libdir_separator" && 9571c2939121Smrg test -n "$hardcode_libdirs"; then 95728292847cSmrg libdir=$hardcode_libdirs 95732836776bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574c2939121Smrg fi 9575c2939121Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576c2939121Smrg # We should set the runpath_var. 9577c2939121Smrg rpath= 9578c2939121Smrg for dir in $perm_rpath; do 95792836776bSmrg func_append rpath "$dir:" 9580c2939121Smrg done 9581c2939121Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582c2939121Smrg fi 9583c2939121Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584c2939121Smrg fi 9585c76ae52dSmrg 95868292847cSmrg shlibpath=$finalize_shlibpath 95878292847cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588c2939121Smrg if test -n "$shlibpath"; then 9589c2939121Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590c2939121Smrg fi 9591c76ae52dSmrg 9592c2939121Smrg # Get the real and link names of the library. 9593c2939121Smrg eval shared_ext=\"$shrext_cmds\" 9594c2939121Smrg eval library_names=\"$library_names_spec\" 9595c2939121Smrg set dummy $library_names 9596c2939121Smrg shift 95978292847cSmrg realname=$1 9598c2939121Smrg shift 9599c76ae52dSmrg 9600c2939121Smrg if test -n "$soname_spec"; then 9601c2939121Smrg eval soname=\"$soname_spec\" 9602c2939121Smrg else 96038292847cSmrg soname=$realname 9604c2939121Smrg fi 9605c2939121Smrg if test -z "$dlname"; then 9606c2939121Smrg dlname=$soname 9607c2939121Smrg fi 9608c76ae52dSmrg 96098292847cSmrg lib=$output_objdir/$realname 9610c2939121Smrg linknames= 9611c2939121Smrg for link 9612c2939121Smrg do 96132836776bSmrg func_append linknames " $link" 9614c2939121Smrg done 9615c76ae52dSmrg 9616c2939121Smrg # Use standard objects if they are pic 9617c2939121Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618c2939121Smrg test "X$libobjs" = "X " && libobjs= 9619c76ae52dSmrg 9620c2939121Smrg delfiles= 9621c2939121Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622c2939121Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 96238292847cSmrg export_symbols=$output_objdir/$libname.uexp 96242836776bSmrg func_append delfiles " $export_symbols" 9625c2939121Smrg fi 9626c76ae52dSmrg 9627c2939121Smrg orig_export_symbols= 9628c2939121Smrg case $host_os in 9629c2939121Smrg cygwin* | mingw* | cegcc*) 9630c2939121Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631c2939121Smrg # exporting using user supplied symfile 96328292847cSmrg func_dll_def_p "$export_symbols" || { 9633c2939121Smrg # and it's NOT already a .def file. Must figure out 9634c2939121Smrg # which of the given symbols are data symbols and tag 9635c2939121Smrg # them as such. So, trigger use of export_symbols_cmds. 9636c2939121Smrg # export_symbols gets reassigned inside the "prepare 9637c2939121Smrg # the list of exported symbols" if statement, so the 9638c2939121Smrg # include_expsyms logic still works. 96398292847cSmrg orig_export_symbols=$export_symbols 9640c2939121Smrg export_symbols= 9641c2939121Smrg always_export_symbols=yes 96428292847cSmrg } 9643c2939121Smrg fi 9644c2939121Smrg ;; 9645c2939121Smrg esac 9646c76ae52dSmrg 9647c2939121Smrg # Prepare the list of exported symbols 9648c2939121Smrg if test -z "$export_symbols"; then 96498292847cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 96508292847cSmrg func_verbose "generating symbol list for '$libname.la'" 96518292847cSmrg export_symbols=$output_objdir/$libname.exp 9652c2939121Smrg $opt_dry_run || $RM $export_symbols 9653c2939121Smrg cmds=$export_symbols_cmds 96548292847cSmrg save_ifs=$IFS; IFS='~' 96552836776bSmrg for cmd1 in $cmds; do 96568292847cSmrg IFS=$save_ifs 96572836776bSmrg # Take the normal branch if the nm_file_list_spec branch 96582836776bSmrg # doesn't work or if tool conversion is not needed. 96592836776bSmrg case $nm_file_list_spec~$to_tool_file_cmd in 96602836776bSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 96612836776bSmrg try_normal_branch=yes 96622836776bSmrg eval cmd=\"$cmd1\" 96632836776bSmrg func_len " $cmd" 96642836776bSmrg len=$func_len_result 96652836776bSmrg ;; 96662836776bSmrg *) 96672836776bSmrg try_normal_branch=no 96682836776bSmrg ;; 96692836776bSmrg esac 96708292847cSmrg if test yes = "$try_normal_branch" \ 96712836776bSmrg && { test "$len" -lt "$max_cmd_len" \ 96722836776bSmrg || test "$max_cmd_len" -le -1; } 96732836776bSmrg then 96742836776bSmrg func_show_eval "$cmd" 'exit $?' 96752836776bSmrg skipped_export=false 96762836776bSmrg elif test -n "$nm_file_list_spec"; then 96772836776bSmrg func_basename "$output" 96782836776bSmrg output_la=$func_basename_result 96792836776bSmrg save_libobjs=$libobjs 96802836776bSmrg save_output=$output 96818292847cSmrg output=$output_objdir/$output_la.nm 96822836776bSmrg func_to_tool_file "$output" 96832836776bSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 96842836776bSmrg func_append delfiles " $output" 96852836776bSmrg func_verbose "creating $NM input file list: $output" 96862836776bSmrg for obj in $save_libobjs; do 96872836776bSmrg func_to_tool_file "$obj" 96882836776bSmrg $ECHO "$func_to_tool_file_result" 96892836776bSmrg done > "$output" 96902836776bSmrg eval cmd=\"$cmd1\" 9691c2939121Smrg func_show_eval "$cmd" 'exit $?' 96922836776bSmrg output=$save_output 96932836776bSmrg libobjs=$save_libobjs 9694c2939121Smrg skipped_export=false 9695c2939121Smrg else 9696c2939121Smrg # The command line is too long to execute in one step. 9697c2939121Smrg func_verbose "using reloadable object file for export list..." 9698c2939121Smrg skipped_export=: 9699c2939121Smrg # Break out early, otherwise skipped_export may be 9700c2939121Smrg # set to false by a later but shorter cmd. 9701c2939121Smrg break 9702c2939121Smrg fi 9703c2939121Smrg done 97048292847cSmrg IFS=$save_ifs 97058292847cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706c2939121Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707c2939121Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708c2939121Smrg fi 9709c2939121Smrg fi 9710c2939121Smrg fi 9711c76ae52dSmrg 9712c2939121Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 97138292847cSmrg tmp_export_symbols=$export_symbols 97148292847cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715c2939121Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716c2939121Smrg fi 9717c76ae52dSmrg 97188292847cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719c2939121Smrg # The given exports_symbols file has to be filtered, so filter it. 97208292847cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721c2939121Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 97228292847cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9723c2939121Smrg # though. Also, the filter scales superlinearly with the number of 9724c2939121Smrg # global variables. join(1) would be nice here, but unfortunately 9725c2939121Smrg # isn't a blessed tool. 9726c2939121Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 97272836776bSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728c2939121Smrg export_symbols=$output_objdir/$libname.def 9729c2939121Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730c76ae52dSmrg fi 9731c76ae52dSmrg 9732c2939121Smrg tmp_deplibs= 9733c2939121Smrg for test_deplib in $deplibs; do 9734c2939121Smrg case " $convenience " in 9735c2939121Smrg *" $test_deplib "*) ;; 9736c2939121Smrg *) 97372836776bSmrg func_append tmp_deplibs " $test_deplib" 9738c2939121Smrg ;; 9739c2939121Smrg esac 9740c2939121Smrg done 97418292847cSmrg deplibs=$tmp_deplibs 9742c76ae52dSmrg 9743c2939121Smrg if test -n "$convenience"; then 9744c2939121Smrg if test -n "$whole_archive_flag_spec" && 97458292847cSmrg test yes = "$compiler_needs_object" && 9746c2939121Smrg test -z "$libobjs"; then 9747c2939121Smrg # extract the archives, so we have objects to list. 9748c2939121Smrg # TODO: could optimize this to just extract one archive. 9749c2939121Smrg whole_archive_flag_spec= 9750c2939121Smrg fi 9751c2939121Smrg if test -n "$whole_archive_flag_spec"; then 9752c2939121Smrg save_libobjs=$libobjs 9753c2939121Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754c2939121Smrg test "X$libobjs" = "X " && libobjs= 9755c2939121Smrg else 97568292847cSmrg gentop=$output_objdir/${outputname}x 97572836776bSmrg func_append generated " $gentop" 9758c76ae52dSmrg 9759c2939121Smrg func_extract_archives $gentop $convenience 97602836776bSmrg func_append libobjs " $func_extract_archives_result" 9761c2939121Smrg test "X$libobjs" = "X " && libobjs= 9762c2939121Smrg fi 9763c2939121Smrg fi 9764c76ae52dSmrg 97658292847cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766c2939121Smrg eval flag=\"$thread_safe_flag_spec\" 97672836776bSmrg func_append linker_flags " $flag" 9768c2939121Smrg fi 9769c76ae52dSmrg 9770c2939121Smrg # Make a backup of the uninstalled library when relinking 97718292847cSmrg if test relink = "$opt_mode"; then 9772c2939121Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773c76ae52dSmrg fi 9774c76ae52dSmrg 9775c2939121Smrg # Do each of the archive commands. 97768292847cSmrg if test yes = "$module" && test -n "$module_cmds"; then 9777c2939121Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778c2939121Smrg eval test_cmds=\"$module_expsym_cmds\" 9779c2939121Smrg cmds=$module_expsym_cmds 9780c2939121Smrg else 9781c2939121Smrg eval test_cmds=\"$module_cmds\" 9782c2939121Smrg cmds=$module_cmds 9783c2939121Smrg fi 9784c2939121Smrg else 9785c2939121Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786c2939121Smrg eval test_cmds=\"$archive_expsym_cmds\" 9787c2939121Smrg cmds=$archive_expsym_cmds 9788c2939121Smrg else 9789c2939121Smrg eval test_cmds=\"$archive_cmds\" 9790c2939121Smrg cmds=$archive_cmds 9791c2939121Smrg fi 9792c76ae52dSmrg fi 9793c76ae52dSmrg 97948292847cSmrg if test : != "$skipped_export" && 9795c2939121Smrg func_len " $test_cmds" && 9796c2939121Smrg len=$func_len_result && 9797c2939121Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798c2939121Smrg : 9799c2939121Smrg else 9800c2939121Smrg # The command line is too long to link in one step, link piecewise 9801c2939121Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9802c2939121Smrg # script. 9803c76ae52dSmrg 9804c2939121Smrg # Save the value of $output and $libobjs because we want to 9805c2939121Smrg # use them later. If we have whole_archive_flag_spec, we 9806c2939121Smrg # want to use save_libobjs as it was before 9807c2939121Smrg # whole_archive_flag_spec was expanded, because we can't 9808c2939121Smrg # assume the linker understands whole_archive_flag_spec. 9809c2939121Smrg # This may have to be revisited, in case too many 9810c2939121Smrg # convenience libraries get linked in and end up exceeding 9811c2939121Smrg # the spec. 9812c2939121Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813c2939121Smrg save_libobjs=$libobjs 9814c2939121Smrg fi 9815c2939121Smrg save_output=$output 9816c2939121Smrg func_basename "$output" 9817c2939121Smrg output_la=$func_basename_result 9818c76ae52dSmrg 9819c2939121Smrg # Clear the reloadable object creation command queue and 9820c2939121Smrg # initialize k to one. 9821c2939121Smrg test_cmds= 9822c2939121Smrg concat_cmds= 9823c2939121Smrg objlist= 9824c2939121Smrg last_robj= 9825c2939121Smrg k=1 9826c76ae52dSmrg 98278292847cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 98288292847cSmrg output=$output_objdir/$output_la.lnkscript 9829c2939121Smrg func_verbose "creating GNU ld script: $output" 9830c2939121Smrg echo 'INPUT (' > $output 9831c2939121Smrg for obj in $save_libobjs 9832c2939121Smrg do 98332836776bSmrg func_to_tool_file "$obj" 98342836776bSmrg $ECHO "$func_to_tool_file_result" >> $output 9835c2939121Smrg done 9836c2939121Smrg echo ')' >> $output 98372836776bSmrg func_append delfiles " $output" 98382836776bSmrg func_to_tool_file "$output" 98392836776bSmrg output=$func_to_tool_file_result 98408292847cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 98418292847cSmrg output=$output_objdir/$output_la.lnk 9842c2939121Smrg func_verbose "creating linker input file list: $output" 9843c2939121Smrg : > $output 9844c2939121Smrg set x $save_libobjs 9845c2939121Smrg shift 9846c2939121Smrg firstobj= 98478292847cSmrg if test yes = "$compiler_needs_object"; then 9848c2939121Smrg firstobj="$1 " 9849c2939121Smrg shift 9850c2939121Smrg fi 9851c2939121Smrg for obj 9852c2939121Smrg do 98532836776bSmrg func_to_tool_file "$obj" 98542836776bSmrg $ECHO "$func_to_tool_file_result" >> $output 9855c2939121Smrg done 98562836776bSmrg func_append delfiles " $output" 98572836776bSmrg func_to_tool_file "$output" 98582836776bSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859c2939121Smrg else 9860c2939121Smrg if test -n "$save_libobjs"; then 9861c2939121Smrg func_verbose "creating reloadable object files..." 98628292847cSmrg output=$output_objdir/$output_la-$k.$objext 9863c2939121Smrg eval test_cmds=\"$reload_cmds\" 9864c2939121Smrg func_len " $test_cmds" 9865c2939121Smrg len0=$func_len_result 9866c2939121Smrg len=$len0 9867c2939121Smrg 9868c2939121Smrg # Loop over the list of objects to be linked. 9869c2939121Smrg for obj in $save_libobjs 9870c2939121Smrg do 9871c2939121Smrg func_len " $obj" 9872c2939121Smrg func_arith $len + $func_len_result 9873c2939121Smrg len=$func_arith_result 98748292847cSmrg if test -z "$objlist" || 9875c2939121Smrg test "$len" -lt "$max_cmd_len"; then 9876c2939121Smrg func_append objlist " $obj" 9877c2939121Smrg else 9878c2939121Smrg # The command $test_cmds is almost too long, add a 9879c2939121Smrg # command to the queue. 98808292847cSmrg if test 1 -eq "$k"; then 9881c2939121Smrg # The first file doesn't have a previous command to add. 9882c2939121Smrg reload_objs=$objlist 9883c2939121Smrg eval concat_cmds=\"$reload_cmds\" 9884c2939121Smrg else 9885c2939121Smrg # All subsequent reloadable object files will link in 9886c2939121Smrg # the last one created. 9887c2939121Smrg reload_objs="$objlist $last_robj" 9888c2939121Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889c2939121Smrg fi 98908292847cSmrg last_robj=$output_objdir/$output_la-$k.$objext 9891c2939121Smrg func_arith $k + 1 9892c2939121Smrg k=$func_arith_result 98938292847cSmrg output=$output_objdir/$output_la-$k.$objext 9894c2939121Smrg objlist=" $obj" 9895c2939121Smrg func_len " $last_robj" 9896c2939121Smrg func_arith $len0 + $func_len_result 9897c2939121Smrg len=$func_arith_result 9898c2939121Smrg fi 9899c2939121Smrg done 9900c2939121Smrg # Handle the remaining objects by creating one last 9901c2939121Smrg # reloadable object file. All subsequent reloadable object 9902c2939121Smrg # files will link in the last one created. 9903c2939121Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904c2939121Smrg reload_objs="$objlist $last_robj" 99058292847cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906c2939121Smrg if test -n "$last_robj"; then 99078292847cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908c2939121Smrg fi 99092836776bSmrg func_append delfiles " $output" 9910c2939121Smrg 9911c2939121Smrg else 9912c2939121Smrg output= 9913c2939121Smrg fi 9914c76ae52dSmrg 99158292847cSmrg ${skipped_export-false} && { 99168292847cSmrg func_verbose "generating symbol list for '$libname.la'" 99178292847cSmrg export_symbols=$output_objdir/$libname.exp 9918c2939121Smrg $opt_dry_run || $RM $export_symbols 9919c2939121Smrg libobjs=$output 9920c2939121Smrg # Append the command to create the export file. 9921c2939121Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922c2939121Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923c2939121Smrg if test -n "$last_robj"; then 9924c2939121Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925c2939121Smrg fi 99268292847cSmrg } 9927c76ae52dSmrg 9928c2939121Smrg test -n "$save_libobjs" && 9929c2939121Smrg func_verbose "creating a temporary reloadable object file: $output" 9930c76ae52dSmrg 9931c2939121Smrg # Loop through the commands generated above and execute them. 99328292847cSmrg save_ifs=$IFS; IFS='~' 9933c2939121Smrg for cmd in $concat_cmds; do 99348292847cSmrg IFS=$save_ifs 99358292847cSmrg $opt_quiet || { 9936c2939121Smrg func_quote_for_expand "$cmd" 9937c2939121Smrg eval "func_echo $func_quote_for_expand_result" 9938c2939121Smrg } 9939c2939121Smrg $opt_dry_run || eval "$cmd" || { 9940c2939121Smrg lt_exit=$? 9941c2939121Smrg 9942c2939121Smrg # Restore the uninstalled library and exit 99438292847cSmrg if test relink = "$opt_mode"; then 9944c2939121Smrg ( cd "$output_objdir" && \ 9945c2939121Smrg $RM "${realname}T" && \ 9946c2939121Smrg $MV "${realname}U" "$realname" ) 9947c2939121Smrg fi 9948c76ae52dSmrg 9949c2939121Smrg exit $lt_exit 9950c2939121Smrg } 9951c2939121Smrg done 99528292847cSmrg IFS=$save_ifs 9953c76ae52dSmrg 9954c2939121Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955c2939121Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956c2939121Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957c76ae52dSmrg fi 9958c76ae52dSmrg fi 9959c76ae52dSmrg 99608292847cSmrg ${skipped_export-false} && { 9961c2939121Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99628292847cSmrg tmp_export_symbols=$export_symbols 99638292847cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964c2939121Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965c2939121Smrg fi 9966c76ae52dSmrg 9967c2939121Smrg if test -n "$orig_export_symbols"; then 9968c2939121Smrg # The given exports_symbols file has to be filtered, so filter it. 99698292847cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970c2939121Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 99718292847cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9972c2939121Smrg # though. Also, the filter scales superlinearly with the number of 9973c2939121Smrg # global variables. join(1) would be nice here, but unfortunately 9974c2939121Smrg # isn't a blessed tool. 9975c2939121Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 99762836776bSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977c2939121Smrg export_symbols=$output_objdir/$libname.def 9978c2939121Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979c2939121Smrg fi 99808292847cSmrg } 9981c76ae52dSmrg 9982c2939121Smrg libobjs=$output 9983c2939121Smrg # Restore the value of output. 9984c2939121Smrg output=$save_output 9985c76ae52dSmrg 9986c2939121Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987c2939121Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988c2939121Smrg test "X$libobjs" = "X " && libobjs= 9989c2939121Smrg fi 9990c2939121Smrg # Expand the library linking commands again to reset the 9991c2939121Smrg # value of $libobjs for piecewise linking. 9992c2939121Smrg 9993c2939121Smrg # Do each of the archive commands. 99948292847cSmrg if test yes = "$module" && test -n "$module_cmds"; then 9995c2939121Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996c2939121Smrg cmds=$module_expsym_cmds 9997c76ae52dSmrg else 9998c2939121Smrg cmds=$module_cmds 9999c76ae52dSmrg fi 10000c76ae52dSmrg else 10001c2939121Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002c2939121Smrg cmds=$archive_expsym_cmds 10003c2939121Smrg else 10004c2939121Smrg cmds=$archive_cmds 10005c2939121Smrg fi 10006c76ae52dSmrg fi 10007c76ae52dSmrg fi 10008c76ae52dSmrg 10009c2939121Smrg if test -n "$delfiles"; then 10010c2939121Smrg # Append the command to remove temporary files to $cmds. 10011c2939121Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10012c2939121Smrg fi 10013c76ae52dSmrg 10014c2939121Smrg # Add any objects from preloaded convenience libraries 10015c2939121Smrg if test -n "$dlprefiles"; then 100168292847cSmrg gentop=$output_objdir/${outputname}x 100172836776bSmrg func_append generated " $gentop" 10018c76ae52dSmrg 10019c2939121Smrg func_extract_archives $gentop $dlprefiles 100202836776bSmrg func_append libobjs " $func_extract_archives_result" 10021c2939121Smrg test "X$libobjs" = "X " && libobjs= 10022c76ae52dSmrg fi 10023c76ae52dSmrg 100248292847cSmrg save_ifs=$IFS; IFS='~' 10025c2939121Smrg for cmd in $cmds; do 100268292847cSmrg IFS=$sp$nl 10027c2939121Smrg eval cmd=\"$cmd\" 100288292847cSmrg IFS=$save_ifs 100298292847cSmrg $opt_quiet || { 10030c2939121Smrg func_quote_for_expand "$cmd" 10031c2939121Smrg eval "func_echo $func_quote_for_expand_result" 10032c2939121Smrg } 10033c2939121Smrg $opt_dry_run || eval "$cmd" || { 10034c2939121Smrg lt_exit=$? 10035c76ae52dSmrg 10036c2939121Smrg # Restore the uninstalled library and exit 100378292847cSmrg if test relink = "$opt_mode"; then 10038c2939121Smrg ( cd "$output_objdir" && \ 10039c2939121Smrg $RM "${realname}T" && \ 10040c2939121Smrg $MV "${realname}U" "$realname" ) 10041c76ae52dSmrg fi 10042c76ae52dSmrg 10043c2939121Smrg exit $lt_exit 10044c2939121Smrg } 10045c2939121Smrg done 100468292847cSmrg IFS=$save_ifs 10047c76ae52dSmrg 10048c2939121Smrg # Restore the uninstalled library and exit 100498292847cSmrg if test relink = "$opt_mode"; then 10050c2939121Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051c76ae52dSmrg 10052c2939121Smrg if test -n "$convenience"; then 10053c2939121Smrg if test -z "$whole_archive_flag_spec"; then 10054c2939121Smrg func_show_eval '${RM}r "$gentop"' 10055c2939121Smrg fi 10056c2939121Smrg fi 10057c76ae52dSmrg 10058c2939121Smrg exit $EXIT_SUCCESS 10059c2939121Smrg fi 10060c76ae52dSmrg 10061c2939121Smrg # Create links to the real library. 10062c2939121Smrg for linkname in $linknames; do 10063c2939121Smrg if test "$realname" != "$linkname"; then 10064c2939121Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065c2939121Smrg fi 10066c2939121Smrg done 10067c76ae52dSmrg 10068c2939121Smrg # If -module or -export-dynamic was specified, set the dlname. 100698292847cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10070c2939121Smrg # On all known operating systems, these are identical. 100718292847cSmrg dlname=$soname 10072c2939121Smrg fi 10073c2939121Smrg fi 10074c2939121Smrg ;; 10075c76ae52dSmrg 10076c2939121Smrg obj) 100778292847cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 100788292847cSmrg func_warning "'-dlopen' is ignored for objects" 10079c2939121Smrg fi 10080c76ae52dSmrg 10081c2939121Smrg case " $deplibs" in 10082c2939121Smrg *\ -l* | *\ -L*) 100838292847cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084c2939121Smrg esac 10085c76ae52dSmrg 10086c2939121Smrg test -n "$rpath" && \ 100878292847cSmrg func_warning "'-rpath' is ignored for objects" 10088c76ae52dSmrg 10089c2939121Smrg test -n "$xrpath" && \ 100908292847cSmrg func_warning "'-R' is ignored for objects" 10091c2939121Smrg 10092c2939121Smrg test -n "$vinfo" && \ 100938292847cSmrg func_warning "'-version-info' is ignored for objects" 10094c76ae52dSmrg 10095c2939121Smrg test -n "$release" && \ 100968292847cSmrg func_warning "'-release' is ignored for objects" 10097c76ae52dSmrg 10098c2939121Smrg case $output in 10099c2939121Smrg *.lo) 10100c2939121Smrg test -n "$objs$old_deplibs" && \ 101018292847cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102c2939121Smrg 10103c2939121Smrg libobj=$output 10104c2939121Smrg func_lo2o "$libobj" 10105c2939121Smrg obj=$func_lo2o_result 10106c2939121Smrg ;; 10107c2939121Smrg *) 10108c2939121Smrg libobj= 101098292847cSmrg obj=$output 10110c76ae52dSmrg ;; 10111c76ae52dSmrg esac 10112c76ae52dSmrg 10113c2939121Smrg # Delete the old objects. 10114c2939121Smrg $opt_dry_run || $RM $obj $libobj 10115c76ae52dSmrg 10116c2939121Smrg # Objects from convenience libraries. This assumes 10117c2939121Smrg # single-version convenience libraries. Whenever we create 10118c2939121Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10119c2939121Smrg # the extraction. 10120c2939121Smrg reload_conv_objs= 10121c2939121Smrg gentop= 101228292847cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 101238292847cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 101248292847cSmrg # into space. 101258292847cSmrg case $reload_cmds in 101268292847cSmrg *\$LD[\ \$]*) wl= ;; 101278292847cSmrg esac 10128c2939121Smrg if test -n "$convenience"; then 10129c2939121Smrg if test -n "$whole_archive_flag_spec"; then 10130c2939121Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 101318292847cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 101328292847cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133c76ae52dSmrg else 101348292847cSmrg gentop=$output_objdir/${obj}x 101352836776bSmrg func_append generated " $gentop" 10136c2939121Smrg 10137c2939121Smrg func_extract_archives $gentop $convenience 10138c2939121Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139c76ae52dSmrg fi 10140c2939121Smrg fi 10141c76ae52dSmrg 101422836776bSmrg # If we're not building shared, we need to use non_pic_objs 101438292847cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 101442836776bSmrg 10145c2939121Smrg # Create the old-style object. 101468292847cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147c76ae52dSmrg 101488292847cSmrg output=$obj 10149c2939121Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10150c76ae52dSmrg 10151c2939121Smrg # Exit if we aren't doing a library object file. 10152c2939121Smrg if test -z "$libobj"; then 10153c2939121Smrg if test -n "$gentop"; then 10154c2939121Smrg func_show_eval '${RM}r "$gentop"' 10155c2939121Smrg fi 10156c76ae52dSmrg 10157c2939121Smrg exit $EXIT_SUCCESS 10158c76ae52dSmrg fi 10159c76ae52dSmrg 101608292847cSmrg test yes = "$build_libtool_libs" || { 10161c2939121Smrg if test -n "$gentop"; then 10162c2939121Smrg func_show_eval '${RM}r "$gentop"' 10163c2939121Smrg fi 10164c76ae52dSmrg 10165c2939121Smrg # Create an invalid libtool object if no PIC, so that we don't 10166c2939121Smrg # accidentally link it into a program. 10167c2939121Smrg # $show "echo timestamp > $libobj" 10168c2939121Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169c2939121Smrg exit $EXIT_SUCCESS 101708292847cSmrg } 10171c76ae52dSmrg 101728292847cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10173c2939121Smrg # Only do commands if we really have different PIC objects. 10174c2939121Smrg reload_objs="$libobjs $reload_conv_objs" 101758292847cSmrg output=$libobj 10176c2939121Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10177c76ae52dSmrg fi 10178c2939121Smrg 10179c2939121Smrg if test -n "$gentop"; then 10180c2939121Smrg func_show_eval '${RM}r "$gentop"' 10181c2939121Smrg fi 10182c2939121Smrg 10183c2939121Smrg exit $EXIT_SUCCESS 10184c76ae52dSmrg ;; 10185c76ae52dSmrg 10186c2939121Smrg prog) 10187c2939121Smrg case $host in 10188c2939121Smrg *cygwin*) func_stripname '' '.exe' "$output" 10189c2939121Smrg output=$func_stripname_result.exe;; 10190c2939121Smrg esac 10191c2939121Smrg test -n "$vinfo" && \ 101928292847cSmrg func_warning "'-version-info' is ignored for programs" 10193c76ae52dSmrg 10194c2939121Smrg test -n "$release" && \ 101958292847cSmrg func_warning "'-release' is ignored for programs" 10196c76ae52dSmrg 101978292847cSmrg $preload \ 101988292847cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 101998292847cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200c2939121Smrg 10201c2939121Smrg case $host in 10202c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10203c2939121Smrg # On Rhapsody replace the C library is the System framework 10204c2939121Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205c2939121Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206c76ae52dSmrg ;; 10207c2939121Smrg esac 10208c76ae52dSmrg 10209c2939121Smrg case $host in 10210c2939121Smrg *-*-darwin*) 10211c2939121Smrg # Don't allow lazy linking, it breaks C++ global constructors 10212c2939121Smrg # But is supposedly fixed on 10.4 or later (yay!). 102138292847cSmrg if test CXX = "$tagname"; then 10214c2939121Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215c2939121Smrg 10.[0123]) 102168292847cSmrg func_append compile_command " $wl-bind_at_load" 102178292847cSmrg func_append finalize_command " $wl-bind_at_load" 10218c2939121Smrg ;; 10219c2939121Smrg esac 10220c76ae52dSmrg fi 10221c2939121Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222c2939121Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223c2939121Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224c2939121Smrg ;; 10225c2939121Smrg esac 10226c76ae52dSmrg 10227c76ae52dSmrg 10228c2939121Smrg # move library search paths that coincide with paths to not yet 10229c2939121Smrg # installed libraries to the beginning of the library search list 10230c2939121Smrg new_libs= 10231c2939121Smrg for path in $notinst_path; do 10232c2939121Smrg case " $new_libs " in 10233c2939121Smrg *" -L$path/$objdir "*) ;; 10234c2939121Smrg *) 10235c2939121Smrg case " $compile_deplibs " in 10236c2939121Smrg *" -L$path/$objdir "*) 102372836776bSmrg func_append new_libs " -L$path/$objdir" ;; 10238c76ae52dSmrg esac 10239c2939121Smrg ;; 10240c2939121Smrg esac 10241c2939121Smrg done 10242c2939121Smrg for deplib in $compile_deplibs; do 10243c2939121Smrg case $deplib in 10244c2939121Smrg -L*) 10245c2939121Smrg case " $new_libs " in 10246c2939121Smrg *" $deplib "*) ;; 102472836776bSmrg *) func_append new_libs " $deplib" ;; 10248c76ae52dSmrg esac 10249c2939121Smrg ;; 102502836776bSmrg *) func_append new_libs " $deplib" ;; 10251c2939121Smrg esac 10252c2939121Smrg done 102538292847cSmrg compile_deplibs=$new_libs 10254c76ae52dSmrg 10255c76ae52dSmrg 102562836776bSmrg func_append compile_command " $compile_deplibs" 102572836776bSmrg func_append finalize_command " $finalize_deplibs" 10258c76ae52dSmrg 10259c2939121Smrg if test -n "$rpath$xrpath"; then 10260c2939121Smrg # If the user specified any rpath flags, then add them. 10261c2939121Smrg for libdir in $rpath $xrpath; do 10262c2939121Smrg # This is the magic to use -rpath. 10263c2939121Smrg case "$finalize_rpath " in 10264c2939121Smrg *" $libdir "*) ;; 102652836776bSmrg *) func_append finalize_rpath " $libdir" ;; 10266c2939121Smrg esac 10267c2939121Smrg done 10268c2939121Smrg fi 10269c76ae52dSmrg 10270c2939121Smrg # Now hardcode the library paths 10271c2939121Smrg rpath= 10272c2939121Smrg hardcode_libdirs= 10273c2939121Smrg for libdir in $compile_rpath $finalize_rpath; do 10274c2939121Smrg if test -n "$hardcode_libdir_flag_spec"; then 10275c2939121Smrg if test -n "$hardcode_libdir_separator"; then 10276c2939121Smrg if test -z "$hardcode_libdirs"; then 102778292847cSmrg hardcode_libdirs=$libdir 10278c2939121Smrg else 10279c2939121Smrg # Just accumulate the unique libdirs. 10280c2939121Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281c2939121Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282c2939121Smrg ;; 10283c2939121Smrg *) 102842836776bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285c2939121Smrg ;; 10286c2939121Smrg esac 10287c2939121Smrg fi 10288c76ae52dSmrg else 10289c2939121Smrg eval flag=\"$hardcode_libdir_flag_spec\" 102902836776bSmrg func_append rpath " $flag" 10291c76ae52dSmrg fi 10292c2939121Smrg elif test -n "$runpath_var"; then 10293c2939121Smrg case "$perm_rpath " in 10294c2939121Smrg *" $libdir "*) ;; 102952836776bSmrg *) func_append perm_rpath " $libdir" ;; 10296c2939121Smrg esac 10297c2939121Smrg fi 10298c2939121Smrg case $host in 10299c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 103008292847cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301c2939121Smrg case :$dllsearchpath: in 10302c2939121Smrg *":$libdir:"*) ;; 10303c2939121Smrg ::) dllsearchpath=$libdir;; 103042836776bSmrg *) func_append dllsearchpath ":$libdir";; 10305c2939121Smrg esac 10306c2939121Smrg case :$dllsearchpath: in 10307c2939121Smrg *":$testbindir:"*) ;; 10308c2939121Smrg ::) dllsearchpath=$testbindir;; 103092836776bSmrg *) func_append dllsearchpath ":$testbindir";; 10310c2939121Smrg esac 10311c2939121Smrg ;; 10312c2939121Smrg esac 10313c2939121Smrg done 10314c2939121Smrg # Substitute the hardcoded libdirs into the rpath. 10315c2939121Smrg if test -n "$hardcode_libdir_separator" && 10316c2939121Smrg test -n "$hardcode_libdirs"; then 103178292847cSmrg libdir=$hardcode_libdirs 10318c2939121Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10319c2939121Smrg fi 103208292847cSmrg compile_rpath=$rpath 10321c76ae52dSmrg 10322c2939121Smrg rpath= 10323c2939121Smrg hardcode_libdirs= 10324c2939121Smrg for libdir in $finalize_rpath; do 10325c2939121Smrg if test -n "$hardcode_libdir_flag_spec"; then 10326c2939121Smrg if test -n "$hardcode_libdir_separator"; then 10327c2939121Smrg if test -z "$hardcode_libdirs"; then 103288292847cSmrg hardcode_libdirs=$libdir 10329c2939121Smrg else 10330c2939121Smrg # Just accumulate the unique libdirs. 10331c2939121Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332c2939121Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333c2939121Smrg ;; 10334c2939121Smrg *) 103352836776bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336c2939121Smrg ;; 10337c2939121Smrg esac 10338c2939121Smrg fi 10339c76ae52dSmrg else 10340c2939121Smrg eval flag=\"$hardcode_libdir_flag_spec\" 103412836776bSmrg func_append rpath " $flag" 10342c76ae52dSmrg fi 10343c2939121Smrg elif test -n "$runpath_var"; then 10344c2939121Smrg case "$finalize_perm_rpath " in 10345c2939121Smrg *" $libdir "*) ;; 103462836776bSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10347c2939121Smrg esac 10348c76ae52dSmrg fi 10349c2939121Smrg done 10350c2939121Smrg # Substitute the hardcoded libdirs into the rpath. 10351c2939121Smrg if test -n "$hardcode_libdir_separator" && 10352c2939121Smrg test -n "$hardcode_libdirs"; then 103538292847cSmrg libdir=$hardcode_libdirs 10354c2939121Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10355c2939121Smrg fi 103568292847cSmrg finalize_rpath=$rpath 10357c76ae52dSmrg 103588292847cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359c2939121Smrg # Transform all the library objects into standard objects. 10360c2939121Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362c2939121Smrg fi 10363c76ae52dSmrg 103648292847cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365c76ae52dSmrg 10366c2939121Smrg # template prelinking step 10367c2939121Smrg if test -n "$prelink_cmds"; then 10368c2939121Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10369c2939121Smrg fi 10370c76ae52dSmrg 103718292847cSmrg wrappers_required=: 10372c2939121Smrg case $host in 10373c2939121Smrg *cegcc* | *mingw32ce*) 10374c2939121Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 103758292847cSmrg wrappers_required=false 10376c2939121Smrg ;; 10377c2939121Smrg *cygwin* | *mingw* ) 103788292847cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10379c2939121Smrg ;; 10380c2939121Smrg *) 103818292847cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 103828292847cSmrg wrappers_required=false 10383c2939121Smrg fi 10384c2939121Smrg ;; 10385c2939121Smrg esac 103868292847cSmrg $wrappers_required || { 10387c2939121Smrg # Replace the output file specification. 10388c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 103898292847cSmrg link_command=$compile_command$compile_rpath 10390c76ae52dSmrg 10391c2939121Smrg # We have no uninstalled library dependencies, so finalize right now. 10392c2939121Smrg exit_status=0 10393c2939121Smrg func_show_eval "$link_command" 'exit_status=$?' 10394c76ae52dSmrg 103952836776bSmrg if test -n "$postlink_cmds"; then 103962836776bSmrg func_to_tool_file "$output" 103972836776bSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 103982836776bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 103992836776bSmrg fi 104002836776bSmrg 10401c2939121Smrg # Delete the generated files. 104028292847cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 104038292847cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404c76ae52dSmrg fi 10405c76ae52dSmrg 10406c2939121Smrg exit $exit_status 104078292847cSmrg } 10408c76ae52dSmrg 10409c2939121Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410c2939121Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411c2939121Smrg fi 10412c2939121Smrg if test -n "$finalize_shlibpath"; then 10413c2939121Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414c2939121Smrg fi 10415c76ae52dSmrg 10416c2939121Smrg compile_var= 10417c2939121Smrg finalize_var= 10418c2939121Smrg if test -n "$runpath_var"; then 10419c2939121Smrg if test -n "$perm_rpath"; then 10420c2939121Smrg # We should set the runpath_var. 10421c2939121Smrg rpath= 10422c2939121Smrg for dir in $perm_rpath; do 104232836776bSmrg func_append rpath "$dir:" 10424c2939121Smrg done 10425c2939121Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426c76ae52dSmrg fi 10427c2939121Smrg if test -n "$finalize_perm_rpath"; then 10428c2939121Smrg # We should set the runpath_var. 10429c2939121Smrg rpath= 10430c2939121Smrg for dir in $finalize_perm_rpath; do 104312836776bSmrg func_append rpath "$dir:" 10432c2939121Smrg done 10433c2939121Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434c76ae52dSmrg fi 10435c2939121Smrg fi 10436c76ae52dSmrg 104378292847cSmrg if test yes = "$no_install"; then 10438c2939121Smrg # We don't need to create a wrapper script. 104398292847cSmrg link_command=$compile_var$compile_command$compile_rpath 10440c2939121Smrg # Replace the output file specification. 10441c2939121Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442c2939121Smrg # Delete the old output file. 10443c2939121Smrg $opt_dry_run || $RM $output 10444c2939121Smrg # Link the executable and exit 10445c2939121Smrg func_show_eval "$link_command" 'exit $?' 104462836776bSmrg 104472836776bSmrg if test -n "$postlink_cmds"; then 104482836776bSmrg func_to_tool_file "$output" 104492836776bSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 104502836776bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 104512836776bSmrg fi 104522836776bSmrg 10453c76ae52dSmrg exit $EXIT_SUCCESS 10454c2939121Smrg fi 10455c76ae52dSmrg 104568292847cSmrg case $hardcode_action,$fast_install in 104578292847cSmrg relink,*) 104588292847cSmrg # Fast installation is not supported 104598292847cSmrg link_command=$compile_var$compile_command$compile_rpath 104608292847cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10461c2939121Smrg 104628292847cSmrg func_warning "this platform does not like uninstalled shared libraries" 104638292847cSmrg func_warning "'$output' will be relinked during installation" 104648292847cSmrg ;; 104658292847cSmrg *,yes) 104668292847cSmrg link_command=$finalize_var$compile_command$finalize_rpath 104678292847cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 104688292847cSmrg ;; 104698292847cSmrg *,no) 104708292847cSmrg link_command=$compile_var$compile_command$compile_rpath 104718292847cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 104728292847cSmrg ;; 104738292847cSmrg *,needless) 104748292847cSmrg link_command=$finalize_var$compile_command$finalize_rpath 104758292847cSmrg relink_command= 104768292847cSmrg ;; 104778292847cSmrg esac 10478c76ae52dSmrg 10479c2939121Smrg # Replace the output file specification. 10480c2939121Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481c76ae52dSmrg 10482c2939121Smrg # Delete the old output files. 10483c2939121Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484c76ae52dSmrg 10485c2939121Smrg func_show_eval "$link_command" 'exit $?' 10486c76ae52dSmrg 104872836776bSmrg if test -n "$postlink_cmds"; then 104882836776bSmrg func_to_tool_file "$output_objdir/$outputname" 104892836776bSmrg 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'` 104902836776bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 104912836776bSmrg fi 104922836776bSmrg 10493c2939121Smrg # Now create the wrapper script. 10494c2939121Smrg func_verbose "creating $output" 10495c76ae52dSmrg 10496c2939121Smrg # Quote the relink command for shipping. 10497c2939121Smrg if test -n "$relink_command"; then 10498c2939121Smrg # Preserve any variables that may affect compiler behavior 10499c2939121Smrg for var in $variables_saved_for_relink; do 10500c2939121Smrg if eval test -z \"\${$var+set}\"; then 10501c2939121Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502c2939121Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10503c2939121Smrg relink_command="$var=; export $var; $relink_command" 10504c76ae52dSmrg else 10505c2939121Smrg func_quote_for_eval "$var_value" 10506c2939121Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507c76ae52dSmrg fi 10508c2939121Smrg done 10509c2939121Smrg relink_command="(cd `pwd`; $relink_command)" 10510c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511c2939121Smrg fi 10512c76ae52dSmrg 10513c2939121Smrg # Only actually do things if not in dry run mode. 10514c2939121Smrg $opt_dry_run || { 10515c2939121Smrg # win32 will think the script is a binary if it has 10516c2939121Smrg # a .exe suffix, so we strip it off here. 10517c2939121Smrg case $output in 10518c2939121Smrg *.exe) func_stripname '' '.exe' "$output" 10519c2939121Smrg output=$func_stripname_result ;; 10520c2939121Smrg esac 10521c2939121Smrg # test for cygwin because mv fails w/o .exe extensions 10522c2939121Smrg case $host in 10523c2939121Smrg *cygwin*) 10524c2939121Smrg exeext=.exe 10525c2939121Smrg func_stripname '' '.exe' "$outputname" 10526c2939121Smrg outputname=$func_stripname_result ;; 10527c2939121Smrg *) exeext= ;; 10528c76ae52dSmrg esac 10529c2939121Smrg case $host in 10530c2939121Smrg *cygwin* | *mingw* ) 10531c2939121Smrg func_dirname_and_basename "$output" "" "." 10532c2939121Smrg output_name=$func_basename_result 10533c2939121Smrg output_path=$func_dirname_result 105348292847cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 105358292847cSmrg cwrapper=$output_path/$output_name.exe 10536c2939121Smrg $RM $cwrappersource $cwrapper 10537c2939121Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538c2939121Smrg 10539c2939121Smrg func_emit_cwrapperexe_src > $cwrappersource 10540c2939121Smrg 10541c2939121Smrg # The wrapper executable is built using the $host compiler, 10542c2939121Smrg # because it contains $host paths and files. If cross- 10543c2939121Smrg # compiling, it, like the target executable, must be 10544c2939121Smrg # executed on the $host or under an emulation environment. 10545c2939121Smrg $opt_dry_run || { 10546c2939121Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547c2939121Smrg $STRIP $cwrapper 10548c2939121Smrg } 10549c76ae52dSmrg 10550c2939121Smrg # Now, create the wrapper script for func_source use: 10551c2939121Smrg func_ltwrapper_scriptname $cwrapper 10552c2939121Smrg $RM $func_ltwrapper_scriptname_result 10553c2939121Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554c2939121Smrg $opt_dry_run || { 10555c2939121Smrg # note: this script will not be executed, so do not chmod. 105568292847cSmrg if test "x$build" = "x$host"; then 10557c2939121Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558c2939121Smrg else 10559c2939121Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560c2939121Smrg fi 10561c2939121Smrg } 10562c2939121Smrg ;; 10563c2939121Smrg * ) 10564c2939121Smrg $RM $output 10565c2939121Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566c76ae52dSmrg 10567c2939121Smrg func_emit_wrapper no > $output 10568c2939121Smrg chmod +x $output 10569c2939121Smrg ;; 10570c2939121Smrg esac 10571c2939121Smrg } 10572c2939121Smrg exit $EXIT_SUCCESS 10573c2939121Smrg ;; 10574c2939121Smrg esac 10575c76ae52dSmrg 10576c2939121Smrg # See if we need to build an old-fashioned archive. 10577c2939121Smrg for oldlib in $oldlibs; do 10578c76ae52dSmrg 105798292847cSmrg case $build_libtool_libs in 105808292847cSmrg convenience) 105818292847cSmrg oldobjs="$libobjs_save $symfileobj" 105828292847cSmrg addlibs=$convenience 10583c2939121Smrg build_libtool_libs=no 105848292847cSmrg ;; 105858292847cSmrg module) 105868292847cSmrg oldobjs=$libobjs_save 105878292847cSmrg addlibs=$old_convenience 105888292847cSmrg build_libtool_libs=no 105898292847cSmrg ;; 105908292847cSmrg *) 10591c2939121Smrg oldobjs="$old_deplibs $non_pic_objects" 105928292847cSmrg $preload && test -f "$symfileobj" \ 105938292847cSmrg && func_append oldobjs " $symfileobj" 105948292847cSmrg addlibs=$old_convenience 105958292847cSmrg ;; 105968292847cSmrg esac 10597c76ae52dSmrg 10598c2939121Smrg if test -n "$addlibs"; then 105998292847cSmrg gentop=$output_objdir/${outputname}x 106002836776bSmrg func_append generated " $gentop" 10601c76ae52dSmrg 10602c2939121Smrg func_extract_archives $gentop $addlibs 106032836776bSmrg func_append oldobjs " $func_extract_archives_result" 10604c2939121Smrg fi 10605c76ae52dSmrg 10606c2939121Smrg # Do each command in the archive commands. 106078292847cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608c2939121Smrg cmds=$old_archive_from_new_cmds 10609c2939121Smrg else 10610c76ae52dSmrg 10611c2939121Smrg # Add any objects from preloaded convenience libraries 10612c2939121Smrg if test -n "$dlprefiles"; then 106138292847cSmrg gentop=$output_objdir/${outputname}x 106142836776bSmrg func_append generated " $gentop" 10615c76ae52dSmrg 10616c2939121Smrg func_extract_archives $gentop $dlprefiles 106172836776bSmrg func_append oldobjs " $func_extract_archives_result" 10618c2939121Smrg fi 10619c76ae52dSmrg 10620c2939121Smrg # POSIX demands no paths to be encoded in archives. We have 10621c2939121Smrg # to avoid creating archives with duplicate basenames if we 10622c2939121Smrg # might have to extract them afterwards, e.g., when creating a 10623c2939121Smrg # static archive out of a convenience library, or when linking 10624c2939121Smrg # the entirety of a libtool archive into another (currently 10625c2939121Smrg # not supported by libtool). 10626c2939121Smrg if (for obj in $oldobjs 10627c2939121Smrg do 10628c2939121Smrg func_basename "$obj" 10629c2939121Smrg $ECHO "$func_basename_result" 10630c2939121Smrg done | sort | sort -uc >/dev/null 2>&1); then 10631c2939121Smrg : 10632c2939121Smrg else 10633c2939121Smrg echo "copying selected object files to avoid basename conflicts..." 106348292847cSmrg gentop=$output_objdir/${outputname}x 106352836776bSmrg func_append generated " $gentop" 10636c2939121Smrg func_mkdir_p "$gentop" 10637c2939121Smrg save_oldobjs=$oldobjs 10638c2939121Smrg oldobjs= 10639c2939121Smrg counter=1 10640c2939121Smrg for obj in $save_oldobjs 10641c2939121Smrg do 10642c2939121Smrg func_basename "$obj" 106438292847cSmrg objbase=$func_basename_result 10644c2939121Smrg case " $oldobjs " in 10645c2939121Smrg " ") oldobjs=$obj ;; 10646c2939121Smrg *[\ /]"$objbase "*) 10647c2939121Smrg while :; do 10648c2939121Smrg # Make sure we don't pick an alternate name that also 10649c2939121Smrg # overlaps. 10650c2939121Smrg newobj=lt$counter-$objbase 10651c2939121Smrg func_arith $counter + 1 10652c2939121Smrg counter=$func_arith_result 10653c2939121Smrg case " $oldobjs " in 10654c2939121Smrg *[\ /]"$newobj "*) ;; 10655c2939121Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656c2939121Smrg esac 10657c2939121Smrg done 10658c2939121Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 106592836776bSmrg func_append oldobjs " $gentop/$newobj" 10660c2939121Smrg ;; 106612836776bSmrg *) func_append oldobjs " $obj" ;; 10662c2939121Smrg esac 10663c76ae52dSmrg done 10664c76ae52dSmrg fi 106652836776bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 106662836776bSmrg tool_oldlib=$func_to_tool_file_result 10667c2939121Smrg eval cmds=\"$old_archive_cmds\" 10668c76ae52dSmrg 10669c2939121Smrg func_len " $cmds" 10670c2939121Smrg len=$func_len_result 10671c2939121Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672c2939121Smrg cmds=$old_archive_cmds 106732836776bSmrg elif test -n "$archiver_list_spec"; then 106742836776bSmrg func_verbose "using command file archive linking..." 106752836776bSmrg for obj in $oldobjs 106762836776bSmrg do 106772836776bSmrg func_to_tool_file "$obj" 106782836776bSmrg $ECHO "$func_to_tool_file_result" 106792836776bSmrg done > $output_objdir/$libname.libcmd 106802836776bSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 106812836776bSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 106822836776bSmrg cmds=$old_archive_cmds 10683c2939121Smrg else 10684c2939121Smrg # the command line is too long to link in one step, link in parts 10685c2939121Smrg func_verbose "using piecewise archive linking..." 10686c2939121Smrg save_RANLIB=$RANLIB 10687c2939121Smrg RANLIB=: 10688c2939121Smrg objlist= 10689c2939121Smrg concat_cmds= 10690c2939121Smrg save_oldobjs=$oldobjs 10691c2939121Smrg oldobjs= 10692c2939121Smrg # Is there a better way of finding the last object in the list? 10693c2939121Smrg for obj in $save_oldobjs 10694c2939121Smrg do 10695c2939121Smrg last_oldobj=$obj 10696c2939121Smrg done 10697c2939121Smrg eval test_cmds=\"$old_archive_cmds\" 10698c2939121Smrg func_len " $test_cmds" 10699c2939121Smrg len0=$func_len_result 10700c2939121Smrg len=$len0 10701c2939121Smrg for obj in $save_oldobjs 10702c2939121Smrg do 10703c2939121Smrg func_len " $obj" 10704c2939121Smrg func_arith $len + $func_len_result 10705c2939121Smrg len=$func_arith_result 10706c2939121Smrg func_append objlist " $obj" 10707c2939121Smrg if test "$len" -lt "$max_cmd_len"; then 10708c2939121Smrg : 10709c2939121Smrg else 10710c2939121Smrg # the above command should be used before it gets too long 10711c2939121Smrg oldobjs=$objlist 107128292847cSmrg if test "$obj" = "$last_oldobj"; then 10713c2939121Smrg RANLIB=$save_RANLIB 10714c2939121Smrg fi 10715c2939121Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 107168292847cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717c2939121Smrg objlist= 10718c2939121Smrg len=$len0 10719c2939121Smrg fi 10720c2939121Smrg done 10721c2939121Smrg RANLIB=$save_RANLIB 10722c2939121Smrg oldobjs=$objlist 107238292847cSmrg if test -z "$oldobjs"; then 10724c2939121Smrg eval cmds=\"\$concat_cmds\" 10725c2939121Smrg else 10726c2939121Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727c2939121Smrg fi 10728c2939121Smrg fi 10729c2939121Smrg fi 10730c2939121Smrg func_execute_cmds "$cmds" 'exit $?' 10731c76ae52dSmrg done 10732c76ae52dSmrg 10733c2939121Smrg test -n "$generated" && \ 10734c2939121Smrg func_show_eval "${RM}r$generated" 10735c76ae52dSmrg 10736c2939121Smrg # Now create the libtool archive. 10737c2939121Smrg case $output in 10738c2939121Smrg *.la) 10739c2939121Smrg old_library= 107408292847cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10741c2939121Smrg func_verbose "creating $output" 10742c76ae52dSmrg 10743c2939121Smrg # Preserve any variables that may affect compiler behavior 10744c2939121Smrg for var in $variables_saved_for_relink; do 10745c2939121Smrg if eval test -z \"\${$var+set}\"; then 10746c2939121Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747c2939121Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10748c2939121Smrg relink_command="$var=; export $var; $relink_command" 10749c76ae52dSmrg else 10750c2939121Smrg func_quote_for_eval "$var_value" 10751c2939121Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752c76ae52dSmrg fi 10753c2939121Smrg done 10754c2939121Smrg # Quote the link command for shipping. 107558292847cSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 107578292847cSmrg if test yes = "$hardcode_automatic"; then 10758c2939121Smrg relink_command= 10759c2939121Smrg fi 10760c76ae52dSmrg 10761c2939121Smrg # Only create the output if not a dry run. 10762c2939121Smrg $opt_dry_run || { 10763c2939121Smrg for installed in no yes; do 107648292847cSmrg if test yes = "$installed"; then 10765c2939121Smrg if test -z "$install_libdir"; then 10766c2939121Smrg break 10767c2939121Smrg fi 107688292847cSmrg output=$output_objdir/${outputname}i 10769c2939121Smrg # Replace all uninstalled libtool libraries with the installed ones 10770c2939121Smrg newdependency_libs= 10771c2939121Smrg for deplib in $dependency_libs; do 10772c2939121Smrg case $deplib in 10773c2939121Smrg *.la) 10774c2939121Smrg func_basename "$deplib" 107758292847cSmrg name=$func_basename_result 107762836776bSmrg func_resolve_sysroot "$deplib" 107778292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778c2939121Smrg test -z "$libdir" && \ 107798292847cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 107802836776bSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 107812836776bSmrg ;; 107822836776bSmrg -L*) 107832836776bSmrg func_stripname -L '' "$deplib" 107842836776bSmrg func_replace_sysroot "$func_stripname_result" 107852836776bSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 107862836776bSmrg ;; 107872836776bSmrg -R*) 107882836776bSmrg func_stripname -R '' "$deplib" 107892836776bSmrg func_replace_sysroot "$func_stripname_result" 107902836776bSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791c2939121Smrg ;; 107922836776bSmrg *) func_append newdependency_libs " $deplib" ;; 10793c2939121Smrg esac 10794c2939121Smrg done 107958292847cSmrg dependency_libs=$newdependency_libs 10796c2939121Smrg newdlfiles= 10797c2939121Smrg 10798c2939121Smrg for lib in $dlfiles; do 10799c2939121Smrg case $lib in 10800c2939121Smrg *.la) 10801c2939121Smrg func_basename "$lib" 108028292847cSmrg name=$func_basename_result 108038292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804c2939121Smrg test -z "$libdir" && \ 108058292847cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 108062836776bSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807c2939121Smrg ;; 108082836776bSmrg *) func_append newdlfiles " $lib" ;; 10809c2939121Smrg esac 10810c2939121Smrg done 108118292847cSmrg dlfiles=$newdlfiles 10812c2939121Smrg newdlprefiles= 10813c2939121Smrg for lib in $dlprefiles; do 10814c2939121Smrg case $lib in 10815c2939121Smrg *.la) 10816c2939121Smrg # Only pass preopened files to the pseudo-archive (for 10817c2939121Smrg # eventual linking with the app. that links it) if we 10818c2939121Smrg # didn't already link the preopened objects directly into 10819c2939121Smrg # the library: 10820c2939121Smrg func_basename "$lib" 108218292847cSmrg name=$func_basename_result 108228292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823c2939121Smrg test -z "$libdir" && \ 108248292847cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 108252836776bSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826c2939121Smrg ;; 10827c2939121Smrg esac 10828c2939121Smrg done 108298292847cSmrg dlprefiles=$newdlprefiles 10830c2939121Smrg else 10831c2939121Smrg newdlfiles= 10832c2939121Smrg for lib in $dlfiles; do 10833c2939121Smrg case $lib in 108348292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835c2939121Smrg *) abs=`pwd`"/$lib" ;; 10836c2939121Smrg esac 108372836776bSmrg func_append newdlfiles " $abs" 10838c2939121Smrg done 108398292847cSmrg dlfiles=$newdlfiles 10840c2939121Smrg newdlprefiles= 10841c2939121Smrg for lib in $dlprefiles; do 10842c2939121Smrg case $lib in 108438292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844c2939121Smrg *) abs=`pwd`"/$lib" ;; 10845c2939121Smrg esac 108462836776bSmrg func_append newdlprefiles " $abs" 10847c2939121Smrg done 108488292847cSmrg dlprefiles=$newdlprefiles 10849c2939121Smrg fi 10850c2939121Smrg $RM $output 10851c2939121Smrg # place dlname in correct position for cygwin 10852c2939121Smrg # In fact, it would be nice if we could use this code for all target 10853c2939121Smrg # systems that can't hard-code library paths into their executables 10854c2939121Smrg # and that have no shared library path variable independent of PATH, 10855c2939121Smrg # but it turns out we can't easily determine that from inspecting 10856c2939121Smrg # libtool variables, so we have to hard-code the OSs to which it 10857c2939121Smrg # applies here; at the moment, that means platforms that use the PE 10858c2939121Smrg # object format with DLL files. See the long comment at the top of 10859c2939121Smrg # tests/bindir.at for full details. 10860c2939121Smrg tdlname=$dlname 10861c2939121Smrg case $host,$output,$installed,$module,$dlname in 10862c2939121Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863c2939121Smrg # If a -bindir argument was supplied, place the dll there. 108648292847cSmrg if test -n "$bindir"; then 10865c2939121Smrg func_relative_path "$install_libdir" "$bindir" 108668292847cSmrg tdlname=$func_relative_path_result/$dlname 10867c2939121Smrg else 10868c2939121Smrg # Otherwise fall back on heuristic. 10869c2939121Smrg tdlname=../bin/$dlname 10870c2939121Smrg fi 10871c2939121Smrg ;; 10872c2939121Smrg esac 10873c2939121Smrg $ECHO > $output "\ 10874c2939121Smrg# $outputname - a libtool library file 108758292847cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876c2939121Smrg# 10877c2939121Smrg# Please DO NOT delete this file! 10878c2939121Smrg# It is necessary for linking the library. 10879c76ae52dSmrg 10880c2939121Smrg# The name that we can dlopen(3). 10881c2939121Smrgdlname='$tdlname' 10882c76ae52dSmrg 10883c2939121Smrg# Names of this library. 10884c2939121Smrglibrary_names='$library_names' 10885c76ae52dSmrg 10886c2939121Smrg# The name of the static archive. 10887c2939121Smrgold_library='$old_library' 10888c76ae52dSmrg 108898292847cSmrg# Linker flags that cannot go in dependency_libs. 10890c2939121Smrginherited_linker_flags='$new_inherited_linker_flags' 10891c76ae52dSmrg 10892c2939121Smrg# Libraries that this one depends upon. 10893c2939121Smrgdependency_libs='$dependency_libs' 10894c76ae52dSmrg 10895c2939121Smrg# Names of additional weak libraries provided by this library 10896c2939121Smrgweak_library_names='$weak_libs' 10897c76ae52dSmrg 10898c2939121Smrg# Version information for $libname. 10899c2939121Smrgcurrent=$current 10900c2939121Smrgage=$age 10901c2939121Smrgrevision=$revision 10902c76ae52dSmrg 10903c2939121Smrg# Is this an already installed library? 10904c2939121Smrginstalled=$installed 10905c76ae52dSmrg 10906c2939121Smrg# Should we warn about portability when linking against -modules? 10907c2939121Smrgshouldnotlink=$module 10908c76ae52dSmrg 10909c2939121Smrg# Files to dlopen/dlpreopen 10910c2939121Smrgdlopen='$dlfiles' 10911c2939121Smrgdlpreopen='$dlprefiles' 10912c76ae52dSmrg 10913c2939121Smrg# Directory that this library needs to be installed in: 10914c2939121Smrglibdir='$install_libdir'" 109158292847cSmrg if test no,yes = "$installed,$need_relink"; then 10916c2939121Smrg $ECHO >> $output "\ 10917c2939121Smrgrelink_command=\"$relink_command\"" 10918c2939121Smrg fi 10919c2939121Smrg done 10920c2939121Smrg } 10921c76ae52dSmrg 10922c2939121Smrg # Do a symbolic link so that the libtool archive can be found in 10923c2939121Smrg # LD_LIBRARY_PATH before the program is installed. 10924c2939121Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925c2939121Smrg ;; 10926c2939121Smrg esac 10927c2939121Smrg exit $EXIT_SUCCESS 10928c2939121Smrg} 10929c76ae52dSmrg 109308292847cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 109318292847cSmrg func_mode_link ${1+"$@"} 109328292847cSmrgfi 10933c76ae52dSmrg 10934c76ae52dSmrg 10935c2939121Smrg# func_mode_uninstall arg... 10936c2939121Smrgfunc_mode_uninstall () 10937c2939121Smrg{ 109388292847cSmrg $debug_cmd 109398292847cSmrg 109408292847cSmrg RM=$nonopt 10941c76ae52dSmrg files= 109428292847cSmrg rmforce=false 10943c76ae52dSmrg exit_status=0 10944c76ae52dSmrg 10945c76ae52dSmrg # This variable tells wrapper scripts just to set variables rather 10946c76ae52dSmrg # than running their programs. 109478292847cSmrg libtool_install_magic=$magic 10948c76ae52dSmrg 10949c76ae52dSmrg for arg 10950c76ae52dSmrg do 10951c76ae52dSmrg case $arg in 109528292847cSmrg -f) func_append RM " $arg"; rmforce=: ;; 109532836776bSmrg -*) func_append RM " $arg" ;; 109542836776bSmrg *) func_append files " $arg" ;; 10955c76ae52dSmrg esac 10956c76ae52dSmrg done 10957c76ae52dSmrg 10958c2939121Smrg test -z "$RM" && \ 10959c2939121Smrg func_fatal_help "you must specify an RM program" 10960c76ae52dSmrg 10961c76ae52dSmrg rmdirs= 10962c76ae52dSmrg 10963c76ae52dSmrg for file in $files; do 10964c2939121Smrg func_dirname "$file" "" "." 109658292847cSmrg dir=$func_dirname_result 109668292847cSmrg if test . = "$dir"; then 109678292847cSmrg odir=$objdir 10968c76ae52dSmrg else 109698292847cSmrg odir=$dir/$objdir 10970c76ae52dSmrg fi 10971c2939121Smrg func_basename "$file" 109728292847cSmrg name=$func_basename_result 109738292847cSmrg test uninstall = "$opt_mode" && odir=$dir 10974c76ae52dSmrg 109752836776bSmrg # Remember odir for removal later, being careful to avoid duplicates 109768292847cSmrg if test clean = "$opt_mode"; then 10977c76ae52dSmrg case " $rmdirs " in 109782836776bSmrg *" $odir "*) ;; 109792836776bSmrg *) func_append rmdirs " $odir" ;; 10980c76ae52dSmrg esac 10981c76ae52dSmrg fi 10982c76ae52dSmrg 10983c76ae52dSmrg # Don't error if the file doesn't exist and rm -f was used. 10984c2939121Smrg if { test -L "$file"; } >/dev/null 2>&1 || 10985c2939121Smrg { test -h "$file"; } >/dev/null 2>&1 || 10986c2939121Smrg test -f "$file"; then 10987c76ae52dSmrg : 10988c76ae52dSmrg elif test -d "$file"; then 10989c76ae52dSmrg exit_status=1 10990c76ae52dSmrg continue 109918292847cSmrg elif $rmforce; then 10992c76ae52dSmrg continue 10993c76ae52dSmrg fi 10994c76ae52dSmrg 109958292847cSmrg rmfiles=$file 10996c76ae52dSmrg 10997c76ae52dSmrg case $name in 10998c76ae52dSmrg *.la) 10999c76ae52dSmrg # Possibly a libtool archive, so verify it. 11000c2939121Smrg if func_lalib_p "$file"; then 11001c2939121Smrg func_source $dir/$name 11002c76ae52dSmrg 11003c76ae52dSmrg # Delete the libtool libraries and symlinks. 11004c76ae52dSmrg for n in $library_names; do 110052836776bSmrg func_append rmfiles " $odir/$n" 11006c76ae52dSmrg done 110072836776bSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008c76ae52dSmrg 110098292847cSmrg case $opt_mode in 11010c76ae52dSmrg clean) 110112836776bSmrg case " $library_names " in 11012c76ae52dSmrg *" $dlname "*) ;; 110132836776bSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014c76ae52dSmrg esac 110152836776bSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016c76ae52dSmrg ;; 11017c76ae52dSmrg uninstall) 11018c76ae52dSmrg if test -n "$library_names"; then 11019c76ae52dSmrg # Do each command in the postuninstall commands. 110208292847cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021c76ae52dSmrg fi 11022c76ae52dSmrg 11023c76ae52dSmrg if test -n "$old_library"; then 11024c76ae52dSmrg # Do each command in the old_postuninstall commands. 110258292847cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026c76ae52dSmrg fi 11027c76ae52dSmrg # FIXME: should reinstall the best remaining shared library. 11028c76ae52dSmrg ;; 11029c76ae52dSmrg esac 11030c76ae52dSmrg fi 11031c76ae52dSmrg ;; 11032c76ae52dSmrg 11033c76ae52dSmrg *.lo) 11034c76ae52dSmrg # Possibly a libtool object, so verify it. 11035c2939121Smrg if func_lalib_p "$file"; then 11036c76ae52dSmrg 11037c76ae52dSmrg # Read the .lo file 11038c2939121Smrg func_source $dir/$name 11039c76ae52dSmrg 11040c76ae52dSmrg # Add PIC object to the list of files to remove. 110418292847cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 110422836776bSmrg func_append rmfiles " $dir/$pic_object" 11043c76ae52dSmrg fi 11044c76ae52dSmrg 11045c76ae52dSmrg # Add non-PIC object to the list of files to remove. 110468292847cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 110472836776bSmrg func_append rmfiles " $dir/$non_pic_object" 11048c76ae52dSmrg fi 11049c76ae52dSmrg fi 11050c76ae52dSmrg ;; 11051c76ae52dSmrg 11052c76ae52dSmrg *) 110538292847cSmrg if test clean = "$opt_mode"; then 11054c76ae52dSmrg noexename=$name 11055c76ae52dSmrg case $file in 11056c76ae52dSmrg *.exe) 11057c2939121Smrg func_stripname '' '.exe' "$file" 11058c2939121Smrg file=$func_stripname_result 11059c2939121Smrg func_stripname '' '.exe' "$name" 11060c2939121Smrg noexename=$func_stripname_result 11061c76ae52dSmrg # $file with .exe has already been added to rmfiles, 11062c76ae52dSmrg # add $file without .exe 110632836776bSmrg func_append rmfiles " $file" 11064c76ae52dSmrg ;; 11065c76ae52dSmrg esac 11066c76ae52dSmrg # Do a test to see if this is a libtool program. 11067c2939121Smrg if func_ltwrapper_p "$file"; then 11068c2939121Smrg if func_ltwrapper_executable_p "$file"; then 11069c2939121Smrg func_ltwrapper_scriptname "$file" 11070c2939121Smrg relink_command= 11071c2939121Smrg func_source $func_ltwrapper_scriptname_result 110722836776bSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11073c2939121Smrg else 11074c2939121Smrg relink_command= 11075c2939121Smrg func_source $dir/$noexename 11076c2939121Smrg fi 11077c76ae52dSmrg 11078c76ae52dSmrg # note $name still contains .exe if it was in $file originally 11079c76ae52dSmrg # as does the version of $file that was added into $rmfiles 110808292847cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 110818292847cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 110822836776bSmrg func_append rmfiles " $odir/lt-$name" 11083c76ae52dSmrg fi 110848292847cSmrg if test "X$noexename" != "X$name"; then 110858292847cSmrg func_append rmfiles " $odir/lt-$noexename.c" 11086c76ae52dSmrg fi 11087c76ae52dSmrg fi 11088c76ae52dSmrg fi 11089c76ae52dSmrg ;; 11090c76ae52dSmrg esac 11091c2939121Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092c76ae52dSmrg done 11093c76ae52dSmrg 110948292847cSmrg # Try to remove the $objdir's in the directories where we deleted files 11095c76ae52dSmrg for dir in $rmdirs; do 11096c76ae52dSmrg if test -d "$dir"; then 11097c2939121Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098c76ae52dSmrg fi 11099c76ae52dSmrg done 11100c76ae52dSmrg 11101c76ae52dSmrg exit $exit_status 11102c2939121Smrg} 11103c76ae52dSmrg 111048292847cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 111058292847cSmrg func_mode_uninstall ${1+"$@"} 111068292847cSmrgfi 11107c76ae52dSmrg 111082836776bSmrgtest -z "$opt_mode" && { 111098292847cSmrg help=$generic_help 11110c2939121Smrg func_fatal_help "you must specify a MODE" 11111c2939121Smrg} 11112c2939121Smrg 11113c2939121Smrgtest -z "$exec_cmd" && \ 111148292847cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11115c76ae52dSmrg 11116c76ae52dSmrgif test -n "$exec_cmd"; then 11117c2939121Smrg eval exec "$exec_cmd" 11118c76ae52dSmrg exit $EXIT_FAILURE 11119c76ae52dSmrgfi 11120c76ae52dSmrg 11121c2939121Smrgexit $exit_status 11122c76ae52dSmrg 11123c76ae52dSmrg 11124c76ae52dSmrg# The TAGs below are defined such that we never get into a situation 111258292847cSmrg# where we disable both kinds of libraries. Given conflicting 11126c76ae52dSmrg# choices, we go for a static library, that is the most portable, 11127c76ae52dSmrg# since we can't tell whether shared libraries were disabled because 11128c76ae52dSmrg# the user asked for that or because the platform doesn't support 11129c76ae52dSmrg# them. This is particularly important on AIX, because we don't 11130c76ae52dSmrg# support having both static and shared libraries enabled at the same 11131c76ae52dSmrg# time on that platform, so we default to a shared-only configuration. 11132c76ae52dSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11133c76ae52dSmrg# configuration. But we'll never go from static-only to shared-only. 11134c76ae52dSmrg 11135c76ae52dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136c2939121Smrgbuild_libtool_libs=no 11137c2939121Smrgbuild_old_libs=yes 11138c76ae52dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139c76ae52dSmrg 11140c76ae52dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141c2939121Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142c76ae52dSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11143c76ae52dSmrg 11144c76ae52dSmrg# Local Variables: 11145c76ae52dSmrg# mode:shell-script 11146c76ae52dSmrg# sh-indentation:2 11147c76ae52dSmrg# End: 11148