ltmain.sh revision de3c0529
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 34de3c0529SmrgVERSION="2.4.6 Debian-2.4.6-9" 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. 1373de3c0529Smrgscriptversion=2015-10-07.11; # 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 1533de3c0529Smrg _G_rc_run_hooks=false 1534de3c0529Smrg 15358292847cSmrg case " $hookable_fns " in 15368292847cSmrg *" $1 "*) ;; 15378292847cSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 15388292847cSmrg esac 15398292847cSmrg 15408292847cSmrg eval _G_hook_fns=\$$1_hooks; shift 15418292847cSmrg 15428292847cSmrg for _G_hook in $_G_hook_fns; do 1543de3c0529Smrg if eval $_G_hook '"$@"'; then 1544de3c0529Smrg # store returned options list back into positional 1545de3c0529Smrg # parameters for next 'cmd' execution. 1546de3c0529Smrg eval _G_hook_result=\$${_G_hook}_result 1547de3c0529Smrg eval set dummy "$_G_hook_result"; shift 1548de3c0529Smrg _G_rc_run_hooks=: 1549de3c0529Smrg fi 15508292847cSmrg done 15518292847cSmrg 1552de3c0529Smrg $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result 15538292847cSmrg} 15548292847cSmrg 15558292847cSmrg 15568292847cSmrg 15578292847cSmrg## --------------- ## 15588292847cSmrg## Option parsing. ## 15598292847cSmrg## --------------- ## 15608292847cSmrg 15618292847cSmrg# In order to add your own option parsing hooks, you must accept the 1562de3c0529Smrg# full positional parameter list in your hook function, you may remove/edit 1563de3c0529Smrg# any options that you action, and then pass back the remaining unprocessed 15648292847cSmrg# options in '<hooked_function_name>_result', escaped suitably for 1565de3c0529Smrg# 'eval'. In this case you also must return $EXIT_SUCCESS to let the 1566de3c0529Smrg# hook's caller know that it should pay attention to 1567de3c0529Smrg# '<hooked_function_name>_result'. Returning $EXIT_FAILURE signalizes that 1568de3c0529Smrg# arguments are left untouched by the hook and therefore caller will ignore the 1569de3c0529Smrg# result variable. 1570de3c0529Smrg# 1571de3c0529Smrg# Like this: 15728292847cSmrg# 15738292847cSmrg# my_options_prep () 15748292847cSmrg# { 15758292847cSmrg# $debug_cmd 15768292847cSmrg# 15778292847cSmrg# # Extend the existing usage message. 15788292847cSmrg# usage_message=$usage_message' 15798292847cSmrg# -s, --silent don'\''t print informational messages 15808292847cSmrg# ' 1581de3c0529Smrg# # No change in '$@' (ignored completely by this hook). There is 1582de3c0529Smrg# # no need to do the equivalent (but slower) action: 1583de3c0529Smrg# # func_quote_for_eval ${1+"$@"} 1584de3c0529Smrg# # my_options_prep_result=$func_quote_for_eval_result 1585de3c0529Smrg# false 15868292847cSmrg# } 15878292847cSmrg# func_add_hook func_options_prep my_options_prep 15888292847cSmrg# 15898292847cSmrg# 15908292847cSmrg# my_silent_option () 15918292847cSmrg# { 15928292847cSmrg# $debug_cmd 15938292847cSmrg# 1594de3c0529Smrg# args_changed=false 1595de3c0529Smrg# 15968292847cSmrg# # Note that for efficiency, we parse as many options as we can 15978292847cSmrg# # recognise in a loop before passing the remainder back to the 15988292847cSmrg# # caller on the first unrecognised argument we encounter. 15998292847cSmrg# while test $# -gt 0; do 16008292847cSmrg# opt=$1; shift 16018292847cSmrg# case $opt in 1602de3c0529Smrg# --silent|-s) opt_silent=: 1603de3c0529Smrg# args_changed=: 1604de3c0529Smrg# ;; 16058292847cSmrg# # Separate non-argument short options: 16068292847cSmrg# -s*) func_split_short_opt "$_G_opt" 16078292847cSmrg# set dummy "$func_split_short_opt_name" \ 16088292847cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 16098292847cSmrg# shift 1610de3c0529Smrg# args_changed=: 16118292847cSmrg# ;; 1612de3c0529Smrg# *) # Make sure the first unrecognised option "$_G_opt" 1613de3c0529Smrg# # is added back to "$@", we could need that later 1614de3c0529Smrg# # if $args_changed is true. 1615de3c0529Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 16168292847cSmrg# esac 16178292847cSmrg# done 16188292847cSmrg# 1619de3c0529Smrg# if $args_changed; then 1620de3c0529Smrg# func_quote_for_eval ${1+"$@"} 1621de3c0529Smrg# my_silent_option_result=$func_quote_for_eval_result 1622de3c0529Smrg# fi 1623de3c0529Smrg# 1624de3c0529Smrg# $args_changed 16258292847cSmrg# } 16268292847cSmrg# func_add_hook func_parse_options my_silent_option 16278292847cSmrg# 16288292847cSmrg# 16298292847cSmrg# my_option_validation () 16308292847cSmrg# { 16318292847cSmrg# $debug_cmd 16328292847cSmrg# 16338292847cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 16348292847cSmrg# '--silent' and '--verbose' options are mutually exclusive." 16358292847cSmrg# 1636de3c0529Smrg# false 16378292847cSmrg# } 16388292847cSmrg# func_add_hook func_validate_options my_option_validation 16398292847cSmrg# 1640de3c0529Smrg# You'll also need to manually amend $usage_message to reflect the extra 16418292847cSmrg# options you parse. It's preferable to append if you can, so that 16428292847cSmrg# multiple option parsing hooks can be added safely. 16438292847cSmrg 16448292847cSmrg 1645de3c0529Smrg# func_options_finish [ARG]... 1646de3c0529Smrg# ---------------------------- 1647de3c0529Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1648de3c0529Smrgfunc_options_finish () 1649de3c0529Smrg{ 1650de3c0529Smrg $debug_cmd 1651de3c0529Smrg 1652de3c0529Smrg _G_func_options_finish_exit=false 1653de3c0529Smrg if func_run_hooks func_options ${1+"$@"}; then 1654de3c0529Smrg func_options_finish_result=$func_run_hooks_result 1655de3c0529Smrg _G_func_options_finish_exit=: 1656de3c0529Smrg fi 1657de3c0529Smrg 1658de3c0529Smrg $_G_func_options_finish_exit 1659de3c0529Smrg} 1660de3c0529Smrg 1661de3c0529Smrg 16628292847cSmrg# func_options [ARG]... 16638292847cSmrg# --------------------- 16648292847cSmrg# All the functions called inside func_options are hookable. See the 16658292847cSmrg# individual implementations for details. 16668292847cSmrgfunc_hookable func_options 16678292847cSmrgfunc_options () 16688292847cSmrg{ 16698292847cSmrg $debug_cmd 16708292847cSmrg 1671de3c0529Smrg _G_rc_options=false 1672de3c0529Smrg 1673de3c0529Smrg for my_func in options_prep parse_options validate_options options_finish 1674de3c0529Smrg do 1675de3c0529Smrg if eval func_$my_func '${1+"$@"}'; then 1676de3c0529Smrg eval _G_res_var='$'"func_${my_func}_result" 1677de3c0529Smrg eval set dummy "$_G_res_var" ; shift 1678de3c0529Smrg _G_rc_options=: 1679de3c0529Smrg fi 1680de3c0529Smrg done 16818292847cSmrg 1682de3c0529Smrg # Save modified positional parameters for caller. As a top-level 1683de3c0529Smrg # options-parser function we always need to set the 'func_options_result' 1684de3c0529Smrg # variable (regardless the $_G_rc_options value). 1685de3c0529Smrg if $_G_rc_options; then 1686de3c0529Smrg func_options_result=$_G_res_var 1687de3c0529Smrg else 1688de3c0529Smrg func_quote_for_eval ${1+"$@"} 1689de3c0529Smrg func_options_result=$func_quote_for_eval_result 1690de3c0529Smrg fi 16918292847cSmrg 1692de3c0529Smrg $_G_rc_options 1693c76ae52dSmrg} 1694c76ae52dSmrg 1695c76ae52dSmrg 16968292847cSmrg# func_options_prep [ARG]... 16978292847cSmrg# -------------------------- 16988292847cSmrg# All initialisations required before starting the option parse loop. 16998292847cSmrg# Note that when calling hook functions, we pass through the list of 17008292847cSmrg# positional parameters. If a hook function modifies that list, and 1701de3c0529Smrg# needs to propagate that back to rest of this script, then the complete 17028292847cSmrg# modified list must be put in 'func_run_hooks_result' before 1703de3c0529Smrg# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned). 17048292847cSmrgfunc_hookable func_options_prep 17058292847cSmrgfunc_options_prep () 1706c76ae52dSmrg{ 17078292847cSmrg $debug_cmd 1708c2939121Smrg 17098292847cSmrg # Option defaults: 17108292847cSmrg opt_verbose=false 17118292847cSmrg opt_warning_types= 17128292847cSmrg 1713de3c0529Smrg _G_rc_options_prep=false 1714de3c0529Smrg if func_run_hooks func_options_prep ${1+"$@"}; then 1715de3c0529Smrg _G_rc_options_prep=: 1716de3c0529Smrg # save modified positional parameters for caller 1717de3c0529Smrg func_options_prep_result=$func_run_hooks_result 1718de3c0529Smrg fi 17198292847cSmrg 1720de3c0529Smrg $_G_rc_options_prep 1721c76ae52dSmrg} 1722c76ae52dSmrg 1723c76ae52dSmrg 17248292847cSmrg# func_parse_options [ARG]... 17258292847cSmrg# --------------------------- 17268292847cSmrg# The main option parsing loop. 17278292847cSmrgfunc_hookable func_parse_options 17288292847cSmrgfunc_parse_options () 1729c76ae52dSmrg{ 17308292847cSmrg $debug_cmd 1731c2939121Smrg 17328292847cSmrg func_parse_options_result= 1733c2939121Smrg 1734de3c0529Smrg _G_rc_parse_options=false 17358292847cSmrg # this just eases exit handling 17368292847cSmrg while test $# -gt 0; do 17378292847cSmrg # Defer to hook functions for initial option parsing, so they 17388292847cSmrg # get priority in the event of reusing an option name. 1739de3c0529Smrg if func_run_hooks func_parse_options ${1+"$@"}; then 1740de3c0529Smrg eval set dummy "$func_run_hooks_result"; shift 1741de3c0529Smrg _G_rc_parse_options=: 1742de3c0529Smrg fi 1743c76ae52dSmrg 17448292847cSmrg # Break out of the loop if we already parsed every option. 17458292847cSmrg test $# -gt 0 || break 1746c76ae52dSmrg 1747de3c0529Smrg _G_match_parse_options=: 17488292847cSmrg _G_opt=$1 17498292847cSmrg shift 17508292847cSmrg case $_G_opt in 17518292847cSmrg --debug|-x) debug_cmd='set -x' 17528292847cSmrg func_echo "enabling shell trace mode" 17538292847cSmrg $debug_cmd 17548292847cSmrg ;; 17558292847cSmrg 17568292847cSmrg --no-warnings|--no-warning|--no-warn) 17578292847cSmrg set dummy --warnings none ${1+"$@"} 17588292847cSmrg shift 17598292847cSmrg ;; 1760c2939121Smrg 17618292847cSmrg --warnings|--warning|-W) 1762de3c0529Smrg if test $# = 0 && func_missing_arg $_G_opt; then 1763de3c0529Smrg _G_rc_parse_options=: 1764de3c0529Smrg break 1765de3c0529Smrg fi 17668292847cSmrg case " $warning_categories $1" in 17678292847cSmrg *" $1 "*) 17688292847cSmrg # trailing space prevents matching last $1 above 17698292847cSmrg func_append_uniq opt_warning_types " $1" 17708292847cSmrg ;; 17718292847cSmrg *all) 17728292847cSmrg opt_warning_types=$warning_categories 17738292847cSmrg ;; 17748292847cSmrg *none) 17758292847cSmrg opt_warning_types=none 17768292847cSmrg warning_func=: 17778292847cSmrg ;; 17788292847cSmrg *error) 17798292847cSmrg opt_warning_types=$warning_categories 17808292847cSmrg warning_func=func_fatal_error 17818292847cSmrg ;; 17828292847cSmrg *) 17838292847cSmrg func_fatal_error \ 17848292847cSmrg "unsupported warning category: '$1'" 17858292847cSmrg ;; 17868292847cSmrg esac 17878292847cSmrg shift 17888292847cSmrg ;; 17898292847cSmrg 17908292847cSmrg --verbose|-v) opt_verbose=: ;; 17918292847cSmrg --version) func_version ;; 17928292847cSmrg -\?|-h) func_usage ;; 17938292847cSmrg --help) func_help ;; 17948292847cSmrg 17958292847cSmrg # Separate optargs to long options (plugins may need this): 17968292847cSmrg --*=*) func_split_equals "$_G_opt" 17978292847cSmrg set dummy "$func_split_equals_lhs" \ 17988292847cSmrg "$func_split_equals_rhs" ${1+"$@"} 17998292847cSmrg shift 18008292847cSmrg ;; 18018292847cSmrg 18028292847cSmrg # Separate optargs to short options: 18038292847cSmrg -W*) 18048292847cSmrg func_split_short_opt "$_G_opt" 18058292847cSmrg set dummy "$func_split_short_opt_name" \ 18068292847cSmrg "$func_split_short_opt_arg" ${1+"$@"} 18078292847cSmrg shift 18088292847cSmrg ;; 18098292847cSmrg 18108292847cSmrg # Separate non-argument short options: 18118292847cSmrg -\?*|-h*|-v*|-x*) 18128292847cSmrg func_split_short_opt "$_G_opt" 18138292847cSmrg set dummy "$func_split_short_opt_name" \ 18148292847cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 18158292847cSmrg shift 18168292847cSmrg ;; 18178292847cSmrg 1818de3c0529Smrg --) _G_rc_parse_options=: ; break ;; 18198292847cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1820de3c0529Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1821de3c0529Smrg _G_match_parse_options=false 1822de3c0529Smrg break 1823de3c0529Smrg ;; 18248292847cSmrg esac 1825de3c0529Smrg 1826de3c0529Smrg $_G_match_parse_options && _G_rc_parse_options=: 18278292847cSmrg done 18288292847cSmrg 1829de3c0529Smrg 1830de3c0529Smrg if $_G_rc_parse_options; then 1831de3c0529Smrg # save modified positional parameters for caller 1832de3c0529Smrg func_quote_for_eval ${1+"$@"} 1833de3c0529Smrg func_parse_options_result=$func_quote_for_eval_result 1834de3c0529Smrg fi 1835de3c0529Smrg 1836de3c0529Smrg $_G_rc_parse_options 1837c76ae52dSmrg} 1838c76ae52dSmrg 1839c2939121Smrg 18408292847cSmrg# func_validate_options [ARG]... 18418292847cSmrg# ------------------------------ 18428292847cSmrg# Perform any sanity checks on option settings and/or unconsumed 18438292847cSmrg# arguments. 18448292847cSmrgfunc_hookable func_validate_options 18458292847cSmrgfunc_validate_options () 1846c76ae52dSmrg{ 18478292847cSmrg $debug_cmd 1848c76ae52dSmrg 1849de3c0529Smrg _G_rc_validate_options=false 1850de3c0529Smrg 18518292847cSmrg # Display all warnings if -W was not given. 18528292847cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1853c76ae52dSmrg 1854de3c0529Smrg if func_run_hooks func_validate_options ${1+"$@"}; then 1855de3c0529Smrg # save modified positional parameters for caller 1856de3c0529Smrg func_validate_options_result=$func_run_hooks_result 1857de3c0529Smrg _G_rc_validate_options=: 1858de3c0529Smrg fi 1859c76ae52dSmrg 18608292847cSmrg # Bail if the options were screwed! 18618292847cSmrg $exit_cmd $EXIT_FAILURE 18628292847cSmrg 1863de3c0529Smrg $_G_rc_validate_options 18642836776bSmrg} 18652836776bSmrg 1866c76ae52dSmrg 18672836776bSmrg 18688292847cSmrg## ----------------- ## 18698292847cSmrg## Helper functions. ## 18708292847cSmrg## ----------------- ## 1871c76ae52dSmrg 18728292847cSmrg# This section contains the helper functions used by the rest of the 18738292847cSmrg# hookable option parser framework in ascii-betical order. 18748292847cSmrg 18758292847cSmrg 18768292847cSmrg# func_fatal_help ARG... 18778292847cSmrg# ---------------------- 18788292847cSmrg# Echo program name prefixed message to standard error, followed by 18798292847cSmrg# a help hint, and exit. 18808292847cSmrgfunc_fatal_help () 1881c2939121Smrg{ 18828292847cSmrg $debug_cmd 18832836776bSmrg 18848292847cSmrg eval \$ECHO \""Usage: $usage"\" 18858292847cSmrg eval \$ECHO \""$fatal_help"\" 18868292847cSmrg func_error ${1+"$@"} 18878292847cSmrg exit $EXIT_FAILURE 1888c2939121Smrg} 1889c76ae52dSmrg 18908292847cSmrg 18918292847cSmrg# func_help 18928292847cSmrg# --------- 18938292847cSmrg# Echo long help message to standard output and exit. 1894c2939121Smrgfunc_help () 1895c2939121Smrg{ 18968292847cSmrg $debug_cmd 18978292847cSmrg 18988292847cSmrg func_usage_message 18998292847cSmrg $ECHO "$long_help_message" 19008292847cSmrg exit 0 1901c2939121Smrg} 1902c76ae52dSmrg 19038292847cSmrg 19048292847cSmrg# func_missing_arg ARGNAME 19058292847cSmrg# ------------------------ 1906c2939121Smrg# Echo program name prefixed message to standard error and set global 1907c2939121Smrg# exit_cmd. 1908c2939121Smrgfunc_missing_arg () 1909c2939121Smrg{ 19108292847cSmrg $debug_cmd 19112836776bSmrg 19128292847cSmrg func_error "Missing argument for '$1'." 1913c2939121Smrg exit_cmd=exit 1914c2939121Smrg} 1915c76ae52dSmrg 1916c76ae52dSmrg 19178292847cSmrg# func_split_equals STRING 19188292847cSmrg# ------------------------ 19198292847cSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 19208292847cSmrg# splitting STRING at the '=' sign. 19218292847cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 19228292847cSmrg && (eval 'x=a/b/c; 19238292847cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 19248292847cSmrg && _G_HAVE_XSI_OPS=yes 19258292847cSmrg 19268292847cSmrgif test yes = "$_G_HAVE_XSI_OPS" 19278292847cSmrgthen 19288292847cSmrg # This is an XSI compatible shell, allowing a faster implementation... 19298292847cSmrg eval 'func_split_equals () 19308292847cSmrg { 19318292847cSmrg $debug_cmd 19328292847cSmrg 19338292847cSmrg func_split_equals_lhs=${1%%=*} 19348292847cSmrg func_split_equals_rhs=${1#*=} 19358292847cSmrg test "x$func_split_equals_lhs" = "x$1" \ 19368292847cSmrg && func_split_equals_rhs= 19378292847cSmrg }' 19388292847cSmrgelse 19398292847cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 19408292847cSmrg func_split_equals () 19418292847cSmrg { 19428292847cSmrg $debug_cmd 19438292847cSmrg 19448292847cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 19458292847cSmrg func_split_equals_rhs= 19468292847cSmrg test "x$func_split_equals_lhs" = "x$1" \ 19478292847cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 19488292847cSmrg } 19498292847cSmrgfi #func_split_equals 19508292847cSmrg 19518292847cSmrg 19528292847cSmrg# func_split_short_opt SHORTOPT 19538292847cSmrg# ----------------------------- 19542836776bSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 19552836776bSmrg# variables after splitting SHORTOPT after the 2nd character. 19568292847cSmrgif test yes = "$_G_HAVE_XSI_OPS" 19578292847cSmrgthen 19588292847cSmrg # This is an XSI compatible shell, allowing a faster implementation... 19598292847cSmrg eval 'func_split_short_opt () 19608292847cSmrg { 19618292847cSmrg $debug_cmd 19628292847cSmrg 19638292847cSmrg func_split_short_opt_arg=${1#??} 19648292847cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 19658292847cSmrg }' 19668292847cSmrgelse 19678292847cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 19688292847cSmrg func_split_short_opt () 19698292847cSmrg { 19708292847cSmrg $debug_cmd 19718292847cSmrg 19728292847cSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 19738292847cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 19748292847cSmrg } 19758292847cSmrgfi #func_split_short_opt 19768292847cSmrg 19778292847cSmrg 19788292847cSmrg# func_usage 19798292847cSmrg# ---------- 19808292847cSmrg# Echo short help message to standard output and exit. 19818292847cSmrgfunc_usage () 19822836776bSmrg{ 19838292847cSmrg $debug_cmd 19842836776bSmrg 19858292847cSmrg func_usage_message 19868292847cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 19878292847cSmrg exit 0 19888292847cSmrg} 19892836776bSmrg 19902836776bSmrg 19918292847cSmrg# func_usage_message 19928292847cSmrg# ------------------ 19938292847cSmrg# Echo short help message to standard output. 19948292847cSmrgfunc_usage_message () 19952836776bSmrg{ 19968292847cSmrg $debug_cmd 19972836776bSmrg 19988292847cSmrg eval \$ECHO \""Usage: $usage"\" 19998292847cSmrg echo 20008292847cSmrg $SED -n 's|^# || 20018292847cSmrg /^Written by/{ 20028292847cSmrg x;p;x 20038292847cSmrg } 20048292847cSmrg h 20058292847cSmrg /^Written by/q' < "$progpath" 20068292847cSmrg echo 20078292847cSmrg eval \$ECHO \""$usage_message"\" 20088292847cSmrg} 20092836776bSmrg 2010c76ae52dSmrg 20118292847cSmrg# func_version 20128292847cSmrg# ------------ 20138292847cSmrg# Echo version message to standard output and exit. 20148292847cSmrgfunc_version () 20158292847cSmrg{ 20168292847cSmrg $debug_cmd 2017c76ae52dSmrg 20188292847cSmrg printf '%s\n' "$progname $scriptversion" 20198292847cSmrg $SED -n ' 20208292847cSmrg /(C)/!b go 20218292847cSmrg :more 20228292847cSmrg /\./!{ 20238292847cSmrg N 20248292847cSmrg s|\n# | | 20258292847cSmrg b more 20268292847cSmrg } 20278292847cSmrg :go 20288292847cSmrg /^# Written by /,/# warranty; / { 20298292847cSmrg s|^# || 20308292847cSmrg s|^# *$|| 20318292847cSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 20328292847cSmrg p 20338292847cSmrg } 20348292847cSmrg /^# Written by / { 20358292847cSmrg s|^# || 20368292847cSmrg p 20378292847cSmrg } 20388292847cSmrg /^warranty; /q' < "$progpath" 20390d590c07Smrg 20408292847cSmrg exit $? 20418292847cSmrg} 2042c76ae52dSmrg 2043c2939121Smrg 20448292847cSmrg# Local variables: 20458292847cSmrg# mode: shell-script 20468292847cSmrg# sh-indentation: 2 20478292847cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 20488292847cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 20498292847cSmrg# time-stamp-time-zone: "UTC" 20508292847cSmrg# End: 2051c2939121Smrg 20528292847cSmrg# Set a version string. 20538292847cSmrgscriptversion='(GNU libtool) 2.4.6' 2054c2939121Smrg 2055c2939121Smrg 20568292847cSmrg# func_echo ARG... 20578292847cSmrg# ---------------- 20588292847cSmrg# Libtool also displays the current mode in messages, so override 20598292847cSmrg# funclib.sh func_echo with this custom definition. 20608292847cSmrgfunc_echo () 20612836776bSmrg{ 20628292847cSmrg $debug_cmd 20632836776bSmrg 20648292847cSmrg _G_message=$* 20652836776bSmrg 20668292847cSmrg func_echo_IFS=$IFS 20678292847cSmrg IFS=$nl 20688292847cSmrg for _G_line in $_G_message; do 20698292847cSmrg IFS=$func_echo_IFS 20708292847cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 20718292847cSmrg done 20728292847cSmrg IFS=$func_echo_IFS 20738292847cSmrg} 20742836776bSmrg 20758292847cSmrg 20768292847cSmrg# func_warning ARG... 20778292847cSmrg# ------------------- 20788292847cSmrg# Libtool warnings are not categorized, so override funclib.sh 20798292847cSmrg# func_warning with this simpler definition. 20808292847cSmrgfunc_warning () 20812836776bSmrg{ 20828292847cSmrg $debug_cmd 20832836776bSmrg 20848292847cSmrg $warning_func ${1+"$@"} 20858292847cSmrg} 20862836776bSmrg 20872836776bSmrg 20888292847cSmrg## ---------------- ## 20898292847cSmrg## Options parsing. ## 20908292847cSmrg## ---------------- ## 20918292847cSmrg 20928292847cSmrg# Hook in the functions to make sure our own options are parsed during 20938292847cSmrg# the option parsing loop. 20948292847cSmrg 20958292847cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 20968292847cSmrg 20978292847cSmrg# Short help message in response to '-h'. 20988292847cSmrgusage_message="Options: 20998292847cSmrg --config show all configuration variables 21008292847cSmrg --debug enable verbose shell tracing 21018292847cSmrg -n, --dry-run display commands without modifying any files 21028292847cSmrg --features display basic configuration information and exit 21038292847cSmrg --mode=MODE use operation mode MODE 21048292847cSmrg --no-warnings equivalent to '-Wnone' 21058292847cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 21068292847cSmrg --quiet, --silent don't print informational messages 21078292847cSmrg --tag=TAG use configuration variables from tag TAG 21088292847cSmrg -v, --verbose print more informational messages than default 21098292847cSmrg --version print version information 21108292847cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 21118292847cSmrg -h, --help, --help-all print short, long, or detailed help message 21128292847cSmrg" 21132836776bSmrg 21148292847cSmrg# Additional text appended to 'usage_message' in response to '--help'. 21158292847cSmrgfunc_help () 21162836776bSmrg{ 21178292847cSmrg $debug_cmd 21188292847cSmrg 21198292847cSmrg func_usage_message 21208292847cSmrg $ECHO "$long_help_message 21218292847cSmrg 21228292847cSmrgMODE must be one of the following: 21238292847cSmrg 21248292847cSmrg clean remove files from the build directory 21258292847cSmrg compile compile a source file into a libtool object 21268292847cSmrg execute automatically set library path, then run a program 21278292847cSmrg finish complete the installation of libtool libraries 21288292847cSmrg install install libraries or executables 21298292847cSmrg link create a library or an executable 21308292847cSmrg uninstall remove libraries from an installed directory 21318292847cSmrg 21328292847cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 21338292847cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 21348292847cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 21358292847cSmrg 21368292847cSmrgWhen reporting a bug, please describe a test case to reproduce it and 21378292847cSmrginclude the following information: 21388292847cSmrg 21398292847cSmrg host-triplet: $host 21408292847cSmrg shell: $SHELL 21418292847cSmrg compiler: $LTCC 21428292847cSmrg compiler flags: $LTCFLAGS 21438292847cSmrg linker: $LD (gnu? $with_gnu_ld) 2144de3c0529Smrg version: $progname $scriptversion Debian-2.4.6-9 21458292847cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 21468292847cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 21478292847cSmrg 21488292847cSmrgReport bugs to <bug-libtool@gnu.org>. 2149de3c0529SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 21508292847cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 21518292847cSmrg exit 0 21528292847cSmrg} 21532836776bSmrg 21542836776bSmrg 21558292847cSmrg# func_lo2o OBJECT-NAME 21568292847cSmrg# --------------------- 21578292847cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 21588292847cSmrg# object suffix. 21598292847cSmrg 21608292847cSmrglo2o=s/\\.lo\$/.$objext/ 21618292847cSmrgo2lo=s/\\.$objext\$/.lo/ 21628292847cSmrg 21638292847cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 21648292847cSmrg eval 'func_lo2o () 21658292847cSmrg { 21668292847cSmrg case $1 in 21678292847cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 21688292847cSmrg * ) func_lo2o_result=$1 ;; 21698292847cSmrg esac 21708292847cSmrg }' 21718292847cSmrg 21728292847cSmrg # func_xform LIBOBJ-OR-SOURCE 21738292847cSmrg # --------------------------- 21748292847cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 21758292847cSmrg # suffix to a '.lo' libtool-object suffix. 21768292847cSmrg eval 'func_xform () 21778292847cSmrg { 21788292847cSmrg func_xform_result=${1%.*}.lo 21798292847cSmrg }' 21808292847cSmrgelse 21818292847cSmrg # ...otherwise fall back to using sed. 21828292847cSmrg func_lo2o () 21838292847cSmrg { 21848292847cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 21858292847cSmrg } 21868292847cSmrg 21878292847cSmrg func_xform () 21888292847cSmrg { 21898292847cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 21908292847cSmrg } 21918292847cSmrgfi 21922836776bSmrg 21932836776bSmrg 21948292847cSmrg# func_fatal_configuration ARG... 21958292847cSmrg# ------------------------------- 2196c2939121Smrg# Echo program name prefixed message to standard error, followed by 2197c2939121Smrg# a configuration failure hint, and exit. 2198c2939121Smrgfunc_fatal_configuration () 2199c2939121Smrg{ 22008292847cSmrg func__fatal_error ${1+"$@"} \ 22018292847cSmrg "See the $PACKAGE documentation for more information." \ 22028292847cSmrg "Fatal configuration error." 2203c2939121Smrg} 2204c2939121Smrg 2205c2939121Smrg 2206c2939121Smrg# func_config 22078292847cSmrg# ----------- 2208c2939121Smrg# Display the configuration for all the tags in this script. 2209c2939121Smrgfunc_config () 2210c2939121Smrg{ 2211c2939121Smrg re_begincf='^# ### BEGIN LIBTOOL' 2212c2939121Smrg re_endcf='^# ### END LIBTOOL' 2213c2939121Smrg 2214c2939121Smrg # Default configuration. 2215c2939121Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2216c2939121Smrg 2217c76ae52dSmrg # Now print the configurations for the tags. 2218c76ae52dSmrg for tagname in $taglist; do 2219c2939121Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2220c76ae52dSmrg done 2221c76ae52dSmrg 2222c2939121Smrg exit $? 2223c2939121Smrg} 2224c76ae52dSmrg 22258292847cSmrg 2226c2939121Smrg# func_features 22278292847cSmrg# ------------- 2228c2939121Smrg# Display the features supported by this script. 2229c2939121Smrgfunc_features () 2230c2939121Smrg{ 2231c2939121Smrg echo "host: $host" 22328292847cSmrg if test yes = "$build_libtool_libs"; then 2233c2939121Smrg echo "enable shared libraries" 2234c76ae52dSmrg else 2235c2939121Smrg echo "disable shared libraries" 2236c76ae52dSmrg fi 22378292847cSmrg if test yes = "$build_old_libs"; then 2238c2939121Smrg echo "enable static libraries" 2239c76ae52dSmrg else 2240c2939121Smrg echo "disable static libraries" 2241c76ae52dSmrg fi 2242c2939121Smrg 2243c76ae52dSmrg exit $? 2244c2939121Smrg} 2245c76ae52dSmrg 22468292847cSmrg 22478292847cSmrg# func_enable_tag TAGNAME 22488292847cSmrg# ----------------------- 2249c2939121Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2250c2939121Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2251c2939121Smrg# variable here. 2252c2939121Smrgfunc_enable_tag () 2253c2939121Smrg{ 22548292847cSmrg # Global variable: 22558292847cSmrg tagname=$1 2256c76ae52dSmrg 22578292847cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 22588292847cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 22598292847cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2260c76ae52dSmrg 22618292847cSmrg # Validate tagname. 22628292847cSmrg case $tagname in 22638292847cSmrg *[!-_A-Za-z0-9,/]*) 22648292847cSmrg func_fatal_error "invalid tag name: $tagname" 22658292847cSmrg ;; 22668292847cSmrg esac 2267c76ae52dSmrg 22688292847cSmrg # Don't test for the "default" C tag, as we know it's 22698292847cSmrg # there but not specially marked. 22708292847cSmrg case $tagname in 22718292847cSmrg CC) ;; 2272c2939121Smrg *) 22738292847cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 22748292847cSmrg taglist="$taglist $tagname" 22758292847cSmrg 22768292847cSmrg # Evaluate the configuration. Be careful to quote the path 22778292847cSmrg # and the sed script, to avoid splitting on whitespace, but 22788292847cSmrg # also don't use non-portable quotes within backquotes within 22798292847cSmrg # quotes we have to do it in 2 steps: 22808292847cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 22818292847cSmrg eval "$extractedcf" 22828292847cSmrg else 22838292847cSmrg func_error "ignoring unknown tag $tagname" 22848292847cSmrg fi 22858292847cSmrg ;; 22868292847cSmrg esac 2287c2939121Smrg} 2288c2939121Smrg 22898292847cSmrg 22902836776bSmrg# func_check_version_match 22918292847cSmrg# ------------------------ 22922836776bSmrg# Ensure that we are using m4 macros, and libtool script from the same 22932836776bSmrg# release of libtool. 22942836776bSmrgfunc_check_version_match () 2295c2939121Smrg{ 22968292847cSmrg if test "$package_revision" != "$macro_revision"; then 22978292847cSmrg if test "$VERSION" != "$macro_version"; then 22988292847cSmrg if test -z "$macro_version"; then 22998292847cSmrg cat >&2 <<_LT_EOF 23002836776bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 23012836776bSmrg$progname: definition of this LT_INIT comes from an older release. 23022836776bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 23032836776bSmrg$progname: and run autoconf again. 23042836776bSmrg_LT_EOF 23058292847cSmrg else 23068292847cSmrg cat >&2 <<_LT_EOF 23072836776bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 23082836776bSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 23092836776bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 23102836776bSmrg$progname: and run autoconf again. 23112836776bSmrg_LT_EOF 23128292847cSmrg fi 23138292847cSmrg else 23148292847cSmrg cat >&2 <<_LT_EOF 23152836776bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 23162836776bSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 23172836776bSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 23182836776bSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 23192836776bSmrg_LT_EOF 23208292847cSmrg fi 23212836776bSmrg 23228292847cSmrg exit $EXIT_MISMATCH 23238292847cSmrg fi 23242836776bSmrg} 23252836776bSmrg 23262836776bSmrg 23278292847cSmrg# libtool_options_prep [ARG]... 23288292847cSmrg# ----------------------------- 23298292847cSmrg# Preparation for options parsed by libtool. 23308292847cSmrglibtool_options_prep () 23318292847cSmrg{ 23328292847cSmrg $debug_mode 23332836776bSmrg 23348292847cSmrg # Option defaults: 23358292847cSmrg opt_config=false 23368292847cSmrg opt_dlopen= 23378292847cSmrg opt_dry_run=false 23388292847cSmrg opt_help=false 23398292847cSmrg opt_mode= 23408292847cSmrg opt_preserve_dup_deps=false 23418292847cSmrg opt_quiet=false 23422836776bSmrg 23438292847cSmrg nonopt= 23448292847cSmrg preserve_args= 23452836776bSmrg 2346de3c0529Smrg _G_rc_lt_options_prep=: 2347de3c0529Smrg 23488292847cSmrg # Shorthand for --mode=foo, only valid as the first argument 23498292847cSmrg case $1 in 23508292847cSmrg clean|clea|cle|cl) 23518292847cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 23528292847cSmrg ;; 23538292847cSmrg compile|compil|compi|comp|com|co|c) 23548292847cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 23558292847cSmrg ;; 23568292847cSmrg execute|execut|execu|exec|exe|ex|e) 23578292847cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 23588292847cSmrg ;; 23598292847cSmrg finish|finis|fini|fin|fi|f) 23608292847cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 23618292847cSmrg ;; 23628292847cSmrg install|instal|insta|inst|ins|in|i) 23638292847cSmrg shift; set dummy --mode install ${1+"$@"}; shift 23648292847cSmrg ;; 23658292847cSmrg link|lin|li|l) 23668292847cSmrg shift; set dummy --mode link ${1+"$@"}; shift 23678292847cSmrg ;; 23688292847cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 23698292847cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 23708292847cSmrg ;; 2371de3c0529Smrg *) 2372de3c0529Smrg _G_rc_lt_options_prep=false 2373de3c0529Smrg ;; 23748292847cSmrg esac 23758292847cSmrg 2376de3c0529Smrg if $_G_rc_lt_options_prep; then 2377de3c0529Smrg # Pass back the list of options. 2378de3c0529Smrg func_quote_for_eval ${1+"$@"} 2379de3c0529Smrg libtool_options_prep_result=$func_quote_for_eval_result 2380de3c0529Smrg fi 2381de3c0529Smrg 2382de3c0529Smrg $_G_rc_lt_options_prep 23838292847cSmrg} 23848292847cSmrgfunc_add_hook func_options_prep libtool_options_prep 2385c76ae52dSmrg 2386c76ae52dSmrg 23878292847cSmrg# libtool_parse_options [ARG]... 23888292847cSmrg# --------------------------------- 23898292847cSmrg# Provide handling for libtool specific options. 23908292847cSmrglibtool_parse_options () 23912836776bSmrg{ 23928292847cSmrg $debug_cmd 2393c2939121Smrg 2394de3c0529Smrg _G_rc_lt_parse_options=false 2395de3c0529Smrg 23968292847cSmrg # Perform our own loop to consume as many options as possible in 23978292847cSmrg # each iteration. 23988292847cSmrg while test $# -gt 0; do 2399de3c0529Smrg _G_match_lt_parse_options=: 24008292847cSmrg _G_opt=$1 24018292847cSmrg shift 24028292847cSmrg case $_G_opt in 24038292847cSmrg --dry-run|--dryrun|-n) 24048292847cSmrg opt_dry_run=: 24058292847cSmrg ;; 24068292847cSmrg 24078292847cSmrg --config) func_config ;; 24088292847cSmrg 24098292847cSmrg --dlopen|-dlopen) 24108292847cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 24118292847cSmrg}$1" 24128292847cSmrg shift 24138292847cSmrg ;; 24148292847cSmrg 24158292847cSmrg --preserve-dup-deps) 24168292847cSmrg opt_preserve_dup_deps=: ;; 24178292847cSmrg 24188292847cSmrg --features) func_features ;; 24198292847cSmrg 24208292847cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 24218292847cSmrg 24228292847cSmrg --help) opt_help=: ;; 24238292847cSmrg 24248292847cSmrg --help-all) opt_help=': help-all' ;; 24258292847cSmrg 24268292847cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 24278292847cSmrg opt_mode=$1 24288292847cSmrg case $1 in 24298292847cSmrg # Valid mode arguments: 24308292847cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 24318292847cSmrg 24328292847cSmrg # Catch anything else as an error 24338292847cSmrg *) func_error "invalid argument for $_G_opt" 24348292847cSmrg exit_cmd=exit 24358292847cSmrg break 24368292847cSmrg ;; 24378292847cSmrg esac 24388292847cSmrg shift 24398292847cSmrg ;; 24408292847cSmrg 24418292847cSmrg --no-silent|--no-quiet) 24428292847cSmrg opt_quiet=false 24438292847cSmrg func_append preserve_args " $_G_opt" 24448292847cSmrg ;; 24458292847cSmrg 24468292847cSmrg --no-warnings|--no-warning|--no-warn) 24478292847cSmrg opt_warning=false 24488292847cSmrg func_append preserve_args " $_G_opt" 24498292847cSmrg ;; 24508292847cSmrg 24518292847cSmrg --no-verbose) 24528292847cSmrg opt_verbose=false 24538292847cSmrg func_append preserve_args " $_G_opt" 24548292847cSmrg ;; 24558292847cSmrg 24568292847cSmrg --silent|--quiet) 24578292847cSmrg opt_quiet=: 24588292847cSmrg opt_verbose=false 24598292847cSmrg func_append preserve_args " $_G_opt" 24608292847cSmrg ;; 24618292847cSmrg 24628292847cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 24638292847cSmrg opt_tag=$1 24648292847cSmrg func_append preserve_args " $_G_opt $1" 24658292847cSmrg func_enable_tag "$1" 24668292847cSmrg shift 24678292847cSmrg ;; 24688292847cSmrg 24698292847cSmrg --verbose|-v) opt_quiet=false 24708292847cSmrg opt_verbose=: 24718292847cSmrg func_append preserve_args " $_G_opt" 24728292847cSmrg ;; 24738292847cSmrg 2474de3c0529Smrg # An option not handled by this hook function: 2475de3c0529Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2476de3c0529Smrg _G_match_lt_parse_options=false 2477de3c0529Smrg break 2478de3c0529Smrg ;; 24798292847cSmrg esac 2480de3c0529Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 24818292847cSmrg done 24822836776bSmrg 2483de3c0529Smrg if $_G_rc_lt_parse_options; then 2484de3c0529Smrg # save modified positional parameters for caller 2485de3c0529Smrg func_quote_for_eval ${1+"$@"} 2486de3c0529Smrg libtool_parse_options_result=$func_quote_for_eval_result 2487de3c0529Smrg fi 24882836776bSmrg 2489de3c0529Smrg $_G_rc_lt_parse_options 24908292847cSmrg} 24918292847cSmrgfunc_add_hook func_parse_options libtool_parse_options 2492c2939121Smrg 2493c76ae52dSmrg 2494c2939121Smrg 24958292847cSmrg# libtool_validate_options [ARG]... 24968292847cSmrg# --------------------------------- 24978292847cSmrg# Perform any sanity checks on option settings and/or unconsumed 24988292847cSmrg# arguments. 24998292847cSmrglibtool_validate_options () 25008292847cSmrg{ 25018292847cSmrg # save first non-option argument 25028292847cSmrg if test 0 -lt $#; then 25038292847cSmrg nonopt=$1 25048292847cSmrg shift 2505c2939121Smrg fi 2506c2939121Smrg 25078292847cSmrg # preserve --debug 25088292847cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2509c2939121Smrg 25108292847cSmrg case $host in 25118292847cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 25128292847cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 25138292847cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 25148292847cSmrg # don't eliminate duplications in $postdeps and $predeps 25158292847cSmrg opt_duplicate_compiler_generated_deps=: 25168292847cSmrg ;; 25178292847cSmrg *) 25188292847cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 25198292847cSmrg ;; 25208292847cSmrg esac 2521c2939121Smrg 25228292847cSmrg $opt_help || { 25238292847cSmrg # Sanity checks first: 25248292847cSmrg func_check_version_match 25258292847cSmrg 25268292847cSmrg test yes != "$build_libtool_libs" \ 25278292847cSmrg && test yes != "$build_old_libs" \ 25288292847cSmrg && func_fatal_configuration "not configured to build any kind of library" 25298292847cSmrg 25308292847cSmrg # Darwin sucks 25318292847cSmrg eval std_shrext=\"$shrext_cmds\" 25328292847cSmrg 25338292847cSmrg # Only execute mode is allowed to have -dlopen flags. 25348292847cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 25358292847cSmrg func_error "unrecognized option '-dlopen'" 25368292847cSmrg $ECHO "$help" 1>&2 25378292847cSmrg exit $EXIT_FAILURE 25388292847cSmrg fi 2539c2939121Smrg 25408292847cSmrg # Change the help message to a mode-specific one. 25418292847cSmrg generic_help=$help 25428292847cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 25438292847cSmrg } 2544c2939121Smrg 25458292847cSmrg # Pass back the unparsed argument list 25468292847cSmrg func_quote_for_eval ${1+"$@"} 25478292847cSmrg libtool_validate_options_result=$func_quote_for_eval_result 25482836776bSmrg} 25498292847cSmrgfunc_add_hook func_validate_options libtool_validate_options 2550c2939121Smrg 2551c2939121Smrg 25528292847cSmrg# Process options as early as possible so that --help and --version 25538292847cSmrg# can return quickly. 25548292847cSmrgfunc_options ${1+"$@"} 25558292847cSmrgeval set dummy "$func_options_result"; shift 25568292847cSmrg 2557c76ae52dSmrg 2558c76ae52dSmrg 25592836776bSmrg## ----------- ## 25602836776bSmrg## Main. ## 25612836776bSmrg## ----------- ## 2562c76ae52dSmrg 25638292847cSmrgmagic='%%%MAGIC variable%%%' 25648292847cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 25658292847cSmrg 25668292847cSmrg# Global variables. 25678292847cSmrgextracted_archives= 25688292847cSmrgextracted_serial=0 25698292847cSmrg 25708292847cSmrg# If this variable is set in any of the actions, the command in it 25718292847cSmrg# will be execed at the end. This prevents here-documents from being 25728292847cSmrg# left over by shells. 25738292847cSmrgexec_cmd= 25748292847cSmrg 25758292847cSmrg 25768292847cSmrg# A function that is used when there is no print builtin or printf. 25778292847cSmrgfunc_fallback_echo () 25788292847cSmrg{ 25798292847cSmrg eval 'cat <<_LTECHO_EOF 25808292847cSmrg$1 25818292847cSmrg_LTECHO_EOF' 25828292847cSmrg} 25838292847cSmrg 25848292847cSmrg# func_generated_by_libtool 25858292847cSmrg# True iff stdin has been generated by Libtool. This function is only 25868292847cSmrg# a basic sanity check; it will hardly flush out determined imposters. 25878292847cSmrgfunc_generated_by_libtool_p () 25888292847cSmrg{ 25898292847cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 25908292847cSmrg} 25918292847cSmrg 2592c2939121Smrg# func_lalib_p file 25938292847cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2594c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2595c2939121Smrg# determined imposters. 2596c2939121Smrgfunc_lalib_p () 2597c2939121Smrg{ 2598c2939121Smrg test -f "$1" && 25998292847cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2600c2939121Smrg} 2601c76ae52dSmrg 2602c2939121Smrg# func_lalib_unsafe_p file 26038292847cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2604c2939121Smrg# This function implements the same check as func_lalib_p without 2605c2939121Smrg# resorting to external programs. To this end, it redirects stdin and 2606c2939121Smrg# closes it afterwards, without saving the original file descriptor. 2607c2939121Smrg# As a safety measure, use it only where a negative result would be 26088292847cSmrg# fatal anyway. Works if 'file' does not exist. 2609c2939121Smrgfunc_lalib_unsafe_p () 2610c2939121Smrg{ 2611c2939121Smrg lalib_p=no 2612c2939121Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2613c2939121Smrg for lalib_p_l in 1 2 3 4 2614c2939121Smrg do 2615c2939121Smrg read lalib_p_line 26168292847cSmrg case $lalib_p_line in 2617c2939121Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2618c2939121Smrg esac 2619c2939121Smrg done 2620c2939121Smrg exec 0<&5 5<&- 2621c2939121Smrg fi 26228292847cSmrg test yes = "$lalib_p" 2623c2939121Smrg} 2624c76ae52dSmrg 2625c2939121Smrg# func_ltwrapper_script_p file 2626c2939121Smrg# True iff FILE is a libtool wrapper script 2627c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2628c2939121Smrg# determined imposters. 2629c2939121Smrgfunc_ltwrapper_script_p () 2630c2939121Smrg{ 26318292847cSmrg test -f "$1" && 26328292847cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2633c2939121Smrg} 2634c76ae52dSmrg 2635c2939121Smrg# func_ltwrapper_executable_p file 2636c2939121Smrg# True iff FILE is a libtool wrapper executable 2637c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2638c2939121Smrg# determined imposters. 2639c2939121Smrgfunc_ltwrapper_executable_p () 2640c2939121Smrg{ 2641c2939121Smrg func_ltwrapper_exec_suffix= 2642c2939121Smrg case $1 in 2643c2939121Smrg *.exe) ;; 2644c2939121Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2645c2939121Smrg esac 2646c2939121Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2647c2939121Smrg} 2648c2939121Smrg 2649c2939121Smrg# func_ltwrapper_scriptname file 2650c2939121Smrg# Assumes file is an ltwrapper_executable 2651c2939121Smrg# uses $file to determine the appropriate filename for a 2652c2939121Smrg# temporary ltwrapper_script. 2653c2939121Smrgfunc_ltwrapper_scriptname () 2654c2939121Smrg{ 26552836776bSmrg func_dirname_and_basename "$1" "" "." 26562836776bSmrg func_stripname '' '.exe' "$func_basename_result" 26578292847cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2658c2939121Smrg} 2659c2939121Smrg 2660c2939121Smrg# func_ltwrapper_p file 2661c2939121Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2662c2939121Smrg# This function is only a basic sanity check; it will hardly flush out 2663c2939121Smrg# determined imposters. 2664c2939121Smrgfunc_ltwrapper_p () 2665c2939121Smrg{ 2666c2939121Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2667c2939121Smrg} 2668c2939121Smrg 2669c2939121Smrg 2670c2939121Smrg# func_execute_cmds commands fail_cmd 2671c2939121Smrg# Execute tilde-delimited COMMANDS. 2672c2939121Smrg# If FAIL_CMD is given, eval that upon failure. 2673c2939121Smrg# FAIL_CMD may read-access the current command in variable CMD! 2674c2939121Smrgfunc_execute_cmds () 2675c2939121Smrg{ 26768292847cSmrg $debug_cmd 26778292847cSmrg 2678c2939121Smrg save_ifs=$IFS; IFS='~' 2679c2939121Smrg for cmd in $1; do 26808292847cSmrg IFS=$sp$nl 2681c2939121Smrg eval cmd=\"$cmd\" 26828292847cSmrg IFS=$save_ifs 2683c2939121Smrg func_show_eval "$cmd" "${2-:}" 2684c2939121Smrg done 2685c2939121Smrg IFS=$save_ifs 2686c2939121Smrg} 2687c2939121Smrg 2688c2939121Smrg 2689c2939121Smrg# func_source file 2690c2939121Smrg# Source FILE, adding directory component if necessary. 2691c2939121Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2692c2939121Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2693c2939121Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 26948292847cSmrg# 'FILE.' does not work on cygwin managed mounts. 2695c2939121Smrgfunc_source () 2696c2939121Smrg{ 26978292847cSmrg $debug_cmd 26988292847cSmrg 2699c2939121Smrg case $1 in 2700c2939121Smrg */* | *\\*) . "$1" ;; 2701c2939121Smrg *) . "./$1" ;; 2702c2939121Smrg esac 2703c2939121Smrg} 2704c2939121Smrg 2705c2939121Smrg 27062836776bSmrg# func_resolve_sysroot PATH 27072836776bSmrg# Replace a leading = in PATH with a sysroot. Store the result into 27082836776bSmrg# func_resolve_sysroot_result 27092836776bSmrgfunc_resolve_sysroot () 27102836776bSmrg{ 27112836776bSmrg func_resolve_sysroot_result=$1 27122836776bSmrg case $func_resolve_sysroot_result in 27132836776bSmrg =*) 27142836776bSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 27152836776bSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 27162836776bSmrg ;; 27172836776bSmrg esac 27182836776bSmrg} 27192836776bSmrg 27202836776bSmrg# func_replace_sysroot PATH 27212836776bSmrg# If PATH begins with the sysroot, replace it with = and 27222836776bSmrg# store the result into func_replace_sysroot_result. 27232836776bSmrgfunc_replace_sysroot () 27242836776bSmrg{ 27258292847cSmrg case $lt_sysroot:$1 in 27262836776bSmrg ?*:"$lt_sysroot"*) 27272836776bSmrg func_stripname "$lt_sysroot" '' "$1" 27288292847cSmrg func_replace_sysroot_result='='$func_stripname_result 27292836776bSmrg ;; 27302836776bSmrg *) 27312836776bSmrg # Including no sysroot. 27322836776bSmrg func_replace_sysroot_result=$1 27332836776bSmrg ;; 27342836776bSmrg esac 27352836776bSmrg} 27362836776bSmrg 2737c2939121Smrg# func_infer_tag arg 2738c2939121Smrg# Infer tagged configuration to use if any are available and 2739c2939121Smrg# if one wasn't chosen via the "--tag" command line option. 2740c2939121Smrg# Only attempt this if the compiler in the base compile 2741c2939121Smrg# command doesn't match the default compiler. 2742c2939121Smrg# arg is usually of the form 'gcc ...' 2743c2939121Smrgfunc_infer_tag () 2744c2939121Smrg{ 27458292847cSmrg $debug_cmd 27468292847cSmrg 2747c2939121Smrg if test -n "$available_tags" && test -z "$tagname"; then 2748c2939121Smrg CC_quoted= 2749c2939121Smrg for arg in $CC; do 27502836776bSmrg func_append_quoted CC_quoted "$arg" 2751c2939121Smrg done 2752c2939121Smrg CC_expanded=`func_echo_all $CC` 2753c2939121Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2754c2939121Smrg case $@ in 2755c2939121Smrg # Blanks in the command may have been stripped by the calling shell, 2756c2939121Smrg # but not from the CC environment variable when configure was run. 2757c2939121Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2758c2939121Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2759c2939121Smrg # Blanks at the start of $base_compile will cause this to fail 2760c2939121Smrg # if we don't check for them as well. 2761c2939121Smrg *) 2762c2939121Smrg for z in $available_tags; do 2763c2939121Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2764c2939121Smrg # Evaluate the configuration. 27658292847cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2766c2939121Smrg CC_quoted= 2767c2939121Smrg for arg in $CC; do 2768c2939121Smrg # Double-quote args containing other shell metacharacters. 27692836776bSmrg func_append_quoted CC_quoted "$arg" 2770c2939121Smrg done 2771c2939121Smrg CC_expanded=`func_echo_all $CC` 2772c2939121Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2773c2939121Smrg case "$@ " in 2774c2939121Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2775c2939121Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2776c2939121Smrg # The compiler in the base compile command matches 2777c2939121Smrg # the one in the tagged configuration. 2778c2939121Smrg # Assume this is the tagged configuration we want. 2779c2939121Smrg tagname=$z 2780c2939121Smrg break 2781c2939121Smrg ;; 2782c2939121Smrg esac 2783c2939121Smrg fi 2784c2939121Smrg done 2785c2939121Smrg # If $tagname still isn't set, then no tagged configuration 2786c2939121Smrg # was found and let the user know that the "--tag" command 2787c2939121Smrg # line option must be used. 2788c2939121Smrg if test -z "$tagname"; then 2789c2939121Smrg func_echo "unable to infer tagged configuration" 27908292847cSmrg func_fatal_error "specify a tag with '--tag'" 2791c2939121Smrg# else 2792c2939121Smrg# func_verbose "using $tagname tagged configuration" 2793c2939121Smrg fi 2794c2939121Smrg ;; 2795c2939121Smrg esac 2796c2939121Smrg fi 2797c2939121Smrg} 2798c2939121Smrg 2799c2939121Smrg 28002836776bSmrg 28012836776bSmrg# func_write_libtool_object output_name pic_name nonpic_name 28022836776bSmrg# Create a libtool object file (analogous to a ".la" file), 28032836776bSmrg# but don't create it if we're doing a dry run. 28042836776bSmrgfunc_write_libtool_object () 28052836776bSmrg{ 28068292847cSmrg write_libobj=$1 28078292847cSmrg if test yes = "$build_libtool_libs"; then 28088292847cSmrg write_lobj=\'$2\' 28092836776bSmrg else 28102836776bSmrg write_lobj=none 28112836776bSmrg fi 28122836776bSmrg 28138292847cSmrg if test yes = "$build_old_libs"; then 28148292847cSmrg write_oldobj=\'$3\' 28152836776bSmrg else 28162836776bSmrg write_oldobj=none 28172836776bSmrg fi 28182836776bSmrg 28192836776bSmrg $opt_dry_run || { 28202836776bSmrg cat >${write_libobj}T <<EOF 28212836776bSmrg# $write_libobj - a libtool object file 28228292847cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 28232836776bSmrg# 28242836776bSmrg# Please DO NOT delete this file! 28252836776bSmrg# It is necessary for linking the library. 28262836776bSmrg 28272836776bSmrg# Name of the PIC object. 28282836776bSmrgpic_object=$write_lobj 28292836776bSmrg 28302836776bSmrg# Name of the non-PIC object 28312836776bSmrgnon_pic_object=$write_oldobj 28322836776bSmrg 28332836776bSmrgEOF 28348292847cSmrg $MV "${write_libobj}T" "$write_libobj" 28352836776bSmrg } 28362836776bSmrg} 28372836776bSmrg 28382836776bSmrg 28392836776bSmrg################################################## 28402836776bSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 28412836776bSmrg################################################## 28422836776bSmrg 28432836776bSmrg# func_convert_core_file_wine_to_w32 ARG 28442836776bSmrg# Helper function used by file name conversion functions when $build is *nix, 28452836776bSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 28462836776bSmrg# correctly configured wine environment available, with the winepath program 28472836776bSmrg# in $build's $PATH. 28482836776bSmrg# 28492836776bSmrg# ARG is the $build file name to be converted to w32 format. 28502836776bSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 28512836776bSmrg# be empty on error (or when ARG is empty) 28522836776bSmrgfunc_convert_core_file_wine_to_w32 () 28532836776bSmrg{ 28548292847cSmrg $debug_cmd 28558292847cSmrg 28568292847cSmrg func_convert_core_file_wine_to_w32_result=$1 28572836776bSmrg if test -n "$1"; then 28582836776bSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 28592836776bSmrg # are forced to check the contents of stdout. On the other hand, if the 28602836776bSmrg # command is not found, the shell will set an exit code of 127 and print 28612836776bSmrg # *an error message* to stdout. So we must check for both error code of 28622836776bSmrg # zero AND non-empty stdout, which explains the odd construction: 28632836776bSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 28648292847cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 28652836776bSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 28668292847cSmrg $SED -e "$sed_naive_backslashify"` 28672836776bSmrg else 28682836776bSmrg func_convert_core_file_wine_to_w32_result= 28692836776bSmrg fi 28702836776bSmrg fi 28712836776bSmrg} 28722836776bSmrg# end: func_convert_core_file_wine_to_w32 28732836776bSmrg 28742836776bSmrg 28752836776bSmrg# func_convert_core_path_wine_to_w32 ARG 28762836776bSmrg# Helper function used by path conversion functions when $build is *nix, and 28772836776bSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 28782836776bSmrg# configured wine environment available, with the winepath program in $build's 28792836776bSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 28802836776bSmrg# 28812836776bSmrg# ARG is path to be converted from $build format to win32. 28822836776bSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 28832836776bSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 28842836776bSmrg# are convertible, then the result may be empty. 28852836776bSmrgfunc_convert_core_path_wine_to_w32 () 28862836776bSmrg{ 28878292847cSmrg $debug_cmd 28888292847cSmrg 28892836776bSmrg # unfortunately, winepath doesn't convert paths, only file names 28908292847cSmrg func_convert_core_path_wine_to_w32_result= 28912836776bSmrg if test -n "$1"; then 28922836776bSmrg oldIFS=$IFS 28932836776bSmrg IFS=: 28942836776bSmrg for func_convert_core_path_wine_to_w32_f in $1; do 28952836776bSmrg IFS=$oldIFS 28962836776bSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 28978292847cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 28982836776bSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 28998292847cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 29002836776bSmrg else 29012836776bSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 29022836776bSmrg fi 29032836776bSmrg fi 29042836776bSmrg done 29052836776bSmrg IFS=$oldIFS 29062836776bSmrg fi 29072836776bSmrg} 29082836776bSmrg# end: func_convert_core_path_wine_to_w32 29092836776bSmrg 29102836776bSmrg 29112836776bSmrg# func_cygpath ARGS... 29122836776bSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 29132836776bSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 29142836776bSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 29152836776bSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 29162836776bSmrg# file name or path is assumed to be in w32 format, as previously converted 29172836776bSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 29182836776bSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 29192836776bSmrg# Cygwin format). Returns an empty string on error. 29202836776bSmrg# 29212836776bSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 29222836776bSmrg# be converted. 29232836776bSmrg# 29242836776bSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 29252836776bSmrg# environment variable; do not put it in $PATH. 29262836776bSmrgfunc_cygpath () 29272836776bSmrg{ 29288292847cSmrg $debug_cmd 29298292847cSmrg 29302836776bSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 29312836776bSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 29322836776bSmrg if test "$?" -ne 0; then 29332836776bSmrg # on failure, ensure result is empty 29342836776bSmrg func_cygpath_result= 29352836776bSmrg fi 29362836776bSmrg else 29372836776bSmrg func_cygpath_result= 29388292847cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 29392836776bSmrg fi 29402836776bSmrg} 29412836776bSmrg#end: func_cygpath 29422836776bSmrg 29432836776bSmrg 29442836776bSmrg# func_convert_core_msys_to_w32 ARG 29452836776bSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 29462836776bSmrg# result in func_convert_core_msys_to_w32_result. 29472836776bSmrgfunc_convert_core_msys_to_w32 () 29482836776bSmrg{ 29498292847cSmrg $debug_cmd 29508292847cSmrg 29512836776bSmrg # awkward: cmd appends spaces to result 29522836776bSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 29538292847cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 29542836776bSmrg} 29552836776bSmrg#end: func_convert_core_msys_to_w32 29562836776bSmrg 29572836776bSmrg 29582836776bSmrg# func_convert_file_check ARG1 ARG2 29592836776bSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 29602836776bSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 29612836776bSmrg# func_to_host_file_result to ARG1). 29622836776bSmrgfunc_convert_file_check () 29632836776bSmrg{ 29648292847cSmrg $debug_cmd 29658292847cSmrg 29668292847cSmrg if test -z "$2" && test -n "$1"; then 29672836776bSmrg func_error "Could not determine host file name corresponding to" 29688292847cSmrg func_error " '$1'" 29692836776bSmrg func_error "Continuing, but uninstalled executables may not work." 29702836776bSmrg # Fallback: 29718292847cSmrg func_to_host_file_result=$1 29722836776bSmrg fi 29732836776bSmrg} 29742836776bSmrg# end func_convert_file_check 29752836776bSmrg 29762836776bSmrg 29772836776bSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 29782836776bSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 29792836776bSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 29802836776bSmrg# func_to_host_file_result to a simplistic fallback value (see below). 29812836776bSmrgfunc_convert_path_check () 29822836776bSmrg{ 29838292847cSmrg $debug_cmd 29848292847cSmrg 29852836776bSmrg if test -z "$4" && test -n "$3"; then 29862836776bSmrg func_error "Could not determine the host path corresponding to" 29878292847cSmrg func_error " '$3'" 29882836776bSmrg func_error "Continuing, but uninstalled executables may not work." 29892836776bSmrg # Fallback. This is a deliberately simplistic "conversion" and 29902836776bSmrg # should not be "improved". See libtool.info. 29912836776bSmrg if test "x$1" != "x$2"; then 29922836776bSmrg lt_replace_pathsep_chars="s|$1|$2|g" 29932836776bSmrg func_to_host_path_result=`echo "$3" | 29942836776bSmrg $SED -e "$lt_replace_pathsep_chars"` 29952836776bSmrg else 29968292847cSmrg func_to_host_path_result=$3 29972836776bSmrg fi 29982836776bSmrg fi 29992836776bSmrg} 30002836776bSmrg# end func_convert_path_check 30012836776bSmrg 30022836776bSmrg 30032836776bSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 30042836776bSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 30052836776bSmrg# and appending REPL if ORIG matches BACKPAT. 30062836776bSmrgfunc_convert_path_front_back_pathsep () 30072836776bSmrg{ 30088292847cSmrg $debug_cmd 30098292847cSmrg 30102836776bSmrg case $4 in 30118292847cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 30122836776bSmrg ;; 30132836776bSmrg esac 30142836776bSmrg case $4 in 30152836776bSmrg $2 ) func_append func_to_host_path_result "$3" 30162836776bSmrg ;; 30172836776bSmrg esac 30182836776bSmrg} 30192836776bSmrg# end func_convert_path_front_back_pathsep 30202836776bSmrg 30212836776bSmrg 30222836776bSmrg################################################## 30232836776bSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 30242836776bSmrg################################################## 30258292847cSmrg# invoked via '$to_host_file_cmd ARG' 30262836776bSmrg# 30272836776bSmrg# In each case, ARG is the path to be converted from $build to $host format. 30282836776bSmrg# Result will be available in $func_to_host_file_result. 30292836776bSmrg 30302836776bSmrg 30312836776bSmrg# func_to_host_file ARG 30322836776bSmrg# Converts the file name ARG from $build format to $host format. Return result 30332836776bSmrg# in func_to_host_file_result. 30342836776bSmrgfunc_to_host_file () 30352836776bSmrg{ 30368292847cSmrg $debug_cmd 30378292847cSmrg 30382836776bSmrg $to_host_file_cmd "$1" 30392836776bSmrg} 30402836776bSmrg# end func_to_host_file 30412836776bSmrg 30422836776bSmrg 30432836776bSmrg# func_to_tool_file ARG LAZY 30442836776bSmrg# converts the file name ARG from $build format to toolchain format. Return 30452836776bSmrg# result in func_to_tool_file_result. If the conversion in use is listed 30462836776bSmrg# in (the comma separated) LAZY, no conversion takes place. 30472836776bSmrgfunc_to_tool_file () 30482836776bSmrg{ 30498292847cSmrg $debug_cmd 30508292847cSmrg 30512836776bSmrg case ,$2, in 30522836776bSmrg *,"$to_tool_file_cmd",*) 30532836776bSmrg func_to_tool_file_result=$1 30542836776bSmrg ;; 30552836776bSmrg *) 30562836776bSmrg $to_tool_file_cmd "$1" 30572836776bSmrg func_to_tool_file_result=$func_to_host_file_result 30582836776bSmrg ;; 30592836776bSmrg esac 30602836776bSmrg} 30612836776bSmrg# end func_to_tool_file 30622836776bSmrg 30632836776bSmrg 30642836776bSmrg# func_convert_file_noop ARG 30652836776bSmrg# Copy ARG to func_to_host_file_result. 30662836776bSmrgfunc_convert_file_noop () 30672836776bSmrg{ 30688292847cSmrg func_to_host_file_result=$1 30692836776bSmrg} 30702836776bSmrg# end func_convert_file_noop 30712836776bSmrg 30722836776bSmrg 30732836776bSmrg# func_convert_file_msys_to_w32 ARG 30742836776bSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 30752836776bSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 30762836776bSmrg# func_to_host_file_result. 30772836776bSmrgfunc_convert_file_msys_to_w32 () 30782836776bSmrg{ 30798292847cSmrg $debug_cmd 30808292847cSmrg 30818292847cSmrg func_to_host_file_result=$1 30822836776bSmrg if test -n "$1"; then 30832836776bSmrg func_convert_core_msys_to_w32 "$1" 30848292847cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 30852836776bSmrg fi 30862836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 30872836776bSmrg} 30882836776bSmrg# end func_convert_file_msys_to_w32 30892836776bSmrg 30902836776bSmrg 30912836776bSmrg# func_convert_file_cygwin_to_w32 ARG 30922836776bSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 30932836776bSmrg# func_to_host_file_result. 30942836776bSmrgfunc_convert_file_cygwin_to_w32 () 30952836776bSmrg{ 30968292847cSmrg $debug_cmd 30978292847cSmrg 30988292847cSmrg func_to_host_file_result=$1 30992836776bSmrg if test -n "$1"; then 31002836776bSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 31012836776bSmrg # LT_CYGPATH in this case. 31022836776bSmrg func_to_host_file_result=`cygpath -m "$1"` 31032836776bSmrg fi 31042836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 31052836776bSmrg} 31062836776bSmrg# end func_convert_file_cygwin_to_w32 31072836776bSmrg 31082836776bSmrg 31092836776bSmrg# func_convert_file_nix_to_w32 ARG 31102836776bSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 31112836776bSmrg# and a working winepath. Returns result in func_to_host_file_result. 31122836776bSmrgfunc_convert_file_nix_to_w32 () 31132836776bSmrg{ 31148292847cSmrg $debug_cmd 31158292847cSmrg 31168292847cSmrg func_to_host_file_result=$1 31172836776bSmrg if test -n "$1"; then 31182836776bSmrg func_convert_core_file_wine_to_w32 "$1" 31198292847cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 31202836776bSmrg fi 31212836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 31222836776bSmrg} 31232836776bSmrg# end func_convert_file_nix_to_w32 31242836776bSmrg 31252836776bSmrg 31262836776bSmrg# func_convert_file_msys_to_cygwin ARG 31272836776bSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 31282836776bSmrg# Returns result in func_to_host_file_result. 31292836776bSmrgfunc_convert_file_msys_to_cygwin () 31302836776bSmrg{ 31318292847cSmrg $debug_cmd 31328292847cSmrg 31338292847cSmrg func_to_host_file_result=$1 31342836776bSmrg if test -n "$1"; then 31352836776bSmrg func_convert_core_msys_to_w32 "$1" 31362836776bSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 31378292847cSmrg func_to_host_file_result=$func_cygpath_result 31382836776bSmrg fi 31392836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 31402836776bSmrg} 31412836776bSmrg# end func_convert_file_msys_to_cygwin 31422836776bSmrg 31432836776bSmrg 31442836776bSmrg# func_convert_file_nix_to_cygwin ARG 31452836776bSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 31462836776bSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 31472836776bSmrg# in func_to_host_file_result. 31482836776bSmrgfunc_convert_file_nix_to_cygwin () 31492836776bSmrg{ 31508292847cSmrg $debug_cmd 31518292847cSmrg 31528292847cSmrg func_to_host_file_result=$1 31532836776bSmrg if test -n "$1"; then 31542836776bSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 31552836776bSmrg func_convert_core_file_wine_to_w32 "$1" 31562836776bSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 31578292847cSmrg func_to_host_file_result=$func_cygpath_result 31582836776bSmrg fi 31592836776bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 31602836776bSmrg} 31612836776bSmrg# end func_convert_file_nix_to_cygwin 31622836776bSmrg 31632836776bSmrg 31642836776bSmrg############################################# 31652836776bSmrg# $build to $host PATH CONVERSION FUNCTIONS # 31662836776bSmrg############################################# 31678292847cSmrg# invoked via '$to_host_path_cmd ARG' 31682836776bSmrg# 31692836776bSmrg# In each case, ARG is the path to be converted from $build to $host format. 31702836776bSmrg# The result will be available in $func_to_host_path_result. 31712836776bSmrg# 31722836776bSmrg# Path separators are also converted from $build format to $host format. If 31732836776bSmrg# ARG begins or ends with a path separator character, it is preserved (but 31742836776bSmrg# converted to $host format) on output. 31752836776bSmrg# 31762836776bSmrg# All path conversion functions are named using the following convention: 31772836776bSmrg# file name conversion function : func_convert_file_X_to_Y () 31782836776bSmrg# path conversion function : func_convert_path_X_to_Y () 31792836776bSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 31802836776bSmrg# same. If conversion functions are added for new $build/$host combinations, 31812836776bSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 31822836776bSmrg# will break. 31832836776bSmrg 31842836776bSmrg 31852836776bSmrg# func_init_to_host_path_cmd 31862836776bSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 31872836776bSmrg# appropriate value, based on the value of $to_host_file_cmd. 31882836776bSmrgto_host_path_cmd= 31892836776bSmrgfunc_init_to_host_path_cmd () 31902836776bSmrg{ 31918292847cSmrg $debug_cmd 31928292847cSmrg 31932836776bSmrg if test -z "$to_host_path_cmd"; then 31942836776bSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 31958292847cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 31962836776bSmrg fi 31972836776bSmrg} 31982836776bSmrg 31992836776bSmrg 32002836776bSmrg# func_to_host_path ARG 32012836776bSmrg# Converts the path ARG from $build format to $host format. Return result 32022836776bSmrg# in func_to_host_path_result. 32032836776bSmrgfunc_to_host_path () 32042836776bSmrg{ 32058292847cSmrg $debug_cmd 32068292847cSmrg 32072836776bSmrg func_init_to_host_path_cmd 32082836776bSmrg $to_host_path_cmd "$1" 32092836776bSmrg} 32102836776bSmrg# end func_to_host_path 32112836776bSmrg 32122836776bSmrg 32132836776bSmrg# func_convert_path_noop ARG 32142836776bSmrg# Copy ARG to func_to_host_path_result. 32152836776bSmrgfunc_convert_path_noop () 32162836776bSmrg{ 32178292847cSmrg func_to_host_path_result=$1 32182836776bSmrg} 32192836776bSmrg# end func_convert_path_noop 32202836776bSmrg 32212836776bSmrg 32222836776bSmrg# func_convert_path_msys_to_w32 ARG 32232836776bSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 32242836776bSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 32252836776bSmrg# func_to_host_path_result. 32262836776bSmrgfunc_convert_path_msys_to_w32 () 32272836776bSmrg{ 32288292847cSmrg $debug_cmd 32298292847cSmrg 32308292847cSmrg func_to_host_path_result=$1 32312836776bSmrg if test -n "$1"; then 32322836776bSmrg # Remove leading and trailing path separator characters from ARG. MSYS 32332836776bSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 32342836776bSmrg # and winepath ignores them completely. 32352836776bSmrg func_stripname : : "$1" 32362836776bSmrg func_to_host_path_tmp1=$func_stripname_result 32372836776bSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 32388292847cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_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 32432836776bSmrg} 32442836776bSmrg# end func_convert_path_msys_to_w32 32452836776bSmrg 32462836776bSmrg 32472836776bSmrg# func_convert_path_cygwin_to_w32 ARG 32482836776bSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 32492836776bSmrg# func_to_host_file_result. 32502836776bSmrgfunc_convert_path_cygwin_to_w32 () 32512836776bSmrg{ 32528292847cSmrg $debug_cmd 32538292847cSmrg 32548292847cSmrg func_to_host_path_result=$1 32552836776bSmrg if test -n "$1"; then 32562836776bSmrg # See func_convert_path_msys_to_w32: 32572836776bSmrg func_stripname : : "$1" 32582836776bSmrg func_to_host_path_tmp1=$func_stripname_result 32592836776bSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 32602836776bSmrg func_convert_path_check : ";" \ 32612836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32622836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 32632836776bSmrg fi 32642836776bSmrg} 32652836776bSmrg# end func_convert_path_cygwin_to_w32 32662836776bSmrg 32672836776bSmrg 32682836776bSmrg# func_convert_path_nix_to_w32 ARG 32692836776bSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 32702836776bSmrg# a working winepath. Returns result in func_to_host_file_result. 32712836776bSmrgfunc_convert_path_nix_to_w32 () 3272c2939121Smrg{ 32738292847cSmrg $debug_cmd 32748292847cSmrg 32758292847cSmrg func_to_host_path_result=$1 32762836776bSmrg if test -n "$1"; then 32772836776bSmrg # See func_convert_path_msys_to_w32: 32782836776bSmrg func_stripname : : "$1" 32792836776bSmrg func_to_host_path_tmp1=$func_stripname_result 32802836776bSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 32818292847cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 32822836776bSmrg func_convert_path_check : ";" \ 32832836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 32842836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 32852836776bSmrg fi 32862836776bSmrg} 32872836776bSmrg# end func_convert_path_nix_to_w32 3288c2939121Smrg 3289c2939121Smrg 32902836776bSmrg# func_convert_path_msys_to_cygwin ARG 32912836776bSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32922836776bSmrg# Returns result in func_to_host_file_result. 32932836776bSmrgfunc_convert_path_msys_to_cygwin () 32942836776bSmrg{ 32958292847cSmrg $debug_cmd 32968292847cSmrg 32978292847cSmrg func_to_host_path_result=$1 32982836776bSmrg if test -n "$1"; then 32992836776bSmrg # See func_convert_path_msys_to_w32: 33002836776bSmrg func_stripname : : "$1" 33012836776bSmrg func_to_host_path_tmp1=$func_stripname_result 33022836776bSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33032836776bSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 33048292847cSmrg func_to_host_path_result=$func_cygpath_result 33052836776bSmrg func_convert_path_check : : \ 33062836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 33072836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 33082836776bSmrg fi 33092836776bSmrg} 33102836776bSmrg# end func_convert_path_msys_to_cygwin 3311c2939121Smrg 3312c2939121Smrg 33132836776bSmrg# func_convert_path_nix_to_cygwin ARG 33142836776bSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 33152836776bSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 33162836776bSmrg# func_to_host_file_result. 33172836776bSmrgfunc_convert_path_nix_to_cygwin () 33182836776bSmrg{ 33198292847cSmrg $debug_cmd 33208292847cSmrg 33218292847cSmrg func_to_host_path_result=$1 33222836776bSmrg if test -n "$1"; then 33232836776bSmrg # Remove leading and trailing path separator characters from 33242836776bSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 33252836776bSmrg # into '.;' and ';.', and winepath ignores them completely. 33262836776bSmrg func_stripname : : "$1" 33272836776bSmrg func_to_host_path_tmp1=$func_stripname_result 33282836776bSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 33292836776bSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 33308292847cSmrg func_to_host_path_result=$func_cygpath_result 33312836776bSmrg func_convert_path_check : : \ 33322836776bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 33332836776bSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 33342836776bSmrg fi 3335c2939121Smrg} 33362836776bSmrg# end func_convert_path_nix_to_cygwin 33372836776bSmrg 3338c2939121Smrg 33398292847cSmrg# func_dll_def_p FILE 33408292847cSmrg# True iff FILE is a Windows DLL '.def' file. 33418292847cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 33428292847cSmrgfunc_dll_def_p () 33438292847cSmrg{ 33448292847cSmrg $debug_cmd 33458292847cSmrg 33468292847cSmrg func_dll_def_p_tmp=`$SED -n \ 33478292847cSmrg -e 's/^[ ]*//' \ 33488292847cSmrg -e '/^\(;.*\)*$/d' \ 33498292847cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 33508292847cSmrg -e q \ 33518292847cSmrg "$1"` 33528292847cSmrg test DEF = "$func_dll_def_p_tmp" 33538292847cSmrg} 33548292847cSmrg 33558292847cSmrg 3356c2939121Smrg# func_mode_compile arg... 3357c2939121Smrgfunc_mode_compile () 3358c2939121Smrg{ 33598292847cSmrg $debug_cmd 33608292847cSmrg 3361c2939121Smrg # Get the compilation command and the source file. 3362c2939121Smrg base_compile= 33638292847cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3364c2939121Smrg suppress_opt=yes 3365c2939121Smrg suppress_output= 3366c2939121Smrg arg_mode=normal 3367c2939121Smrg libobj= 3368c2939121Smrg later= 3369c2939121Smrg pie_flag= 3370c2939121Smrg 3371c2939121Smrg for arg 3372c2939121Smrg do 3373c2939121Smrg case $arg_mode in 3374c2939121Smrg arg ) 3375c2939121Smrg # do not "continue". Instead, add this to base_compile 33768292847cSmrg lastarg=$arg 3377c2939121Smrg arg_mode=normal 3378c2939121Smrg ;; 3379c2939121Smrg 3380c2939121Smrg target ) 33818292847cSmrg libobj=$arg 3382c2939121Smrg arg_mode=normal 3383c2939121Smrg continue 3384c2939121Smrg ;; 3385c2939121Smrg 3386c2939121Smrg normal ) 3387c2939121Smrg # Accept any command-line options. 3388c2939121Smrg case $arg in 3389c2939121Smrg -o) 3390c2939121Smrg test -n "$libobj" && \ 33918292847cSmrg func_fatal_error "you cannot specify '-o' more than once" 3392c2939121Smrg arg_mode=target 3393c2939121Smrg continue 3394c2939121Smrg ;; 3395c2939121Smrg 3396c2939121Smrg -pie | -fpie | -fPIE) 33972836776bSmrg func_append pie_flag " $arg" 3398c2939121Smrg continue 3399c2939121Smrg ;; 3400c2939121Smrg 3401c2939121Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 34022836776bSmrg func_append later " $arg" 3403c2939121Smrg continue 3404c2939121Smrg ;; 3405c76ae52dSmrg 3406c76ae52dSmrg -no-suppress) 3407c76ae52dSmrg suppress_opt=no 3408c76ae52dSmrg continue 3409c76ae52dSmrg ;; 3410c76ae52dSmrg 3411c76ae52dSmrg -Xcompiler) 3412c76ae52dSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3413c76ae52dSmrg continue # The current "srcfile" will either be retained or 3414c76ae52dSmrg ;; # replaced later. I would guess that would be a bug. 3415c76ae52dSmrg 3416c76ae52dSmrg -Wc,*) 3417c2939121Smrg func_stripname '-Wc,' '' "$arg" 3418c2939121Smrg args=$func_stripname_result 3419c76ae52dSmrg lastarg= 34208292847cSmrg save_ifs=$IFS; IFS=, 3421c2939121Smrg for arg in $args; do 34228292847cSmrg IFS=$save_ifs 34232836776bSmrg func_append_quoted lastarg "$arg" 3424c76ae52dSmrg done 34258292847cSmrg IFS=$save_ifs 3426c2939121Smrg func_stripname ' ' '' "$lastarg" 3427c2939121Smrg lastarg=$func_stripname_result 3428c76ae52dSmrg 3429c76ae52dSmrg # Add the arguments to base_compile. 34302836776bSmrg func_append base_compile " $lastarg" 3431c76ae52dSmrg continue 3432c76ae52dSmrg ;; 3433c76ae52dSmrg 3434c2939121Smrg *) 3435c76ae52dSmrg # Accept the current argument as the source file. 3436c76ae52dSmrg # The previous "srcfile" becomes the current argument. 3437c76ae52dSmrg # 34388292847cSmrg lastarg=$srcfile 34398292847cSmrg srcfile=$arg 3440c76ae52dSmrg ;; 3441c76ae52dSmrg esac # case $arg 3442c76ae52dSmrg ;; 3443c76ae52dSmrg esac # case $arg_mode 3444c76ae52dSmrg 3445c76ae52dSmrg # Aesthetically quote the previous argument. 34462836776bSmrg func_append_quoted base_compile "$lastarg" 3447c76ae52dSmrg done # for arg 3448c76ae52dSmrg 3449c76ae52dSmrg case $arg_mode in 3450c76ae52dSmrg arg) 3451c2939121Smrg func_fatal_error "you must specify an argument for -Xcompile" 3452c76ae52dSmrg ;; 3453c76ae52dSmrg target) 34548292847cSmrg func_fatal_error "you must specify a target with '-o'" 3455c76ae52dSmrg ;; 3456c76ae52dSmrg *) 3457c76ae52dSmrg # Get the name of the library object. 3458c2939121Smrg test -z "$libobj" && { 3459c2939121Smrg func_basename "$srcfile" 34608292847cSmrg libobj=$func_basename_result 3461c2939121Smrg } 3462c76ae52dSmrg ;; 3463c76ae52dSmrg esac 3464c76ae52dSmrg 3465c76ae52dSmrg # Recognize several different file suffixes. 3466c76ae52dSmrg # If the user specifies -o file.o, it is replaced with file.lo 3467c76ae52dSmrg case $libobj in 3468c2939121Smrg *.[cCFSifmso] | \ 3469c2939121Smrg *.ada | *.adb | *.ads | *.asm | \ 3470c2939121Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 34712836776bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3472c2939121Smrg func_xform "$libobj" 3473c2939121Smrg libobj=$func_xform_result 3474c2939121Smrg ;; 3475c76ae52dSmrg esac 3476c76ae52dSmrg 3477c76ae52dSmrg case $libobj in 3478c2939121Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3479c76ae52dSmrg *) 34808292847cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3481c76ae52dSmrg ;; 3482c76ae52dSmrg esac 3483c76ae52dSmrg 3484c76ae52dSmrg func_infer_tag $base_compile 3485c76ae52dSmrg 3486c76ae52dSmrg for arg in $later; do 3487c76ae52dSmrg case $arg in 3488c2939121Smrg -shared) 34898292847cSmrg test yes = "$build_libtool_libs" \ 34908292847cSmrg || func_fatal_configuration "cannot build a shared library" 3491c2939121Smrg build_old_libs=no 3492c2939121Smrg continue 3493c2939121Smrg ;; 3494c2939121Smrg 3495c76ae52dSmrg -static) 3496c2939121Smrg build_libtool_libs=no 3497c76ae52dSmrg build_old_libs=yes 3498c76ae52dSmrg continue 3499c76ae52dSmrg ;; 3500c76ae52dSmrg 3501c76ae52dSmrg -prefer-pic) 3502c76ae52dSmrg pic_mode=yes 3503c76ae52dSmrg continue 3504c76ae52dSmrg ;; 3505c76ae52dSmrg 3506c76ae52dSmrg -prefer-non-pic) 3507c76ae52dSmrg pic_mode=no 3508c76ae52dSmrg continue 3509c76ae52dSmrg ;; 3510c76ae52dSmrg esac 3511c76ae52dSmrg done 3512c76ae52dSmrg 3513c2939121Smrg func_quote_for_eval "$libobj" 3514c2939121Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3515c2939121Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 35168292847cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3517c2939121Smrg func_dirname_and_basename "$obj" "/" "" 35188292847cSmrg objname=$func_basename_result 35198292847cSmrg xdir=$func_dirname_result 35208292847cSmrg lobj=$xdir$objdir/$objname 3521c76ae52dSmrg 3522c2939121Smrg test -z "$base_compile" && \ 3523c2939121Smrg func_fatal_help "you must specify a compilation command" 3524c76ae52dSmrg 3525c76ae52dSmrg # Delete any leftover library objects. 35268292847cSmrg if test yes = "$build_old_libs"; then 3527c76ae52dSmrg removelist="$obj $lobj $libobj ${libobj}T" 3528c76ae52dSmrg else 3529c76ae52dSmrg removelist="$lobj $libobj ${libobj}T" 3530c76ae52dSmrg fi 3531c76ae52dSmrg 3532c76ae52dSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3533c76ae52dSmrg case $host_os in 3534c2939121Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3535c76ae52dSmrg pic_mode=default 3536c76ae52dSmrg ;; 3537c76ae52dSmrg esac 35388292847cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3539c76ae52dSmrg # non-PIC code in shared libraries is not supported 3540c76ae52dSmrg pic_mode=default 3541c76ae52dSmrg fi 3542c76ae52dSmrg 3543c76ae52dSmrg # Calculate the filename of the output object if compiler does 3544c76ae52dSmrg # not support -o with -c 35458292847cSmrg if test no = "$compiler_c_o"; then 35468292847cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 35478292847cSmrg lockfile=$output_obj.lock 3548c76ae52dSmrg else 3549c76ae52dSmrg output_obj= 3550c76ae52dSmrg need_locks=no 3551c76ae52dSmrg lockfile= 3552c76ae52dSmrg fi 3553c76ae52dSmrg 3554c76ae52dSmrg # Lock this critical section if it is needed 3555c76ae52dSmrg # We use this script file to make the link, it avoids creating a new file 35568292847cSmrg if test yes = "$need_locks"; then 3557c2939121Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3558c2939121Smrg func_echo "Waiting for $lockfile to be removed" 3559c76ae52dSmrg sleep 2 3560c76ae52dSmrg done 35618292847cSmrg elif test warn = "$need_locks"; then 3562c76ae52dSmrg if test -f "$lockfile"; then 3563c2939121Smrg $ECHO "\ 3564c76ae52dSmrg*** ERROR, $lockfile exists and contains: 3565c76ae52dSmrg`cat $lockfile 2>/dev/null` 3566c76ae52dSmrg 3567c76ae52dSmrgThis indicates that another process is trying to use the same 3568c76ae52dSmrgtemporary object file, and libtool could not work around it because 35698292847cSmrgyour compiler does not support '-c' and '-o' together. If you 3570c76ae52dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3571c76ae52dSmrgavoid parallel builds (make -j) in this platform, or get a better 3572c76ae52dSmrgcompiler." 3573c76ae52dSmrg 3574c2939121Smrg $opt_dry_run || $RM $removelist 3575c76ae52dSmrg exit $EXIT_FAILURE 3576c76ae52dSmrg fi 35772836776bSmrg func_append removelist " $output_obj" 3578c2939121Smrg $ECHO "$srcfile" > "$lockfile" 3579c76ae52dSmrg fi 3580c76ae52dSmrg 3581c2939121Smrg $opt_dry_run || $RM $removelist 35822836776bSmrg func_append removelist " $lockfile" 3583c2939121Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3584c2939121Smrg 35852836776bSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 35862836776bSmrg srcfile=$func_to_tool_file_result 3587c2939121Smrg func_quote_for_eval "$srcfile" 3588c2939121Smrg qsrcfile=$func_quote_for_eval_result 3589c76ae52dSmrg 3590c76ae52dSmrg # Only build a PIC object if we are building libtool libraries. 35918292847cSmrg if test yes = "$build_libtool_libs"; then 3592c76ae52dSmrg # Without this assignment, base_compile gets emptied. 3593c76ae52dSmrg fbsd_hideous_sh_bug=$base_compile 3594c76ae52dSmrg 35958292847cSmrg if test no != "$pic_mode"; then 3596c76ae52dSmrg command="$base_compile $qsrcfile $pic_flag" 3597c76ae52dSmrg else 3598c76ae52dSmrg # Don't build PIC code 3599c76ae52dSmrg command="$base_compile $qsrcfile" 3600c76ae52dSmrg fi 3601c76ae52dSmrg 3602c2939121Smrg func_mkdir_p "$xdir$objdir" 3603c76ae52dSmrg 3604c76ae52dSmrg if test -z "$output_obj"; then 3605c76ae52dSmrg # Place PIC objects in $objdir 36062836776bSmrg func_append command " -o $lobj" 3607c76ae52dSmrg fi 3608c76ae52dSmrg 3609c2939121Smrg func_show_eval_locale "$command" \ 3610c2939121Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3611c76ae52dSmrg 36128292847cSmrg if test warn = "$need_locks" && 3613c76ae52dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3614c2939121Smrg $ECHO "\ 3615c76ae52dSmrg*** ERROR, $lockfile contains: 3616c76ae52dSmrg`cat $lockfile 2>/dev/null` 3617c76ae52dSmrg 3618c76ae52dSmrgbut it should contain: 3619c76ae52dSmrg$srcfile 3620c76ae52dSmrg 3621c76ae52dSmrgThis indicates that another process is trying to use the same 3622c76ae52dSmrgtemporary object file, and libtool could not work around it because 36238292847cSmrgyour compiler does not support '-c' and '-o' together. If you 3624c76ae52dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3625c76ae52dSmrgavoid parallel builds (make -j) in this platform, or get a better 3626c76ae52dSmrgcompiler." 3627c76ae52dSmrg 3628c2939121Smrg $opt_dry_run || $RM $removelist 3629c76ae52dSmrg exit $EXIT_FAILURE 3630c76ae52dSmrg fi 3631c76ae52dSmrg 3632c76ae52dSmrg # Just move the object if needed, then go on to compile the next one 3633c76ae52dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3634c2939121Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3635c2939121Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3636c76ae52dSmrg fi 3637c76ae52dSmrg 3638c76ae52dSmrg # Allow error messages only from the first compilation. 36398292847cSmrg if test yes = "$suppress_opt"; then 3640c2939121Smrg suppress_output=' >/dev/null 2>&1' 3641c76ae52dSmrg fi 3642c76ae52dSmrg fi 3643c76ae52dSmrg 3644c76ae52dSmrg # Only build a position-dependent object if we build old libraries. 36458292847cSmrg if test yes = "$build_old_libs"; then 36468292847cSmrg if test yes != "$pic_mode"; then 3647c76ae52dSmrg # Don't build PIC code 3648c2939121Smrg command="$base_compile $qsrcfile$pie_flag" 3649c76ae52dSmrg else 3650c76ae52dSmrg command="$base_compile $qsrcfile $pic_flag" 3651c76ae52dSmrg fi 36528292847cSmrg if test yes = "$compiler_c_o"; then 36532836776bSmrg func_append command " -o $obj" 3654c76ae52dSmrg fi 3655c76ae52dSmrg 3656c76ae52dSmrg # Suppress compiler output if we already did a PIC compilation. 36572836776bSmrg func_append command "$suppress_output" 3658c2939121Smrg func_show_eval_locale "$command" \ 3659c2939121Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3660c76ae52dSmrg 36618292847cSmrg if test warn = "$need_locks" && 3662c76ae52dSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3663c2939121Smrg $ECHO "\ 3664c76ae52dSmrg*** ERROR, $lockfile contains: 3665c76ae52dSmrg`cat $lockfile 2>/dev/null` 3666c76ae52dSmrg 3667c76ae52dSmrgbut it should contain: 3668c76ae52dSmrg$srcfile 3669c76ae52dSmrg 3670c76ae52dSmrgThis indicates that another process is trying to use the same 3671c76ae52dSmrgtemporary object file, and libtool could not work around it because 36728292847cSmrgyour compiler does not support '-c' and '-o' together. If you 3673c76ae52dSmrgrepeat this compilation, it may succeed, by chance, but you had better 3674c76ae52dSmrgavoid parallel builds (make -j) in this platform, or get a better 3675c76ae52dSmrgcompiler." 3676c76ae52dSmrg 3677c2939121Smrg $opt_dry_run || $RM $removelist 3678c76ae52dSmrg exit $EXIT_FAILURE 3679c76ae52dSmrg fi 3680c76ae52dSmrg 3681c76ae52dSmrg # Just move the object if needed 3682c76ae52dSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3683c2939121Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3684c2939121Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3685c76ae52dSmrg fi 3686c76ae52dSmrg fi 3687c76ae52dSmrg 3688c2939121Smrg $opt_dry_run || { 3689c2939121Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3690c76ae52dSmrg 3691c2939121Smrg # Unlock the critical section if it was locked 36928292847cSmrg if test no != "$need_locks"; then 3693c2939121Smrg removelist=$lockfile 3694c2939121Smrg $RM "$lockfile" 3695c2939121Smrg fi 3696c2939121Smrg } 3697c76ae52dSmrg 3698c76ae52dSmrg exit $EXIT_SUCCESS 3699c2939121Smrg} 3700c76ae52dSmrg 3701c2939121Smrg$opt_help || { 37028292847cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3703c2939121Smrg} 3704c76ae52dSmrg 3705c2939121Smrgfunc_mode_help () 3706c2939121Smrg{ 3707c2939121Smrg # We need to display help for each of the modes. 37082836776bSmrg case $opt_mode in 3709c2939121Smrg "") 3710c2939121Smrg # Generic help is extracted from the usage comments 3711c2939121Smrg # at the start of this file. 3712c2939121Smrg func_help 3713c2939121Smrg ;; 3714c76ae52dSmrg 3715c2939121Smrg clean) 3716c2939121Smrg $ECHO \ 3717c2939121Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3718c76ae52dSmrg 3719c2939121SmrgRemove files from the build directory. 3720c76ae52dSmrg 3721c2939121SmrgRM is the name of the program to use to delete files associated with each FILE 37228292847cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3723c2939121Smrgto RM. 3724c76ae52dSmrg 3725c2939121SmrgIf FILE is a libtool library, object or program, all the files associated 3726c2939121Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3727c2939121Smrg ;; 3728c76ae52dSmrg 3729c2939121Smrg compile) 3730c2939121Smrg $ECHO \ 3731c2939121Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3732c76ae52dSmrg 3733c2939121SmrgCompile a source file into a libtool library object. 3734c76ae52dSmrg 3735c2939121SmrgThis mode accepts the following additional options: 3736c76ae52dSmrg 3737c2939121Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3738c2939121Smrg -no-suppress do not suppress compiler output for multiple passes 3739c2939121Smrg -prefer-pic try to build PIC objects only 3740c2939121Smrg -prefer-non-pic try to build non-PIC objects only 37418292847cSmrg -shared do not build a '.o' file suitable for static linking 37428292847cSmrg -static only build a '.o' file suitable for static linking 3743c2939121Smrg -Wc,FLAG pass FLAG directly to the compiler 3744c76ae52dSmrg 37458292847cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3746c2939121Smrgfrom the given SOURCEFILE. 3747c76ae52dSmrg 3748c2939121SmrgThe output file name is determined by removing the directory component from 37498292847cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 37508292847cSmrglibrary object suffix, '.lo'." 3751c2939121Smrg ;; 3752c76ae52dSmrg 3753c2939121Smrg execute) 3754c2939121Smrg $ECHO \ 3755c2939121Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3756c76ae52dSmrg 3757c2939121SmrgAutomatically set library path, then run a program. 3758c76ae52dSmrg 3759c2939121SmrgThis mode accepts the following additional options: 3760c76ae52dSmrg 3761c2939121Smrg -dlopen FILE add the directory containing FILE to the library path 3762c76ae52dSmrg 37638292847cSmrgThis mode sets the library path environment variable according to '-dlopen' 3764c2939121Smrgflags. 3765c76ae52dSmrg 3766c2939121SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3767c2939121Smrginto their corresponding uninstalled binary, and any of their required library 3768c2939121Smrgdirectories are added to the library path. 3769c76ae52dSmrg 3770c2939121SmrgThen, COMMAND is executed, with ARGS as arguments." 3771c2939121Smrg ;; 3772c76ae52dSmrg 3773c2939121Smrg finish) 3774c2939121Smrg $ECHO \ 3775c2939121Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3776c76ae52dSmrg 3777c2939121SmrgComplete the installation of libtool libraries. 3778c76ae52dSmrg 3779c2939121SmrgEach LIBDIR is a directory that contains libtool libraries. 3780c76ae52dSmrg 3781c2939121SmrgThe commands that this mode executes may require superuser privileges. Use 37828292847cSmrgthe '--dry-run' option if you just want to see what would be executed." 3783c2939121Smrg ;; 3784c76ae52dSmrg 3785c2939121Smrg install) 3786c2939121Smrg $ECHO \ 3787c2939121Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3788c76ae52dSmrg 3789c2939121SmrgInstall executables or libraries. 3790c76ae52dSmrg 3791c2939121SmrgINSTALL-COMMAND is the installation command. The first component should be 37928292847cSmrgeither the 'install' or 'cp' program. 3793c76ae52dSmrg 3794c2939121SmrgThe following components of INSTALL-COMMAND are treated specially: 3795c76ae52dSmrg 3796c2939121Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3797c76ae52dSmrg 3798c2939121SmrgThe rest of the components are interpreted as arguments to that command (only 3799c2939121SmrgBSD-compatible install options are recognized)." 3800c2939121Smrg ;; 3801c76ae52dSmrg 3802c2939121Smrg link) 3803c2939121Smrg $ECHO \ 3804c2939121Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3805c76ae52dSmrg 3806c2939121SmrgLink object files or libraries together to form another library, or to 3807c2939121Smrgcreate an executable program. 3808c76ae52dSmrg 3809c2939121SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3810c2939121Smrga program from several object files. 3811c76ae52dSmrg 3812c2939121SmrgThe following components of LINK-COMMAND are treated specially: 3813c76ae52dSmrg 3814c2939121Smrg -all-static do not do any dynamic linking at all 3815c2939121Smrg -avoid-version do not add a version suffix if possible 3816c2939121Smrg -bindir BINDIR specify path to binaries directory (for systems where 3817c2939121Smrg libraries must be found in the PATH setting at runtime) 38188292847cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3819c2939121Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3820c2939121Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3821c2939121Smrg -export-symbols SYMFILE 3822c2939121Smrg try to export only the symbols listed in SYMFILE 3823c2939121Smrg -export-symbols-regex REGEX 3824c2939121Smrg try to export only the symbols matching REGEX 3825c2939121Smrg -LLIBDIR search LIBDIR for required installed libraries 3826c2939121Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3827c2939121Smrg -module build a library that can dlopened 3828c2939121Smrg -no-fast-install disable the fast-install mode 3829c2939121Smrg -no-install link a not-installable executable 3830c2939121Smrg -no-undefined declare that a library does not refer to external symbols 3831c2939121Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 38328292847cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 38338292847cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3834c2939121Smrg -precious-files-regex REGEX 3835c2939121Smrg don't remove output files matching REGEX 3836c2939121Smrg -release RELEASE specify package release information 3837c2939121Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3838c2939121Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3839c2939121Smrg -shared only do dynamic linking of libtool libraries 3840c2939121Smrg -shrext SUFFIX override the standard shared library file extension 3841c2939121Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3842c2939121Smrg -static-libtool-libs 3843c2939121Smrg do not do any dynamic linking of libtool libraries 3844c2939121Smrg -version-info CURRENT[:REVISION[:AGE]] 3845c2939121Smrg specify library version info [each variable defaults to 0] 3846c2939121Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 3847c2939121Smrg -Wc,FLAG 3848c2939121Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3849c2939121Smrg -Wl,FLAG 3850c2939121Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3851c2939121Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3852c76ae52dSmrg 38538292847cSmrgAll other options (arguments beginning with '-') are ignored. 3854c76ae52dSmrg 38558292847cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3856c2939121Smrgtreated as uninstalled libtool libraries, other files are standard or library 3857c2939121Smrgobject files. 3858c76ae52dSmrg 38598292847cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 38608292847cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3861c2939121Smrgrequired, except when creating a convenience library. 3862c76ae52dSmrg 38638292847cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 38648292847cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 38650d590c07Smrg 38668292847cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3867c2939121Smrgis created, otherwise an executable program is created." 3868c2939121Smrg ;; 3869c76ae52dSmrg 3870c2939121Smrg uninstall) 3871c2939121Smrg $ECHO \ 3872c2939121Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3873c76ae52dSmrg 3874c2939121SmrgRemove libraries from an installation directory. 3875c76ae52dSmrg 3876c2939121SmrgRM is the name of the program to use to delete files associated with each FILE 38778292847cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3878c2939121Smrgto RM. 3879c76ae52dSmrg 3880c2939121SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3881c2939121SmrgOtherwise, only FILE itself is deleted using RM." 3882c2939121Smrg ;; 3883c76ae52dSmrg 3884c2939121Smrg *) 38858292847cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3886c2939121Smrg ;; 3887c2939121Smrg esac 3888c76ae52dSmrg 3889c2939121Smrg echo 38908292847cSmrg $ECHO "Try '$progname --help' for more information about other modes." 3891c2939121Smrg} 3892c76ae52dSmrg 3893c2939121Smrg# Now that we've collected a possible --mode arg, show help if necessary 3894c2939121Smrgif $opt_help; then 38958292847cSmrg if test : = "$opt_help"; then 3896c2939121Smrg func_mode_help 3897c2939121Smrg else 3898c2939121Smrg { 3899c2939121Smrg func_help noexit 39002836776bSmrg for opt_mode in compile link execute install finish uninstall clean; do 3901c2939121Smrg func_mode_help 3902c2939121Smrg done 39038292847cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3904c2939121Smrg { 3905c2939121Smrg func_help noexit 39062836776bSmrg for opt_mode in compile link execute install finish uninstall clean; do 3907c2939121Smrg echo 3908c2939121Smrg func_mode_help 3909c2939121Smrg done 3910c2939121Smrg } | 39118292847cSmrg $SED '1d 3912c2939121Smrg /^When reporting/,/^Report/{ 3913c2939121Smrg H 3914c2939121Smrg d 3915c2939121Smrg } 3916c2939121Smrg $x 3917c2939121Smrg /information about other modes/d 3918c2939121Smrg /more detailed .*MODE/d 3919c2939121Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3920c2939121Smrg fi 3921c2939121Smrg exit $? 3922c2939121Smrgfi 3923c76ae52dSmrg 3924c76ae52dSmrg 3925c2939121Smrg# func_mode_execute arg... 3926c2939121Smrgfunc_mode_execute () 3927c2939121Smrg{ 39288292847cSmrg $debug_cmd 39298292847cSmrg 3930c2939121Smrg # The first argument is the command name. 39318292847cSmrg cmd=$nonopt 3932c2939121Smrg test -z "$cmd" && \ 3933c2939121Smrg func_fatal_help "you must specify a COMMAND" 3934c76ae52dSmrg 3935c2939121Smrg # Handle -dlopen flags immediately. 39362836776bSmrg for file in $opt_dlopen; do 3937c2939121Smrg test -f "$file" \ 39388292847cSmrg || func_fatal_help "'$file' is not a file" 3939c76ae52dSmrg 3940c2939121Smrg dir= 3941c2939121Smrg case $file in 3942c2939121Smrg *.la) 39432836776bSmrg func_resolve_sysroot "$file" 39442836776bSmrg file=$func_resolve_sysroot_result 39452836776bSmrg 3946c2939121Smrg # Check to see that this really is a libtool archive. 3947c2939121Smrg func_lalib_unsafe_p "$file" \ 39488292847cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3949c76ae52dSmrg 3950c2939121Smrg # Read the libtool library. 3951c2939121Smrg dlname= 3952c2939121Smrg library_names= 3953c2939121Smrg func_source "$file" 3954c76ae52dSmrg 3955c2939121Smrg # Skip this library if it cannot be dlopened. 3956c2939121Smrg if test -z "$dlname"; then 3957c2939121Smrg # Warn if it was a shared library. 3958c2939121Smrg test -n "$library_names" && \ 39598292847cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3960c2939121Smrg continue 3961c2939121Smrg fi 3962c76ae52dSmrg 3963c2939121Smrg func_dirname "$file" "" "." 39648292847cSmrg dir=$func_dirname_result 3965c76ae52dSmrg 3966c2939121Smrg if test -f "$dir/$objdir/$dlname"; then 39672836776bSmrg func_append dir "/$objdir" 3968c2939121Smrg else 3969c2939121Smrg if test ! -f "$dir/$dlname"; then 39708292847cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3971c2939121Smrg fi 3972c2939121Smrg fi 3973c76ae52dSmrg ;; 3974c76ae52dSmrg 3975c2939121Smrg *.lo) 3976c2939121Smrg # Just add the directory containing the .lo file. 3977c2939121Smrg func_dirname "$file" "" "." 39788292847cSmrg dir=$func_dirname_result 3979c76ae52dSmrg ;; 3980c2939121Smrg 3981c2939121Smrg *) 39828292847cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3983c76ae52dSmrg continue 3984c76ae52dSmrg ;; 3985c2939121Smrg esac 3986c76ae52dSmrg 3987c2939121Smrg # Get the absolute pathname. 3988c2939121Smrg absdir=`cd "$dir" && pwd` 39898292847cSmrg test -n "$absdir" && dir=$absdir 3990c76ae52dSmrg 3991c2939121Smrg # Now add the directory to shlibpath_var. 3992c2939121Smrg if eval "test -z \"\$$shlibpath_var\""; then 3993c2939121Smrg eval "$shlibpath_var=\"\$dir\"" 3994c2939121Smrg else 3995c2939121Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3996c2939121Smrg fi 3997c2939121Smrg done 3998c76ae52dSmrg 3999c2939121Smrg # This variable tells wrapper scripts just to set shlibpath_var 4000c2939121Smrg # rather than running their programs. 40018292847cSmrg libtool_execute_magic=$magic 4002c76ae52dSmrg 4003c2939121Smrg # Check if any of the arguments is a wrapper script. 4004c2939121Smrg args= 4005c2939121Smrg for file 4006c2939121Smrg do 4007c2939121Smrg case $file in 4008c2939121Smrg -* | *.la | *.lo ) ;; 4009c2939121Smrg *) 4010c2939121Smrg # Do a test to see if this is really a libtool program. 4011c2939121Smrg if func_ltwrapper_script_p "$file"; then 4012c2939121Smrg func_source "$file" 4013c2939121Smrg # Transform arg to wrapped name. 40148292847cSmrg file=$progdir/$program 4015c2939121Smrg elif func_ltwrapper_executable_p "$file"; then 4016c2939121Smrg func_ltwrapper_scriptname "$file" 4017c2939121Smrg func_source "$func_ltwrapper_scriptname_result" 4018c2939121Smrg # Transform arg to wrapped name. 40198292847cSmrg file=$progdir/$program 4020c2939121Smrg fi 4021c76ae52dSmrg ;; 4022c2939121Smrg esac 4023c2939121Smrg # Quote arguments (to preserve shell metacharacters). 40242836776bSmrg func_append_quoted args "$file" 4025c2939121Smrg done 4026c76ae52dSmrg 40278292847cSmrg if $opt_dry_run; then 40288292847cSmrg # Display what would be done. 40298292847cSmrg if test -n "$shlibpath_var"; then 40308292847cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 40318292847cSmrg echo "export $shlibpath_var" 40328292847cSmrg fi 40338292847cSmrg $ECHO "$cmd$args" 40348292847cSmrg exit $EXIT_SUCCESS 40358292847cSmrg else 4036c2939121Smrg if test -n "$shlibpath_var"; then 4037c2939121Smrg # Export the shlibpath_var. 4038c2939121Smrg eval "export $shlibpath_var" 4039c2939121Smrg fi 4040c76ae52dSmrg 4041c2939121Smrg # Restore saved environment variables 4042c2939121Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4043c2939121Smrg do 4044c2939121Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4045c2939121Smrg $lt_var=\$save_$lt_var; export $lt_var 4046c2939121Smrg else 4047c2939121Smrg $lt_unset $lt_var 4048c2939121Smrg fi" 4049c2939121Smrg done 4050c76ae52dSmrg 4051c2939121Smrg # Now prepare to actually exec the command. 40528292847cSmrg exec_cmd=\$cmd$args 4053c2939121Smrg fi 4054c2939121Smrg} 4055c76ae52dSmrg 40568292847cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4057c76ae52dSmrg 4058c76ae52dSmrg 4059c2939121Smrg# func_mode_finish arg... 4060c2939121Smrgfunc_mode_finish () 4061c2939121Smrg{ 40628292847cSmrg $debug_cmd 40638292847cSmrg 40642836776bSmrg libs= 40652836776bSmrg libdirs= 4066c2939121Smrg admincmds= 4067c76ae52dSmrg 40682836776bSmrg for opt in "$nonopt" ${1+"$@"} 40692836776bSmrg do 40702836776bSmrg if test -d "$opt"; then 40712836776bSmrg func_append libdirs " $opt" 40722836776bSmrg 40732836776bSmrg elif test -f "$opt"; then 40742836776bSmrg if func_lalib_unsafe_p "$opt"; then 40752836776bSmrg func_append libs " $opt" 40762836776bSmrg else 40778292847cSmrg func_warning "'$opt' is not a valid libtool archive" 40782836776bSmrg fi 40792836776bSmrg 40802836776bSmrg else 40818292847cSmrg func_fatal_error "invalid argument '$opt'" 40822836776bSmrg fi 40832836776bSmrg done 40842836776bSmrg 40852836776bSmrg if test -n "$libs"; then 40862836776bSmrg if test -n "$lt_sysroot"; then 40872836776bSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 40882836776bSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 40892836776bSmrg else 40902836776bSmrg sysroot_cmd= 40912836776bSmrg fi 40922836776bSmrg 40932836776bSmrg # Remove sysroot references 40942836776bSmrg if $opt_dry_run; then 40952836776bSmrg for lib in $libs; do 40968292847cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 40972836776bSmrg done 40982836776bSmrg else 40992836776bSmrg tmpdir=`func_mktempdir` 41002836776bSmrg for lib in $libs; do 41018292847cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 41022836776bSmrg > $tmpdir/tmp-la 41032836776bSmrg mv -f $tmpdir/tmp-la $lib 41042836776bSmrg done 41052836776bSmrg ${RM}r "$tmpdir" 41062836776bSmrg fi 41072836776bSmrg fi 4108c76ae52dSmrg 41092836776bSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4110c2939121Smrg for libdir in $libdirs; do 4111c2939121Smrg if test -n "$finish_cmds"; then 4112c2939121Smrg # Do each command in the finish commands. 4113c2939121Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4114c2939121Smrg'"$cmd"'"' 4115c2939121Smrg fi 4116c2939121Smrg if test -n "$finish_eval"; then 4117c2939121Smrg # Do the single finish_eval. 4118c2939121Smrg eval cmds=\"$finish_eval\" 41192836776bSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4120c2939121Smrg $cmds" 4121c2939121Smrg fi 4122c2939121Smrg done 4123c2939121Smrg fi 4124c76ae52dSmrg 4125c2939121Smrg # Exit here if they wanted silent mode. 41268292847cSmrg $opt_quiet && exit $EXIT_SUCCESS 4127c76ae52dSmrg 41282836776bSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 41292836776bSmrg echo "----------------------------------------------------------------------" 41302836776bSmrg echo "Libraries have been installed in:" 41312836776bSmrg for libdir in $libdirs; do 41322836776bSmrg $ECHO " $libdir" 41332836776bSmrg done 41342836776bSmrg echo 41352836776bSmrg echo "If you ever happen to want to link against installed libraries" 41362836776bSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 41378292847cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 41382836776bSmrg echo "flag during linking and do at least one of the following:" 41392836776bSmrg if test -n "$shlibpath_var"; then 41408292847cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 41412836776bSmrg echo " during execution" 41422836776bSmrg fi 41432836776bSmrg if test -n "$runpath_var"; then 41448292847cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 41452836776bSmrg echo " during linking" 41462836776bSmrg fi 41472836776bSmrg if test -n "$hardcode_libdir_flag_spec"; then 41482836776bSmrg libdir=LIBDIR 41492836776bSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4150c76ae52dSmrg 41518292847cSmrg $ECHO " - use the '$flag' linker flag" 41522836776bSmrg fi 41532836776bSmrg if test -n "$admincmds"; then 41542836776bSmrg $ECHO " - have your system administrator run these commands:$admincmds" 41552836776bSmrg fi 41562836776bSmrg if test -f /etc/ld.so.conf; then 41578292847cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 41582836776bSmrg fi 41592836776bSmrg echo 4160c76ae52dSmrg 41612836776bSmrg echo "See any operating system documentation about shared libraries for" 41622836776bSmrg case $host in 41632836776bSmrg solaris2.[6789]|solaris2.1[0-9]) 41642836776bSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 41652836776bSmrg echo "pages." 41662836776bSmrg ;; 41672836776bSmrg *) 41682836776bSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 41692836776bSmrg ;; 41702836776bSmrg esac 41712836776bSmrg echo "----------------------------------------------------------------------" 41722836776bSmrg fi 4173c2939121Smrg exit $EXIT_SUCCESS 4174c2939121Smrg} 4175c76ae52dSmrg 41768292847cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4177c76ae52dSmrg 4178c76ae52dSmrg 4179c2939121Smrg# func_mode_install arg... 4180c2939121Smrgfunc_mode_install () 4181c2939121Smrg{ 41828292847cSmrg $debug_cmd 41838292847cSmrg 4184c2939121Smrg # There may be an optional sh(1) argument at the beginning of 4185c2939121Smrg # install_prog (especially on Windows NT). 41868292847cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4187c2939121Smrg # Allow the use of GNU shtool's install command. 41888292847cSmrg case $nonopt in *shtool*) :;; *) false;; esac 41898292847cSmrg then 4190c2939121Smrg # Aesthetically quote it. 4191c2939121Smrg func_quote_for_eval "$nonopt" 4192c2939121Smrg install_prog="$func_quote_for_eval_result " 4193c2939121Smrg arg=$1 4194c2939121Smrg shift 4195c2939121Smrg else 4196c2939121Smrg install_prog= 4197c2939121Smrg arg=$nonopt 4198c2939121Smrg fi 4199c76ae52dSmrg 4200c2939121Smrg # The real first argument should be the name of the installation program. 4201c2939121Smrg # Aesthetically quote it. 4202c2939121Smrg func_quote_for_eval "$arg" 42032836776bSmrg func_append install_prog "$func_quote_for_eval_result" 4204c2939121Smrg install_shared_prog=$install_prog 4205c2939121Smrg case " $install_prog " in 4206c2939121Smrg *[\\\ /]cp\ *) install_cp=: ;; 4207c2939121Smrg *) install_cp=false ;; 4208c2939121Smrg esac 4209c76ae52dSmrg 4210c2939121Smrg # We need to accept at least all the BSD install flags. 4211c2939121Smrg dest= 4212c2939121Smrg files= 4213c2939121Smrg opts= 4214c2939121Smrg prev= 4215c2939121Smrg install_type= 42168292847cSmrg isdir=false 4217c2939121Smrg stripme= 4218c2939121Smrg no_mode=: 4219c2939121Smrg for arg 4220c2939121Smrg do 4221c2939121Smrg arg2= 4222c2939121Smrg if test -n "$dest"; then 42232836776bSmrg func_append files " $dest" 4224c2939121Smrg dest=$arg 4225c76ae52dSmrg continue 4226c2939121Smrg fi 4227c76ae52dSmrg 4228c2939121Smrg case $arg in 42298292847cSmrg -d) isdir=: ;; 4230c2939121Smrg -f) 4231c2939121Smrg if $install_cp; then :; else 4232c2939121Smrg prev=$arg 4233c76ae52dSmrg fi 4234c2939121Smrg ;; 4235c2939121Smrg -g | -m | -o) 4236c2939121Smrg prev=$arg 4237c2939121Smrg ;; 4238c2939121Smrg -s) 4239c2939121Smrg stripme=" -s" 4240c76ae52dSmrg continue 4241c76ae52dSmrg ;; 4242c2939121Smrg -*) 4243c2939121Smrg ;; 4244c76ae52dSmrg *) 4245c2939121Smrg # If the previous option needed an argument, then skip it. 4246c2939121Smrg if test -n "$prev"; then 42478292847cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4248c2939121Smrg arg2=$install_override_mode 4249c2939121Smrg no_mode=false 4250c2939121Smrg fi 4251c2939121Smrg prev= 4252c2939121Smrg else 4253c2939121Smrg dest=$arg 4254c2939121Smrg continue 4255c2939121Smrg fi 4256c76ae52dSmrg ;; 4257c2939121Smrg esac 4258c76ae52dSmrg 4259c2939121Smrg # Aesthetically quote the argument. 4260c2939121Smrg func_quote_for_eval "$arg" 42612836776bSmrg func_append install_prog " $func_quote_for_eval_result" 4262c2939121Smrg if test -n "$arg2"; then 4263c2939121Smrg func_quote_for_eval "$arg2" 4264c76ae52dSmrg fi 42652836776bSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4266c2939121Smrg done 4267c76ae52dSmrg 4268c2939121Smrg test -z "$install_prog" && \ 4269c2939121Smrg func_fatal_help "you must specify an install program" 4270c76ae52dSmrg 4271c2939121Smrg test -n "$prev" && \ 42728292847cSmrg func_fatal_help "the '$prev' option requires an argument" 4273c76ae52dSmrg 4274c2939121Smrg if test -n "$install_override_mode" && $no_mode; then 4275c2939121Smrg if $install_cp; then :; else 4276c2939121Smrg func_quote_for_eval "$install_override_mode" 42772836776bSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4278c2939121Smrg fi 4279c76ae52dSmrg fi 4280c76ae52dSmrg 4281c2939121Smrg if test -z "$files"; then 4282c2939121Smrg if test -z "$dest"; then 4283c2939121Smrg func_fatal_help "no file or destination specified" 4284c2939121Smrg else 4285c2939121Smrg func_fatal_help "you must specify a destination" 4286c76ae52dSmrg fi 4287c76ae52dSmrg fi 4288c76ae52dSmrg 4289c2939121Smrg # Strip any trailing slash from the destination. 4290c2939121Smrg func_stripname '' '/' "$dest" 4291c2939121Smrg dest=$func_stripname_result 4292c76ae52dSmrg 4293c2939121Smrg # Check to see that the destination is a directory. 42948292847cSmrg test -d "$dest" && isdir=: 42958292847cSmrg if $isdir; then 42968292847cSmrg destdir=$dest 4297c2939121Smrg destname= 4298c2939121Smrg else 4299c2939121Smrg func_dirname_and_basename "$dest" "" "." 43008292847cSmrg destdir=$func_dirname_result 43018292847cSmrg destname=$func_basename_result 4302c2939121Smrg 4303c2939121Smrg # Not a directory, so check to see that there is only one file specified. 4304c2939121Smrg set dummy $files; shift 4305c2939121Smrg test "$#" -gt 1 && \ 43068292847cSmrg func_fatal_help "'$dest' is not a directory" 4307c2939121Smrg fi 4308c2939121Smrg case $destdir in 4309c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4310c76ae52dSmrg *) 4311c2939121Smrg for file in $files; do 4312c2939121Smrg case $file in 4313c2939121Smrg *.lo) ;; 4314c2939121Smrg *) 43158292847cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4316c2939121Smrg ;; 4317c2939121Smrg esac 4318c2939121Smrg done 4319c76ae52dSmrg ;; 4320c76ae52dSmrg esac 4321c76ae52dSmrg 4322c2939121Smrg # This variable tells wrapper scripts just to set variables rather 4323c2939121Smrg # than running their programs. 43248292847cSmrg libtool_install_magic=$magic 4325c76ae52dSmrg 4326c2939121Smrg staticlibs= 4327c2939121Smrg future_libdirs= 4328c2939121Smrg current_libdirs= 4329c2939121Smrg for file in $files; do 4330c76ae52dSmrg 4331c2939121Smrg # Do each installation. 4332c2939121Smrg case $file in 4333c2939121Smrg *.$libext) 4334c2939121Smrg # Do the static libraries later. 43352836776bSmrg func_append staticlibs " $file" 4336c2939121Smrg ;; 4337c2939121Smrg 4338c2939121Smrg *.la) 43392836776bSmrg func_resolve_sysroot "$file" 43402836776bSmrg file=$func_resolve_sysroot_result 43412836776bSmrg 4342c2939121Smrg # Check to see that this really is a libtool archive. 4343c2939121Smrg func_lalib_unsafe_p "$file" \ 43448292847cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4345c2939121Smrg 4346c2939121Smrg library_names= 4347c2939121Smrg old_library= 4348c2939121Smrg relink_command= 4349c2939121Smrg func_source "$file" 4350c2939121Smrg 4351c2939121Smrg # Add the libdir to current_libdirs if it is the destination. 4352c2939121Smrg if test "X$destdir" = "X$libdir"; then 4353c2939121Smrg case "$current_libdirs " in 4354c2939121Smrg *" $libdir "*) ;; 43552836776bSmrg *) func_append current_libdirs " $libdir" ;; 4356c76ae52dSmrg esac 4357c2939121Smrg else 4358c2939121Smrg # Note the libdir as a future libdir. 4359c2939121Smrg case "$future_libdirs " in 4360c2939121Smrg *" $libdir "*) ;; 43612836776bSmrg *) func_append future_libdirs " $libdir" ;; 4362c2939121Smrg esac 4363c2939121Smrg fi 4364c76ae52dSmrg 4365c2939121Smrg func_dirname "$file" "/" "" 43668292847cSmrg dir=$func_dirname_result 43672836776bSmrg func_append dir "$objdir" 4368c2939121Smrg 4369c2939121Smrg if test -n "$relink_command"; then 4370c2939121Smrg # Determine the prefix the user has applied to our future dir. 4371c2939121Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4372c2939121Smrg 4373c2939121Smrg # Don't allow the user to place us outside of our expected 4374c2939121Smrg # location b/c this prevents finding dependent libraries that 4375c2939121Smrg # are installed to the same prefix. 4376c2939121Smrg # At present, this check doesn't affect windows .dll's that 4377c2939121Smrg # are installed into $libdir/../bin (currently, that works fine) 4378c2939121Smrg # but it's something to keep an eye on. 4379c2939121Smrg test "$inst_prefix_dir" = "$destdir" && \ 43808292847cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4381c2939121Smrg 4382c2939121Smrg if test -n "$inst_prefix_dir"; then 4383c2939121Smrg # Stick the inst_prefix_dir data into the link command. 4384c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4385c2939121Smrg else 4386c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4387c2939121Smrg fi 4388c2939121Smrg 43898292847cSmrg func_warning "relinking '$file'" 4390c2939121Smrg func_show_eval "$relink_command" \ 43918292847cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4392c2939121Smrg fi 4393c2939121Smrg 4394c2939121Smrg # See the names of the shared library. 4395c2939121Smrg set dummy $library_names; shift 4396c2939121Smrg if test -n "$1"; then 43978292847cSmrg realname=$1 4398c2939121Smrg shift 4399c2939121Smrg 44008292847cSmrg srcname=$realname 44018292847cSmrg test -n "$relink_command" && srcname=${realname}T 4402c2939121Smrg 4403c2939121Smrg # Install the shared library and build the symlinks. 4404c2939121Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4405c2939121Smrg 'exit $?' 44068292847cSmrg tstripme=$stripme 4407c2939121Smrg case $host_os in 4408c2939121Smrg cygwin* | mingw* | pw32* | cegcc*) 4409c2939121Smrg case $realname in 4410c2939121Smrg *.dll.a) 44118292847cSmrg tstripme= 44128292847cSmrg ;; 44138292847cSmrg esac 44148292847cSmrg ;; 44158292847cSmrg os2*) 44168292847cSmrg case $realname in 44178292847cSmrg *_dll.a) 44188292847cSmrg tstripme= 4419c2939121Smrg ;; 4420c2939121Smrg esac 4421c76ae52dSmrg ;; 4422c76ae52dSmrg esac 4423c2939121Smrg if test -n "$tstripme" && test -n "$striplib"; then 4424c2939121Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4425c2939121Smrg fi 4426c2939121Smrg 4427c2939121Smrg if test "$#" -gt 0; then 4428c2939121Smrg # Delete the old symlinks, and create new ones. 44298292847cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4430c2939121Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4431c2939121Smrg # so we also need to try rm && ln -s. 4432c2939121Smrg for linkname 4433c2939121Smrg do 4434c2939121Smrg test "$linkname" != "$realname" \ 4435c2939121Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4436c2939121Smrg done 4437c2939121Smrg fi 4438c2939121Smrg 4439c2939121Smrg # Do each command in the postinstall commands. 44408292847cSmrg lib=$destdir/$realname 4441c2939121Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4442c2939121Smrg fi 4443c2939121Smrg 4444c2939121Smrg # Install the pseudo-library for information purposes. 4445c2939121Smrg func_basename "$file" 44468292847cSmrg name=$func_basename_result 44478292847cSmrg instname=$dir/${name}i 4448c2939121Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4449c2939121Smrg 4450c2939121Smrg # Maybe install the static library, too. 44512836776bSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4452c76ae52dSmrg ;; 4453c2939121Smrg 4454c2939121Smrg *.lo) 4455c2939121Smrg # Install (i.e. copy) a libtool object. 4456c2939121Smrg 4457c2939121Smrg # Figure out destination file name, if it wasn't already specified. 4458c2939121Smrg if test -n "$destname"; then 44598292847cSmrg destfile=$destdir/$destname 4460c2939121Smrg else 4461c2939121Smrg func_basename "$file" 44628292847cSmrg destfile=$func_basename_result 44638292847cSmrg destfile=$destdir/$destfile 4464c2939121Smrg fi 4465c2939121Smrg 4466c2939121Smrg # Deduce the name of the destination old-style object file. 4467c2939121Smrg case $destfile in 4468c2939121Smrg *.lo) 4469c2939121Smrg func_lo2o "$destfile" 4470c2939121Smrg staticdest=$func_lo2o_result 4471c76ae52dSmrg ;; 4472c2939121Smrg *.$objext) 44738292847cSmrg staticdest=$destfile 4474c2939121Smrg destfile= 4475c76ae52dSmrg ;; 4476c2939121Smrg *) 44778292847cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4478c76ae52dSmrg ;; 4479c2939121Smrg esac 4480c2939121Smrg 4481c2939121Smrg # Install the libtool object if requested. 4482c2939121Smrg test -n "$destfile" && \ 4483c2939121Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4484c2939121Smrg 4485c2939121Smrg # Install the old object if enabled. 44868292847cSmrg if test yes = "$build_old_libs"; then 4487c2939121Smrg # Deduce the name of the old-style object file. 4488c2939121Smrg func_lo2o "$file" 4489c2939121Smrg staticobj=$func_lo2o_result 4490c2939121Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4491c76ae52dSmrg fi 4492c2939121Smrg exit $EXIT_SUCCESS 4493c2939121Smrg ;; 4494c76ae52dSmrg 4495c2939121Smrg *) 4496c2939121Smrg # Figure out destination file name, if it wasn't already specified. 4497c2939121Smrg if test -n "$destname"; then 44988292847cSmrg destfile=$destdir/$destname 4499c76ae52dSmrg else 4500c2939121Smrg func_basename "$file" 45018292847cSmrg destfile=$func_basename_result 45028292847cSmrg destfile=$destdir/$destfile 4503c76ae52dSmrg fi 4504c76ae52dSmrg 4505c2939121Smrg # If the file is missing, and there is a .exe on the end, strip it 4506c2939121Smrg # because it is most likely a libtool script we actually want to 4507c2939121Smrg # install 45088292847cSmrg stripped_ext= 4509c2939121Smrg case $file in 4510c2939121Smrg *.exe) 4511c2939121Smrg if test ! -f "$file"; then 4512c2939121Smrg func_stripname '' '.exe' "$file" 4513c2939121Smrg file=$func_stripname_result 45148292847cSmrg stripped_ext=.exe 4515c2939121Smrg fi 4516c2939121Smrg ;; 4517c2939121Smrg esac 4518c76ae52dSmrg 4519c2939121Smrg # Do a test to see if this is really a libtool program. 4520c2939121Smrg case $host in 4521c2939121Smrg *cygwin* | *mingw*) 4522c2939121Smrg if func_ltwrapper_executable_p "$file"; then 4523c2939121Smrg func_ltwrapper_scriptname "$file" 4524c2939121Smrg wrapper=$func_ltwrapper_scriptname_result 4525c2939121Smrg else 4526c2939121Smrg func_stripname '' '.exe' "$file" 4527c2939121Smrg wrapper=$func_stripname_result 4528c2939121Smrg fi 4529c2939121Smrg ;; 4530c2939121Smrg *) 4531c2939121Smrg wrapper=$file 4532c2939121Smrg ;; 4533c2939121Smrg esac 4534c2939121Smrg if func_ltwrapper_script_p "$wrapper"; then 4535c2939121Smrg notinst_deplibs= 4536c2939121Smrg relink_command= 4537c76ae52dSmrg 4538c2939121Smrg func_source "$wrapper" 4539c76ae52dSmrg 4540c2939121Smrg # Check the variables that should have been set. 4541c2939121Smrg test -z "$generated_by_libtool_version" && \ 45428292847cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4543c76ae52dSmrg 45448292847cSmrg finalize=: 4545c2939121Smrg for lib in $notinst_deplibs; do 4546c2939121Smrg # Check to see that each library is installed. 4547c2939121Smrg libdir= 4548c2939121Smrg if test -f "$lib"; then 4549c2939121Smrg func_source "$lib" 4550c76ae52dSmrg fi 45518292847cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4552c2939121Smrg if test -n "$libdir" && test ! -f "$libfile"; then 45538292847cSmrg func_warning "'$lib' has not been installed in '$libdir'" 45548292847cSmrg finalize=false 4555c2939121Smrg fi 4556c2939121Smrg done 4557c76ae52dSmrg 4558c2939121Smrg relink_command= 4559c2939121Smrg func_source "$wrapper" 4560c76ae52dSmrg 4561c2939121Smrg outputname= 45628292847cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4563c2939121Smrg $opt_dry_run || { 45648292847cSmrg if $finalize; then 4565c2939121Smrg tmpdir=`func_mktempdir` 4566c2939121Smrg func_basename "$file$stripped_ext" 45678292847cSmrg file=$func_basename_result 45688292847cSmrg outputname=$tmpdir/$file 4569c2939121Smrg # Replace the output file specification. 4570c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4571c2939121Smrg 45728292847cSmrg $opt_quiet || { 4573c2939121Smrg func_quote_for_expand "$relink_command" 4574c2939121Smrg eval "func_echo $func_quote_for_expand_result" 4575c2939121Smrg } 4576c2939121Smrg if eval "$relink_command"; then : 4577c2939121Smrg else 45788292847cSmrg func_error "error: relink '$file' with the above command before installing it" 4579c2939121Smrg $opt_dry_run || ${RM}r "$tmpdir" 4580c2939121Smrg continue 4581c2939121Smrg fi 45828292847cSmrg file=$outputname 4583c2939121Smrg else 45848292847cSmrg func_warning "cannot relink '$file'" 4585c2939121Smrg fi 4586c2939121Smrg } 4587c76ae52dSmrg else 4588c2939121Smrg # Install the binary that we compiled earlier. 4589c2939121Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4590c76ae52dSmrg fi 4591c2939121Smrg fi 4592c76ae52dSmrg 4593c2939121Smrg # remove .exe since cygwin /usr/bin/install will append another 4594c2939121Smrg # one anyway 4595c2939121Smrg case $install_prog,$host in 4596c2939121Smrg */usr/bin/install*,*cygwin*) 4597c2939121Smrg case $file:$destfile in 4598c2939121Smrg *.exe:*.exe) 4599c2939121Smrg # this is ok 4600c2939121Smrg ;; 4601c2939121Smrg *.exe:*) 4602c2939121Smrg destfile=$destfile.exe 4603c2939121Smrg ;; 4604c2939121Smrg *:*.exe) 4605c2939121Smrg func_stripname '' '.exe' "$destfile" 4606c2939121Smrg destfile=$func_stripname_result 4607c2939121Smrg ;; 4608c2939121Smrg esac 4609c76ae52dSmrg ;; 4610c76ae52dSmrg esac 4611c2939121Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4612c2939121Smrg $opt_dry_run || if test -n "$outputname"; then 4613c2939121Smrg ${RM}r "$tmpdir" 4614c2939121Smrg fi 4615c2939121Smrg ;; 4616c2939121Smrg esac 4617c2939121Smrg done 4618c76ae52dSmrg 4619c2939121Smrg for file in $staticlibs; do 4620c2939121Smrg func_basename "$file" 46218292847cSmrg name=$func_basename_result 4622c2939121Smrg 4623c2939121Smrg # Set up the ranlib parameters. 46248292847cSmrg oldlib=$destdir/$name 46252836776bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 46262836776bSmrg tool_oldlib=$func_to_tool_file_result 4627c2939121Smrg 4628c2939121Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4629c2939121Smrg 4630c2939121Smrg if test -n "$stripme" && test -n "$old_striplib"; then 46312836776bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4632c2939121Smrg fi 4633c2939121Smrg 4634c2939121Smrg # Do each command in the postinstall commands. 4635c2939121Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4636c2939121Smrg done 4637c2939121Smrg 4638c2939121Smrg test -n "$future_libdirs" && \ 46398292847cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4640c2939121Smrg 4641c2939121Smrg if test -n "$current_libdirs"; then 4642c2939121Smrg # Maybe just do a dry run. 4643c2939121Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 46448292847cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4645c2939121Smrg else 4646c2939121Smrg exit $EXIT_SUCCESS 4647c2939121Smrg fi 4648c2939121Smrg} 4649c2939121Smrg 46508292847cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4651c2939121Smrg 4652c2939121Smrg 4653c2939121Smrg# func_generate_dlsyms outputname originator pic_p 4654c2939121Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4655c2939121Smrg# a dlpreopen symbol table. 4656c2939121Smrgfunc_generate_dlsyms () 4657c2939121Smrg{ 46588292847cSmrg $debug_cmd 46598292847cSmrg 46608292847cSmrg my_outputname=$1 46618292847cSmrg my_originator=$2 46628292847cSmrg my_pic_p=${3-false} 46638292847cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4664c2939121Smrg my_dlsyms= 4665c2939121Smrg 46668292847cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4667c2939121Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 46688292847cSmrg my_dlsyms=${my_outputname}S.c 4669c2939121Smrg else 4670c2939121Smrg func_error "not configured to extract global symbols from dlpreopened files" 4671c2939121Smrg fi 4672c2939121Smrg fi 4673c2939121Smrg 4674c2939121Smrg if test -n "$my_dlsyms"; then 4675c2939121Smrg case $my_dlsyms in 4676c2939121Smrg "") ;; 4677c2939121Smrg *.c) 4678c2939121Smrg # Discover the nlist of each of the dlfiles. 46798292847cSmrg nlist=$output_objdir/$my_outputname.nm 4680c2939121Smrg 4681c2939121Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4682c2939121Smrg 4683c2939121Smrg # Parse the name list into a source file. 4684c2939121Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4685c2939121Smrg 4686c2939121Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 46878292847cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 46888292847cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4689c2939121Smrg 4690c2939121Smrg#ifdef __cplusplus 4691c2939121Smrgextern \"C\" { 4692c2939121Smrg#endif 4693c2939121Smrg 46948292847cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4695c2939121Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4696c2939121Smrg#endif 4697c2939121Smrg 46982836776bSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 46998292847cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 47008292847cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 47012836776bSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 47022836776bSmrg# define LT_DLSYM_CONST 47038292847cSmrg#elif defined __osf__ 47042836776bSmrg/* This system does not cope well with relocations in const data. */ 47052836776bSmrg# define LT_DLSYM_CONST 47062836776bSmrg#else 47072836776bSmrg# define LT_DLSYM_CONST const 47082836776bSmrg#endif 47092836776bSmrg 47108292847cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 47118292847cSmrg 4712c2939121Smrg/* External symbol declarations for the compiler. */\ 4713c2939121Smrg" 4714c2939121Smrg 47158292847cSmrg if test yes = "$dlself"; then 47168292847cSmrg func_verbose "generating symbol list for '$output'" 4717c2939121Smrg 4718c2939121Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4719c2939121Smrg 4720c2939121Smrg # Add our own program objects to the symbol list. 4721c2939121Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4722c2939121Smrg for progfile in $progfiles; do 47232836776bSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 47248292847cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 47252836776bSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4726c2939121Smrg done 4727c2939121Smrg 4728c2939121Smrg if test -n "$exclude_expsyms"; then 4729c2939121Smrg $opt_dry_run || { 4730c2939121Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4731c2939121Smrg eval '$MV "$nlist"T "$nlist"' 4732c2939121Smrg } 4733c76ae52dSmrg fi 4734c2939121Smrg 4735c2939121Smrg if test -n "$export_symbols_regex"; then 4736c2939121Smrg $opt_dry_run || { 4737c2939121Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4738c2939121Smrg eval '$MV "$nlist"T "$nlist"' 4739c2939121Smrg } 4740c2939121Smrg fi 4741c2939121Smrg 4742c2939121Smrg # Prepare the list of exported symbols 4743c2939121Smrg if test -z "$export_symbols"; then 47448292847cSmrg export_symbols=$output_objdir/$outputname.exp 4745c2939121Smrg $opt_dry_run || { 4746c2939121Smrg $RM $export_symbols 47478292847cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4748c2939121Smrg case $host in 4749c2939121Smrg *cygwin* | *mingw* | *cegcc* ) 4750c2939121Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4751c2939121Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4752c2939121Smrg ;; 4753c2939121Smrg esac 4754c2939121Smrg } 4755c76ae52dSmrg else 4756c2939121Smrg $opt_dry_run || { 47578292847cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4758c2939121Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4759c2939121Smrg eval '$MV "$nlist"T "$nlist"' 4760c2939121Smrg case $host in 4761c2939121Smrg *cygwin* | *mingw* | *cegcc* ) 4762c2939121Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4763c2939121Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4764c2939121Smrg ;; 4765c2939121Smrg esac 4766c2939121Smrg } 4767c76ae52dSmrg fi 4768c2939121Smrg fi 4769c76ae52dSmrg 4770c2939121Smrg for dlprefile in $dlprefiles; do 47718292847cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4772c2939121Smrg func_basename "$dlprefile" 47738292847cSmrg name=$func_basename_result 47742836776bSmrg case $host in 47752836776bSmrg *cygwin* | *mingw* | *cegcc* ) 47762836776bSmrg # if an import library, we need to obtain dlname 47772836776bSmrg if func_win32_import_lib_p "$dlprefile"; then 47782836776bSmrg func_tr_sh "$dlprefile" 47792836776bSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 47808292847cSmrg dlprefile_dlbasename= 47812836776bSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 47822836776bSmrg # Use subshell, to avoid clobbering current variable values 47832836776bSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 47848292847cSmrg if test -n "$dlprefile_dlname"; then 47852836776bSmrg func_basename "$dlprefile_dlname" 47868292847cSmrg dlprefile_dlbasename=$func_basename_result 47872836776bSmrg else 47882836776bSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 47892836776bSmrg $sharedlib_from_linklib_cmd "$dlprefile" 47902836776bSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 47912836776bSmrg fi 47922836776bSmrg fi 47932836776bSmrg $opt_dry_run || { 47948292847cSmrg if test -n "$dlprefile_dlbasename"; then 47952836776bSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 47962836776bSmrg else 47972836776bSmrg func_warning "Could not compute DLL name from $name" 47982836776bSmrg eval '$ECHO ": $name " >> "$nlist"' 47992836776bSmrg fi 48002836776bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 48012836776bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 48022836776bSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 48032836776bSmrg } 48042836776bSmrg else # not an import lib 48052836776bSmrg $opt_dry_run || { 48062836776bSmrg eval '$ECHO ": $name " >> "$nlist"' 48072836776bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 48082836776bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 48092836776bSmrg } 48102836776bSmrg fi 48112836776bSmrg ;; 48122836776bSmrg *) 48132836776bSmrg $opt_dry_run || { 48142836776bSmrg eval '$ECHO ": $name " >> "$nlist"' 48152836776bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 48162836776bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 48172836776bSmrg } 48182836776bSmrg ;; 48192836776bSmrg esac 4820c2939121Smrg done 4821c2939121Smrg 4822c2939121Smrg $opt_dry_run || { 4823c2939121Smrg # Make sure we have at least an empty file. 4824c2939121Smrg test -f "$nlist" || : > "$nlist" 4825c2939121Smrg 4826c2939121Smrg if test -n "$exclude_expsyms"; then 4827c2939121Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4828c2939121Smrg $MV "$nlist"T "$nlist" 4829c76ae52dSmrg fi 4830c2939121Smrg 4831c2939121Smrg # Try sorting and uniquifying the output. 4832c2939121Smrg if $GREP -v "^: " < "$nlist" | 4833c2939121Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4834c2939121Smrg sort -k 3 4835c2939121Smrg else 4836c2939121Smrg sort +2 4837c2939121Smrg fi | 4838c2939121Smrg uniq > "$nlist"S; then 4839c2939121Smrg : 4840c76ae52dSmrg else 4841c2939121Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4842c76ae52dSmrg fi 4843c76ae52dSmrg 4844c2939121Smrg if test -f "$nlist"S; then 4845c2939121Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4846c76ae52dSmrg else 4847c2939121Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4848c76ae52dSmrg fi 4849c76ae52dSmrg 48508292847cSmrg func_show_eval '$RM "${nlist}I"' 48518292847cSmrg if test -n "$global_symbol_to_import"; then 48528292847cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 48538292847cSmrg fi 48548292847cSmrg 4855c2939121Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4856c76ae52dSmrg 4857c2939121Smrg/* The mapping between symbol names and symbols. */ 4858c2939121Smrgtypedef struct { 4859c2939121Smrg const char *name; 4860c2939121Smrg void *address; 4861c2939121Smrg} lt_dlsymlist; 48622836776bSmrgextern LT_DLSYM_CONST lt_dlsymlist 48638292847cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 48648292847cSmrg" 48658292847cSmrg 48668292847cSmrg if test -s "$nlist"I; then 48678292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48688292847cSmrgstatic void lt_syminit(void) 48698292847cSmrg{ 48708292847cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 48718292847cSmrg for (; symbol->name; ++symbol) 48728292847cSmrg {" 48738292847cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 48748292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48758292847cSmrg } 48768292847cSmrg}" 48778292847cSmrg fi 48788292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48792836776bSmrgLT_DLSYM_CONST lt_dlsymlist 4880c2939121Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 48818292847cSmrg{ {\"$my_originator\", (void *) 0}," 48828292847cSmrg 48838292847cSmrg if test -s "$nlist"I; then 48848292847cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48858292847cSmrg {\"@INIT@\", (void *) <_syminit}," 48868292847cSmrg fi 4887c76ae52dSmrg 4888c2939121Smrg case $need_lib_prefix in 4889c2939121Smrg no) 4890c2939121Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4891c2939121Smrg ;; 4892c2939121Smrg *) 4893c2939121Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4894c2939121Smrg ;; 4895c2939121Smrg esac 4896c2939121Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4897c2939121Smrg {0, (void *) 0} 4898c2939121Smrg}; 4899c76ae52dSmrg 4900c2939121Smrg/* This works around a problem in FreeBSD linker */ 4901c2939121Smrg#ifdef FREEBSD_WORKAROUND 4902c2939121Smrgstatic const void *lt_preloaded_setup() { 4903c2939121Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4904c2939121Smrg} 4905c2939121Smrg#endif 4906c76ae52dSmrg 4907c2939121Smrg#ifdef __cplusplus 4908c2939121Smrg} 4909c2939121Smrg#endif\ 4910c2939121Smrg" 4911c2939121Smrg } # !$opt_dry_run 4912c76ae52dSmrg 4913c2939121Smrg pic_flag_for_symtable= 4914c2939121Smrg case "$compile_command " in 4915c2939121Smrg *" -static "*) ;; 4916c2939121Smrg *) 4917c2939121Smrg case $host in 4918c2939121Smrg # compiling the symbol table file with pic_flag works around 4919c2939121Smrg # a FreeBSD bug that causes programs to crash when -lm is 4920c2939121Smrg # linked before any other PIC object. But we must not use 4921c2939121Smrg # pic_flag when linking with -static. The problem exists in 4922c2939121Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 49232836776bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4924c2939121Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4925c2939121Smrg *-*-hpux*) 4926c2939121Smrg pic_flag_for_symtable=" $pic_flag" ;; 4927c2939121Smrg *) 49288292847cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4929c2939121Smrg ;; 4930c2939121Smrg esac 4931c2939121Smrg ;; 4932c2939121Smrg esac 4933c2939121Smrg symtab_cflags= 4934c2939121Smrg for arg in $LTCFLAGS; do 4935c2939121Smrg case $arg in 4936c2939121Smrg -pie | -fpie | -fPIE) ;; 49372836776bSmrg *) func_append symtab_cflags " $arg" ;; 4938c2939121Smrg esac 4939c2939121Smrg done 4940c76ae52dSmrg 4941c2939121Smrg # Now compile the dynamic symbol file. 4942c2939121Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4943c76ae52dSmrg 4944c2939121Smrg # Clean up the generated files. 49458292847cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4946c76ae52dSmrg 4947c2939121Smrg # Transform the symbol file into the correct name. 49488292847cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4949c2939121Smrg case $host in 4950c2939121Smrg *cygwin* | *mingw* | *cegcc* ) 4951c2939121Smrg if test -f "$output_objdir/$my_outputname.def"; then 4952c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4953c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4954c2939121Smrg else 4955c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4956c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4957c2939121Smrg fi 4958c2939121Smrg ;; 4959c2939121Smrg *) 4960c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4961c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4962c2939121Smrg ;; 4963c2939121Smrg esac 4964c2939121Smrg ;; 4965c2939121Smrg *) 49668292847cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4967c2939121Smrg ;; 4968c2939121Smrg esac 4969c2939121Smrg else 4970c2939121Smrg # We keep going just in case the user didn't refer to 4971c2939121Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4972c2939121Smrg # really was required. 4973c76ae52dSmrg 4974c2939121Smrg # Nullify the symbol file. 4975c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4976c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4977c2939121Smrg fi 4978c2939121Smrg} 4979c76ae52dSmrg 49808292847cSmrg# func_cygming_gnu_implib_p ARG 49818292847cSmrg# This predicate returns with zero status (TRUE) if 49828292847cSmrg# ARG is a GNU/binutils-style import library. Returns 49838292847cSmrg# with nonzero status (FALSE) otherwise. 49848292847cSmrgfunc_cygming_gnu_implib_p () 49858292847cSmrg{ 49868292847cSmrg $debug_cmd 49878292847cSmrg 49888292847cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49898292847cSmrg 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)$'` 49908292847cSmrg test -n "$func_cygming_gnu_implib_tmp" 49918292847cSmrg} 49928292847cSmrg 49938292847cSmrg# func_cygming_ms_implib_p ARG 49948292847cSmrg# This predicate returns with zero status (TRUE) if 49958292847cSmrg# ARG is an MS-style import library. Returns 49968292847cSmrg# with nonzero status (FALSE) otherwise. 49978292847cSmrgfunc_cygming_ms_implib_p () 49988292847cSmrg{ 49998292847cSmrg $debug_cmd 50008292847cSmrg 50018292847cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 50028292847cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 50038292847cSmrg test -n "$func_cygming_ms_implib_tmp" 50048292847cSmrg} 50058292847cSmrg 5006c2939121Smrg# func_win32_libid arg 5007c2939121Smrg# return the library type of file 'arg' 5008c2939121Smrg# 5009c2939121Smrg# Need a lot of goo to handle *both* DLLs and import libs 5010c2939121Smrg# Has to be a shell function in order to 'eat' the argument 5011c2939121Smrg# that is supplied when $file_magic_command is called. 5012c2939121Smrg# Despite the name, also deal with 64 bit binaries. 5013c2939121Smrgfunc_win32_libid () 5014c2939121Smrg{ 50158292847cSmrg $debug_cmd 50168292847cSmrg 50178292847cSmrg win32_libid_type=unknown 5018c2939121Smrg win32_fileres=`file -L $1 2>/dev/null` 5019c2939121Smrg case $win32_fileres in 5020c2939121Smrg *ar\ archive\ import\ library*) # definitely import 5021c2939121Smrg win32_libid_type="x86 archive import" 5022c2939121Smrg ;; 5023c2939121Smrg *ar\ archive*) # could be an import, or static 5024c2939121Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5025c2939121Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5026c2939121Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 50278292847cSmrg case $nm_interface in 50288292847cSmrg "MS dumpbin") 50298292847cSmrg if func_cygming_ms_implib_p "$1" || 50308292847cSmrg func_cygming_gnu_implib_p "$1" 50318292847cSmrg then 50328292847cSmrg win32_nmres=import 50338292847cSmrg else 50348292847cSmrg win32_nmres= 50358292847cSmrg fi 50368292847cSmrg ;; 50378292847cSmrg *) 50388292847cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 50398292847cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 50408292847cSmrg $SED -n -e ' 5041c2939121Smrg 1,100{ 5042c2939121Smrg / I /{ 50438292847cSmrg s|.*|import| 5044c2939121Smrg p 5045c2939121Smrg q 5046c2939121Smrg } 5047c2939121Smrg }'` 50488292847cSmrg ;; 50498292847cSmrg esac 5050c2939121Smrg case $win32_nmres in 5051c2939121Smrg import*) win32_libid_type="x86 archive import";; 5052c2939121Smrg *) win32_libid_type="x86 archive static";; 5053c2939121Smrg esac 5054c2939121Smrg fi 5055c2939121Smrg ;; 5056c2939121Smrg *DLL*) 5057c2939121Smrg win32_libid_type="x86 DLL" 5058c2939121Smrg ;; 5059c2939121Smrg *executable*) # but shell scripts are "executable" too... 5060c2939121Smrg case $win32_fileres in 5061c2939121Smrg *MS\ Windows\ PE\ Intel*) 5062c2939121Smrg win32_libid_type="x86 DLL" 5063c2939121Smrg ;; 5064c2939121Smrg esac 5065c2939121Smrg ;; 5066c2939121Smrg esac 5067c2939121Smrg $ECHO "$win32_libid_type" 5068c2939121Smrg} 5069c76ae52dSmrg 50702836776bSmrg# func_cygming_dll_for_implib ARG 50712836776bSmrg# 50722836776bSmrg# Platform-specific function to extract the 50732836776bSmrg# name of the DLL associated with the specified 50742836776bSmrg# import library ARG. 50752836776bSmrg# Invoked by eval'ing the libtool variable 50762836776bSmrg# $sharedlib_from_linklib_cmd 50772836776bSmrg# Result is available in the variable 50782836776bSmrg# $sharedlib_from_linklib_result 50792836776bSmrgfunc_cygming_dll_for_implib () 50802836776bSmrg{ 50818292847cSmrg $debug_cmd 50828292847cSmrg 50832836776bSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 50842836776bSmrg} 50852836776bSmrg 50862836776bSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 50872836776bSmrg# 50882836776bSmrg# The is the core of a fallback implementation of a 50892836776bSmrg# platform-specific function to extract the name of the 50902836776bSmrg# DLL associated with the specified import library LIBNAME. 50912836776bSmrg# 50922836776bSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 50932836776bSmrg# on the platform and compiler that created the implib. 50942836776bSmrg# 50952836776bSmrg# Echos the name of the DLL associated with the 50962836776bSmrg# specified import library. 50972836776bSmrgfunc_cygming_dll_for_implib_fallback_core () 50982836776bSmrg{ 50998292847cSmrg $debug_cmd 51008292847cSmrg 51012836776bSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 51022836776bSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 51032836776bSmrg $SED '/^Contents of section '"$match_literal"':/{ 51042836776bSmrg # Place marker at beginning of archive member dllname section 51052836776bSmrg s/.*/====MARK====/ 51062836776bSmrg p 51072836776bSmrg d 51082836776bSmrg } 51092836776bSmrg # These lines can sometimes be longer than 43 characters, but 51102836776bSmrg # are always uninteresting 51112836776bSmrg /:[ ]*file format pe[i]\{,1\}-/d 51122836776bSmrg /^In archive [^:]*:/d 51132836776bSmrg # Ensure marker is printed 51142836776bSmrg /^====MARK====/p 51152836776bSmrg # Remove all lines with less than 43 characters 51162836776bSmrg /^.\{43\}/!d 51172836776bSmrg # From remaining lines, remove first 43 characters 51182836776bSmrg s/^.\{43\}//' | 51192836776bSmrg $SED -n ' 51202836776bSmrg # Join marker and all lines until next marker into a single line 51212836776bSmrg /^====MARK====/ b para 51222836776bSmrg H 51232836776bSmrg $ b para 51242836776bSmrg b 51252836776bSmrg :para 51262836776bSmrg x 51272836776bSmrg s/\n//g 51282836776bSmrg # Remove the marker 51292836776bSmrg s/^====MARK====// 51302836776bSmrg # Remove trailing dots and whitespace 51312836776bSmrg s/[\. \t]*$// 51322836776bSmrg # Print 51332836776bSmrg /./p' | 51342836776bSmrg # we now have a list, one entry per line, of the stringified 51352836776bSmrg # contents of the appropriate section of all members of the 51368292847cSmrg # archive that possess that section. Heuristic: eliminate 51378292847cSmrg # all those that have a first or second character that is 51382836776bSmrg # a '.' (that is, objdump's representation of an unprintable 51392836776bSmrg # character.) This should work for all archives with less than 51402836776bSmrg # 0x302f exports -- but will fail for DLLs whose name actually 51412836776bSmrg # begins with a literal '.' or a single character followed by 51422836776bSmrg # a '.'. 51432836776bSmrg # 51442836776bSmrg # Of those that remain, print the first one. 51452836776bSmrg $SED -e '/^\./d;/^.\./d;q' 51462836776bSmrg} 51472836776bSmrg 51482836776bSmrg# func_cygming_dll_for_implib_fallback ARG 51492836776bSmrg# Platform-specific function to extract the 51502836776bSmrg# name of the DLL associated with the specified 51512836776bSmrg# import library ARG. 51522836776bSmrg# 51532836776bSmrg# This fallback implementation is for use when $DLLTOOL 51542836776bSmrg# does not support the --identify-strict option. 51552836776bSmrg# Invoked by eval'ing the libtool variable 51562836776bSmrg# $sharedlib_from_linklib_cmd 51572836776bSmrg# Result is available in the variable 51582836776bSmrg# $sharedlib_from_linklib_result 51592836776bSmrgfunc_cygming_dll_for_implib_fallback () 51602836776bSmrg{ 51618292847cSmrg $debug_cmd 51628292847cSmrg 51638292847cSmrg if func_cygming_gnu_implib_p "$1"; then 51642836776bSmrg # binutils import library 51652836776bSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 51668292847cSmrg elif func_cygming_ms_implib_p "$1"; then 51672836776bSmrg # ms-generated import library 51682836776bSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 51692836776bSmrg else 51702836776bSmrg # unknown 51718292847cSmrg sharedlib_from_linklib_result= 51722836776bSmrg fi 51732836776bSmrg} 5174c76ae52dSmrg 5175c76ae52dSmrg 5176c2939121Smrg# func_extract_an_archive dir oldlib 5177c2939121Smrgfunc_extract_an_archive () 5178c2939121Smrg{ 51798292847cSmrg $debug_cmd 51808292847cSmrg 51818292847cSmrg f_ex_an_ar_dir=$1; shift 51828292847cSmrg f_ex_an_ar_oldlib=$1 51838292847cSmrg if test yes = "$lock_old_archive_extraction"; then 5184c2939121Smrg lockfile=$f_ex_an_ar_oldlib.lock 5185c2939121Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5186c2939121Smrg func_echo "Waiting for $lockfile to be removed" 5187c2939121Smrg sleep 2 5188c2939121Smrg done 5189c2939121Smrg fi 5190c2939121Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5191c2939121Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 51928292847cSmrg if test yes = "$lock_old_archive_extraction"; then 5193c2939121Smrg $opt_dry_run || rm -f "$lockfile" 5194c2939121Smrg fi 5195c2939121Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5196c2939121Smrg : 5197c2939121Smrg else 5198c2939121Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5199c2939121Smrg fi 5200c2939121Smrg} 5201c76ae52dSmrg 5202c76ae52dSmrg 5203c2939121Smrg# func_extract_archives gentop oldlib ... 5204c2939121Smrgfunc_extract_archives () 5205c2939121Smrg{ 52068292847cSmrg $debug_cmd 52078292847cSmrg 52088292847cSmrg my_gentop=$1; shift 5209c2939121Smrg my_oldlibs=${1+"$@"} 52108292847cSmrg my_oldobjs= 52118292847cSmrg my_xlib= 52128292847cSmrg my_xabs= 52138292847cSmrg my_xdir= 5214c76ae52dSmrg 5215c2939121Smrg for my_xlib in $my_oldlibs; do 5216c2939121Smrg # Extract the objects. 5217c2939121Smrg case $my_xlib in 52188292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5219c2939121Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5220c2939121Smrg esac 5221c2939121Smrg func_basename "$my_xlib" 52228292847cSmrg my_xlib=$func_basename_result 5223c2939121Smrg my_xlib_u=$my_xlib 5224c2939121Smrg while :; do 5225c2939121Smrg case " $extracted_archives " in 5226c2939121Smrg *" $my_xlib_u "*) 5227c2939121Smrg func_arith $extracted_serial + 1 5228c2939121Smrg extracted_serial=$func_arith_result 5229c2939121Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5230c2939121Smrg *) break ;; 5231c2939121Smrg esac 5232c2939121Smrg done 5233c2939121Smrg extracted_archives="$extracted_archives $my_xlib_u" 52348292847cSmrg my_xdir=$my_gentop/$my_xlib_u 5235c76ae52dSmrg 5236c2939121Smrg func_mkdir_p "$my_xdir" 5237c2939121Smrg 5238c2939121Smrg case $host in 5239c2939121Smrg *-darwin*) 5240c2939121Smrg func_verbose "Extracting $my_xabs" 5241c2939121Smrg # Do not bother doing anything if just a dry run 5242c2939121Smrg $opt_dry_run || { 5243c2939121Smrg darwin_orig_dir=`pwd` 5244c2939121Smrg cd $my_xdir || exit $? 5245c2939121Smrg darwin_archive=$my_xabs 5246c2939121Smrg darwin_curdir=`pwd` 52478292847cSmrg func_basename "$darwin_archive" 52488292847cSmrg darwin_base_archive=$func_basename_result 5249c2939121Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5250c2939121Smrg if test -n "$darwin_arches"; then 5251c2939121Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5252c2939121Smrg darwin_arch= 5253c2939121Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 52548292847cSmrg for darwin_arch in $darwin_arches; do 52558292847cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 52568292847cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 52578292847cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 52588292847cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5259c2939121Smrg cd "$darwin_curdir" 52608292847cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5261c2939121Smrg done # $darwin_arches 5262c2939121Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 52638292847cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5264c2939121Smrg darwin_file= 5265c2939121Smrg darwin_files= 5266c2939121Smrg for darwin_file in $darwin_filelist; do 5267c2939121Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5268c2939121Smrg $LIPO -create -output "$darwin_file" $darwin_files 5269c2939121Smrg done # $darwin_filelist 5270c2939121Smrg $RM -rf unfat-$$ 5271c2939121Smrg cd "$darwin_orig_dir" 5272c76ae52dSmrg else 5273c2939121Smrg cd $darwin_orig_dir 5274c2939121Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5275c2939121Smrg fi # $darwin_arches 5276c2939121Smrg } # !$opt_dry_run 5277c2939121Smrg ;; 5278c2939121Smrg *) 5279c2939121Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5280c2939121Smrg ;; 5281c2939121Smrg esac 5282c2939121Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5283c2939121Smrg done 5284c76ae52dSmrg 52858292847cSmrg func_extract_archives_result=$my_oldobjs 5286c2939121Smrg} 5287c76ae52dSmrg 5288c76ae52dSmrg 5289c2939121Smrg# func_emit_wrapper [arg=no] 5290c2939121Smrg# 5291c2939121Smrg# Emit a libtool wrapper script on stdout. 5292c2939121Smrg# Don't directly open a file because we may want to 5293c2939121Smrg# incorporate the script contents within a cygwin/mingw 5294c2939121Smrg# wrapper executable. Must ONLY be called from within 5295c2939121Smrg# func_mode_link because it depends on a number of variables 5296c2939121Smrg# set therein. 5297c2939121Smrg# 5298c2939121Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5299c2939121Smrg# variable will take. If 'yes', then the emitted script 53008292847cSmrg# will assume that the directory where it is stored is 5301c2939121Smrg# the $objdir directory. This is a cygwin/mingw-specific 5302c2939121Smrg# behavior. 5303c2939121Smrgfunc_emit_wrapper () 5304c2939121Smrg{ 5305c2939121Smrg func_emit_wrapper_arg1=${1-no} 5306c76ae52dSmrg 5307c2939121Smrg $ECHO "\ 5308c2939121Smrg#! $SHELL 5309c76ae52dSmrg 5310c2939121Smrg# $output - temporary wrapper script for $objdir/$outputname 53118292847cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5312c2939121Smrg# 5313c2939121Smrg# The $output program cannot be directly executed until all the libtool 5314c2939121Smrg# libraries that it depends on are installed. 5315c2939121Smrg# 5316c2939121Smrg# This wrapper script should never be moved out of the build directory. 5317c2939121Smrg# If it is, it will not operate correctly. 5318c76ae52dSmrg 5319c2939121Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5320c2939121Smrg# metacharacters that are still active within double-quoted strings. 5321c2939121Smrgsed_quote_subst='$sed_quote_subst' 5322c76ae52dSmrg 5323c2939121Smrg# Be Bourne compatible 5324c2939121Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5325c2939121Smrg emulate sh 5326c2939121Smrg NULLCMD=: 5327c2939121Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5328c2939121Smrg # is contrary to our usage. Disable this feature. 5329c2939121Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5330c2939121Smrg setopt NO_GLOB_SUBST 5331c2939121Smrgelse 5332c2939121Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5333c2939121Smrgfi 5334c2939121SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5335c2939121SmrgDUALCASE=1; export DUALCASE # for MKS sh 5336c76ae52dSmrg 5337c2939121Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5338c2939121Smrg# if CDPATH is set. 5339c2939121Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5340c76ae52dSmrg 5341c2939121Smrgrelink_command=\"$relink_command\" 5342c76ae52dSmrg 5343c2939121Smrg# This environment variable determines our operation mode. 5344c2939121Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5345c2939121Smrg # install mode needs the following variables: 5346c2939121Smrg generated_by_libtool_version='$macro_version' 5347c2939121Smrg notinst_deplibs='$notinst_deplibs' 5348c2939121Smrgelse 5349c2939121Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5350c2939121Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5351c2939121Smrg file=\"\$0\"" 5352c76ae52dSmrg 5353c2939121Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5354c2939121Smrg $ECHO "\ 5355c76ae52dSmrg 5356c2939121Smrg# A function that is used when there is no print builtin or printf. 5357c2939121Smrgfunc_fallback_echo () 5358c2939121Smrg{ 5359c2939121Smrg eval 'cat <<_LTECHO_EOF 5360c2939121Smrg\$1 5361c2939121Smrg_LTECHO_EOF' 5362c2939121Smrg} 5363c2939121Smrg ECHO=\"$qECHO\" 5364c2939121Smrg fi 5365c2939121Smrg 5366c2939121Smrg# Very basic option parsing. These options are (a) specific to 5367c2939121Smrg# the libtool wrapper, (b) are identical between the wrapper 53688292847cSmrg# /script/ and the wrapper /executable/ that is used only on 5369c2939121Smrg# windows platforms, and (c) all begin with the string "--lt-" 53708292847cSmrg# (application programs are unlikely to have options that match 5371c2939121Smrg# this pattern). 5372c2939121Smrg# 5373c2939121Smrg# There are only two supported options: --lt-debug and 5374c2939121Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5375c2939121Smrg# 5376c2939121Smrg# The first argument to this parsing function should be the 5377c2939121Smrg# script's $0 value, followed by "$@". 5378c2939121Smrglt_option_debug= 5379c2939121Smrgfunc_parse_lt_options () 5380c2939121Smrg{ 5381c2939121Smrg lt_script_arg0=\$0 5382c2939121Smrg shift 5383c2939121Smrg for lt_opt 5384c2939121Smrg do 5385c2939121Smrg case \"\$lt_opt\" in 5386c2939121Smrg --lt-debug) lt_option_debug=1 ;; 5387c2939121Smrg --lt-dump-script) 5388c2939121Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5389c2939121Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5390c2939121Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5391c2939121Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5392c2939121Smrg exit 0 5393c2939121Smrg ;; 5394c2939121Smrg --lt-*) 5395c2939121Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5396c2939121Smrg exit 1 5397c76ae52dSmrg ;; 5398c2939121Smrg esac 5399c2939121Smrg done 5400c76ae52dSmrg 5401c2939121Smrg # Print the debug banner immediately: 5402c2939121Smrg if test -n \"\$lt_option_debug\"; then 54038292847cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5404c2939121Smrg fi 5405c2939121Smrg} 5406c76ae52dSmrg 5407c2939121Smrg# Used when --lt-debug. Prints its arguments to stdout 5408c2939121Smrg# (redirection is the responsibility of the caller) 5409c2939121Smrgfunc_lt_dump_args () 5410c2939121Smrg{ 5411c2939121Smrg lt_dump_args_N=1; 5412c2939121Smrg for lt_arg 5413c2939121Smrg do 54148292847cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5415c2939121Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5416c2939121Smrg done 5417c2939121Smrg} 5418c76ae52dSmrg 5419c2939121Smrg# Core function for launching the target application 5420c2939121Smrgfunc_exec_program_core () 5421c2939121Smrg{ 5422c2939121Smrg" 5423c2939121Smrg case $host in 5424c2939121Smrg # Backslashes separate directories on plain windows 5425c2939121Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5426c2939121Smrg $ECHO "\ 5427c2939121Smrg if test -n \"\$lt_option_debug\"; then 54288292847cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5429c2939121Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5430c76ae52dSmrg fi 5431c2939121Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5432c2939121Smrg" 5433c2939121Smrg ;; 5434c76ae52dSmrg 5435c2939121Smrg *) 5436c2939121Smrg $ECHO "\ 5437c2939121Smrg if test -n \"\$lt_option_debug\"; then 54388292847cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5439c2939121Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5440c76ae52dSmrg fi 5441c2939121Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5442c2939121Smrg" 5443c2939121Smrg ;; 5444c2939121Smrg esac 5445c2939121Smrg $ECHO "\ 5446c2939121Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5447c2939121Smrg exit 1 5448c2939121Smrg} 5449c76ae52dSmrg 5450c2939121Smrg# A function to encapsulate launching the target application 5451c2939121Smrg# Strips options in the --lt-* namespace from \$@ and 5452c2939121Smrg# launches target application with the remaining arguments. 5453c2939121Smrgfunc_exec_program () 5454c2939121Smrg{ 54552836776bSmrg case \" \$* \" in 54562836776bSmrg *\\ --lt-*) 54572836776bSmrg for lt_wr_arg 54582836776bSmrg do 54592836776bSmrg case \$lt_wr_arg in 54602836776bSmrg --lt-*) ;; 54612836776bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 54622836776bSmrg esac 54632836776bSmrg shift 54642836776bSmrg done ;; 54652836776bSmrg esac 5466c2939121Smrg func_exec_program_core \${1+\"\$@\"} 5467c2939121Smrg} 5468c76ae52dSmrg 5469c2939121Smrg # Parse options 5470c2939121Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5471c76ae52dSmrg 5472c2939121Smrg # Find the directory that this script lives in. 5473c2939121Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5474c2939121Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5475c76ae52dSmrg 5476c2939121Smrg # Follow symbolic links until we get to the real thisdir. 5477c2939121Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5478c2939121Smrg while test -n \"\$file\"; do 5479c2939121Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5480c76ae52dSmrg 5481c2939121Smrg # If there was a directory component, then change thisdir. 5482c2939121Smrg if test \"x\$destdir\" != \"x\$file\"; then 5483c2939121Smrg case \"\$destdir\" in 5484c2939121Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5485c2939121Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5486c2939121Smrg esac 5487c2939121Smrg fi 5488c76ae52dSmrg 5489c2939121Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5490c2939121Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5491c2939121Smrg done 5492c76ae52dSmrg 5493c2939121Smrg # Usually 'no', except on cygwin/mingw when embedded into 5494c2939121Smrg # the cwrapper. 5495c2939121Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5496c2939121Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5497c2939121Smrg # special case for '.' 5498c2939121Smrg if test \"\$thisdir\" = \".\"; then 5499c2939121Smrg thisdir=\`pwd\` 5500c2939121Smrg fi 5501c2939121Smrg # remove .libs from thisdir 5502c2939121Smrg case \"\$thisdir\" in 5503c2939121Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5504c2939121Smrg $objdir ) thisdir=. ;; 5505c2939121Smrg esac 5506c2939121Smrg fi 5507c76ae52dSmrg 5508c2939121Smrg # Try to get the absolute directory name. 5509c2939121Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5510c2939121Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5511c2939121Smrg" 5512c76ae52dSmrg 55138292847cSmrg if test yes = "$fast_install"; then 5514c2939121Smrg $ECHO "\ 5515c2939121Smrg program=lt-'$outputname'$exeext 5516c2939121Smrg progdir=\"\$thisdir/$objdir\" 5517c76ae52dSmrg 5518c2939121Smrg if test ! -f \"\$progdir/\$program\" || 55198292847cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5520c2939121Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5521c76ae52dSmrg 5522c2939121Smrg file=\"\$\$-\$program\" 5523c76ae52dSmrg 5524c2939121Smrg if test ! -d \"\$progdir\"; then 5525c2939121Smrg $MKDIR \"\$progdir\" 5526c2939121Smrg else 5527c2939121Smrg $RM \"\$progdir/\$file\" 5528c2939121Smrg fi" 5529c76ae52dSmrg 5530c2939121Smrg $ECHO "\ 5531c76ae52dSmrg 5532c2939121Smrg # relink executable if necessary 5533c2939121Smrg if test -n \"\$relink_command\"; then 5534c2939121Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5535c2939121Smrg else 55368292847cSmrg \$ECHO \"\$relink_command_output\" >&2 5537c2939121Smrg $RM \"\$progdir/\$file\" 5538c2939121Smrg exit 1 5539c2939121Smrg fi 5540c2939121Smrg fi 5541c76ae52dSmrg 5542c2939121Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5543c2939121Smrg { $RM \"\$progdir/\$program\"; 5544c2939121Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5545c2939121Smrg $RM \"\$progdir/\$file\" 5546c2939121Smrg fi" 5547c2939121Smrg else 5548c2939121Smrg $ECHO "\ 5549c2939121Smrg program='$outputname' 5550c2939121Smrg progdir=\"\$thisdir/$objdir\" 5551c2939121Smrg" 5552c2939121Smrg fi 5553c76ae52dSmrg 5554c2939121Smrg $ECHO "\ 5555c76ae52dSmrg 5556c2939121Smrg if test -f \"\$progdir/\$program\"; then" 5557c76ae52dSmrg 55582836776bSmrg # fixup the dll searchpath if we need to. 55592836776bSmrg # 55602836776bSmrg # Fix the DLL searchpath if we need to. Do this before prepending 55612836776bSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 55622836776bSmrg # libraries must come first. 55632836776bSmrg if test -n "$dllsearchpath"; then 55642836776bSmrg $ECHO "\ 55652836776bSmrg # Add the dll search path components to the executable PATH 55662836776bSmrg PATH=$dllsearchpath:\$PATH 55672836776bSmrg" 55682836776bSmrg fi 55692836776bSmrg 5570c2939121Smrg # Export our shlibpath_var if we have one. 55718292847cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5572c2939121Smrg $ECHO "\ 5573c2939121Smrg # Add our own library path to $shlibpath_var 5574c2939121Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5575c76ae52dSmrg 5576c2939121Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5577c2939121Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5578c2939121Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5579c76ae52dSmrg 5580c2939121Smrg export $shlibpath_var 5581c2939121Smrg" 5582c2939121Smrg fi 5583c76ae52dSmrg 5584c2939121Smrg $ECHO "\ 5585c2939121Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5586c2939121Smrg # Run the actual program with our arguments. 5587c2939121Smrg func_exec_program \${1+\"\$@\"} 5588c2939121Smrg fi 5589c2939121Smrg else 5590c2939121Smrg # The program doesn't exist. 55918292847cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5592c2939121Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5593c2939121Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5594c2939121Smrg exit 1 5595c2939121Smrg fi 5596c2939121Smrgfi\ 5597c2939121Smrg" 5598c2939121Smrg} 5599c76ae52dSmrg 5600c76ae52dSmrg 5601c2939121Smrg# func_emit_cwrapperexe_src 5602c2939121Smrg# emit the source code for a wrapper executable on stdout 5603c2939121Smrg# Must ONLY be called from within func_mode_link because 5604c2939121Smrg# it depends on a number of variable set therein. 5605c2939121Smrgfunc_emit_cwrapperexe_src () 5606c2939121Smrg{ 5607c2939121Smrg cat <<EOF 5608c76ae52dSmrg 5609c2939121Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 56108292847cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5611c76ae52dSmrg 5612c2939121Smrg The $output program cannot be directly executed until all the libtool 5613c2939121Smrg libraries that it depends on are installed. 5614c76ae52dSmrg 5615c2939121Smrg This wrapper executable should never be moved out of the build directory. 5616c2939121Smrg If it is, it will not operate correctly. 5617c2939121Smrg*/ 5618c2939121SmrgEOF 5619c2939121Smrg cat <<"EOF" 5620c2939121Smrg#ifdef _MSC_VER 5621c2939121Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5622c2939121Smrg#endif 5623c2939121Smrg#include <stdio.h> 5624c2939121Smrg#include <stdlib.h> 5625c2939121Smrg#ifdef _MSC_VER 5626c2939121Smrg# include <direct.h> 5627c2939121Smrg# include <process.h> 5628c2939121Smrg# include <io.h> 5629c2939121Smrg#else 5630c2939121Smrg# include <unistd.h> 5631c2939121Smrg# include <stdint.h> 5632c2939121Smrg# ifdef __CYGWIN__ 5633c2939121Smrg# include <io.h> 5634c2939121Smrg# endif 5635c2939121Smrg#endif 5636c2939121Smrg#include <malloc.h> 5637c2939121Smrg#include <stdarg.h> 5638c2939121Smrg#include <assert.h> 5639c2939121Smrg#include <string.h> 5640c2939121Smrg#include <ctype.h> 5641c2939121Smrg#include <errno.h> 5642c2939121Smrg#include <fcntl.h> 5643c2939121Smrg#include <sys/stat.h> 5644c76ae52dSmrg 56458292847cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 56468292847cSmrg 5647c2939121Smrg/* declarations of non-ANSI functions */ 56488292847cSmrg#if defined __MINGW32__ 5649c2939121Smrg# ifdef __STRICT_ANSI__ 5650c2939121Smrgint _putenv (const char *); 5651c2939121Smrg# endif 56528292847cSmrg#elif defined __CYGWIN__ 5653c2939121Smrg# ifdef __STRICT_ANSI__ 5654c2939121Smrgchar *realpath (const char *, char *); 5655c2939121Smrgint putenv (char *); 5656c2939121Smrgint setenv (const char *, const char *, int); 5657c2939121Smrg# endif 56588292847cSmrg/* #elif defined other_platform || defined ... */ 5659c2939121Smrg#endif 5660c76ae52dSmrg 5661c2939121Smrg/* portability defines, excluding path handling macros */ 56628292847cSmrg#if defined _MSC_VER 5663c2939121Smrg# define setmode _setmode 5664c2939121Smrg# define stat _stat 5665c2939121Smrg# define chmod _chmod 5666c2939121Smrg# define getcwd _getcwd 5667c2939121Smrg# define putenv _putenv 5668c2939121Smrg# define S_IXUSR _S_IEXEC 56698292847cSmrg#elif defined __MINGW32__ 5670c2939121Smrg# define setmode _setmode 5671c2939121Smrg# define stat _stat 5672c2939121Smrg# define chmod _chmod 5673c2939121Smrg# define getcwd _getcwd 5674c2939121Smrg# define putenv _putenv 56758292847cSmrg#elif defined __CYGWIN__ 5676c2939121Smrg# define HAVE_SETENV 5677c2939121Smrg# define FOPEN_WB "wb" 56788292847cSmrg/* #elif defined other platforms ... */ 5679c2939121Smrg#endif 5680c76ae52dSmrg 56818292847cSmrg#if defined PATH_MAX 5682c2939121Smrg# define LT_PATHMAX PATH_MAX 56838292847cSmrg#elif defined MAXPATHLEN 5684c2939121Smrg# define LT_PATHMAX MAXPATHLEN 5685c2939121Smrg#else 5686c2939121Smrg# define LT_PATHMAX 1024 5687c2939121Smrg#endif 5688c76ae52dSmrg 5689c2939121Smrg#ifndef S_IXOTH 5690c2939121Smrg# define S_IXOTH 0 5691c2939121Smrg#endif 5692c2939121Smrg#ifndef S_IXGRP 5693c2939121Smrg# define S_IXGRP 0 5694c2939121Smrg#endif 5695c76ae52dSmrg 5696c2939121Smrg/* path handling portability macros */ 5697c2939121Smrg#ifndef DIR_SEPARATOR 5698c2939121Smrg# define DIR_SEPARATOR '/' 5699c2939121Smrg# define PATH_SEPARATOR ':' 5700c2939121Smrg#endif 5701c76ae52dSmrg 57028292847cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 57038292847cSmrg defined __OS2__ 5704c2939121Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5705c2939121Smrg# define FOPEN_WB "wb" 5706c2939121Smrg# ifndef DIR_SEPARATOR_2 5707c2939121Smrg# define DIR_SEPARATOR_2 '\\' 5708c2939121Smrg# endif 5709c2939121Smrg# ifndef PATH_SEPARATOR_2 5710c2939121Smrg# define PATH_SEPARATOR_2 ';' 5711c2939121Smrg# endif 5712c2939121Smrg#endif 5713c76ae52dSmrg 5714c2939121Smrg#ifndef DIR_SEPARATOR_2 5715c2939121Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5716c2939121Smrg#else /* DIR_SEPARATOR_2 */ 5717c2939121Smrg# define IS_DIR_SEPARATOR(ch) \ 5718c2939121Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5719c2939121Smrg#endif /* DIR_SEPARATOR_2 */ 5720c76ae52dSmrg 5721c2939121Smrg#ifndef PATH_SEPARATOR_2 5722c2939121Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5723c2939121Smrg#else /* PATH_SEPARATOR_2 */ 5724c2939121Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5725c2939121Smrg#endif /* PATH_SEPARATOR_2 */ 5726c2939121Smrg 5727c2939121Smrg#ifndef FOPEN_WB 5728c2939121Smrg# define FOPEN_WB "w" 5729c2939121Smrg#endif 5730c2939121Smrg#ifndef _O_BINARY 5731c2939121Smrg# define _O_BINARY 0 5732c2939121Smrg#endif 5733c2939121Smrg 5734c2939121Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5735c2939121Smrg#define XFREE(stale) do { \ 57368292847cSmrg if (stale) { free (stale); stale = 0; } \ 5737c2939121Smrg} while (0) 5738c2939121Smrg 57398292847cSmrg#if defined LT_DEBUGWRAPPER 5740c2939121Smrgstatic int lt_debug = 1; 5741c2939121Smrg#else 5742c2939121Smrgstatic int lt_debug = 0; 5743c2939121Smrg#endif 5744c2939121Smrg 5745c2939121Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5746c2939121Smrg 5747c2939121Smrgvoid *xmalloc (size_t num); 5748c2939121Smrgchar *xstrdup (const char *string); 5749c2939121Smrgconst char *base_name (const char *name); 5750c2939121Smrgchar *find_executable (const char *wrapper); 5751c2939121Smrgchar *chase_symlinks (const char *pathspec); 5752c2939121Smrgint make_executable (const char *path); 5753c2939121Smrgint check_executable (const char *path); 5754c2939121Smrgchar *strendzap (char *str, const char *pat); 5755c2939121Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5756c2939121Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5757c2939121Smrgstatic const char *nonnull (const char *s); 5758c2939121Smrgstatic const char *nonempty (const char *s); 5759c2939121Smrgvoid lt_setenv (const char *name, const char *value); 5760c2939121Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5761c2939121Smrgvoid lt_update_exe_path (const char *name, const char *value); 5762c2939121Smrgvoid lt_update_lib_path (const char *name, const char *value); 5763c2939121Smrgchar **prepare_spawn (char **argv); 5764c2939121Smrgvoid lt_dump_script (FILE *f); 5765c2939121SmrgEOF 5766c2939121Smrg 5767c2939121Smrg cat <<EOF 57688292847cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 57698292847cSmrg# define externally_visible volatile 57708292847cSmrg#else 57718292847cSmrg# define externally_visible __attribute__((externally_visible)) volatile 57728292847cSmrg#endif 57738292847cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5774c2939121Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5775c2939121SmrgEOF 5776c2939121Smrg 57778292847cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57782836776bSmrg func_to_host_path "$temp_rpath" 5779c2939121Smrg cat <<EOF 57802836776bSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5781c76ae52dSmrgEOF 5782c76ae52dSmrg else 5783c2939121Smrg cat <<"EOF" 5784c2939121Smrgconst char * LIB_PATH_VALUE = ""; 5785c2939121SmrgEOF 5786c76ae52dSmrg fi 5787c2939121Smrg 5788c2939121Smrg if test -n "$dllsearchpath"; then 57892836776bSmrg func_to_host_path "$dllsearchpath:" 5790c2939121Smrg cat <<EOF 5791c2939121Smrgconst char * EXE_PATH_VARNAME = "PATH"; 57922836776bSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5793c2939121SmrgEOF 5794c76ae52dSmrg else 5795c2939121Smrg cat <<"EOF" 5796c2939121Smrgconst char * EXE_PATH_VARNAME = ""; 5797c2939121Smrgconst char * EXE_PATH_VALUE = ""; 5798c2939121SmrgEOF 5799c76ae52dSmrg fi 5800c2939121Smrg 58018292847cSmrg if test yes = "$fast_install"; then 5802c2939121Smrg cat <<EOF 5803c2939121Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5804c2939121SmrgEOF 5805c76ae52dSmrg else 5806c2939121Smrg cat <<EOF 5807c2939121Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5808c2939121SmrgEOF 5809c76ae52dSmrg fi 5810c76ae52dSmrg 5811c76ae52dSmrg 5812c2939121Smrg cat <<"EOF" 5813c76ae52dSmrg 5814c2939121Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5815c76ae52dSmrg 5816c2939121Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5817c2939121Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5818c2939121Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5819c76ae52dSmrg 5820c2939121Smrgint 5821c2939121Smrgmain (int argc, char *argv[]) 5822c2939121Smrg{ 5823c2939121Smrg char **newargz; 5824c2939121Smrg int newargc; 5825c2939121Smrg char *tmp_pathspec; 5826c2939121Smrg char *actual_cwrapper_path; 5827c2939121Smrg char *actual_cwrapper_name; 5828c2939121Smrg char *target_name; 5829c2939121Smrg char *lt_argv_zero; 58308292847cSmrg int rval = 127; 5831c76ae52dSmrg 5832c2939121Smrg int i; 5833c76ae52dSmrg 5834c2939121Smrg program_name = (char *) xstrdup (base_name (argv[0])); 58358292847cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5836c76ae52dSmrg 5837c2939121Smrg /* very simple arg parsing; don't want to rely on getopt 5838c2939121Smrg * also, copy all non cwrapper options to newargz, except 5839c2939121Smrg * argz[0], which is handled differently 5840c2939121Smrg */ 5841c2939121Smrg newargc=0; 5842c2939121Smrg for (i = 1; i < argc; i++) 5843c2939121Smrg { 58448292847cSmrg if (STREQ (argv[i], dumpscript_opt)) 5845c2939121Smrg { 5846c2939121SmrgEOF 58478292847cSmrg case $host in 5848c2939121Smrg *mingw* | *cygwin* ) 5849c2939121Smrg # make stdout use "unix" line endings 5850c2939121Smrg echo " setmode(1,_O_BINARY);" 5851c2939121Smrg ;; 58520d590c07Smrg esac 5853c76ae52dSmrg 5854c2939121Smrg cat <<"EOF" 5855c2939121Smrg lt_dump_script (stdout); 5856c2939121Smrg return 0; 5857c2939121Smrg } 58588292847cSmrg if (STREQ (argv[i], debug_opt)) 5859c2939121Smrg { 5860c2939121Smrg lt_debug = 1; 5861c2939121Smrg continue; 5862c2939121Smrg } 58638292847cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5864c2939121Smrg { 5865c2939121Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5866c2939121Smrg namespace, but it is not one of the ones we know about and 5867c2939121Smrg have already dealt with, above (inluding dump-script), then 5868c2939121Smrg report an error. Otherwise, targets might begin to believe 5869c2939121Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5870c2939121Smrg namespace. The first time any user complains about this, we'll 5871c2939121Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5872c2939121Smrg or a configure.ac-settable value. 5873c2939121Smrg */ 5874c2939121Smrg lt_fatal (__FILE__, __LINE__, 5875c2939121Smrg "unrecognized %s option: '%s'", 5876c2939121Smrg ltwrapper_option_prefix, argv[i]); 5877c2939121Smrg } 5878c2939121Smrg /* otherwise ... */ 5879c2939121Smrg newargz[++newargc] = xstrdup (argv[i]); 5880c2939121Smrg } 5881c2939121Smrg newargz[++newargc] = NULL; 5882c76ae52dSmrg 5883c2939121SmrgEOF 5884c2939121Smrg cat <<EOF 5885c2939121Smrg /* The GNU banner must be the first non-error debug message */ 58868292847cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5887c2939121SmrgEOF 5888c2939121Smrg cat <<"EOF" 5889c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5890c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5891c2939121Smrg 5892c2939121Smrg tmp_pathspec = find_executable (argv[0]); 5893c2939121Smrg if (tmp_pathspec == NULL) 5894c2939121Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5895c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5896c2939121Smrg "(main) found exe (before symlink chase) at: %s\n", 5897c2939121Smrg tmp_pathspec); 5898c2939121Smrg 5899c2939121Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5900c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5901c2939121Smrg "(main) found exe (after symlink chase) at: %s\n", 5902c2939121Smrg actual_cwrapper_path); 5903c2939121Smrg XFREE (tmp_pathspec); 5904c2939121Smrg 5905c2939121Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5906c2939121Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5907c2939121Smrg 5908c2939121Smrg /* wrapper name transforms */ 5909c2939121Smrg strendzap (actual_cwrapper_name, ".exe"); 5910c2939121Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5911c2939121Smrg XFREE (actual_cwrapper_name); 5912c2939121Smrg actual_cwrapper_name = tmp_pathspec; 5913c2939121Smrg tmp_pathspec = 0; 5914c2939121Smrg 5915c2939121Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5916c2939121Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5917c2939121Smrg strendzap (target_name, ".exe"); 5918c2939121Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5919c2939121Smrg XFREE (target_name); 5920c2939121Smrg target_name = tmp_pathspec; 5921c2939121Smrg tmp_pathspec = 0; 5922c2939121Smrg 5923c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 5924c2939121Smrg "(main) libtool target name: %s\n", 5925c2939121Smrg target_name); 5926c2939121SmrgEOF 5927c76ae52dSmrg 5928c2939121Smrg cat <<EOF 5929c2939121Smrg newargz[0] = 5930c2939121Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5931c2939121Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5932c2939121Smrg strcpy (newargz[0], actual_cwrapper_path); 5933c2939121Smrg strcat (newargz[0], "$objdir"); 5934c2939121Smrg strcat (newargz[0], "/"); 5935c2939121SmrgEOF 5936c76ae52dSmrg 5937c2939121Smrg cat <<"EOF" 5938c2939121Smrg /* stop here, and copy so we don't have to do this twice */ 5939c2939121Smrg tmp_pathspec = xstrdup (newargz[0]); 5940c76ae52dSmrg 5941c2939121Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5942c2939121Smrg strcat (newargz[0], actual_cwrapper_name); 5943c76ae52dSmrg 5944c2939121Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5945c2939121Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5946c2939121Smrg XFREE (tmp_pathspec); 5947c2939121Smrg tmp_pathspec = NULL; 5948c2939121SmrgEOF 5949c76ae52dSmrg 5950c2939121Smrg case $host_os in 5951c2939121Smrg mingw*) 5952c2939121Smrg cat <<"EOF" 5953c2939121Smrg { 5954c2939121Smrg char* p; 5955c2939121Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5956c2939121Smrg { 5957c2939121Smrg *p = '/'; 5958c2939121Smrg } 5959c2939121Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5960c2939121Smrg { 5961c2939121Smrg *p = '/'; 5962c2939121Smrg } 5963c2939121Smrg } 5964c2939121SmrgEOF 5965c2939121Smrg ;; 5966c2939121Smrg esac 5967c76ae52dSmrg 5968c2939121Smrg cat <<"EOF" 5969c2939121Smrg XFREE (target_name); 5970c2939121Smrg XFREE (actual_cwrapper_path); 5971c2939121Smrg XFREE (actual_cwrapper_name); 5972c76ae52dSmrg 5973c2939121Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5974c2939121Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 59752836776bSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 59762836776bSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 59772836776bSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 59782836776bSmrg libraries must come first. */ 5979c2939121Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 59802836776bSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5981c76ae52dSmrg 5982c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5983c2939121Smrg nonnull (lt_argv_zero)); 5984c2939121Smrg for (i = 0; i < newargc; i++) 5985c2939121Smrg { 5986c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5987c2939121Smrg i, nonnull (newargz[i])); 5988c2939121Smrg } 5989c76ae52dSmrg 5990c2939121SmrgEOF 5991c76ae52dSmrg 5992c2939121Smrg case $host_os in 5993c2939121Smrg mingw*) 5994c2939121Smrg cat <<"EOF" 5995c2939121Smrg /* execv doesn't actually work on mingw as expected on unix */ 5996c2939121Smrg newargz = prepare_spawn (newargz); 59978292847cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5998c2939121Smrg if (rval == -1) 5999c2939121Smrg { 6000c2939121Smrg /* failed to start process */ 6001c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6002c2939121Smrg "(main) failed to launch target \"%s\": %s\n", 6003c2939121Smrg lt_argv_zero, nonnull (strerror (errno))); 6004c2939121Smrg return 127; 6005c2939121Smrg } 6006c2939121Smrg return rval; 6007c2939121SmrgEOF 6008c2939121Smrg ;; 6009c2939121Smrg *) 6010c2939121Smrg cat <<"EOF" 6011c2939121Smrg execv (lt_argv_zero, newargz); 6012c2939121Smrg return rval; /* =127, but avoids unused variable warning */ 6013c2939121SmrgEOF 6014c2939121Smrg ;; 6015c2939121Smrg esac 6016c76ae52dSmrg 6017c2939121Smrg cat <<"EOF" 6018c2939121Smrg} 6019c76ae52dSmrg 6020c2939121Smrgvoid * 6021c2939121Smrgxmalloc (size_t num) 6022c2939121Smrg{ 6023c2939121Smrg void *p = (void *) malloc (num); 6024c2939121Smrg if (!p) 6025c2939121Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6026c76ae52dSmrg 6027c2939121Smrg return p; 6028c2939121Smrg} 6029c76ae52dSmrg 6030c2939121Smrgchar * 6031c2939121Smrgxstrdup (const char *string) 6032c2939121Smrg{ 6033c2939121Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6034c2939121Smrg string) : NULL; 6035c2939121Smrg} 6036c76ae52dSmrg 6037c2939121Smrgconst char * 6038c2939121Smrgbase_name (const char *name) 6039c2939121Smrg{ 6040c2939121Smrg const char *base; 6041c76ae52dSmrg 60428292847cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6043c2939121Smrg /* Skip over the disk name in MSDOS pathnames. */ 6044c2939121Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6045c2939121Smrg name += 2; 6046c2939121Smrg#endif 6047c76ae52dSmrg 6048c2939121Smrg for (base = name; *name; name++) 6049c2939121Smrg if (IS_DIR_SEPARATOR (*name)) 6050c2939121Smrg base = name + 1; 6051c2939121Smrg return base; 6052c2939121Smrg} 6053c76ae52dSmrg 6054c2939121Smrgint 6055c2939121Smrgcheck_executable (const char *path) 6056c2939121Smrg{ 6057c2939121Smrg struct stat st; 6058c76ae52dSmrg 6059c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6060c2939121Smrg nonempty (path)); 6061c2939121Smrg if ((!path) || (!*path)) 6062c2939121Smrg return 0; 6063c76ae52dSmrg 6064c2939121Smrg if ((stat (path, &st) >= 0) 6065c2939121Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6066c2939121Smrg return 1; 6067c2939121Smrg else 6068c2939121Smrg return 0; 6069c2939121Smrg} 6070c76ae52dSmrg 6071c2939121Smrgint 6072c2939121Smrgmake_executable (const char *path) 6073c2939121Smrg{ 6074c2939121Smrg int rval = 0; 6075c2939121Smrg struct stat st; 6076c76ae52dSmrg 6077c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6078c2939121Smrg nonempty (path)); 6079c2939121Smrg if ((!path) || (!*path)) 6080c2939121Smrg return 0; 6081c76ae52dSmrg 6082c2939121Smrg if (stat (path, &st) >= 0) 6083c2939121Smrg { 6084c2939121Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6085c2939121Smrg } 6086c2939121Smrg return rval; 6087c2939121Smrg} 6088c76ae52dSmrg 6089c2939121Smrg/* Searches for the full path of the wrapper. Returns 6090c2939121Smrg newly allocated full path name if found, NULL otherwise 6091c2939121Smrg Does not chase symlinks, even on platforms that support them. 6092c2939121Smrg*/ 6093c2939121Smrgchar * 6094c2939121Smrgfind_executable (const char *wrapper) 6095c2939121Smrg{ 6096c2939121Smrg int has_slash = 0; 6097c2939121Smrg const char *p; 6098c2939121Smrg const char *p_next; 6099c2939121Smrg /* static buffer for getcwd */ 6100c2939121Smrg char tmp[LT_PATHMAX + 1]; 61018292847cSmrg size_t tmp_len; 6102c2939121Smrg char *concat_name; 6103c76ae52dSmrg 6104c2939121Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6105c2939121Smrg nonempty (wrapper)); 6106c76ae52dSmrg 6107c2939121Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6108c2939121Smrg return NULL; 6109c76ae52dSmrg 6110c2939121Smrg /* Absolute path? */ 61118292847cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6112c2939121Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6113c2939121Smrg { 6114c2939121Smrg concat_name = xstrdup (wrapper); 6115c2939121Smrg if (check_executable (concat_name)) 6116c2939121Smrg return concat_name; 6117c2939121Smrg XFREE (concat_name); 6118c2939121Smrg } 6119c2939121Smrg else 6120c2939121Smrg { 6121c2939121Smrg#endif 6122c2939121Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6123c2939121Smrg { 6124c2939121Smrg concat_name = xstrdup (wrapper); 6125c2939121Smrg if (check_executable (concat_name)) 6126c2939121Smrg return concat_name; 6127c2939121Smrg XFREE (concat_name); 6128c2939121Smrg } 61298292847cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6130c2939121Smrg } 6131c2939121Smrg#endif 6132c76ae52dSmrg 6133c2939121Smrg for (p = wrapper; *p; p++) 6134c2939121Smrg if (*p == '/') 6135c2939121Smrg { 6136c2939121Smrg has_slash = 1; 6137c2939121Smrg break; 6138c2939121Smrg } 6139c2939121Smrg if (!has_slash) 6140c2939121Smrg { 6141c2939121Smrg /* no slashes; search PATH */ 6142c2939121Smrg const char *path = getenv ("PATH"); 6143c2939121Smrg if (path != NULL) 6144c2939121Smrg { 6145c2939121Smrg for (p = path; *p; p = p_next) 6146c2939121Smrg { 6147c2939121Smrg const char *q; 6148c2939121Smrg size_t p_len; 6149c2939121Smrg for (q = p; *q; q++) 6150c2939121Smrg if (IS_PATH_SEPARATOR (*q)) 6151c2939121Smrg break; 61528292847cSmrg p_len = (size_t) (q - p); 6153c2939121Smrg p_next = (*q == '\0' ? q : q + 1); 6154c2939121Smrg if (p_len == 0) 6155c2939121Smrg { 6156c2939121Smrg /* empty path: current directory */ 6157c2939121Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6158c2939121Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6159c2939121Smrg nonnull (strerror (errno))); 6160c2939121Smrg tmp_len = strlen (tmp); 6161c2939121Smrg concat_name = 6162c2939121Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6163c2939121Smrg memcpy (concat_name, tmp, tmp_len); 6164c2939121Smrg concat_name[tmp_len] = '/'; 6165c2939121Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6166c2939121Smrg } 6167c2939121Smrg else 6168c2939121Smrg { 6169c2939121Smrg concat_name = 6170c2939121Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6171c2939121Smrg memcpy (concat_name, p, p_len); 6172c2939121Smrg concat_name[p_len] = '/'; 6173c2939121Smrg strcpy (concat_name + p_len + 1, wrapper); 6174c2939121Smrg } 6175c2939121Smrg if (check_executable (concat_name)) 6176c2939121Smrg return concat_name; 6177c2939121Smrg XFREE (concat_name); 6178c2939121Smrg } 6179c2939121Smrg } 6180c2939121Smrg /* not found in PATH; assume curdir */ 6181c2939121Smrg } 6182c2939121Smrg /* Relative path | not found in path: prepend cwd */ 6183c2939121Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6184c2939121Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6185c2939121Smrg nonnull (strerror (errno))); 6186c2939121Smrg tmp_len = strlen (tmp); 6187c2939121Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6188c2939121Smrg memcpy (concat_name, tmp, tmp_len); 6189c2939121Smrg concat_name[tmp_len] = '/'; 6190c2939121Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6191c76ae52dSmrg 6192c2939121Smrg if (check_executable (concat_name)) 6193c2939121Smrg return concat_name; 6194c2939121Smrg XFREE (concat_name); 6195c2939121Smrg return NULL; 6196c2939121Smrg} 6197c76ae52dSmrg 6198c2939121Smrgchar * 6199c2939121Smrgchase_symlinks (const char *pathspec) 6200c2939121Smrg{ 6201c2939121Smrg#ifndef S_ISLNK 6202c2939121Smrg return xstrdup (pathspec); 6203c2939121Smrg#else 6204c2939121Smrg char buf[LT_PATHMAX]; 6205c2939121Smrg struct stat s; 6206c2939121Smrg char *tmp_pathspec = xstrdup (pathspec); 6207c2939121Smrg char *p; 6208c2939121Smrg int has_symlinks = 0; 6209c2939121Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6210c2939121Smrg { 6211c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6212c2939121Smrg "checking path component for symlinks: %s\n", 6213c2939121Smrg tmp_pathspec); 6214c2939121Smrg if (lstat (tmp_pathspec, &s) == 0) 6215c2939121Smrg { 6216c2939121Smrg if (S_ISLNK (s.st_mode) != 0) 6217c2939121Smrg { 6218c2939121Smrg has_symlinks = 1; 6219c2939121Smrg break; 6220c2939121Smrg } 6221c76ae52dSmrg 6222c2939121Smrg /* search backwards for last DIR_SEPARATOR */ 6223c2939121Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6224c2939121Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6225c2939121Smrg p--; 6226c2939121Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6227c2939121Smrg { 6228c2939121Smrg /* no more DIR_SEPARATORS left */ 6229c2939121Smrg break; 6230c2939121Smrg } 6231c2939121Smrg *p = '\0'; 6232c2939121Smrg } 6233c2939121Smrg else 6234c2939121Smrg { 6235c2939121Smrg lt_fatal (__FILE__, __LINE__, 6236c2939121Smrg "error accessing file \"%s\": %s", 6237c2939121Smrg tmp_pathspec, nonnull (strerror (errno))); 6238c2939121Smrg } 6239c2939121Smrg } 6240c2939121Smrg XFREE (tmp_pathspec); 6241c76ae52dSmrg 6242c2939121Smrg if (!has_symlinks) 6243c2939121Smrg { 6244c2939121Smrg return xstrdup (pathspec); 6245c2939121Smrg } 6246c76ae52dSmrg 6247c2939121Smrg tmp_pathspec = realpath (pathspec, buf); 6248c2939121Smrg if (tmp_pathspec == 0) 6249c2939121Smrg { 6250c2939121Smrg lt_fatal (__FILE__, __LINE__, 6251c2939121Smrg "could not follow symlinks for %s", pathspec); 6252c2939121Smrg } 6253c2939121Smrg return xstrdup (tmp_pathspec); 6254c2939121Smrg#endif 6255c2939121Smrg} 6256c76ae52dSmrg 6257c2939121Smrgchar * 6258c2939121Smrgstrendzap (char *str, const char *pat) 6259c2939121Smrg{ 6260c2939121Smrg size_t len, patlen; 6261c76ae52dSmrg 6262c2939121Smrg assert (str != NULL); 6263c2939121Smrg assert (pat != NULL); 6264c76ae52dSmrg 6265c2939121Smrg len = strlen (str); 6266c2939121Smrg patlen = strlen (pat); 6267c76ae52dSmrg 6268c2939121Smrg if (patlen <= len) 6269c2939121Smrg { 6270c2939121Smrg str += len - patlen; 62718292847cSmrg if (STREQ (str, pat)) 6272c2939121Smrg *str = '\0'; 6273c2939121Smrg } 6274c2939121Smrg return str; 6275c2939121Smrg} 6276c76ae52dSmrg 6277c2939121Smrgvoid 6278c2939121Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6279c2939121Smrg{ 6280c2939121Smrg va_list args; 6281c2939121Smrg if (lt_debug) 6282c2939121Smrg { 6283c2939121Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6284c2939121Smrg va_start (args, fmt); 6285c2939121Smrg (void) vfprintf (stderr, fmt, args); 6286c2939121Smrg va_end (args); 6287c2939121Smrg } 6288c2939121Smrg} 6289c76ae52dSmrg 6290c2939121Smrgstatic void 6291c2939121Smrglt_error_core (int exit_status, const char *file, 6292c2939121Smrg int line, const char *mode, 6293c2939121Smrg const char *message, va_list ap) 6294c2939121Smrg{ 6295c2939121Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6296c2939121Smrg vfprintf (stderr, message, ap); 6297c2939121Smrg fprintf (stderr, ".\n"); 6298c76ae52dSmrg 6299c2939121Smrg if (exit_status >= 0) 6300c2939121Smrg exit (exit_status); 6301c2939121Smrg} 6302c76ae52dSmrg 6303c2939121Smrgvoid 6304c2939121Smrglt_fatal (const char *file, int line, const char *message, ...) 6305c2939121Smrg{ 6306c2939121Smrg va_list ap; 6307c2939121Smrg va_start (ap, message); 6308c2939121Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6309c2939121Smrg va_end (ap); 6310c2939121Smrg} 6311c76ae52dSmrg 6312c2939121Smrgstatic const char * 6313c2939121Smrgnonnull (const char *s) 6314c2939121Smrg{ 6315c2939121Smrg return s ? s : "(null)"; 6316c2939121Smrg} 6317c76ae52dSmrg 6318c2939121Smrgstatic const char * 6319c2939121Smrgnonempty (const char *s) 6320c2939121Smrg{ 6321c2939121Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6322c2939121Smrg} 6323c76ae52dSmrg 6324c2939121Smrgvoid 6325c2939121Smrglt_setenv (const char *name, const char *value) 6326c2939121Smrg{ 6327c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6328c2939121Smrg "(lt_setenv) setting '%s' to '%s'\n", 6329c2939121Smrg nonnull (name), nonnull (value)); 6330c2939121Smrg { 6331c2939121Smrg#ifdef HAVE_SETENV 6332c2939121Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6333c2939121Smrg char *str = xstrdup (value); 6334c2939121Smrg setenv (name, str, 1); 6335c2939121Smrg#else 63368292847cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6337c2939121Smrg char *str = XMALLOC (char, len); 6338c2939121Smrg sprintf (str, "%s=%s", name, value); 6339c2939121Smrg if (putenv (str) != EXIT_SUCCESS) 6340c2939121Smrg { 6341c2939121Smrg XFREE (str); 6342c2939121Smrg } 6343c2939121Smrg#endif 6344c2939121Smrg } 6345c2939121Smrg} 6346c76ae52dSmrg 6347c2939121Smrgchar * 6348c2939121Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6349c2939121Smrg{ 6350c2939121Smrg char *new_value; 6351c2939121Smrg if (orig_value && *orig_value) 6352c2939121Smrg { 63538292847cSmrg size_t orig_value_len = strlen (orig_value); 63548292847cSmrg size_t add_len = strlen (add); 6355c2939121Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6356c2939121Smrg if (to_end) 6357c2939121Smrg { 6358c2939121Smrg strcpy (new_value, orig_value); 6359c2939121Smrg strcpy (new_value + orig_value_len, add); 6360c2939121Smrg } 6361c2939121Smrg else 6362c2939121Smrg { 6363c2939121Smrg strcpy (new_value, add); 6364c2939121Smrg strcpy (new_value + add_len, orig_value); 6365c2939121Smrg } 6366c2939121Smrg } 6367c2939121Smrg else 6368c2939121Smrg { 6369c2939121Smrg new_value = xstrdup (add); 6370c2939121Smrg } 6371c2939121Smrg return new_value; 6372c2939121Smrg} 6373c76ae52dSmrg 6374c2939121Smrgvoid 6375c2939121Smrglt_update_exe_path (const char *name, const char *value) 6376c2939121Smrg{ 6377c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6378c2939121Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6379c2939121Smrg nonnull (name), nonnull (value)); 6380c76ae52dSmrg 6381c2939121Smrg if (name && *name && value && *value) 6382c2939121Smrg { 6383c2939121Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6384c2939121Smrg /* some systems can't cope with a ':'-terminated path #' */ 63858292847cSmrg size_t len = strlen (new_value); 63868292847cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6387c2939121Smrg { 63888292847cSmrg new_value[--len] = '\0'; 6389c2939121Smrg } 6390c2939121Smrg lt_setenv (name, new_value); 6391c2939121Smrg XFREE (new_value); 6392c2939121Smrg } 6393c2939121Smrg} 6394c76ae52dSmrg 6395c2939121Smrgvoid 6396c2939121Smrglt_update_lib_path (const char *name, const char *value) 6397c2939121Smrg{ 6398c2939121Smrg lt_debugprintf (__FILE__, __LINE__, 6399c2939121Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6400c2939121Smrg nonnull (name), nonnull (value)); 6401c76ae52dSmrg 6402c2939121Smrg if (name && *name && value && *value) 6403c2939121Smrg { 6404c2939121Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6405c2939121Smrg lt_setenv (name, new_value); 6406c2939121Smrg XFREE (new_value); 6407c2939121Smrg } 6408c2939121Smrg} 6409c76ae52dSmrg 6410c2939121SmrgEOF 6411c2939121Smrg case $host_os in 6412c2939121Smrg mingw*) 6413c2939121Smrg cat <<"EOF" 6414c2939121Smrg 6415c2939121Smrg/* Prepares an argument vector before calling spawn(). 6416c2939121Smrg Note that spawn() does not by itself call the command interpreter 6417c2939121Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6418c2939121Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6419c2939121Smrg GetVersionEx(&v); 6420c2939121Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6421c2939121Smrg }) ? "cmd.exe" : "command.com"). 6422c2939121Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6423c2939121Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6424c2939121Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6425c2939121Smrg special way: 6426c2939121Smrg - Space and tab are interpreted as delimiters. They are not treated as 6427c2939121Smrg delimiters if they are surrounded by double quotes: "...". 6428c2939121Smrg - Unescaped double quotes are removed from the input. Their only effect is 6429c2939121Smrg that within double quotes, space and tab are treated like normal 6430c2939121Smrg characters. 6431c2939121Smrg - Backslashes not followed by double quotes are not special. 6432c2939121Smrg - But 2*n+1 backslashes followed by a double quote become 6433c2939121Smrg n backslashes followed by a double quote (n >= 0): 6434c2939121Smrg \" -> " 6435c2939121Smrg \\\" -> \" 6436c2939121Smrg \\\\\" -> \\" 6437c2939121Smrg */ 6438c2939121Smrg#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" 6439c2939121Smrg#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" 6440c2939121Smrgchar ** 6441c2939121Smrgprepare_spawn (char **argv) 6442c2939121Smrg{ 6443c2939121Smrg size_t argc; 6444c2939121Smrg char **new_argv; 6445c2939121Smrg size_t i; 6446c76ae52dSmrg 6447c2939121Smrg /* Count number of arguments. */ 6448c2939121Smrg for (argc = 0; argv[argc] != NULL; argc++) 6449c2939121Smrg ; 6450c76ae52dSmrg 6451c2939121Smrg /* Allocate new argument vector. */ 6452c2939121Smrg new_argv = XMALLOC (char *, argc + 1); 6453c76ae52dSmrg 6454c2939121Smrg /* Put quoted arguments into the new argument vector. */ 6455c2939121Smrg for (i = 0; i < argc; i++) 6456c2939121Smrg { 6457c2939121Smrg const char *string = argv[i]; 6458c2939121Smrg 6459c2939121Smrg if (string[0] == '\0') 6460c2939121Smrg new_argv[i] = xstrdup ("\"\""); 6461c2939121Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6462c2939121Smrg { 6463c2939121Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6464c2939121Smrg size_t length; 6465c2939121Smrg unsigned int backslashes; 6466c2939121Smrg const char *s; 6467c2939121Smrg char *quoted_string; 6468c2939121Smrg char *p; 6469c2939121Smrg 6470c2939121Smrg length = 0; 6471c2939121Smrg backslashes = 0; 6472c2939121Smrg if (quote_around) 6473c2939121Smrg length++; 6474c2939121Smrg for (s = string; *s != '\0'; s++) 6475c2939121Smrg { 6476c2939121Smrg char c = *s; 6477c2939121Smrg if (c == '"') 6478c2939121Smrg length += backslashes + 1; 6479c2939121Smrg length++; 6480c2939121Smrg if (c == '\\') 6481c2939121Smrg backslashes++; 6482c2939121Smrg else 6483c2939121Smrg backslashes = 0; 6484c2939121Smrg } 6485c2939121Smrg if (quote_around) 6486c2939121Smrg length += backslashes + 1; 6487c2939121Smrg 6488c2939121Smrg quoted_string = XMALLOC (char, length + 1); 6489c2939121Smrg 6490c2939121Smrg p = quoted_string; 6491c2939121Smrg backslashes = 0; 6492c2939121Smrg if (quote_around) 6493c2939121Smrg *p++ = '"'; 6494c2939121Smrg for (s = string; *s != '\0'; s++) 6495c2939121Smrg { 6496c2939121Smrg char c = *s; 6497c2939121Smrg if (c == '"') 6498c2939121Smrg { 6499c2939121Smrg unsigned int j; 6500c2939121Smrg for (j = backslashes + 1; j > 0; j--) 6501c2939121Smrg *p++ = '\\'; 6502c2939121Smrg } 6503c2939121Smrg *p++ = c; 6504c2939121Smrg if (c == '\\') 6505c2939121Smrg backslashes++; 6506c2939121Smrg else 6507c2939121Smrg backslashes = 0; 6508c2939121Smrg } 6509c2939121Smrg if (quote_around) 6510c2939121Smrg { 6511c2939121Smrg unsigned int j; 6512c2939121Smrg for (j = backslashes; j > 0; j--) 6513c2939121Smrg *p++ = '\\'; 6514c2939121Smrg *p++ = '"'; 6515c2939121Smrg } 6516c2939121Smrg *p = '\0'; 6517c76ae52dSmrg 6518c2939121Smrg new_argv[i] = quoted_string; 6519c2939121Smrg } 6520c2939121Smrg else 6521c2939121Smrg new_argv[i] = (char *) string; 6522c2939121Smrg } 6523c2939121Smrg new_argv[argc] = NULL; 6524c76ae52dSmrg 6525c2939121Smrg return new_argv; 6526c2939121Smrg} 6527c2939121SmrgEOF 6528c76ae52dSmrg ;; 6529c2939121Smrg esac 6530c76ae52dSmrg 6531c2939121Smrg cat <<"EOF" 6532c2939121Smrgvoid lt_dump_script (FILE* f) 6533c2939121Smrg{ 6534c2939121SmrgEOF 6535c2939121Smrg func_emit_wrapper yes | 65362836776bSmrg $SED -n -e ' 65372836776bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 65382836776bSmrg\2/ 65392836776bSmrgh 65402836776bSmrgs/\([\\"]\)/\\\1/g 65412836776bSmrgs/$/\\n/ 65422836776bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 65432836776bSmrgg 65442836776bSmrgD' 6545c2939121Smrg cat <<"EOF" 6546c2939121Smrg} 6547c2939121SmrgEOF 6548c2939121Smrg} 6549c2939121Smrg# end: func_emit_cwrapperexe_src 6550c76ae52dSmrg 6551c2939121Smrg# func_win32_import_lib_p ARG 6552c2939121Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6553c2939121Smrgfunc_win32_import_lib_p () 6554c2939121Smrg{ 65558292847cSmrg $debug_cmd 65568292847cSmrg 6557c2939121Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6558c2939121Smrg *import*) : ;; 6559c2939121Smrg *) false ;; 6560c2939121Smrg esac 6561c2939121Smrg} 6562c76ae52dSmrg 65638292847cSmrg# func_suncc_cstd_abi 65648292847cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 65658292847cSmrg# Several compiler flags select an ABI that is incompatible with the 65668292847cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 65678292847cSmrgfunc_suncc_cstd_abi () 65688292847cSmrg{ 65698292847cSmrg $debug_cmd 65708292847cSmrg 65718292847cSmrg case " $compile_command " in 65728292847cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 65738292847cSmrg suncc_use_cstd_abi=no 65748292847cSmrg ;; 65758292847cSmrg *) 65768292847cSmrg suncc_use_cstd_abi=yes 65778292847cSmrg ;; 65788292847cSmrg esac 65798292847cSmrg} 65808292847cSmrg 6581c2939121Smrg# func_mode_link arg... 6582c2939121Smrgfunc_mode_link () 6583c2939121Smrg{ 65848292847cSmrg $debug_cmd 65858292847cSmrg 6586c2939121Smrg case $host in 6587c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6588c2939121Smrg # It is impossible to link a dll without this setting, and 6589c2939121Smrg # we shouldn't force the makefile maintainer to figure out 65908292847cSmrg # what system we are compiling for in order to pass an extra 6591c2939121Smrg # flag for every libtool invocation. 6592c2939121Smrg # allow_undefined=no 6593c76ae52dSmrg 6594c2939121Smrg # FIXME: Unfortunately, there are problems with the above when trying 65958292847cSmrg # to make a dll that has undefined symbols, in which case not 6596c2939121Smrg # even a static library is built. For now, we need to specify 6597c2939121Smrg # -no-undefined on the libtool link line when we can be certain 6598c2939121Smrg # that all symbols are satisfied, otherwise we get a static library. 6599c2939121Smrg allow_undefined=yes 6600c2939121Smrg ;; 6601c2939121Smrg *) 6602c2939121Smrg allow_undefined=yes 6603c2939121Smrg ;; 6604c2939121Smrg esac 6605c2939121Smrg libtool_args=$nonopt 6606c2939121Smrg base_compile="$nonopt $@" 6607c2939121Smrg compile_command=$nonopt 6608c2939121Smrg finalize_command=$nonopt 6609c76ae52dSmrg 6610c2939121Smrg compile_rpath= 6611c2939121Smrg finalize_rpath= 6612c2939121Smrg compile_shlibpath= 6613c2939121Smrg finalize_shlibpath= 6614c2939121Smrg convenience= 6615c2939121Smrg old_convenience= 6616c2939121Smrg deplibs= 6617c2939121Smrg old_deplibs= 6618c2939121Smrg compiler_flags= 6619c2939121Smrg linker_flags= 6620c2939121Smrg dllsearchpath= 6621c2939121Smrg lib_search_path=`pwd` 6622c2939121Smrg inst_prefix_dir= 6623c2939121Smrg new_inherited_linker_flags= 6624c76ae52dSmrg 6625c2939121Smrg avoid_version=no 6626c2939121Smrg bindir= 6627c2939121Smrg dlfiles= 6628c2939121Smrg dlprefiles= 6629c2939121Smrg dlself=no 6630c2939121Smrg export_dynamic=no 6631c2939121Smrg export_symbols= 6632c2939121Smrg export_symbols_regex= 6633c2939121Smrg generated= 6634c2939121Smrg libobjs= 6635c2939121Smrg ltlibs= 6636c2939121Smrg module=no 6637c2939121Smrg no_install=no 6638c2939121Smrg objs= 66398292847cSmrg os2dllname= 6640c2939121Smrg non_pic_objects= 6641c2939121Smrg precious_files_regex= 6642c2939121Smrg prefer_static_libs=no 66438292847cSmrg preload=false 6644c2939121Smrg prev= 6645c2939121Smrg prevarg= 6646c2939121Smrg release= 6647c2939121Smrg rpath= 6648c2939121Smrg xrpath= 6649c2939121Smrg perm_rpath= 6650c2939121Smrg temp_rpath= 6651c2939121Smrg thread_safe=no 6652c2939121Smrg vinfo= 6653c2939121Smrg vinfo_number=no 6654c2939121Smrg weak_libs= 66558292847cSmrg single_module=$wl-single_module 6656c2939121Smrg func_infer_tag $base_compile 6657c76ae52dSmrg 6658c2939121Smrg # We need to know -static, to get the right output filenames. 6659c2939121Smrg for arg 6660c2939121Smrg do 6661c2939121Smrg case $arg in 6662c2939121Smrg -shared) 66638292847cSmrg test yes != "$build_libtool_libs" \ 66648292847cSmrg && func_fatal_configuration "cannot build a shared library" 6665c2939121Smrg build_old_libs=no 6666c2939121Smrg break 6667c2939121Smrg ;; 6668c2939121Smrg -all-static | -static | -static-libtool-libs) 6669c2939121Smrg case $arg in 6670c2939121Smrg -all-static) 66718292847cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6672c2939121Smrg func_warning "complete static linking is impossible in this configuration" 6673c2939121Smrg fi 6674c2939121Smrg if test -n "$link_static_flag"; then 6675c2939121Smrg dlopen_self=$dlopen_self_static 6676c2939121Smrg fi 6677c2939121Smrg prefer_static_libs=yes 6678c2939121Smrg ;; 6679c2939121Smrg -static) 6680c2939121Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6681c2939121Smrg dlopen_self=$dlopen_self_static 6682c2939121Smrg fi 6683c2939121Smrg prefer_static_libs=built 6684c2939121Smrg ;; 6685c2939121Smrg -static-libtool-libs) 6686c2939121Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6687c2939121Smrg dlopen_self=$dlopen_self_static 6688c2939121Smrg fi 6689c2939121Smrg prefer_static_libs=yes 6690c2939121Smrg ;; 6691c2939121Smrg esac 6692c2939121Smrg build_libtool_libs=no 6693c2939121Smrg build_old_libs=yes 6694c2939121Smrg break 6695c2939121Smrg ;; 6696c2939121Smrg esac 6697c2939121Smrg done 6698c76ae52dSmrg 6699c2939121Smrg # See if our shared archives depend on static archives. 6700c2939121Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6701c76ae52dSmrg 6702c2939121Smrg # Go through the arguments, transforming them on the way. 6703c2939121Smrg while test "$#" -gt 0; do 67048292847cSmrg arg=$1 6705c2939121Smrg shift 6706c2939121Smrg func_quote_for_eval "$arg" 6707c2939121Smrg qarg=$func_quote_for_eval_unquoted_result 6708c2939121Smrg func_append libtool_args " $func_quote_for_eval_result" 6709c76ae52dSmrg 6710c2939121Smrg # If the previous option needs an argument, assign it. 6711c2939121Smrg if test -n "$prev"; then 6712c2939121Smrg case $prev in 6713c2939121Smrg output) 6714c2939121Smrg func_append compile_command " @OUTPUT@" 6715c2939121Smrg func_append finalize_command " @OUTPUT@" 6716c2939121Smrg ;; 6717c2939121Smrg esac 6718c76ae52dSmrg 6719c2939121Smrg case $prev in 6720c2939121Smrg bindir) 67218292847cSmrg bindir=$arg 6722c2939121Smrg prev= 6723c2939121Smrg continue 6724c2939121Smrg ;; 6725c2939121Smrg dlfiles|dlprefiles) 67268292847cSmrg $preload || { 6727c2939121Smrg # Add the symbol object into the linking commands. 6728c2939121Smrg func_append compile_command " @SYMFILE@" 6729c2939121Smrg func_append finalize_command " @SYMFILE@" 67308292847cSmrg preload=: 67318292847cSmrg } 6732c2939121Smrg case $arg in 6733c2939121Smrg *.la | *.lo) ;; # We handle these cases below. 6734c2939121Smrg force) 67358292847cSmrg if test no = "$dlself"; then 6736c2939121Smrg dlself=needless 6737c2939121Smrg export_dynamic=yes 6738c76ae52dSmrg fi 6739c2939121Smrg prev= 6740c2939121Smrg continue 6741c2939121Smrg ;; 6742c2939121Smrg self) 67438292847cSmrg if test dlprefiles = "$prev"; then 6744c2939121Smrg dlself=yes 67458292847cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6746c2939121Smrg dlself=yes 6747c76ae52dSmrg else 6748c2939121Smrg dlself=needless 6749c2939121Smrg export_dynamic=yes 6750c76ae52dSmrg fi 6751c2939121Smrg prev= 6752c2939121Smrg continue 6753c2939121Smrg ;; 6754c2939121Smrg *) 67558292847cSmrg if test dlfiles = "$prev"; then 67562836776bSmrg func_append dlfiles " $arg" 6757c76ae52dSmrg else 67582836776bSmrg func_append dlprefiles " $arg" 6759c76ae52dSmrg fi 6760c2939121Smrg prev= 6761c2939121Smrg continue 6762c2939121Smrg ;; 6763c2939121Smrg esac 6764c2939121Smrg ;; 6765c2939121Smrg expsyms) 67668292847cSmrg export_symbols=$arg 6767c2939121Smrg test -f "$arg" \ 67688292847cSmrg || func_fatal_error "symbol file '$arg' does not exist" 6769c2939121Smrg prev= 6770c2939121Smrg continue 6771c2939121Smrg ;; 6772c2939121Smrg expsyms_regex) 67738292847cSmrg export_symbols_regex=$arg 6774c2939121Smrg prev= 6775c2939121Smrg continue 6776c2939121Smrg ;; 6777c2939121Smrg framework) 6778c76ae52dSmrg case $host in 6779c2939121Smrg *-*-darwin*) 6780c2939121Smrg case "$deplibs " in 6781c2939121Smrg *" $qarg.ltframework "*) ;; 67822836776bSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6783c2939121Smrg ;; 6784c2939121Smrg esac 6785c2939121Smrg ;; 6786c76ae52dSmrg esac 6787c2939121Smrg prev= 6788c2939121Smrg continue 6789c76ae52dSmrg ;; 6790c2939121Smrg inst_prefix) 67918292847cSmrg inst_prefix_dir=$arg 67928292847cSmrg prev= 67938292847cSmrg continue 67948292847cSmrg ;; 67958292847cSmrg mllvm) 67968292847cSmrg # Clang does not use LLVM to link, so we can simply discard any 67978292847cSmrg # '-mllvm $arg' options when doing the link step. 6798c2939121Smrg prev= 6799c2939121Smrg continue 6800c76ae52dSmrg ;; 6801c2939121Smrg objectlist) 6802c2939121Smrg if test -f "$arg"; then 6803c2939121Smrg save_arg=$arg 6804c2939121Smrg moreargs= 6805c2939121Smrg for fil in `cat "$save_arg"` 6806c2939121Smrg do 68072836776bSmrg# func_append moreargs " $fil" 6808c2939121Smrg arg=$fil 6809c2939121Smrg # A libtool-controlled object. 6810c76ae52dSmrg 6811c2939121Smrg # Check to see that this really is a libtool object. 6812c2939121Smrg if func_lalib_unsafe_p "$arg"; then 6813c2939121Smrg pic_object= 6814c2939121Smrg non_pic_object= 6815c76ae52dSmrg 6816c2939121Smrg # Read the .lo file 6817c2939121Smrg func_source "$arg" 6818c76ae52dSmrg 6819c2939121Smrg if test -z "$pic_object" || 6820c2939121Smrg test -z "$non_pic_object" || 68218292847cSmrg test none = "$pic_object" && 68228292847cSmrg test none = "$non_pic_object"; then 68238292847cSmrg func_fatal_error "cannot find name of object for '$arg'" 6824c2939121Smrg fi 6825c76ae52dSmrg 6826c2939121Smrg # Extract subdirectory from the argument. 6827c2939121Smrg func_dirname "$arg" "/" "" 68288292847cSmrg xdir=$func_dirname_result 6829c76ae52dSmrg 68308292847cSmrg if test none != "$pic_object"; then 6831c2939121Smrg # Prepend the subdirectory the object is found in. 68328292847cSmrg pic_object=$xdir$pic_object 6833c76ae52dSmrg 68348292847cSmrg if test dlfiles = "$prev"; then 68358292847cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 68362836776bSmrg func_append dlfiles " $pic_object" 6837c2939121Smrg prev= 6838c2939121Smrg continue 6839c2939121Smrg else 6840c2939121Smrg # If libtool objects are unsupported, then we need to preload. 6841c2939121Smrg prev=dlprefiles 6842c2939121Smrg fi 6843c2939121Smrg fi 6844c76ae52dSmrg 6845c2939121Smrg # CHECK ME: I think I busted this. -Ossama 68468292847cSmrg if test dlprefiles = "$prev"; then 6847c2939121Smrg # Preload the old-style object. 68482836776bSmrg func_append dlprefiles " $pic_object" 6849c2939121Smrg prev= 6850c2939121Smrg fi 6851c76ae52dSmrg 6852c2939121Smrg # A PIC object. 6853c2939121Smrg func_append libobjs " $pic_object" 68548292847cSmrg arg=$pic_object 6855c2939121Smrg fi 6856c76ae52dSmrg 6857c2939121Smrg # Non-PIC object. 68588292847cSmrg if test none != "$non_pic_object"; then 6859c2939121Smrg # Prepend the subdirectory the object is found in. 68608292847cSmrg non_pic_object=$xdir$non_pic_object 6861c76ae52dSmrg 6862c2939121Smrg # A standard non-PIC object 6863c2939121Smrg func_append non_pic_objects " $non_pic_object" 68648292847cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 68658292847cSmrg arg=$non_pic_object 6866c2939121Smrg fi 6867c2939121Smrg else 6868c2939121Smrg # If the PIC object exists, use it instead. 6869c2939121Smrg # $xdir was prepended to $pic_object above. 68708292847cSmrg non_pic_object=$pic_object 6871c2939121Smrg func_append non_pic_objects " $non_pic_object" 6872c2939121Smrg fi 6873c2939121Smrg else 6874c2939121Smrg # Only an error if not doing a dry-run. 6875c2939121Smrg if $opt_dry_run; then 6876c2939121Smrg # Extract subdirectory from the argument. 6877c2939121Smrg func_dirname "$arg" "/" "" 68788292847cSmrg xdir=$func_dirname_result 6879c2939121Smrg 6880c2939121Smrg func_lo2o "$arg" 6881c2939121Smrg pic_object=$xdir$objdir/$func_lo2o_result 6882c2939121Smrg non_pic_object=$xdir$func_lo2o_result 6883c2939121Smrg func_append libobjs " $pic_object" 6884c2939121Smrg func_append non_pic_objects " $non_pic_object" 6885c2939121Smrg else 68868292847cSmrg func_fatal_error "'$arg' is not a valid libtool object" 6887c2939121Smrg fi 6888c2939121Smrg fi 6889c2939121Smrg done 6890c76ae52dSmrg else 68918292847cSmrg func_fatal_error "link input file '$arg' does not exist" 6892c76ae52dSmrg fi 6893c2939121Smrg arg=$save_arg 6894c2939121Smrg prev= 6895c2939121Smrg continue 6896c2939121Smrg ;; 68978292847cSmrg os2dllname) 68988292847cSmrg os2dllname=$arg 68998292847cSmrg prev= 69008292847cSmrg continue 69018292847cSmrg ;; 6902c2939121Smrg precious_regex) 69038292847cSmrg precious_files_regex=$arg 6904c2939121Smrg prev= 6905c2939121Smrg continue 6906c2939121Smrg ;; 6907c2939121Smrg release) 69088292847cSmrg release=-$arg 6909c2939121Smrg prev= 6910c2939121Smrg continue 6911c2939121Smrg ;; 6912c2939121Smrg rpath | xrpath) 6913c2939121Smrg # We need an absolute path. 6914c2939121Smrg case $arg in 6915c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6916c2939121Smrg *) 6917c2939121Smrg func_fatal_error "only absolute run-paths are allowed" 6918c2939121Smrg ;; 6919c2939121Smrg esac 69208292847cSmrg if test rpath = "$prev"; then 6921c2939121Smrg case "$rpath " in 6922c2939121Smrg *" $arg "*) ;; 69232836776bSmrg *) func_append rpath " $arg" ;; 6924c2939121Smrg esac 6925c76ae52dSmrg else 6926c2939121Smrg case "$xrpath " in 6927c2939121Smrg *" $arg "*) ;; 69282836776bSmrg *) func_append xrpath " $arg" ;; 6929c2939121Smrg esac 6930c76ae52dSmrg fi 6931c2939121Smrg prev= 6932c2939121Smrg continue 6933c2939121Smrg ;; 6934c2939121Smrg shrext) 69358292847cSmrg shrext_cmds=$arg 6936c2939121Smrg prev= 6937c2939121Smrg continue 6938c2939121Smrg ;; 6939c2939121Smrg weak) 69402836776bSmrg func_append weak_libs " $arg" 6941c2939121Smrg prev= 6942c2939121Smrg continue 6943c2939121Smrg ;; 6944c2939121Smrg xcclinker) 69452836776bSmrg func_append linker_flags " $qarg" 69462836776bSmrg func_append compiler_flags " $qarg" 6947c2939121Smrg prev= 6948c2939121Smrg func_append compile_command " $qarg" 6949c2939121Smrg func_append finalize_command " $qarg" 6950c2939121Smrg continue 6951c2939121Smrg ;; 6952c2939121Smrg xcompiler) 69532836776bSmrg func_append compiler_flags " $qarg" 6954c2939121Smrg prev= 6955c2939121Smrg func_append compile_command " $qarg" 6956c2939121Smrg func_append finalize_command " $qarg" 6957c2939121Smrg continue 6958c2939121Smrg ;; 6959c2939121Smrg xlinker) 69602836776bSmrg func_append linker_flags " $qarg" 69612836776bSmrg func_append compiler_flags " $wl$qarg" 6962c2939121Smrg prev= 6963c2939121Smrg func_append compile_command " $wl$qarg" 6964c2939121Smrg func_append finalize_command " $wl$qarg" 6965c2939121Smrg continue 6966c2939121Smrg ;; 6967c2939121Smrg *) 6968c2939121Smrg eval "$prev=\"\$arg\"" 6969c2939121Smrg prev= 6970c2939121Smrg continue 6971c2939121Smrg ;; 6972c76ae52dSmrg esac 6973c2939121Smrg fi # test -n "$prev" 6974c76ae52dSmrg 69758292847cSmrg prevarg=$arg 6976c76ae52dSmrg 6977c2939121Smrg case $arg in 6978c2939121Smrg -all-static) 6979c2939121Smrg if test -n "$link_static_flag"; then 6980c2939121Smrg # See comment for -static flag below, for more details. 6981c2939121Smrg func_append compile_command " $link_static_flag" 6982c2939121Smrg func_append finalize_command " $link_static_flag" 6983c2939121Smrg fi 6984c2939121Smrg continue 6985c2939121Smrg ;; 6986c76ae52dSmrg 6987c2939121Smrg -allow-undefined) 6988c2939121Smrg # FIXME: remove this flag sometime in the future. 69898292847cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6990c2939121Smrg ;; 6991c76ae52dSmrg 6992c2939121Smrg -avoid-version) 6993c2939121Smrg avoid_version=yes 6994c2939121Smrg continue 6995c2939121Smrg ;; 6996c76ae52dSmrg 6997c2939121Smrg -bindir) 6998c2939121Smrg prev=bindir 6999c2939121Smrg continue 7000c2939121Smrg ;; 7001c76ae52dSmrg 7002c2939121Smrg -dlopen) 7003c2939121Smrg prev=dlfiles 7004c2939121Smrg continue 7005c2939121Smrg ;; 7006c76ae52dSmrg 7007c2939121Smrg -dlpreopen) 7008c2939121Smrg prev=dlprefiles 7009c2939121Smrg continue 7010c2939121Smrg ;; 7011c76ae52dSmrg 7012c2939121Smrg -export-dynamic) 7013c2939121Smrg export_dynamic=yes 7014c2939121Smrg continue 7015c2939121Smrg ;; 7016c76ae52dSmrg 7017c2939121Smrg -export-symbols | -export-symbols-regex) 7018c2939121Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7019c2939121Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7020c2939121Smrg fi 70218292847cSmrg if test X-export-symbols = "X$arg"; then 7022c2939121Smrg prev=expsyms 7023c2939121Smrg else 7024c2939121Smrg prev=expsyms_regex 7025c2939121Smrg fi 7026c2939121Smrg continue 7027c2939121Smrg ;; 7028c76ae52dSmrg 7029c2939121Smrg -framework) 7030c2939121Smrg prev=framework 7031c2939121Smrg continue 7032c2939121Smrg ;; 7033c76ae52dSmrg 7034c2939121Smrg -inst-prefix-dir) 7035c2939121Smrg prev=inst_prefix 7036c2939121Smrg continue 7037c2939121Smrg ;; 7038c76ae52dSmrg 7039c2939121Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7040c2939121Smrg # so, if we see these flags be careful not to treat them like -L 7041c2939121Smrg -L[A-Z][A-Z]*:*) 7042c2939121Smrg case $with_gcc/$host in 7043c2939121Smrg no/*-*-irix* | /*-*-irix*) 7044c2939121Smrg func_append compile_command " $arg" 7045c2939121Smrg func_append finalize_command " $arg" 7046c2939121Smrg ;; 7047c2939121Smrg esac 7048c2939121Smrg continue 7049c2939121Smrg ;; 7050c76ae52dSmrg 7051c2939121Smrg -L*) 70522836776bSmrg func_stripname "-L" '' "$arg" 70532836776bSmrg if test -z "$func_stripname_result"; then 7054c2939121Smrg if test "$#" -gt 0; then 70558292847cSmrg func_fatal_error "require no space between '-L' and '$1'" 7056c2939121Smrg else 70578292847cSmrg func_fatal_error "need path for '-L' option" 7058c2939121Smrg fi 7059c2939121Smrg fi 70602836776bSmrg func_resolve_sysroot "$func_stripname_result" 70612836776bSmrg dir=$func_resolve_sysroot_result 7062c2939121Smrg # We need an absolute path. 7063c2939121Smrg case $dir in 7064c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7065c2939121Smrg *) 7066c2939121Smrg absdir=`cd "$dir" && pwd` 7067c2939121Smrg test -z "$absdir" && \ 70688292847cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 70698292847cSmrg dir=$absdir 7070c2939121Smrg ;; 7071c2939121Smrg esac 7072c2939121Smrg case "$deplibs " in 70732836776bSmrg *" -L$dir "* | *" $arg "*) 70742836776bSmrg # Will only happen for absolute or sysroot arguments 70752836776bSmrg ;; 7076c2939121Smrg *) 70772836776bSmrg # Preserve sysroot, but never include relative directories 70782836776bSmrg case $dir in 70792836776bSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 70802836776bSmrg *) func_append deplibs " -L$dir" ;; 70812836776bSmrg esac 70822836776bSmrg func_append lib_search_path " $dir" 7083c2939121Smrg ;; 7084c2939121Smrg esac 7085c2939121Smrg case $host in 7086c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7087c2939121Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7088c2939121Smrg case :$dllsearchpath: in 7089c2939121Smrg *":$dir:"*) ;; 7090c2939121Smrg ::) dllsearchpath=$dir;; 70912836776bSmrg *) func_append dllsearchpath ":$dir";; 7092c2939121Smrg esac 7093c2939121Smrg case :$dllsearchpath: in 7094c2939121Smrg *":$testbindir:"*) ;; 7095c2939121Smrg ::) dllsearchpath=$testbindir;; 70962836776bSmrg *) func_append dllsearchpath ":$testbindir";; 7097c2939121Smrg esac 7098c2939121Smrg ;; 7099c2939121Smrg esac 7100c2939121Smrg continue 7101c2939121Smrg ;; 7102c76ae52dSmrg 7103c2939121Smrg -l*) 71048292847cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7105c2939121Smrg case $host in 7106c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7107c2939121Smrg # These systems don't actually have a C or math library (as such) 7108c2939121Smrg continue 7109c2939121Smrg ;; 7110c2939121Smrg *-*-os2*) 7111c2939121Smrg # These systems don't actually have a C library (as such) 71128292847cSmrg test X-lc = "X$arg" && continue 7113c2939121Smrg ;; 71148292847cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7115c2939121Smrg # Do not include libc due to us having libc/libc_r. 71168292847cSmrg test X-lc = "X$arg" && continue 7117c2939121Smrg ;; 7118c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7119c2939121Smrg # Rhapsody C and math libraries are in the System framework 71202836776bSmrg func_append deplibs " System.ltframework" 7121c2939121Smrg continue 7122c2939121Smrg ;; 7123c2939121Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7124c2939121Smrg # Causes problems with __ctype 71258292847cSmrg test X-lc = "X$arg" && continue 7126c2939121Smrg ;; 7127c2939121Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7128c2939121Smrg # Compiler inserts libc in the correct place for threads to work 71298292847cSmrg test X-lc = "X$arg" && continue 7130c2939121Smrg ;; 7131c2939121Smrg esac 71328292847cSmrg elif test X-lc_r = "X$arg"; then 7133c2939121Smrg case $host in 71348292847cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7135c2939121Smrg # Do not include libc_r directly, use -pthread flag. 7136c2939121Smrg continue 7137c2939121Smrg ;; 7138c2939121Smrg esac 7139c2939121Smrg fi 71402836776bSmrg func_append deplibs " $arg" 7141c2939121Smrg continue 7142c2939121Smrg ;; 7143c76ae52dSmrg 71448292847cSmrg -mllvm) 71458292847cSmrg prev=mllvm 71468292847cSmrg continue 71478292847cSmrg ;; 71488292847cSmrg 7149c2939121Smrg -module) 7150c2939121Smrg module=yes 7151c2939121Smrg continue 7152c2939121Smrg ;; 7153c76ae52dSmrg 7154c2939121Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7155c2939121Smrg # classes, name mangling, and exception handling. 7156c2939121Smrg # Darwin uses the -arch flag to determine output architecture. 71572836776bSmrg -model|-arch|-isysroot|--sysroot) 71582836776bSmrg func_append compiler_flags " $arg" 7159c2939121Smrg func_append compile_command " $arg" 7160c2939121Smrg func_append finalize_command " $arg" 7161c2939121Smrg prev=xcompiler 7162c2939121Smrg continue 7163c2939121Smrg ;; 7164c76ae52dSmrg 71652836776bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 71662836776bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 71672836776bSmrg func_append compiler_flags " $arg" 7168c2939121Smrg func_append compile_command " $arg" 7169c2939121Smrg func_append finalize_command " $arg" 7170c2939121Smrg case "$new_inherited_linker_flags " in 7171c2939121Smrg *" $arg "*) ;; 71722836776bSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7173c2939121Smrg esac 7174c2939121Smrg continue 7175c2939121Smrg ;; 7176c76ae52dSmrg 7177c2939121Smrg -multi_module) 71788292847cSmrg single_module=$wl-multi_module 7179c2939121Smrg continue 7180c2939121Smrg ;; 7181c76ae52dSmrg 7182c2939121Smrg -no-fast-install) 7183c2939121Smrg fast_install=no 7184c2939121Smrg continue 7185c2939121Smrg ;; 7186c76ae52dSmrg 7187c2939121Smrg -no-install) 7188c2939121Smrg case $host in 7189c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7190c2939121Smrg # The PATH hackery in wrapper scripts is required on Windows 7191c2939121Smrg # and Darwin in order for the loader to find any dlls it needs. 71928292847cSmrg func_warning "'-no-install' is ignored for $host" 71938292847cSmrg func_warning "assuming '-no-fast-install' instead" 7194c2939121Smrg fast_install=no 7195c2939121Smrg ;; 7196c2939121Smrg *) no_install=yes ;; 7197c2939121Smrg esac 7198c2939121Smrg continue 7199c2939121Smrg ;; 7200c76ae52dSmrg 7201c2939121Smrg -no-undefined) 7202c2939121Smrg allow_undefined=no 7203c2939121Smrg continue 7204c2939121Smrg ;; 7205c76ae52dSmrg 7206c2939121Smrg -objectlist) 7207c2939121Smrg prev=objectlist 7208c2939121Smrg continue 7209c2939121Smrg ;; 7210c76ae52dSmrg 72118292847cSmrg -os2dllname) 72128292847cSmrg prev=os2dllname 72138292847cSmrg continue 72148292847cSmrg ;; 72158292847cSmrg 7216c2939121Smrg -o) prev=output ;; 7217c76ae52dSmrg 7218c2939121Smrg -precious-files-regex) 7219c2939121Smrg prev=precious_regex 7220c2939121Smrg continue 7221c2939121Smrg ;; 7222c76ae52dSmrg 7223c2939121Smrg -release) 7224c2939121Smrg prev=release 7225c2939121Smrg continue 7226c2939121Smrg ;; 7227c76ae52dSmrg 7228c2939121Smrg -rpath) 7229c2939121Smrg prev=rpath 7230c2939121Smrg continue 7231c2939121Smrg ;; 7232c76ae52dSmrg 7233c2939121Smrg -R) 7234c2939121Smrg prev=xrpath 7235c2939121Smrg continue 7236c2939121Smrg ;; 7237c76ae52dSmrg 7238c2939121Smrg -R*) 7239c2939121Smrg func_stripname '-R' '' "$arg" 7240c2939121Smrg dir=$func_stripname_result 7241c2939121Smrg # We need an absolute path. 7242c2939121Smrg case $dir in 7243c2939121Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72442836776bSmrg =*) 72452836776bSmrg func_stripname '=' '' "$dir" 72462836776bSmrg dir=$lt_sysroot$func_stripname_result 72472836776bSmrg ;; 7248c2939121Smrg *) 7249c2939121Smrg func_fatal_error "only absolute run-paths are allowed" 7250c2939121Smrg ;; 7251c2939121Smrg esac 7252c2939121Smrg case "$xrpath " in 7253c2939121Smrg *" $dir "*) ;; 72542836776bSmrg *) func_append xrpath " $dir" ;; 7255c2939121Smrg esac 7256c2939121Smrg continue 7257c2939121Smrg ;; 7258c76ae52dSmrg 7259c2939121Smrg -shared) 7260c2939121Smrg # The effects of -shared are defined in a previous loop. 7261c2939121Smrg continue 7262c2939121Smrg ;; 7263c76ae52dSmrg 7264c2939121Smrg -shrext) 7265c2939121Smrg prev=shrext 7266c2939121Smrg continue 7267c2939121Smrg ;; 7268c76ae52dSmrg 7269c2939121Smrg -static | -static-libtool-libs) 7270c2939121Smrg # The effects of -static are defined in a previous loop. 7271c2939121Smrg # We used to do the same as -all-static on platforms that 7272c2939121Smrg # didn't have a PIC flag, but the assumption that the effects 7273c2939121Smrg # would be equivalent was wrong. It would break on at least 7274c2939121Smrg # Digital Unix and AIX. 7275c2939121Smrg continue 7276c2939121Smrg ;; 7277c76ae52dSmrg 7278c2939121Smrg -thread-safe) 7279c2939121Smrg thread_safe=yes 7280c2939121Smrg continue 7281c2939121Smrg ;; 7282c76ae52dSmrg 7283c2939121Smrg -version-info) 7284c2939121Smrg prev=vinfo 7285c2939121Smrg continue 7286c2939121Smrg ;; 7287c76ae52dSmrg 7288c2939121Smrg -version-number) 7289c2939121Smrg prev=vinfo 7290c2939121Smrg vinfo_number=yes 7291c2939121Smrg continue 7292c2939121Smrg ;; 7293c76ae52dSmrg 7294c2939121Smrg -weak) 7295c2939121Smrg prev=weak 7296c2939121Smrg continue 7297c2939121Smrg ;; 7298c76ae52dSmrg 7299c2939121Smrg -Wc,*) 7300c2939121Smrg func_stripname '-Wc,' '' "$arg" 7301c2939121Smrg args=$func_stripname_result 7302c2939121Smrg arg= 73038292847cSmrg save_ifs=$IFS; IFS=, 7304c2939121Smrg for flag in $args; do 73058292847cSmrg IFS=$save_ifs 7306c2939121Smrg func_quote_for_eval "$flag" 73072836776bSmrg func_append arg " $func_quote_for_eval_result" 73082836776bSmrg func_append compiler_flags " $func_quote_for_eval_result" 7309c2939121Smrg done 73108292847cSmrg IFS=$save_ifs 7311c2939121Smrg func_stripname ' ' '' "$arg" 7312c2939121Smrg arg=$func_stripname_result 7313c2939121Smrg ;; 7314c76ae52dSmrg 7315c2939121Smrg -Wl,*) 7316c2939121Smrg func_stripname '-Wl,' '' "$arg" 7317c2939121Smrg args=$func_stripname_result 7318c2939121Smrg arg= 73198292847cSmrg save_ifs=$IFS; IFS=, 7320c2939121Smrg for flag in $args; do 73218292847cSmrg IFS=$save_ifs 7322c2939121Smrg func_quote_for_eval "$flag" 73232836776bSmrg func_append arg " $wl$func_quote_for_eval_result" 73242836776bSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 73252836776bSmrg func_append linker_flags " $func_quote_for_eval_result" 7326c2939121Smrg done 73278292847cSmrg IFS=$save_ifs 7328c2939121Smrg func_stripname ' ' '' "$arg" 7329c2939121Smrg arg=$func_stripname_result 7330c2939121Smrg ;; 7331c76ae52dSmrg 7332c2939121Smrg -Xcompiler) 7333c2939121Smrg prev=xcompiler 7334c2939121Smrg continue 7335c2939121Smrg ;; 7336c76ae52dSmrg 7337c2939121Smrg -Xlinker) 7338c2939121Smrg prev=xlinker 7339c2939121Smrg continue 7340c2939121Smrg ;; 7341c76ae52dSmrg 7342c2939121Smrg -XCClinker) 7343c2939121Smrg prev=xcclinker 7344c2939121Smrg continue 7345c2939121Smrg ;; 7346c76ae52dSmrg 7347c2939121Smrg # -msg_* for osf cc 7348c2939121Smrg -msg_*) 7349c2939121Smrg func_quote_for_eval "$arg" 73508292847cSmrg arg=$func_quote_for_eval_result 7351c2939121Smrg ;; 7352c76ae52dSmrg 7353c2939121Smrg # Flags to be passed through unchanged, with rationale: 7354c2939121Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7355c2939121Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7356c2939121Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7357c2939121Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7358c2939121Smrg # -q* compiler args for the IBM compiler 7359c2939121Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7360c2939121Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7361c2939121Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 73628292847cSmrg # -fstack-protector* stack protector flags for GCC 7363c2939121Smrg # @file GCC response files 7364c2939121Smrg # -tp=* Portland pgcc target processor selection 73652836776bSmrg # --sysroot=* for sysroot support 73668292847cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7367de3c0529Smrg # -specs=* GCC specs files 73688292847cSmrg # -stdlib=* select c++ std lib with clang 7369de3c0529Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7370de3c0529Smrg # -fuse-ld=* Linker select flags for GCC 7371c2939121Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 73722836776bSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7373de3c0529Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7374de3c0529Smrg -specs=*|-fsanitize=*|-fuse-ld=*) 7375c2939121Smrg func_quote_for_eval "$arg" 73768292847cSmrg arg=$func_quote_for_eval_result 7377c2939121Smrg func_append compile_command " $arg" 7378c2939121Smrg func_append finalize_command " $arg" 73792836776bSmrg func_append compiler_flags " $arg" 7380c2939121Smrg continue 7381c2939121Smrg ;; 7382c76ae52dSmrg 73838292847cSmrg -Z*) 73848292847cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 73858292847cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 73868292847cSmrg compiler_flags="$compiler_flags $arg" 73878292847cSmrg func_append compile_command " $arg" 73888292847cSmrg func_append finalize_command " $arg" 73898292847cSmrg case $arg in 73908292847cSmrg -Zlinker | -Zstack) 73918292847cSmrg prev=xcompiler 73928292847cSmrg ;; 73938292847cSmrg esac 73948292847cSmrg continue 73958292847cSmrg else 73968292847cSmrg # Otherwise treat like 'Some other compiler flag' below 73978292847cSmrg func_quote_for_eval "$arg" 73988292847cSmrg arg=$func_quote_for_eval_result 73998292847cSmrg fi 74008292847cSmrg ;; 74018292847cSmrg 7402c2939121Smrg # Some other compiler flag. 7403c2939121Smrg -* | +*) 7404c2939121Smrg func_quote_for_eval "$arg" 74058292847cSmrg arg=$func_quote_for_eval_result 7406c2939121Smrg ;; 7407c76ae52dSmrg 7408c2939121Smrg *.$objext) 7409c2939121Smrg # A standard object. 74102836776bSmrg func_append objs " $arg" 7411c2939121Smrg ;; 7412c76ae52dSmrg 7413c2939121Smrg *.lo) 7414c2939121Smrg # A libtool-controlled object. 7415c76ae52dSmrg 7416c2939121Smrg # Check to see that this really is a libtool object. 7417c2939121Smrg if func_lalib_unsafe_p "$arg"; then 7418c2939121Smrg pic_object= 7419c2939121Smrg non_pic_object= 7420c76ae52dSmrg 7421c2939121Smrg # Read the .lo file 7422c2939121Smrg func_source "$arg" 7423c76ae52dSmrg 7424c2939121Smrg if test -z "$pic_object" || 7425c2939121Smrg test -z "$non_pic_object" || 74268292847cSmrg test none = "$pic_object" && 74278292847cSmrg test none = "$non_pic_object"; then 74288292847cSmrg func_fatal_error "cannot find name of object for '$arg'" 7429c2939121Smrg fi 74300d590c07Smrg 7431c2939121Smrg # Extract subdirectory from the argument. 7432c2939121Smrg func_dirname "$arg" "/" "" 74338292847cSmrg xdir=$func_dirname_result 7434c76ae52dSmrg 74358292847cSmrg test none = "$pic_object" || { 7436c2939121Smrg # Prepend the subdirectory the object is found in. 74378292847cSmrg pic_object=$xdir$pic_object 7438c76ae52dSmrg 74398292847cSmrg if test dlfiles = "$prev"; then 74408292847cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 74412836776bSmrg func_append dlfiles " $pic_object" 7442c2939121Smrg prev= 7443c2939121Smrg continue 7444c2939121Smrg else 7445c2939121Smrg # If libtool objects are unsupported, then we need to preload. 7446c2939121Smrg prev=dlprefiles 7447c2939121Smrg fi 7448c2939121Smrg fi 7449c2939121Smrg 7450c2939121Smrg # CHECK ME: I think I busted this. -Ossama 74518292847cSmrg if test dlprefiles = "$prev"; then 7452c2939121Smrg # Preload the old-style object. 74532836776bSmrg func_append dlprefiles " $pic_object" 7454c2939121Smrg prev= 7455c2939121Smrg fi 7456c2939121Smrg 7457c2939121Smrg # A PIC object. 7458c2939121Smrg func_append libobjs " $pic_object" 74598292847cSmrg arg=$pic_object 74608292847cSmrg } 7461c2939121Smrg 7462c2939121Smrg # Non-PIC object. 74638292847cSmrg if test none != "$non_pic_object"; then 7464c2939121Smrg # Prepend the subdirectory the object is found in. 74658292847cSmrg non_pic_object=$xdir$non_pic_object 7466c2939121Smrg 7467c2939121Smrg # A standard non-PIC object 7468c2939121Smrg func_append non_pic_objects " $non_pic_object" 74698292847cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 74708292847cSmrg arg=$non_pic_object 7471c2939121Smrg fi 7472c2939121Smrg else 7473c2939121Smrg # If the PIC object exists, use it instead. 7474c2939121Smrg # $xdir was prepended to $pic_object above. 74758292847cSmrg non_pic_object=$pic_object 7476c2939121Smrg func_append non_pic_objects " $non_pic_object" 7477c2939121Smrg fi 7478c2939121Smrg else 7479c2939121Smrg # Only an error if not doing a dry-run. 7480c2939121Smrg if $opt_dry_run; then 7481c2939121Smrg # Extract subdirectory from the argument. 7482c2939121Smrg func_dirname "$arg" "/" "" 74838292847cSmrg xdir=$func_dirname_result 7484c2939121Smrg 7485c2939121Smrg func_lo2o "$arg" 7486c2939121Smrg pic_object=$xdir$objdir/$func_lo2o_result 7487c2939121Smrg non_pic_object=$xdir$func_lo2o_result 7488c2939121Smrg func_append libobjs " $pic_object" 7489c2939121Smrg func_append non_pic_objects " $non_pic_object" 7490c2939121Smrg else 74918292847cSmrg func_fatal_error "'$arg' is not a valid libtool object" 7492c2939121Smrg fi 7493c2939121Smrg fi 7494c2939121Smrg ;; 7495c2939121Smrg 7496c2939121Smrg *.$libext) 7497c2939121Smrg # An archive. 74982836776bSmrg func_append deplibs " $arg" 74992836776bSmrg func_append old_deplibs " $arg" 7500c2939121Smrg continue 7501c2939121Smrg ;; 7502c2939121Smrg 7503c2939121Smrg *.la) 7504c2939121Smrg # A libtool-controlled library. 7505c2939121Smrg 75062836776bSmrg func_resolve_sysroot "$arg" 75078292847cSmrg if test dlfiles = "$prev"; then 7508c2939121Smrg # This library was specified with -dlopen. 75092836776bSmrg func_append dlfiles " $func_resolve_sysroot_result" 7510c2939121Smrg prev= 75118292847cSmrg elif test dlprefiles = "$prev"; then 7512c2939121Smrg # The library was specified with -dlpreopen. 75132836776bSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7514c2939121Smrg prev= 7515c2939121Smrg else 75162836776bSmrg func_append deplibs " $func_resolve_sysroot_result" 7517c2939121Smrg fi 7518c2939121Smrg continue 7519c2939121Smrg ;; 7520c2939121Smrg 7521c2939121Smrg # Some other compiler argument. 7522c2939121Smrg *) 7523c2939121Smrg # Unknown arguments in both finalize_command and compile_command need 7524c2939121Smrg # to be aesthetically quoted because they are evaled later. 7525c2939121Smrg func_quote_for_eval "$arg" 75268292847cSmrg arg=$func_quote_for_eval_result 7527c2939121Smrg ;; 7528c2939121Smrg esac # arg 7529c2939121Smrg 7530c2939121Smrg # Now actually substitute the argument into the commands. 7531c2939121Smrg if test -n "$arg"; then 7532c2939121Smrg func_append compile_command " $arg" 7533c2939121Smrg func_append finalize_command " $arg" 7534c2939121Smrg fi 7535c2939121Smrg done # argument parsing loop 7536c2939121Smrg 7537c2939121Smrg test -n "$prev" && \ 75388292847cSmrg func_fatal_help "the '$prevarg' option requires an argument" 7539c2939121Smrg 75408292847cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7541c2939121Smrg eval arg=\"$export_dynamic_flag_spec\" 7542c2939121Smrg func_append compile_command " $arg" 7543c2939121Smrg func_append finalize_command " $arg" 7544c2939121Smrg fi 7545c2939121Smrg 7546c2939121Smrg oldlibs= 7547c2939121Smrg # calculate the name of the file, without its directory 7548c2939121Smrg func_basename "$output" 75498292847cSmrg outputname=$func_basename_result 75508292847cSmrg libobjs_save=$libobjs 7551c2939121Smrg 7552c2939121Smrg if test -n "$shlibpath_var"; then 7553c2939121Smrg # get the directories listed in $shlibpath_var 75548292847cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7555c76ae52dSmrg else 7556c2939121Smrg shlib_search_path= 7557c76ae52dSmrg fi 7558c2939121Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7559c2939121Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7560c76ae52dSmrg 75618292847cSmrg # Definition is injected by LT_CONFIG during libtool generation. 75628292847cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 75638292847cSmrg 7564c2939121Smrg func_dirname "$output" "/" "" 75658292847cSmrg output_objdir=$func_dirname_result$objdir 75662836776bSmrg func_to_tool_file "$output_objdir/" 75672836776bSmrg tool_output_objdir=$func_to_tool_file_result 7568c2939121Smrg # Create the object directory. 7569c2939121Smrg func_mkdir_p "$output_objdir" 7570c76ae52dSmrg 7571c2939121Smrg # Determine the type of output 7572c2939121Smrg case $output in 7573c2939121Smrg "") 7574c2939121Smrg func_fatal_help "you must specify an output file" 7575c2939121Smrg ;; 7576c2939121Smrg *.$libext) linkmode=oldlib ;; 7577c2939121Smrg *.lo | *.$objext) linkmode=obj ;; 7578c2939121Smrg *.la) linkmode=lib ;; 7579c2939121Smrg *) linkmode=prog ;; # Anything else should be a program. 7580c2939121Smrg esac 7581c2939121Smrg 7582c2939121Smrg specialdeplibs= 7583c2939121Smrg 7584c2939121Smrg libs= 7585c2939121Smrg # Find all interdependent deplibs by searching for libraries 7586c2939121Smrg # that are linked more than once (e.g. -la -lb -la) 7587c2939121Smrg for deplib in $deplibs; do 75888292847cSmrg if $opt_preserve_dup_deps; then 7589c2939121Smrg case "$libs " in 75902836776bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7591c2939121Smrg esac 7592c2939121Smrg fi 75932836776bSmrg func_append libs " $deplib" 7594c2939121Smrg done 7595c2939121Smrg 75968292847cSmrg if test lib = "$linkmode"; then 7597c2939121Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7598c2939121Smrg 7599c2939121Smrg # Compute libraries that are listed more than once in $predeps 7600c2939121Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7601c2939121Smrg # not to be eliminated). 7602c2939121Smrg pre_post_deps= 7603c2939121Smrg if $opt_duplicate_compiler_generated_deps; then 7604c2939121Smrg for pre_post_dep in $predeps $postdeps; do 7605c2939121Smrg case "$pre_post_deps " in 76062836776bSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7607c2939121Smrg esac 76082836776bSmrg func_append pre_post_deps " $pre_post_dep" 7609c2939121Smrg done 7610c2939121Smrg fi 7611c2939121Smrg pre_post_deps= 7612c2939121Smrg fi 7613c2939121Smrg 7614c2939121Smrg deplibs= 7615c2939121Smrg newdependency_libs= 7616c2939121Smrg newlib_search_path= 7617c2939121Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7618c2939121Smrg notinst_deplibs= # not-installed libtool libraries 7619c2939121Smrg notinst_path= # paths that contain not-installed libtool libraries 7620c2939121Smrg 7621c2939121Smrg case $linkmode in 7622c2939121Smrg lib) 7623c2939121Smrg passes="conv dlpreopen link" 7624c2939121Smrg for file in $dlfiles $dlprefiles; do 7625c2939121Smrg case $file in 7626c2939121Smrg *.la) ;; 7627c2939121Smrg *) 76288292847cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7629c2939121Smrg ;; 7630c2939121Smrg esac 7631c2939121Smrg done 7632c2939121Smrg ;; 7633c2939121Smrg prog) 7634c2939121Smrg compile_deplibs= 7635c2939121Smrg finalize_deplibs= 76368292847cSmrg alldeplibs=false 7637c2939121Smrg newdlfiles= 7638c2939121Smrg newdlprefiles= 7639c2939121Smrg passes="conv scan dlopen dlpreopen link" 7640c2939121Smrg ;; 7641c2939121Smrg *) passes="conv" 7642c2939121Smrg ;; 7643c2939121Smrg esac 7644c2939121Smrg 7645c2939121Smrg for pass in $passes; do 7646c2939121Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7647c2939121Smrg # so that -L comes before libs that need it for instance... 76488292847cSmrg if test lib,link = "$linkmode,$pass"; then 7649c2939121Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7650c2939121Smrg ## order, and fix it there properly 7651c2939121Smrg tmp_deplibs= 7652c2939121Smrg for deplib in $deplibs; do 7653c2939121Smrg tmp_deplibs="$deplib $tmp_deplibs" 7654c2939121Smrg done 76558292847cSmrg deplibs=$tmp_deplibs 7656c2939121Smrg fi 7657c2939121Smrg 76588292847cSmrg if test lib,link = "$linkmode,$pass" || 76598292847cSmrg test prog,scan = "$linkmode,$pass"; then 76608292847cSmrg libs=$deplibs 7661c2939121Smrg deplibs= 7662c2939121Smrg fi 76638292847cSmrg if test prog = "$linkmode"; then 7664c2939121Smrg case $pass in 76658292847cSmrg dlopen) libs=$dlfiles ;; 76668292847cSmrg dlpreopen) libs=$dlprefiles ;; 7667de3c0529Smrg link) 7668de3c0529Smrg libs="$deplibs %DEPLIBS%" 7669de3c0529Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 7670de3c0529Smrg ;; 7671c2939121Smrg esac 7672c2939121Smrg fi 76738292847cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7674c2939121Smrg # Collect and forward deplibs of preopened libtool libs 7675c2939121Smrg for lib in $dlprefiles; do 7676c2939121Smrg # Ignore non-libtool-libs 7677c2939121Smrg dependency_libs= 76782836776bSmrg func_resolve_sysroot "$lib" 7679c2939121Smrg case $lib in 76802836776bSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7681c2939121Smrg esac 7682c2939121Smrg 7683c2939121Smrg # Collect preopened libtool deplibs, except any this library 7684c2939121Smrg # has declared as weak libs 7685c2939121Smrg for deplib in $dependency_libs; do 7686c2939121Smrg func_basename "$deplib" 7687c2939121Smrg deplib_base=$func_basename_result 7688c2939121Smrg case " $weak_libs " in 7689c2939121Smrg *" $deplib_base "*) ;; 76902836776bSmrg *) func_append deplibs " $deplib" ;; 7691c2939121Smrg esac 7692c2939121Smrg done 7693c2939121Smrg done 76948292847cSmrg libs=$dlprefiles 7695c2939121Smrg fi 76968292847cSmrg if test dlopen = "$pass"; then 7697c2939121Smrg # Collect dlpreopened libraries 76988292847cSmrg save_deplibs=$deplibs 7699c2939121Smrg deplibs= 7700c2939121Smrg fi 7701c2939121Smrg 7702c2939121Smrg for deplib in $libs; do 7703c2939121Smrg lib= 77048292847cSmrg found=false 7705c2939121Smrg case $deplib in 77062836776bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 77072836776bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 77088292847cSmrg if test prog,link = "$linkmode,$pass"; then 7709c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7710c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7711c2939121Smrg else 77122836776bSmrg func_append compiler_flags " $deplib" 77138292847cSmrg if test lib = "$linkmode"; then 7714c2939121Smrg case "$new_inherited_linker_flags " in 7715c2939121Smrg *" $deplib "*) ;; 77162836776bSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7717c2939121Smrg esac 7718c2939121Smrg fi 7719c2939121Smrg fi 7720c2939121Smrg continue 7721c2939121Smrg ;; 7722c2939121Smrg -l*) 77238292847cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 77248292847cSmrg func_warning "'-l' is ignored for archives/objects" 7725c2939121Smrg continue 7726c2939121Smrg fi 7727c2939121Smrg func_stripname '-l' '' "$deplib" 7728c2939121Smrg name=$func_stripname_result 77298292847cSmrg if test lib = "$linkmode"; then 7730c2939121Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7731c2939121Smrg else 7732c2939121Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7733c2939121Smrg fi 7734c2939121Smrg for searchdir in $searchdirs; do 7735c2939121Smrg for search_ext in .la $std_shrext .so .a; do 7736c2939121Smrg # Search the libtool library 77378292847cSmrg lib=$searchdir/lib$name$search_ext 7738c2939121Smrg if test -f "$lib"; then 77398292847cSmrg if test .la = "$search_ext"; then 77408292847cSmrg found=: 7741c2939121Smrg else 77428292847cSmrg found=false 7743c2939121Smrg fi 7744c2939121Smrg break 2 7745c2939121Smrg fi 7746c2939121Smrg done 7747c2939121Smrg done 77488292847cSmrg if $found; then 77498292847cSmrg # deplib is a libtool library 7750c2939121Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7751c2939121Smrg # We need to do some special things here, and not later. 77528292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7753c2939121Smrg case " $predeps $postdeps " in 7754c2939121Smrg *" $deplib "*) 7755c2939121Smrg if func_lalib_p "$lib"; then 7756c2939121Smrg library_names= 7757c2939121Smrg old_library= 7758c2939121Smrg func_source "$lib" 7759c2939121Smrg for l in $old_library $library_names; do 77608292847cSmrg ll=$l 7761c2939121Smrg done 77628292847cSmrg if test "X$ll" = "X$old_library"; then # only static version available 77638292847cSmrg found=false 7764c2939121Smrg func_dirname "$lib" "" "." 77658292847cSmrg ladir=$func_dirname_result 7766c2939121Smrg lib=$ladir/$old_library 77678292847cSmrg if test prog,link = "$linkmode,$pass"; then 7768c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7769c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7770c2939121Smrg else 7771c2939121Smrg deplibs="$deplib $deplibs" 77728292847cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7773c2939121Smrg fi 7774c2939121Smrg continue 7775c2939121Smrg fi 7776c2939121Smrg fi 7777c2939121Smrg ;; 7778c2939121Smrg *) ;; 7779c2939121Smrg esac 7780c2939121Smrg fi 77818292847cSmrg else 77828292847cSmrg # deplib doesn't seem to be a libtool library 77838292847cSmrg if test prog,link = "$linkmode,$pass"; then 77848292847cSmrg compile_deplibs="$deplib $compile_deplibs" 77858292847cSmrg finalize_deplibs="$deplib $finalize_deplibs" 77868292847cSmrg else 77878292847cSmrg deplibs="$deplib $deplibs" 77888292847cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 77898292847cSmrg fi 77908292847cSmrg continue 7791c2939121Smrg fi 7792c2939121Smrg ;; # -l 7793c2939121Smrg *.ltframework) 77948292847cSmrg if test prog,link = "$linkmode,$pass"; then 7795c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7796c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7797c2939121Smrg else 7798c2939121Smrg deplibs="$deplib $deplibs" 77998292847cSmrg if test lib = "$linkmode"; then 7800c2939121Smrg case "$new_inherited_linker_flags " in 7801c2939121Smrg *" $deplib "*) ;; 78022836776bSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7803c2939121Smrg esac 7804c2939121Smrg fi 7805c2939121Smrg fi 7806c2939121Smrg continue 7807c2939121Smrg ;; 7808c2939121Smrg -L*) 7809c2939121Smrg case $linkmode in 7810c2939121Smrg lib) 7811c2939121Smrg deplibs="$deplib $deplibs" 78128292847cSmrg test conv = "$pass" && continue 7813c2939121Smrg newdependency_libs="$deplib $newdependency_libs" 7814c2939121Smrg func_stripname '-L' '' "$deplib" 78152836776bSmrg func_resolve_sysroot "$func_stripname_result" 78162836776bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7817c2939121Smrg ;; 7818c2939121Smrg prog) 78198292847cSmrg if test conv = "$pass"; then 7820c2939121Smrg deplibs="$deplib $deplibs" 7821c2939121Smrg continue 7822c2939121Smrg fi 78238292847cSmrg if test scan = "$pass"; then 7824c2939121Smrg deplibs="$deplib $deplibs" 7825c2939121Smrg else 7826c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7827c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7828c2939121Smrg fi 7829c2939121Smrg func_stripname '-L' '' "$deplib" 78302836776bSmrg func_resolve_sysroot "$func_stripname_result" 78312836776bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7832c2939121Smrg ;; 7833c2939121Smrg *) 78348292847cSmrg func_warning "'-L' is ignored for archives/objects" 7835c2939121Smrg ;; 7836c2939121Smrg esac # linkmode 7837c2939121Smrg continue 7838c2939121Smrg ;; # -L 7839c2939121Smrg -R*) 78408292847cSmrg if test link = "$pass"; then 7841c2939121Smrg func_stripname '-R' '' "$deplib" 78422836776bSmrg func_resolve_sysroot "$func_stripname_result" 78432836776bSmrg dir=$func_resolve_sysroot_result 7844c2939121Smrg # Make sure the xrpath contains only unique directories. 7845c2939121Smrg case "$xrpath " in 7846c2939121Smrg *" $dir "*) ;; 78472836776bSmrg *) func_append xrpath " $dir" ;; 7848c2939121Smrg esac 7849c2939121Smrg fi 7850c2939121Smrg deplibs="$deplib $deplibs" 7851c2939121Smrg continue 7852c2939121Smrg ;; 78532836776bSmrg *.la) 78542836776bSmrg func_resolve_sysroot "$deplib" 78552836776bSmrg lib=$func_resolve_sysroot_result 78562836776bSmrg ;; 7857c2939121Smrg *.$libext) 78588292847cSmrg if test conv = "$pass"; then 7859c2939121Smrg deplibs="$deplib $deplibs" 7860c2939121Smrg continue 7861c2939121Smrg fi 7862c2939121Smrg case $linkmode in 7863c2939121Smrg lib) 7864c2939121Smrg # Linking convenience modules into shared libraries is allowed, 7865c2939121Smrg # but linking other static libraries is non-portable. 7866c2939121Smrg case " $dlpreconveniencelibs " in 7867c2939121Smrg *" $deplib "*) ;; 7868c2939121Smrg *) 78698292847cSmrg valid_a_lib=false 7870c2939121Smrg case $deplibs_check_method in 7871c2939121Smrg match_pattern*) 7872c2939121Smrg set dummy $deplibs_check_method; shift 7873c2939121Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7874c2939121Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7875c2939121Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 78768292847cSmrg valid_a_lib=: 7877c2939121Smrg fi 7878c2939121Smrg ;; 7879c2939121Smrg pass_all) 78808292847cSmrg valid_a_lib=: 7881c2939121Smrg ;; 7882c2939121Smrg esac 78838292847cSmrg if $valid_a_lib; then 78848292847cSmrg echo 78858292847cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 78868292847cSmrg $ECHO "*** static library $deplib is not portable!" 78878292847cSmrg deplibs="$deplib $deplibs" 78888292847cSmrg else 7889c2939121Smrg echo 7890c2939121Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7891c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 7892c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 7893c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 7894c2939121Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 7895c2939121Smrg echo "*** that it is just a static archive that I should not use here." 7896c2939121Smrg fi 7897c2939121Smrg ;; 7898c2939121Smrg esac 7899c2939121Smrg continue 7900c2939121Smrg ;; 7901c2939121Smrg prog) 79028292847cSmrg if test link != "$pass"; then 7903c2939121Smrg deplibs="$deplib $deplibs" 7904c2939121Smrg else 7905c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7906c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7907c2939121Smrg fi 7908c2939121Smrg continue 7909c2939121Smrg ;; 7910c2939121Smrg esac # linkmode 7911c2939121Smrg ;; # *.$libext 7912c2939121Smrg *.lo | *.$objext) 79138292847cSmrg if test conv = "$pass"; then 7914c2939121Smrg deplibs="$deplib $deplibs" 79158292847cSmrg elif test prog = "$linkmode"; then 79168292847cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7917c2939121Smrg # If there is no dlopen support or we're linking statically, 7918c2939121Smrg # we need to preload. 79192836776bSmrg func_append newdlprefiles " $deplib" 7920c2939121Smrg compile_deplibs="$deplib $compile_deplibs" 7921c2939121Smrg finalize_deplibs="$deplib $finalize_deplibs" 7922c2939121Smrg else 79232836776bSmrg func_append newdlfiles " $deplib" 7924c2939121Smrg fi 7925c2939121Smrg fi 7926c2939121Smrg continue 7927c2939121Smrg ;; 7928c2939121Smrg %DEPLIBS%) 79298292847cSmrg alldeplibs=: 7930c2939121Smrg continue 7931c2939121Smrg ;; 7932c2939121Smrg esac # case $deplib 7933c2939121Smrg 79348292847cSmrg $found || test -f "$lib" \ 79358292847cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7936c2939121Smrg 7937c2939121Smrg # Check to see that this really is a libtool archive. 7938c2939121Smrg func_lalib_unsafe_p "$lib" \ 79398292847cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7940c2939121Smrg 7941c2939121Smrg func_dirname "$lib" "" "." 79428292847cSmrg ladir=$func_dirname_result 7943c2939121Smrg 7944c2939121Smrg dlname= 7945c2939121Smrg dlopen= 7946c2939121Smrg dlpreopen= 7947c2939121Smrg libdir= 7948c2939121Smrg library_names= 7949c2939121Smrg old_library= 7950c2939121Smrg inherited_linker_flags= 7951c2939121Smrg # If the library was installed with an old release of libtool, 7952c2939121Smrg # it will not redefine variables installed, or shouldnotlink 7953c2939121Smrg installed=yes 7954c2939121Smrg shouldnotlink=no 7955c2939121Smrg avoidtemprpath= 7956c2939121Smrg 7957c2939121Smrg 7958c2939121Smrg # Read the .la file 7959c2939121Smrg func_source "$lib" 7960c2939121Smrg 7961c2939121Smrg # Convert "-framework foo" to "foo.ltframework" 7962c2939121Smrg if test -n "$inherited_linker_flags"; then 7963c2939121Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7964c2939121Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7965c2939121Smrg case " $new_inherited_linker_flags " in 7966c2939121Smrg *" $tmp_inherited_linker_flag "*) ;; 79672836776bSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7968c2939121Smrg esac 7969c2939121Smrg done 7970c2939121Smrg fi 7971c2939121Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 79728292847cSmrg if test lib,link = "$linkmode,$pass" || 79738292847cSmrg test prog,scan = "$linkmode,$pass" || 79748292847cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 79752836776bSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 79762836776bSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7977c2939121Smrg fi 7978c2939121Smrg 79798292847cSmrg if test conv = "$pass"; then 7980c2939121Smrg # Only check for convenience libraries 7981c2939121Smrg deplibs="$lib $deplibs" 7982c2939121Smrg if test -z "$libdir"; then 7983c2939121Smrg if test -z "$old_library"; then 79848292847cSmrg func_fatal_error "cannot find name of link library for '$lib'" 7985c2939121Smrg fi 7986c2939121Smrg # It is a libtool convenience library, so add in its objects. 79872836776bSmrg func_append convenience " $ladir/$objdir/$old_library" 79882836776bSmrg func_append old_convenience " $ladir/$objdir/$old_library" 7989de3c0529Smrg tmp_libs= 7990de3c0529Smrg for deplib in $dependency_libs; do 7991de3c0529Smrg deplibs="$deplib $deplibs" 7992de3c0529Smrg if $opt_preserve_dup_deps; then 7993de3c0529Smrg case "$tmp_libs " in 7994de3c0529Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7995de3c0529Smrg esac 7996de3c0529Smrg fi 7997de3c0529Smrg func_append tmp_libs " $deplib" 7998de3c0529Smrg done 79998292847cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 80008292847cSmrg func_fatal_error "'$lib' is not a convenience library" 8001c2939121Smrg fi 8002c2939121Smrg continue 8003c2939121Smrg fi # $pass = conv 8004c2939121Smrg 8005c2939121Smrg 8006c2939121Smrg # Get the name of the library we link against. 8007c2939121Smrg linklib= 80082836776bSmrg if test -n "$old_library" && 80098292847cSmrg { test yes = "$prefer_static_libs" || 80108292847cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 80112836776bSmrg linklib=$old_library 80122836776bSmrg else 80132836776bSmrg for l in $old_library $library_names; do 80148292847cSmrg linklib=$l 80152836776bSmrg done 80162836776bSmrg fi 8017c2939121Smrg if test -z "$linklib"; then 80188292847cSmrg func_fatal_error "cannot find name of link library for '$lib'" 8019c2939121Smrg fi 8020c2939121Smrg 8021c2939121Smrg # This library was specified with -dlopen. 80228292847cSmrg if test dlopen = "$pass"; then 80238292847cSmrg test -z "$libdir" \ 80248292847cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8025c2939121Smrg if test -z "$dlname" || 80268292847cSmrg test yes != "$dlopen_support" || 80278292847cSmrg test no = "$build_libtool_libs" 80288292847cSmrg then 8029c2939121Smrg # If there is no dlname, no dlopen support or we're linking 8030c2939121Smrg # statically, we need to preload. We also need to preload any 8031c2939121Smrg # dependent libraries so libltdl's deplib preloader doesn't 8032c2939121Smrg # bomb out in the load deplibs phase. 80332836776bSmrg func_append dlprefiles " $lib $dependency_libs" 8034c2939121Smrg else 80352836776bSmrg func_append newdlfiles " $lib" 8036c2939121Smrg fi 8037c2939121Smrg continue 8038c2939121Smrg fi # $pass = dlopen 8039c2939121Smrg 8040c2939121Smrg # We need an absolute path. 8041c2939121Smrg case $ladir in 80428292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8043c2939121Smrg *) 8044c2939121Smrg abs_ladir=`cd "$ladir" && pwd` 8045c2939121Smrg if test -z "$abs_ladir"; then 80468292847cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8047c2939121Smrg func_warning "passing it literally to the linker, although it might fail" 80488292847cSmrg abs_ladir=$ladir 8049c2939121Smrg fi 8050c2939121Smrg ;; 8051c2939121Smrg esac 8052c2939121Smrg func_basename "$lib" 80538292847cSmrg laname=$func_basename_result 8054c2939121Smrg 8055c2939121Smrg # Find the relevant object directory and library name. 80568292847cSmrg if test yes = "$installed"; then 80572836776bSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 80588292847cSmrg func_warning "library '$lib' was moved." 80598292847cSmrg dir=$ladir 80608292847cSmrg absdir=$abs_ladir 80618292847cSmrg libdir=$abs_ladir 8062c2939121Smrg else 80638292847cSmrg dir=$lt_sysroot$libdir 80648292847cSmrg absdir=$lt_sysroot$libdir 8065c2939121Smrg fi 80668292847cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8067c2939121Smrg else 8068c2939121Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 80698292847cSmrg dir=$ladir 80708292847cSmrg absdir=$abs_ladir 8071c2939121Smrg # Remove this search path later 80722836776bSmrg func_append notinst_path " $abs_ladir" 8073c2939121Smrg else 80748292847cSmrg dir=$ladir/$objdir 80758292847cSmrg absdir=$abs_ladir/$objdir 8076c2939121Smrg # Remove this search path later 80772836776bSmrg func_append notinst_path " $abs_ladir" 8078c2939121Smrg fi 8079c2939121Smrg fi # $installed = yes 8080c2939121Smrg func_stripname 'lib' '.la' "$laname" 8081c2939121Smrg name=$func_stripname_result 8082c2939121Smrg 8083c2939121Smrg # This library was specified with -dlpreopen. 80848292847cSmrg if test dlpreopen = "$pass"; then 80858292847cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 80868292847cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8087c2939121Smrg fi 80888292847cSmrg case $host in 80892836776bSmrg # special handling for platforms with PE-DLLs. 80902836776bSmrg *cygwin* | *mingw* | *cegcc* ) 80912836776bSmrg # Linker will automatically link against shared library if both 80922836776bSmrg # static and shared are present. Therefore, ensure we extract 80932836776bSmrg # symbols from the import library if a shared library is present 80942836776bSmrg # (otherwise, the dlopen module name will be incorrect). We do 80952836776bSmrg # this by putting the import library name into $newdlprefiles. 80962836776bSmrg # We recover the dlopen module name by 'saving' the la file 80972836776bSmrg # name in a special purpose variable, and (later) extracting the 80982836776bSmrg # dlname from the la file. 80992836776bSmrg if test -n "$dlname"; then 81002836776bSmrg func_tr_sh "$dir/$linklib" 81012836776bSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 81022836776bSmrg func_append newdlprefiles " $dir/$linklib" 81032836776bSmrg else 81042836776bSmrg func_append newdlprefiles " $dir/$old_library" 81052836776bSmrg # Keep a list of preopened convenience libraries to check 81062836776bSmrg # that they are being used correctly in the link pass. 81072836776bSmrg test -z "$libdir" && \ 81082836776bSmrg func_append dlpreconveniencelibs " $dir/$old_library" 81092836776bSmrg fi 81102836776bSmrg ;; 81112836776bSmrg * ) 81122836776bSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 81132836776bSmrg # are required to link). 81142836776bSmrg if test -n "$old_library"; then 81152836776bSmrg func_append newdlprefiles " $dir/$old_library" 81162836776bSmrg # Keep a list of preopened convenience libraries to check 81172836776bSmrg # that they are being used correctly in the link pass. 81182836776bSmrg test -z "$libdir" && \ 81192836776bSmrg func_append dlpreconveniencelibs " $dir/$old_library" 81202836776bSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 81212836776bSmrg elif test -n "$dlname"; then 81222836776bSmrg func_append newdlprefiles " $dir/$dlname" 81232836776bSmrg else 81242836776bSmrg func_append newdlprefiles " $dir/$linklib" 81252836776bSmrg fi 81262836776bSmrg ;; 81272836776bSmrg esac 8128c2939121Smrg fi # $pass = dlpreopen 8129c2939121Smrg 8130c2939121Smrg if test -z "$libdir"; then 8131c2939121Smrg # Link the convenience library 81328292847cSmrg if test lib = "$linkmode"; then 8133c2939121Smrg deplibs="$dir/$old_library $deplibs" 81348292847cSmrg elif test prog,link = "$linkmode,$pass"; then 8135c2939121Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8136c2939121Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8137c2939121Smrg else 8138c2939121Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8139c2939121Smrg fi 8140c2939121Smrg continue 8141c2939121Smrg fi 8142c2939121Smrg 8143c2939121Smrg 81448292847cSmrg if test prog = "$linkmode" && test link != "$pass"; then 81452836776bSmrg func_append newlib_search_path " $ladir" 8146c2939121Smrg deplibs="$lib $deplibs" 8147c2939121Smrg 81488292847cSmrg linkalldeplibs=false 81498292847cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 81508292847cSmrg test no = "$build_libtool_libs"; then 81518292847cSmrg linkalldeplibs=: 8152c2939121Smrg fi 8153c2939121Smrg 8154c2939121Smrg tmp_libs= 8155c2939121Smrg for deplib in $dependency_libs; do 8156c2939121Smrg case $deplib in 8157c2939121Smrg -L*) func_stripname '-L' '' "$deplib" 81582836776bSmrg func_resolve_sysroot "$func_stripname_result" 81592836776bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8160c2939121Smrg ;; 8161c2939121Smrg esac 8162c2939121Smrg # Need to link against all dependency_libs? 81638292847cSmrg if $linkalldeplibs; then 8164c2939121Smrg deplibs="$deplib $deplibs" 8165c2939121Smrg else 8166c2939121Smrg # Need to hardcode shared library paths 8167c2939121Smrg # or/and link against static libraries 8168c2939121Smrg newdependency_libs="$deplib $newdependency_libs" 8169c2939121Smrg fi 81708292847cSmrg if $opt_preserve_dup_deps; then 8171c2939121Smrg case "$tmp_libs " in 81722836776bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8173c2939121Smrg esac 8174c2939121Smrg fi 81752836776bSmrg func_append tmp_libs " $deplib" 8176c2939121Smrg done # for deplib 8177c2939121Smrg continue 8178c2939121Smrg fi # $linkmode = prog... 8179c2939121Smrg 81808292847cSmrg if test prog,link = "$linkmode,$pass"; then 8181c2939121Smrg if test -n "$library_names" && 81828292847cSmrg { { test no = "$prefer_static_libs" || 81838292847cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8184c2939121Smrg test -z "$old_library"; }; then 8185c2939121Smrg # We need to hardcode the library path 81868292847cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8187c2939121Smrg # Make sure the rpath contains only unique directories. 81888292847cSmrg case $temp_rpath: in 8189c2939121Smrg *"$absdir:"*) ;; 81902836776bSmrg *) func_append temp_rpath "$absdir:" ;; 8191c2939121Smrg esac 8192c2939121Smrg fi 8193c2939121Smrg 8194c2939121Smrg # Hardcode the library path. 8195c2939121Smrg # Skip directories that are in the system default run-time 8196c2939121Smrg # search path. 8197c2939121Smrg case " $sys_lib_dlsearch_path " in 8198c2939121Smrg *" $absdir "*) ;; 8199c2939121Smrg *) 8200c2939121Smrg case "$compile_rpath " in 8201c2939121Smrg *" $absdir "*) ;; 82022836776bSmrg *) func_append compile_rpath " $absdir" ;; 8203c2939121Smrg esac 8204c2939121Smrg ;; 8205c2939121Smrg esac 8206c2939121Smrg case " $sys_lib_dlsearch_path " in 8207c2939121Smrg *" $libdir "*) ;; 8208c2939121Smrg *) 8209c2939121Smrg case "$finalize_rpath " in 8210c2939121Smrg *" $libdir "*) ;; 82112836776bSmrg *) func_append finalize_rpath " $libdir" ;; 8212c2939121Smrg esac 8213c2939121Smrg ;; 8214c2939121Smrg esac 8215c2939121Smrg fi # $linkmode,$pass = prog,link... 8216c2939121Smrg 82178292847cSmrg if $alldeplibs && 82188292847cSmrg { test pass_all = "$deplibs_check_method" || 82198292847cSmrg { test yes = "$build_libtool_libs" && 8220c2939121Smrg test -n "$library_names"; }; }; then 8221c2939121Smrg # We only need to search for static libraries 8222c2939121Smrg continue 8223c2939121Smrg fi 8224c2939121Smrg fi 8225c2939121Smrg 8226c2939121Smrg link_static=no # Whether the deplib will be linked statically 8227c2939121Smrg use_static_libs=$prefer_static_libs 82288292847cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8229c2939121Smrg use_static_libs=no 8230c2939121Smrg fi 8231c2939121Smrg if test -n "$library_names" && 82328292847cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8233c2939121Smrg case $host in 82348292847cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8235c2939121Smrg # No point in relinking DLLs because paths are not encoded 82362836776bSmrg func_append notinst_deplibs " $lib" 8237c2939121Smrg need_relink=no 8238c2939121Smrg ;; 8239c2939121Smrg *) 82408292847cSmrg if test no = "$installed"; then 82412836776bSmrg func_append notinst_deplibs " $lib" 8242c2939121Smrg need_relink=yes 8243c2939121Smrg fi 8244c2939121Smrg ;; 8245c2939121Smrg esac 8246c2939121Smrg # This is a shared library 8247c2939121Smrg 8248c2939121Smrg # Warn about portability, can't link against -module's on some 8249c2939121Smrg # systems (darwin). Don't bleat about dlopened modules though! 82508292847cSmrg dlopenmodule= 8251c2939121Smrg for dlpremoduletest in $dlprefiles; do 8252c2939121Smrg if test "X$dlpremoduletest" = "X$lib"; then 82538292847cSmrg dlopenmodule=$dlpremoduletest 8254c2939121Smrg break 8255c2939121Smrg fi 8256c2939121Smrg done 82578292847cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8258c2939121Smrg echo 82598292847cSmrg if test prog = "$linkmode"; then 8260c2939121Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8261c2939121Smrg else 8262c2939121Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8263c2939121Smrg fi 8264c2939121Smrg $ECHO "*** $linklib is not portable!" 8265c2939121Smrg fi 82668292847cSmrg if test lib = "$linkmode" && 82678292847cSmrg test yes = "$hardcode_into_libs"; then 8268c2939121Smrg # Hardcode the library path. 8269c2939121Smrg # Skip directories that are in the system default run-time 8270c2939121Smrg # search path. 8271c2939121Smrg case " $sys_lib_dlsearch_path " in 8272c2939121Smrg *" $absdir "*) ;; 8273c2939121Smrg *) 8274c2939121Smrg case "$compile_rpath " in 8275c2939121Smrg *" $absdir "*) ;; 82762836776bSmrg *) func_append compile_rpath " $absdir" ;; 8277c2939121Smrg esac 8278c2939121Smrg ;; 8279c2939121Smrg esac 8280c2939121Smrg case " $sys_lib_dlsearch_path " in 8281c2939121Smrg *" $libdir "*) ;; 8282c2939121Smrg *) 8283c2939121Smrg case "$finalize_rpath " in 8284c2939121Smrg *" $libdir "*) ;; 82852836776bSmrg *) func_append finalize_rpath " $libdir" ;; 8286c2939121Smrg esac 8287c2939121Smrg ;; 8288c2939121Smrg esac 8289c2939121Smrg fi 8290c2939121Smrg 8291c2939121Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8292c2939121Smrg # figure out the soname 8293c2939121Smrg set dummy $library_names 8294c2939121Smrg shift 82958292847cSmrg realname=$1 8296c2939121Smrg shift 8297c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8298c2939121Smrg # use dlname if we got it. it's perfectly good, no? 8299c2939121Smrg if test -n "$dlname"; then 83008292847cSmrg soname=$dlname 8301c2939121Smrg elif test -n "$soname_spec"; then 8302c2939121Smrg # bleh windows 8303c2939121Smrg case $host in 83048292847cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8305c2939121Smrg func_arith $current - $age 8306c2939121Smrg major=$func_arith_result 83078292847cSmrg versuffix=-$major 8308c2939121Smrg ;; 8309c2939121Smrg esac 8310c2939121Smrg eval soname=\"$soname_spec\" 8311c2939121Smrg else 83128292847cSmrg soname=$realname 8313c2939121Smrg fi 8314c2939121Smrg 8315c2939121Smrg # Make a new name for the extract_expsyms_cmds to use 83168292847cSmrg soroot=$soname 8317c2939121Smrg func_basename "$soroot" 83188292847cSmrg soname=$func_basename_result 8319c2939121Smrg func_stripname 'lib' '.dll' "$soname" 8320c2939121Smrg newlib=libimp-$func_stripname_result.a 8321c2939121Smrg 8322c2939121Smrg # If the library has no export list, then create one now 8323c2939121Smrg if test -f "$output_objdir/$soname-def"; then : 8324c2939121Smrg else 83258292847cSmrg func_verbose "extracting exported symbol list from '$soname'" 8326c2939121Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8327c2939121Smrg fi 8328c2939121Smrg 8329c2939121Smrg # Create $newlib 8330c2939121Smrg if test -f "$output_objdir/$newlib"; then :; else 83318292847cSmrg func_verbose "generating import library for '$soname'" 8332c2939121Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8333c2939121Smrg fi 8334c2939121Smrg # make sure the library variables are pointing to the new library 8335c2939121Smrg dir=$output_objdir 8336c2939121Smrg linklib=$newlib 8337c2939121Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8338c2939121Smrg 83398292847cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8340c2939121Smrg add_shlibpath= 8341c2939121Smrg add_dir= 8342c2939121Smrg add= 8343c2939121Smrg lib_linked=yes 8344c2939121Smrg case $hardcode_action in 8345c2939121Smrg immediate | unsupported) 83468292847cSmrg if test no = "$hardcode_direct"; then 83478292847cSmrg add=$dir/$linklib 8348c2939121Smrg case $host in 83498292847cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 83508292847cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8351c2939121Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 83528292847cSmrg *-*-unixware7*) add_dir=-L$dir ;; 8353c2939121Smrg *-*-darwin* ) 83548292847cSmrg # if the lib is a (non-dlopened) module then we cannot 8355c2939121Smrg # link against it, someone is ignoring the earlier warnings 8356c2939121Smrg if /usr/bin/file -L $add 2> /dev/null | 83578292847cSmrg $GREP ": [^:]* bundle" >/dev/null; then 8358c2939121Smrg if test "X$dlopenmodule" != "X$lib"; then 8359c2939121Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 83608292847cSmrg if test -z "$old_library"; then 8361c2939121Smrg echo 8362c2939121Smrg echo "*** And there doesn't seem to be a static archive available" 8363c2939121Smrg echo "*** The link will probably fail, sorry" 8364c2939121Smrg else 83658292847cSmrg add=$dir/$old_library 8366c2939121Smrg fi 8367c2939121Smrg elif test -n "$old_library"; then 83688292847cSmrg add=$dir/$old_library 8369c2939121Smrg fi 8370c2939121Smrg fi 8371c2939121Smrg esac 83728292847cSmrg elif test no = "$hardcode_minus_L"; then 8373c2939121Smrg case $host in 83748292847cSmrg *-*-sunos*) add_shlibpath=$dir ;; 8375c2939121Smrg esac 83768292847cSmrg add_dir=-L$dir 83778292847cSmrg add=-l$name 83788292847cSmrg elif test no = "$hardcode_shlibpath_var"; then 83798292847cSmrg add_shlibpath=$dir 83808292847cSmrg add=-l$name 8381c2939121Smrg else 8382c2939121Smrg lib_linked=no 8383c2939121Smrg fi 8384c2939121Smrg ;; 8385c2939121Smrg relink) 83868292847cSmrg if test yes = "$hardcode_direct" && 83878292847cSmrg test no = "$hardcode_direct_absolute"; then 83888292847cSmrg add=$dir/$linklib 83898292847cSmrg elif test yes = "$hardcode_minus_L"; then 83908292847cSmrg add_dir=-L$absdir 8391c2939121Smrg # Try looking first in the location we're being installed to. 8392c2939121Smrg if test -n "$inst_prefix_dir"; then 8393c2939121Smrg case $libdir in 8394c2939121Smrg [\\/]*) 83952836776bSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8396c2939121Smrg ;; 8397c2939121Smrg esac 8398c2939121Smrg fi 83998292847cSmrg add=-l$name 84008292847cSmrg elif test yes = "$hardcode_shlibpath_var"; then 84018292847cSmrg add_shlibpath=$dir 84028292847cSmrg add=-l$name 8403c2939121Smrg else 8404c2939121Smrg lib_linked=no 8405c2939121Smrg fi 8406c2939121Smrg ;; 8407c2939121Smrg *) lib_linked=no ;; 8408c2939121Smrg esac 8409c2939121Smrg 84108292847cSmrg if test yes != "$lib_linked"; then 8411c2939121Smrg func_fatal_configuration "unsupported hardcode properties" 8412c2939121Smrg fi 8413c2939121Smrg 8414c2939121Smrg if test -n "$add_shlibpath"; then 8415c2939121Smrg case :$compile_shlibpath: in 8416c2939121Smrg *":$add_shlibpath:"*) ;; 84172836776bSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8418c2939121Smrg esac 8419c2939121Smrg fi 84208292847cSmrg if test prog = "$linkmode"; then 8421c2939121Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8422c2939121Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8423c2939121Smrg else 8424c2939121Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8425c2939121Smrg test -n "$add" && deplibs="$add $deplibs" 84268292847cSmrg if test yes != "$hardcode_direct" && 84278292847cSmrg test yes != "$hardcode_minus_L" && 84288292847cSmrg test yes = "$hardcode_shlibpath_var"; then 8429c2939121Smrg case :$finalize_shlibpath: in 8430c2939121Smrg *":$libdir:"*) ;; 84312836776bSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8432c2939121Smrg esac 8433c2939121Smrg fi 8434c2939121Smrg fi 8435c2939121Smrg fi 8436c2939121Smrg 84378292847cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8438c2939121Smrg add_shlibpath= 8439c2939121Smrg add_dir= 8440c2939121Smrg add= 8441c2939121Smrg # Finalize command for both is simple: just hardcode it. 84428292847cSmrg if test yes = "$hardcode_direct" && 84438292847cSmrg test no = "$hardcode_direct_absolute"; then 84448292847cSmrg add=$libdir/$linklib 84458292847cSmrg elif test yes = "$hardcode_minus_L"; then 84468292847cSmrg add_dir=-L$libdir 84478292847cSmrg add=-l$name 84488292847cSmrg elif test yes = "$hardcode_shlibpath_var"; then 8449c2939121Smrg case :$finalize_shlibpath: in 8450c2939121Smrg *":$libdir:"*) ;; 84512836776bSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8452c2939121Smrg esac 84538292847cSmrg add=-l$name 84548292847cSmrg elif test yes = "$hardcode_automatic"; then 8455c2939121Smrg if test -n "$inst_prefix_dir" && 84568292847cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 84578292847cSmrg add=$inst_prefix_dir$libdir/$linklib 8458c2939121Smrg else 84598292847cSmrg add=$libdir/$linklib 8460c2939121Smrg fi 8461c2939121Smrg else 8462c2939121Smrg # We cannot seem to hardcode it, guess we'll fake it. 84638292847cSmrg add_dir=-L$libdir 8464c2939121Smrg # Try looking first in the location we're being installed to. 8465c2939121Smrg if test -n "$inst_prefix_dir"; then 8466c2939121Smrg case $libdir in 8467c2939121Smrg [\\/]*) 84682836776bSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8469c2939121Smrg ;; 8470c2939121Smrg esac 8471c2939121Smrg fi 84728292847cSmrg add=-l$name 8473c2939121Smrg fi 8474c2939121Smrg 84758292847cSmrg if test prog = "$linkmode"; then 8476c2939121Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8477c2939121Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8478c2939121Smrg else 8479c2939121Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8480c2939121Smrg test -n "$add" && deplibs="$add $deplibs" 8481c2939121Smrg fi 8482c2939121Smrg fi 84838292847cSmrg elif test prog = "$linkmode"; then 8484c2939121Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8485c2939121Smrg # is not unsupported. This is valid on all known static and 8486c2939121Smrg # shared platforms. 84878292847cSmrg if test unsupported != "$hardcode_direct"; then 84888292847cSmrg test -n "$old_library" && linklib=$old_library 8489c2939121Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8490c2939121Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8491c2939121Smrg else 8492c2939121Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8493c2939121Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8494c2939121Smrg fi 84958292847cSmrg elif test yes = "$build_libtool_libs"; then 8496c2939121Smrg # Not a shared library 84978292847cSmrg if test pass_all != "$deplibs_check_method"; then 8498c2939121Smrg # We're trying link a shared library against a static one 8499c2939121Smrg # but the system doesn't support it. 8500c2939121Smrg 8501c2939121Smrg # Just print a warning and add the library to dependency_libs so 8502c2939121Smrg # that the program can be linked against the static library. 8503c2939121Smrg echo 85048292847cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8505c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 8506c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 8507c2939121Smrg echo "*** shared version of the library, which you do not appear to have." 85088292847cSmrg if test yes = "$module"; then 8509c2939121Smrg echo "*** But as you try to build a module library, libtool will still create " 8510c2939121Smrg echo "*** a static module, that should work as long as the dlopening application" 8511c2939121Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8512c2939121Smrg if test -z "$global_symbol_pipe"; then 8513c2939121Smrg echo 8514c2939121Smrg echo "*** However, this would only work if libtool was able to extract symbol" 85158292847cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8516c2939121Smrg echo "*** not find such a program. So, this module is probably useless." 85178292847cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8518c2939121Smrg fi 85198292847cSmrg if test no = "$build_old_libs"; then 8520c2939121Smrg build_libtool_libs=module 8521c2939121Smrg build_old_libs=yes 8522c2939121Smrg else 8523c2939121Smrg build_libtool_libs=no 8524c2939121Smrg fi 8525c2939121Smrg fi 8526c2939121Smrg else 8527c2939121Smrg deplibs="$dir/$old_library $deplibs" 8528c2939121Smrg link_static=yes 8529c2939121Smrg fi 8530c2939121Smrg fi # link shared/static library? 8531c2939121Smrg 85328292847cSmrg if test lib = "$linkmode"; then 8533c2939121Smrg if test -n "$dependency_libs" && 85348292847cSmrg { test yes != "$hardcode_into_libs" || 85358292847cSmrg test yes = "$build_old_libs" || 85368292847cSmrg test yes = "$link_static"; }; then 8537c2939121Smrg # Extract -R from dependency_libs 8538c2939121Smrg temp_deplibs= 8539c2939121Smrg for libdir in $dependency_libs; do 8540c2939121Smrg case $libdir in 8541c2939121Smrg -R*) func_stripname '-R' '' "$libdir" 8542c2939121Smrg temp_xrpath=$func_stripname_result 8543c2939121Smrg case " $xrpath " in 8544c2939121Smrg *" $temp_xrpath "*) ;; 85452836776bSmrg *) func_append xrpath " $temp_xrpath";; 8546c2939121Smrg esac;; 85472836776bSmrg *) func_append temp_deplibs " $libdir";; 8548c2939121Smrg esac 8549c2939121Smrg done 85508292847cSmrg dependency_libs=$temp_deplibs 8551c2939121Smrg fi 8552c2939121Smrg 85532836776bSmrg func_append newlib_search_path " $absdir" 8554c2939121Smrg # Link against this library 85558292847cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8556c2939121Smrg # ... and its dependency_libs 8557c2939121Smrg tmp_libs= 8558c2939121Smrg for deplib in $dependency_libs; do 8559c2939121Smrg newdependency_libs="$deplib $newdependency_libs" 85602836776bSmrg case $deplib in 85612836776bSmrg -L*) func_stripname '-L' '' "$deplib" 85622836776bSmrg func_resolve_sysroot "$func_stripname_result";; 85632836776bSmrg *) func_resolve_sysroot "$deplib" ;; 85642836776bSmrg esac 85658292847cSmrg if $opt_preserve_dup_deps; then 8566c2939121Smrg case "$tmp_libs " in 85672836776bSmrg *" $func_resolve_sysroot_result "*) 85682836776bSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8569c2939121Smrg esac 8570c2939121Smrg fi 85712836776bSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8572c2939121Smrg done 8573c2939121Smrg 85748292847cSmrg if test no != "$link_all_deplibs"; then 8575c2939121Smrg # Add the search paths of all dependency libraries 8576c2939121Smrg for deplib in $dependency_libs; do 8577c2939121Smrg path= 8578c2939121Smrg case $deplib in 85798292847cSmrg -L*) path=$deplib ;; 8580c2939121Smrg *.la) 85812836776bSmrg func_resolve_sysroot "$deplib" 85822836776bSmrg deplib=$func_resolve_sysroot_result 8583c2939121Smrg func_dirname "$deplib" "" "." 85842836776bSmrg dir=$func_dirname_result 8585c2939121Smrg # We need an absolute path. 8586c2939121Smrg case $dir in 85878292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8588c2939121Smrg *) 8589c2939121Smrg absdir=`cd "$dir" && pwd` 8590c2939121Smrg if test -z "$absdir"; then 85918292847cSmrg func_warning "cannot determine absolute directory name of '$dir'" 85928292847cSmrg absdir=$dir 8593c2939121Smrg fi 8594c2939121Smrg ;; 8595c2939121Smrg esac 8596c2939121Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8597c2939121Smrg case $host in 8598c2939121Smrg *-*-darwin*) 8599c2939121Smrg depdepl= 86008292847cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 86018292847cSmrg if test -n "$deplibrary_names"; then 86028292847cSmrg for tmp in $deplibrary_names; do 8603c2939121Smrg depdepl=$tmp 8604c2939121Smrg done 86058292847cSmrg if test -f "$absdir/$objdir/$depdepl"; then 86068292847cSmrg depdepl=$absdir/$objdir/$depdepl 86078292847cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8608c2939121Smrg if test -z "$darwin_install_name"; then 86098292847cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8610c2939121Smrg fi 86118292847cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 86128292847cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8613c2939121Smrg path= 8614c2939121Smrg fi 8615c2939121Smrg fi 8616c2939121Smrg ;; 8617c2939121Smrg *) 86188292847cSmrg path=-L$absdir/$objdir 8619c2939121Smrg ;; 8620c2939121Smrg esac 8621c2939121Smrg else 86228292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8623c2939121Smrg test -z "$libdir" && \ 86248292847cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8625c2939121Smrg test "$absdir" != "$libdir" && \ 86268292847cSmrg func_warning "'$deplib' seems to be moved" 8627c2939121Smrg 86288292847cSmrg path=-L$absdir 8629c2939121Smrg fi 8630c2939121Smrg ;; 8631c2939121Smrg esac 8632c2939121Smrg case " $deplibs " in 8633c2939121Smrg *" $path "*) ;; 8634c2939121Smrg *) deplibs="$path $deplibs" ;; 8635c2939121Smrg esac 8636c2939121Smrg done 8637c2939121Smrg fi # link_all_deplibs != no 8638c2939121Smrg fi # linkmode = lib 8639c2939121Smrg done # for deplib in $libs 86408292847cSmrg if test link = "$pass"; then 86418292847cSmrg if test prog = "$linkmode"; then 8642c2939121Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8643c2939121Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8644c2939121Smrg else 8645c2939121Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8646c2939121Smrg fi 8647c2939121Smrg fi 86488292847cSmrg dependency_libs=$newdependency_libs 86498292847cSmrg if test dlpreopen = "$pass"; then 8650c2939121Smrg # Link the dlpreopened libraries before other libraries 8651c2939121Smrg for deplib in $save_deplibs; do 8652c2939121Smrg deplibs="$deplib $deplibs" 8653c2939121Smrg done 8654c2939121Smrg fi 86558292847cSmrg if test dlopen != "$pass"; then 86568292847cSmrg test conv = "$pass" || { 8657c2939121Smrg # Make sure lib_search_path contains only unique directories. 8658c2939121Smrg lib_search_path= 8659c2939121Smrg for dir in $newlib_search_path; do 8660c2939121Smrg case "$lib_search_path " in 8661c2939121Smrg *" $dir "*) ;; 86622836776bSmrg *) func_append lib_search_path " $dir" ;; 8663c2939121Smrg esac 8664c2939121Smrg done 8665c2939121Smrg newlib_search_path= 86668292847cSmrg } 8667c2939121Smrg 86688292847cSmrg if test prog,link = "$linkmode,$pass"; then 8669c2939121Smrg vars="compile_deplibs finalize_deplibs" 86708292847cSmrg else 86718292847cSmrg vars=deplibs 8672c2939121Smrg fi 8673c2939121Smrg for var in $vars dependency_libs; do 8674c2939121Smrg # Add libraries to $var in reverse order 8675c2939121Smrg eval tmp_libs=\"\$$var\" 8676c2939121Smrg new_libs= 8677c2939121Smrg for deplib in $tmp_libs; do 8678c2939121Smrg # FIXME: Pedantically, this is the right thing to do, so 8679c2939121Smrg # that some nasty dependency loop isn't accidentally 8680c2939121Smrg # broken: 8681c2939121Smrg #new_libs="$deplib $new_libs" 8682c2939121Smrg # Pragmatically, this seems to cause very few problems in 8683c2939121Smrg # practice: 8684c2939121Smrg case $deplib in 8685c2939121Smrg -L*) new_libs="$deplib $new_libs" ;; 8686c2939121Smrg -R*) ;; 8687c2939121Smrg *) 8688c2939121Smrg # And here is the reason: when a library appears more 8689c2939121Smrg # than once as an explicit dependence of a library, or 8690c2939121Smrg # is implicitly linked in more than once by the 8691c2939121Smrg # compiler, it is considered special, and multiple 8692c2939121Smrg # occurrences thereof are not removed. Compare this 8693c2939121Smrg # with having the same library being listed as a 8694c2939121Smrg # dependency of multiple other libraries: in this case, 8695c2939121Smrg # we know (pedantically, we assume) the library does not 8696c2939121Smrg # need to be listed more than once, so we keep only the 8697c2939121Smrg # last copy. This is not always right, but it is rare 8698c2939121Smrg # enough that we require users that really mean to play 8699c2939121Smrg # such unportable linking tricks to link the library 8700c2939121Smrg # using -Wl,-lname, so that libtool does not consider it 8701c2939121Smrg # for duplicate removal. 8702c2939121Smrg case " $specialdeplibs " in 8703c2939121Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8704c2939121Smrg *) 8705c2939121Smrg case " $new_libs " in 8706c2939121Smrg *" $deplib "*) ;; 8707c2939121Smrg *) new_libs="$deplib $new_libs" ;; 8708c2939121Smrg esac 8709c2939121Smrg ;; 8710c2939121Smrg esac 8711c2939121Smrg ;; 8712c2939121Smrg esac 8713c2939121Smrg done 8714c2939121Smrg tmp_libs= 8715c2939121Smrg for deplib in $new_libs; do 8716c2939121Smrg case $deplib in 8717c2939121Smrg -L*) 8718c2939121Smrg case " $tmp_libs " in 8719c2939121Smrg *" $deplib "*) ;; 87202836776bSmrg *) func_append tmp_libs " $deplib" ;; 8721c2939121Smrg esac 8722c2939121Smrg ;; 87232836776bSmrg *) func_append tmp_libs " $deplib" ;; 8724c2939121Smrg esac 8725c2939121Smrg done 8726c2939121Smrg eval $var=\"$tmp_libs\" 8727c2939121Smrg done # for var 8728c2939121Smrg fi 87298292847cSmrg 87308292847cSmrg # Add Sun CC postdeps if required: 87318292847cSmrg test CXX = "$tagname" && { 87328292847cSmrg case $host_os in 87338292847cSmrg linux*) 87348292847cSmrg case `$CC -V 2>&1 | sed 5q` in 87358292847cSmrg *Sun\ C*) # Sun C++ 5.9 87368292847cSmrg func_suncc_cstd_abi 87378292847cSmrg 87388292847cSmrg if test no != "$suncc_use_cstd_abi"; then 87398292847cSmrg func_append postdeps ' -library=Cstd -library=Crun' 87408292847cSmrg fi 87418292847cSmrg ;; 87428292847cSmrg esac 87438292847cSmrg ;; 87448292847cSmrg 87458292847cSmrg solaris*) 87468292847cSmrg func_cc_basename "$CC" 87478292847cSmrg case $func_cc_basename_result in 87488292847cSmrg CC* | sunCC*) 87498292847cSmrg func_suncc_cstd_abi 87508292847cSmrg 87518292847cSmrg if test no != "$suncc_use_cstd_abi"; then 87528292847cSmrg func_append postdeps ' -library=Cstd -library=Crun' 87538292847cSmrg fi 87548292847cSmrg ;; 87558292847cSmrg esac 87568292847cSmrg ;; 87578292847cSmrg esac 87588292847cSmrg } 87598292847cSmrg 8760c2939121Smrg # Last step: remove runtime libs from dependency_libs 8761c2939121Smrg # (they stay in deplibs) 8762c2939121Smrg tmp_libs= 87638292847cSmrg for i in $dependency_libs; do 8764c2939121Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8765c2939121Smrg *" $i "*) 87668292847cSmrg i= 8767c2939121Smrg ;; 8768c2939121Smrg esac 87698292847cSmrg if test -n "$i"; then 87702836776bSmrg func_append tmp_libs " $i" 8771c2939121Smrg fi 8772c2939121Smrg done 8773c2939121Smrg dependency_libs=$tmp_libs 8774c2939121Smrg done # for pass 87758292847cSmrg if test prog = "$linkmode"; then 87768292847cSmrg dlfiles=$newdlfiles 8777c2939121Smrg fi 87788292847cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 87798292847cSmrg dlprefiles=$newdlprefiles 8780c2939121Smrg fi 8781c2939121Smrg 8782c2939121Smrg case $linkmode in 8783c2939121Smrg oldlib) 87848292847cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 87858292847cSmrg func_warning "'-dlopen' is ignored for archives" 8786c2939121Smrg fi 8787c2939121Smrg 8788c2939121Smrg case " $deplibs" in 8789c2939121Smrg *\ -l* | *\ -L*) 87908292847cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8791c2939121Smrg esac 8792c2939121Smrg 8793c2939121Smrg test -n "$rpath" && \ 87948292847cSmrg func_warning "'-rpath' is ignored for archives" 8795c2939121Smrg 8796c2939121Smrg test -n "$xrpath" && \ 87978292847cSmrg func_warning "'-R' is ignored for archives" 8798c2939121Smrg 8799c2939121Smrg test -n "$vinfo" && \ 88008292847cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8801c2939121Smrg 8802c2939121Smrg test -n "$release" && \ 88038292847cSmrg func_warning "'-release' is ignored for archives" 8804c2939121Smrg 8805c2939121Smrg test -n "$export_symbols$export_symbols_regex" && \ 88068292847cSmrg func_warning "'-export-symbols' is ignored for archives" 8807c2939121Smrg 8808c2939121Smrg # Now set the variables for building old libraries. 8809c2939121Smrg build_libtool_libs=no 88108292847cSmrg oldlibs=$output 88112836776bSmrg func_append objs "$old_deplibs" 8812c2939121Smrg ;; 8813c2939121Smrg 8814c2939121Smrg lib) 88158292847cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8816c2939121Smrg case $outputname in 8817c2939121Smrg lib*) 8818c2939121Smrg func_stripname 'lib' '.la' "$outputname" 8819c2939121Smrg name=$func_stripname_result 8820c2939121Smrg eval shared_ext=\"$shrext_cmds\" 8821c2939121Smrg eval libname=\"$libname_spec\" 8822c2939121Smrg ;; 8823c2939121Smrg *) 88248292847cSmrg test no = "$module" \ 88258292847cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8826c2939121Smrg 88278292847cSmrg if test no != "$need_lib_prefix"; then 8828c2939121Smrg # Add the "lib" prefix for modules if required 8829c2939121Smrg func_stripname '' '.la' "$outputname" 8830c2939121Smrg name=$func_stripname_result 8831c2939121Smrg eval shared_ext=\"$shrext_cmds\" 8832c2939121Smrg eval libname=\"$libname_spec\" 8833c2939121Smrg else 8834c2939121Smrg func_stripname '' '.la' "$outputname" 8835c2939121Smrg libname=$func_stripname_result 8836c2939121Smrg fi 8837c2939121Smrg ;; 8838c2939121Smrg esac 8839c2939121Smrg 8840c2939121Smrg if test -n "$objs"; then 88418292847cSmrg if test pass_all != "$deplibs_check_method"; then 88428292847cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8843c2939121Smrg else 8844c2939121Smrg echo 8845c2939121Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8846c2939121Smrg $ECHO "*** objects $objs is not portable!" 88472836776bSmrg func_append libobjs " $objs" 8848c2939121Smrg fi 8849c2939121Smrg fi 8850c2939121Smrg 88518292847cSmrg test no = "$dlself" \ 88528292847cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8853c2939121Smrg 8854c2939121Smrg set dummy $rpath 8855c2939121Smrg shift 88568292847cSmrg test 1 -lt "$#" \ 88578292847cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8858c2939121Smrg 88598292847cSmrg install_libdir=$1 8860c2939121Smrg 8861c2939121Smrg oldlibs= 8862c2939121Smrg if test -z "$rpath"; then 88638292847cSmrg if test yes = "$build_libtool_libs"; then 8864c2939121Smrg # Building a libtool convenience library. 88658292847cSmrg # Some compilers have problems with a '.al' extension so 8866c2939121Smrg # convenience libraries should have the same extension an 8867c2939121Smrg # archive normally would. 8868c2939121Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8869c2939121Smrg build_libtool_libs=convenience 8870c2939121Smrg build_old_libs=yes 8871c2939121Smrg fi 8872c2939121Smrg 8873c2939121Smrg test -n "$vinfo" && \ 88748292847cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8875c2939121Smrg 8876c2939121Smrg test -n "$release" && \ 88778292847cSmrg func_warning "'-release' is ignored for convenience libraries" 8878c2939121Smrg else 8879c2939121Smrg 8880c2939121Smrg # Parse the version information argument. 88818292847cSmrg save_ifs=$IFS; IFS=: 8882c2939121Smrg set dummy $vinfo 0 0 0 8883c2939121Smrg shift 88848292847cSmrg IFS=$save_ifs 8885c2939121Smrg 8886c2939121Smrg test -n "$7" && \ 88878292847cSmrg func_fatal_help "too many parameters to '-version-info'" 8888c2939121Smrg 8889c2939121Smrg # convert absolute version numbers to libtool ages 8890c2939121Smrg # this retains compatibility with .la files and attempts 8891c2939121Smrg # to make the code below a bit more comprehensible 8892c2939121Smrg 8893c2939121Smrg case $vinfo_number in 8894c2939121Smrg yes) 88958292847cSmrg number_major=$1 88968292847cSmrg number_minor=$2 88978292847cSmrg number_revision=$3 8898c2939121Smrg # 8899c2939121Smrg # There are really only two kinds -- those that 8900c2939121Smrg # use the current revision as the major version 8901c2939121Smrg # and those that subtract age and use age as 8902c2939121Smrg # a minor version. But, then there is irix 89038292847cSmrg # that has an extra 1 added just for fun 8904c2939121Smrg # 8905c2939121Smrg case $version_type in 89062836776bSmrg # correct linux to gnu/linux during the next big refactor 89078292847cSmrg darwin|freebsd-elf|linux|osf|windows|none) 8908c2939121Smrg func_arith $number_major + $number_minor 8909c2939121Smrg current=$func_arith_result 89108292847cSmrg age=$number_minor 89118292847cSmrg revision=$number_revision 8912c2939121Smrg ;; 89138292847cSmrg freebsd-aout|qnx|sunos) 89148292847cSmrg current=$number_major 89158292847cSmrg revision=$number_minor 89168292847cSmrg age=0 8917c2939121Smrg ;; 8918c2939121Smrg irix|nonstopux) 8919c2939121Smrg func_arith $number_major + $number_minor 8920c2939121Smrg current=$func_arith_result 89218292847cSmrg age=$number_minor 89228292847cSmrg revision=$number_minor 8923c2939121Smrg lt_irix_increment=no 8924c2939121Smrg ;; 8925de3c0529Smrg *) 8926de3c0529Smrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 8927de3c0529Smrg ;; 8928c2939121Smrg esac 8929c2939121Smrg ;; 8930c2939121Smrg no) 89318292847cSmrg current=$1 89328292847cSmrg revision=$2 89338292847cSmrg age=$3 8934c2939121Smrg ;; 8935c2939121Smrg esac 8936c2939121Smrg 8937c2939121Smrg # Check that each of the things are valid numbers. 8938c2939121Smrg case $current in 8939c2939121Smrg 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]) ;; 8940c2939121Smrg *) 89418292847cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 89428292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8943c2939121Smrg ;; 8944c2939121Smrg esac 8945c2939121Smrg 8946c2939121Smrg case $revision in 8947c2939121Smrg 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]) ;; 8948c2939121Smrg *) 89498292847cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 89508292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8951c2939121Smrg ;; 8952c2939121Smrg esac 8953c2939121Smrg 8954c2939121Smrg case $age in 8955c2939121Smrg 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]) ;; 8956c2939121Smrg *) 89578292847cSmrg func_error "AGE '$age' must be a nonnegative integer" 89588292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8959c2939121Smrg ;; 8960c2939121Smrg esac 8961c2939121Smrg 8962c2939121Smrg if test "$age" -gt "$current"; then 89638292847cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 89648292847cSmrg func_fatal_error "'$vinfo' is not valid version information" 8965c2939121Smrg fi 8966c2939121Smrg 8967c2939121Smrg # Calculate the version variables. 8968c2939121Smrg major= 8969c2939121Smrg versuffix= 8970c2939121Smrg verstring= 8971c2939121Smrg case $version_type in 8972c2939121Smrg none) ;; 8973c2939121Smrg 8974c2939121Smrg darwin) 8975c2939121Smrg # Like Linux, but with the current version available in 8976c2939121Smrg # verstring for coding it into the library header 8977c2939121Smrg func_arith $current - $age 8978c2939121Smrg major=.$func_arith_result 89798292847cSmrg versuffix=$major.$age.$revision 8980c2939121Smrg # Darwin ld doesn't like 0 for these options... 8981c2939121Smrg func_arith $current + 1 8982c2939121Smrg minor_current=$func_arith_result 89838292847cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8984c2939121Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 89858292847cSmrg # On Darwin other compilers 89868292847cSmrg case $CC in 89878292847cSmrg nagfor*) 89888292847cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 89898292847cSmrg ;; 89908292847cSmrg *) 89918292847cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 89928292847cSmrg ;; 89938292847cSmrg esac 8994c2939121Smrg ;; 8995c2939121Smrg 8996c2939121Smrg freebsd-aout) 89978292847cSmrg major=.$current 89988292847cSmrg versuffix=.$current.$revision 8999c2939121Smrg ;; 9000c2939121Smrg 9001c2939121Smrg freebsd-elf) 90028292847cSmrg func_arith $current - $age 90038292847cSmrg major=.$func_arith_result 90048292847cSmrg versuffix=$major.$age.$revision 9005c2939121Smrg ;; 9006c2939121Smrg 9007c2939121Smrg irix | nonstopux) 90088292847cSmrg if test no = "$lt_irix_increment"; then 9009c2939121Smrg func_arith $current - $age 9010c2939121Smrg else 9011c2939121Smrg func_arith $current - $age + 1 9012c2939121Smrg fi 9013c2939121Smrg major=$func_arith_result 9014c2939121Smrg 9015c2939121Smrg case $version_type in 9016c2939121Smrg nonstopux) verstring_prefix=nonstopux ;; 9017c2939121Smrg *) verstring_prefix=sgi ;; 9018c2939121Smrg esac 90198292847cSmrg verstring=$verstring_prefix$major.$revision 9020c2939121Smrg 9021c2939121Smrg # Add in all the interfaces that we are compatible with. 9022c2939121Smrg loop=$revision 90238292847cSmrg while test 0 -ne "$loop"; do 9024c2939121Smrg func_arith $revision - $loop 9025c2939121Smrg iface=$func_arith_result 9026c2939121Smrg func_arith $loop - 1 9027c2939121Smrg loop=$func_arith_result 90288292847cSmrg verstring=$verstring_prefix$major.$iface:$verstring 9029c2939121Smrg done 9030c2939121Smrg 90318292847cSmrg # Before this point, $major must not contain '.'. 9032c2939121Smrg major=.$major 90338292847cSmrg versuffix=$major.$revision 9034c2939121Smrg ;; 9035c2939121Smrg 90362836776bSmrg linux) # correct to gnu/linux during the next big refactor 9037c2939121Smrg func_arith $current - $age 9038c2939121Smrg major=.$func_arith_result 90398292847cSmrg versuffix=$major.$age.$revision 9040c2939121Smrg ;; 9041c2939121Smrg 9042c2939121Smrg osf) 9043c2939121Smrg func_arith $current - $age 9044c2939121Smrg major=.$func_arith_result 90458292847cSmrg versuffix=.$current.$age.$revision 90468292847cSmrg verstring=$current.$age.$revision 9047c2939121Smrg 9048c2939121Smrg # Add in all the interfaces that we are compatible with. 9049c2939121Smrg loop=$age 90508292847cSmrg while test 0 -ne "$loop"; do 9051c2939121Smrg func_arith $current - $loop 9052c2939121Smrg iface=$func_arith_result 9053c2939121Smrg func_arith $loop - 1 9054c2939121Smrg loop=$func_arith_result 90558292847cSmrg verstring=$verstring:$iface.0 9056c2939121Smrg done 9057c2939121Smrg 9058c2939121Smrg # Make executables depend on our current version. 90598292847cSmrg func_append verstring ":$current.0" 9060c2939121Smrg ;; 9061c2939121Smrg 9062c2939121Smrg qnx) 90638292847cSmrg major=.$current 90648292847cSmrg versuffix=.$current 90658292847cSmrg ;; 90668292847cSmrg 90678292847cSmrg sco) 90688292847cSmrg major=.$current 90698292847cSmrg versuffix=.$current 9070c2939121Smrg ;; 9071c2939121Smrg 9072c2939121Smrg sunos) 90738292847cSmrg major=.$current 90748292847cSmrg versuffix=.$current.$revision 9075c2939121Smrg ;; 9076c2939121Smrg 9077c2939121Smrg windows) 9078c2939121Smrg # Use '-' rather than '.', since we only want one 90798292847cSmrg # extension on DOS 8.3 file systems. 9080c2939121Smrg func_arith $current - $age 9081c2939121Smrg major=$func_arith_result 90828292847cSmrg versuffix=-$major 9083c2939121Smrg ;; 9084c2939121Smrg 9085c2939121Smrg *) 90868292847cSmrg func_fatal_configuration "unknown library version type '$version_type'" 9087c2939121Smrg ;; 9088c2939121Smrg esac 9089c2939121Smrg 9090c2939121Smrg # Clear the version info if we defaulted, and they specified a release. 9091c2939121Smrg if test -z "$vinfo" && test -n "$release"; then 9092c2939121Smrg major= 9093c2939121Smrg case $version_type in 9094c2939121Smrg darwin) 9095c2939121Smrg # we can't check for "0.0" in archive_cmds due to quoting 9096c2939121Smrg # problems, so we reset it completely 9097c2939121Smrg verstring= 9098c2939121Smrg ;; 9099c2939121Smrg *) 91008292847cSmrg verstring=0.0 9101c2939121Smrg ;; 9102c2939121Smrg esac 91038292847cSmrg if test no = "$need_version"; then 9104c2939121Smrg versuffix= 9105c2939121Smrg else 91068292847cSmrg versuffix=.0.0 9107c2939121Smrg fi 9108c2939121Smrg fi 9109c2939121Smrg 9110c2939121Smrg # Remove version info from name if versioning should be avoided 91118292847cSmrg if test yes,no = "$avoid_version,$need_version"; then 9112c2939121Smrg major= 9113c2939121Smrg versuffix= 91148292847cSmrg verstring= 9115c2939121Smrg fi 9116c2939121Smrg 9117c2939121Smrg # Check to see if the archive will have undefined symbols. 91188292847cSmrg if test yes = "$allow_undefined"; then 91198292847cSmrg if test unsupported = "$allow_undefined_flag"; then 91208292847cSmrg if test yes = "$build_old_libs"; then 91218292847cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 91228292847cSmrg build_libtool_libs=no 91238292847cSmrg else 91248292847cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 91258292847cSmrg fi 9126c2939121Smrg fi 9127c2939121Smrg else 9128c2939121Smrg # Don't allow undefined symbols. 91298292847cSmrg allow_undefined_flag=$no_undefined_flag 9130c2939121Smrg fi 9131c2939121Smrg 9132c2939121Smrg fi 9133c2939121Smrg 91348292847cSmrg func_generate_dlsyms "$libname" "$libname" : 91352836776bSmrg func_append libobjs " $symfileobj" 91368292847cSmrg test " " = "$libobjs" && libobjs= 9137c2939121Smrg 91388292847cSmrg if test relink != "$opt_mode"; then 9139c2939121Smrg # Remove our outputs, but don't remove object files since they 9140c2939121Smrg # may have been created when compiling PIC objects. 9141c2939121Smrg removelist= 9142c2939121Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9143c2939121Smrg for p in $tempremovelist; do 9144c2939121Smrg case $p in 9145c2939121Smrg *.$objext | *.gcno) 9146c2939121Smrg ;; 91478292847cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 91488292847cSmrg if test -n "$precious_files_regex"; then 9149c2939121Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9150c2939121Smrg then 9151c2939121Smrg continue 9152c2939121Smrg fi 9153c2939121Smrg fi 91542836776bSmrg func_append removelist " $p" 9155c2939121Smrg ;; 9156c2939121Smrg *) ;; 9157c2939121Smrg esac 9158c2939121Smrg done 9159c2939121Smrg test -n "$removelist" && \ 9160c2939121Smrg func_show_eval "${RM}r \$removelist" 9161c2939121Smrg fi 9162c2939121Smrg 9163c2939121Smrg # Now set the variables for building old libraries. 91648292847cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 91652836776bSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9166c2939121Smrg 9167c2939121Smrg # Transform .lo files to .o files. 91688292847cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9169c2939121Smrg fi 9170c2939121Smrg 9171c2939121Smrg # Eliminate all temporary directories. 9172c2939121Smrg #for path in $notinst_path; do 9173c2939121Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9174c2939121Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9175c2939121Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9176c2939121Smrg #done 9177c2939121Smrg 9178c2939121Smrg if test -n "$xrpath"; then 9179c2939121Smrg # If the user specified any rpath flags, then add them. 9180c2939121Smrg temp_xrpath= 9181c2939121Smrg for libdir in $xrpath; do 91822836776bSmrg func_replace_sysroot "$libdir" 91832836776bSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9184c2939121Smrg case "$finalize_rpath " in 9185c2939121Smrg *" $libdir "*) ;; 91862836776bSmrg *) func_append finalize_rpath " $libdir" ;; 9187c2939121Smrg esac 9188c2939121Smrg done 91898292847cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9190c2939121Smrg dependency_libs="$temp_xrpath $dependency_libs" 9191c2939121Smrg fi 9192c2939121Smrg fi 9193c2939121Smrg 9194c2939121Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 91958292847cSmrg old_dlfiles=$dlfiles 9196c2939121Smrg dlfiles= 9197c2939121Smrg for lib in $old_dlfiles; do 9198c2939121Smrg case " $dlprefiles $dlfiles " in 9199c2939121Smrg *" $lib "*) ;; 92002836776bSmrg *) func_append dlfiles " $lib" ;; 9201c2939121Smrg esac 9202c2939121Smrg done 9203c2939121Smrg 9204c2939121Smrg # Make sure dlprefiles contains only unique files 92058292847cSmrg old_dlprefiles=$dlprefiles 9206c2939121Smrg dlprefiles= 9207c2939121Smrg for lib in $old_dlprefiles; do 9208c2939121Smrg case "$dlprefiles " in 9209c2939121Smrg *" $lib "*) ;; 92102836776bSmrg *) func_append dlprefiles " $lib" ;; 9211c2939121Smrg esac 9212c2939121Smrg done 9213c2939121Smrg 92148292847cSmrg if test yes = "$build_libtool_libs"; then 9215c2939121Smrg if test -n "$rpath"; then 9216c2939121Smrg case $host in 9217c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9218c2939121Smrg # these systems don't actually have a c library (as such)! 9219c2939121Smrg ;; 9220c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9221c2939121Smrg # Rhapsody C library is in the System framework 92222836776bSmrg func_append deplibs " System.ltframework" 9223c2939121Smrg ;; 9224c2939121Smrg *-*-netbsd*) 9225c2939121Smrg # Don't link with libc until the a.out ld.so is fixed. 9226c2939121Smrg ;; 9227c2939121Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9228c2939121Smrg # Do not include libc due to us having libc/libc_r. 9229c2939121Smrg ;; 9230c2939121Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9231c2939121Smrg # Causes problems with __ctype 9232c2939121Smrg ;; 9233c2939121Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9234c2939121Smrg # Compiler inserts libc in the correct place for threads to work 9235c2939121Smrg ;; 9236c2939121Smrg *) 9237c2939121Smrg # Add libc to deplibs on all other systems if necessary. 92388292847cSmrg if test yes = "$build_libtool_need_lc"; then 92392836776bSmrg func_append deplibs " -lc" 9240c2939121Smrg fi 9241c2939121Smrg ;; 9242c2939121Smrg esac 9243c2939121Smrg fi 9244c2939121Smrg 9245c2939121Smrg # Transform deplibs into only deplibs that can be linked in shared. 9246c2939121Smrg name_save=$name 9247c2939121Smrg libname_save=$libname 9248c2939121Smrg release_save=$release 9249c2939121Smrg versuffix_save=$versuffix 9250c2939121Smrg major_save=$major 9251c2939121Smrg # I'm not sure if I'm treating the release correctly. I think 9252c2939121Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9253c2939121Smrg # add it in twice. Is that correct? 92548292847cSmrg release= 92558292847cSmrg versuffix= 92568292847cSmrg major= 9257c2939121Smrg newdeplibs= 9258c2939121Smrg droppeddeps=no 9259c2939121Smrg case $deplibs_check_method in 9260c2939121Smrg pass_all) 9261c2939121Smrg # Don't check for shared/static. Everything works. 9262c2939121Smrg # This might be a little naive. We might want to check 9263c2939121Smrg # whether the library exists or not. But this is on 9264c2939121Smrg # osf3 & osf4 and I'm not really sure... Just 9265c2939121Smrg # implementing what was already the behavior. 9266c2939121Smrg newdeplibs=$deplibs 9267c2939121Smrg ;; 9268c2939121Smrg test_compile) 9269c2939121Smrg # This code stresses the "libraries are programs" paradigm to its 9270c2939121Smrg # limits. Maybe even breaks it. We compile a program, linking it 9271c2939121Smrg # against the deplibs as a proxy for the library. Then we can check 9272c2939121Smrg # whether they linked in statically or dynamically with ldd. 9273c2939121Smrg $opt_dry_run || $RM conftest.c 9274c2939121Smrg cat > conftest.c <<EOF 9275c2939121Smrg int main() { return 0; } 9276c2939121SmrgEOF 9277c2939121Smrg $opt_dry_run || $RM conftest 9278c2939121Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9279c2939121Smrg ldd_output=`ldd conftest` 9280c2939121Smrg for i in $deplibs; do 9281c2939121Smrg case $i in 9282c2939121Smrg -l*) 9283c2939121Smrg func_stripname -l '' "$i" 9284c2939121Smrg name=$func_stripname_result 92858292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9286c2939121Smrg case " $predeps $postdeps " in 9287c2939121Smrg *" $i "*) 92882836776bSmrg func_append newdeplibs " $i" 92898292847cSmrg i= 9290c2939121Smrg ;; 9291c2939121Smrg esac 9292c2939121Smrg fi 92938292847cSmrg if test -n "$i"; then 9294c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9295c2939121Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9296c2939121Smrg set dummy $deplib_matches; shift 9297c2939121Smrg deplib_match=$1 92988292847cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 92992836776bSmrg func_append newdeplibs " $i" 9300c2939121Smrg else 9301c2939121Smrg droppeddeps=yes 9302c2939121Smrg echo 9303c2939121Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9304c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9305c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9306c2939121Smrg echo "*** shared version of the library, which I believe you do not have" 9307c2939121Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9308c2939121Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9309c2939121Smrg fi 9310c2939121Smrg fi 9311c2939121Smrg ;; 9312c2939121Smrg *) 93132836776bSmrg func_append newdeplibs " $i" 9314c2939121Smrg ;; 9315c2939121Smrg esac 9316c2939121Smrg done 9317c2939121Smrg else 9318c2939121Smrg # Error occurred in the first compile. Let's try to salvage 9319c2939121Smrg # the situation: Compile a separate program for each library. 9320c2939121Smrg for i in $deplibs; do 9321c2939121Smrg case $i in 9322c2939121Smrg -l*) 9323c2939121Smrg func_stripname -l '' "$i" 9324c2939121Smrg name=$func_stripname_result 9325c2939121Smrg $opt_dry_run || $RM conftest 9326c2939121Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9327c2939121Smrg ldd_output=`ldd conftest` 93288292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9329c2939121Smrg case " $predeps $postdeps " in 9330c2939121Smrg *" $i "*) 93312836776bSmrg func_append newdeplibs " $i" 93328292847cSmrg i= 9333c2939121Smrg ;; 9334c2939121Smrg esac 9335c2939121Smrg fi 93368292847cSmrg if test -n "$i"; then 9337c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9338c2939121Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9339c2939121Smrg set dummy $deplib_matches; shift 9340c2939121Smrg deplib_match=$1 93418292847cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 93422836776bSmrg func_append newdeplibs " $i" 9343c2939121Smrg else 9344c2939121Smrg droppeddeps=yes 9345c2939121Smrg echo 9346c2939121Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9347c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9348c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9349c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 9350c2939121Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9351c2939121Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9352c2939121Smrg fi 9353c2939121Smrg fi 9354c2939121Smrg else 9355c2939121Smrg droppeddeps=yes 9356c2939121Smrg echo 9357c2939121Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9358c2939121Smrg echo "*** make it link in! You will probably need to install it or some" 9359c2939121Smrg echo "*** library that it depends on before this library will be fully" 9360c2939121Smrg echo "*** functional. Installing it before continuing would be even better." 9361c2939121Smrg fi 9362c2939121Smrg ;; 9363c2939121Smrg *) 93642836776bSmrg func_append newdeplibs " $i" 9365c2939121Smrg ;; 9366c2939121Smrg esac 9367c2939121Smrg done 9368c2939121Smrg fi 9369c2939121Smrg ;; 9370c2939121Smrg file_magic*) 9371c2939121Smrg set dummy $deplibs_check_method; shift 9372c2939121Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9373c2939121Smrg for a_deplib in $deplibs; do 9374c2939121Smrg case $a_deplib in 9375c2939121Smrg -l*) 9376c2939121Smrg func_stripname -l '' "$a_deplib" 9377c2939121Smrg name=$func_stripname_result 93788292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9379c2939121Smrg case " $predeps $postdeps " in 9380c2939121Smrg *" $a_deplib "*) 93812836776bSmrg func_append newdeplibs " $a_deplib" 93828292847cSmrg a_deplib= 9383c2939121Smrg ;; 9384c2939121Smrg esac 9385c2939121Smrg fi 93868292847cSmrg if test -n "$a_deplib"; then 9387c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 93882836776bSmrg if test -n "$file_magic_glob"; then 93892836776bSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 93902836776bSmrg else 93912836776bSmrg libnameglob=$libname 93922836776bSmrg fi 93938292847cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9394c2939121Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93958292847cSmrg if test yes = "$want_nocaseglob"; then 93962836776bSmrg shopt -s nocaseglob 93972836776bSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 93982836776bSmrg $nocaseglob 93992836776bSmrg else 94002836776bSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 94012836776bSmrg fi 9402c2939121Smrg for potent_lib in $potential_libs; do 9403c2939121Smrg # Follow soft links. 9404c2939121Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9405c2939121Smrg $GREP " -> " >/dev/null; then 9406c2939121Smrg continue 9407c2939121Smrg fi 9408c2939121Smrg # The statement above tries to avoid entering an 9409c2939121Smrg # endless loop below, in case of cyclic links. 9410c2939121Smrg # We might still enter an endless loop, since a link 9411c2939121Smrg # loop can be closed while we follow links, 9412c2939121Smrg # but so what? 94138292847cSmrg potlib=$potent_lib 9414c2939121Smrg while test -h "$potlib" 2>/dev/null; do 94158292847cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9416c2939121Smrg case $potliblink in 94178292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 94188292847cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9419c2939121Smrg esac 9420c2939121Smrg done 9421c2939121Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9422c2939121Smrg $SED -e 10q | 9423c2939121Smrg $EGREP "$file_magic_regex" > /dev/null; then 94242836776bSmrg func_append newdeplibs " $a_deplib" 94258292847cSmrg a_deplib= 9426c2939121Smrg break 2 9427c2939121Smrg fi 9428c2939121Smrg done 9429c2939121Smrg done 9430c2939121Smrg fi 94318292847cSmrg if test -n "$a_deplib"; then 9432c2939121Smrg droppeddeps=yes 9433c2939121Smrg echo 9434c2939121Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9435c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9436c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9437c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 9438c2939121Smrg echo "*** because I did check the linker path looking for a file starting" 94398292847cSmrg if test -z "$potlib"; then 9440c2939121Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9441c2939121Smrg else 9442c2939121Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9443c2939121Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9444c2939121Smrg fi 9445c2939121Smrg fi 9446c2939121Smrg ;; 9447c2939121Smrg *) 9448c2939121Smrg # Add a -L argument. 94492836776bSmrg func_append newdeplibs " $a_deplib" 9450c2939121Smrg ;; 9451c2939121Smrg esac 9452c2939121Smrg done # Gone through all deplibs. 9453c2939121Smrg ;; 9454c2939121Smrg match_pattern*) 9455c2939121Smrg set dummy $deplibs_check_method; shift 9456c2939121Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9457c2939121Smrg for a_deplib in $deplibs; do 9458c2939121Smrg case $a_deplib in 9459c2939121Smrg -l*) 9460c2939121Smrg func_stripname -l '' "$a_deplib" 9461c2939121Smrg name=$func_stripname_result 94628292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9463c2939121Smrg case " $predeps $postdeps " in 9464c2939121Smrg *" $a_deplib "*) 94652836776bSmrg func_append newdeplibs " $a_deplib" 94668292847cSmrg a_deplib= 9467c2939121Smrg ;; 9468c2939121Smrg esac 9469c2939121Smrg fi 94708292847cSmrg if test -n "$a_deplib"; then 9471c2939121Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9472c2939121Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9473c2939121Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9474c2939121Smrg for potent_lib in $potential_libs; do 94758292847cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9476c2939121Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9477c2939121Smrg $EGREP "$match_pattern_regex" > /dev/null; then 94782836776bSmrg func_append newdeplibs " $a_deplib" 94798292847cSmrg a_deplib= 9480c2939121Smrg break 2 9481c2939121Smrg fi 9482c2939121Smrg done 9483c2939121Smrg done 9484c2939121Smrg fi 94858292847cSmrg if test -n "$a_deplib"; then 9486c2939121Smrg droppeddeps=yes 9487c2939121Smrg echo 9488c2939121Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9489c2939121Smrg echo "*** I have the capability to make that library automatically link in when" 9490c2939121Smrg echo "*** you link to this library. But I can only do this if you have a" 9491c2939121Smrg echo "*** shared version of the library, which you do not appear to have" 9492c2939121Smrg echo "*** because I did check the linker path looking for a file starting" 94938292847cSmrg if test -z "$potlib"; then 9494c2939121Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9495c2939121Smrg else 9496c2939121Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9497c2939121Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9498c2939121Smrg fi 9499c2939121Smrg fi 9500c2939121Smrg ;; 9501c2939121Smrg *) 9502c2939121Smrg # Add a -L argument. 95032836776bSmrg func_append newdeplibs " $a_deplib" 9504c2939121Smrg ;; 9505c2939121Smrg esac 9506c2939121Smrg done # Gone through all deplibs. 9507c2939121Smrg ;; 9508c2939121Smrg none | unknown | *) 95098292847cSmrg newdeplibs= 9510c2939121Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 95118292847cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95128292847cSmrg for i in $predeps $postdeps; do 9513c2939121Smrg # can't use Xsed below, because $i might contain '/' 95148292847cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9515c2939121Smrg done 9516c2939121Smrg fi 9517c2939121Smrg case $tmp_deplibs in 9518c2939121Smrg *[!\ \ ]*) 9519c2939121Smrg echo 95208292847cSmrg if test none = "$deplibs_check_method"; then 9521c2939121Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9522c2939121Smrg else 9523c2939121Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9524c2939121Smrg fi 9525c2939121Smrg echo "*** All declared inter-library dependencies are being dropped." 9526c2939121Smrg droppeddeps=yes 9527c2939121Smrg ;; 9528c2939121Smrg esac 9529c2939121Smrg ;; 9530c2939121Smrg esac 9531c2939121Smrg versuffix=$versuffix_save 9532c2939121Smrg major=$major_save 9533c2939121Smrg release=$release_save 9534c2939121Smrg libname=$libname_save 9535c2939121Smrg name=$name_save 9536c2939121Smrg 9537c2939121Smrg case $host in 9538c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9539c2939121Smrg # On Rhapsody replace the C library with the System framework 9540c2939121Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9541c2939121Smrg ;; 9542c2939121Smrg esac 9543c2939121Smrg 95448292847cSmrg if test yes = "$droppeddeps"; then 95458292847cSmrg if test yes = "$module"; then 9546c2939121Smrg echo 9547c2939121Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9548c2939121Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9549c2939121Smrg echo "*** a static module, that should work as long as the dlopening" 9550c2939121Smrg echo "*** application is linked with the -dlopen flag." 9551c2939121Smrg if test -z "$global_symbol_pipe"; then 9552c2939121Smrg echo 9553c2939121Smrg echo "*** However, this would only work if libtool was able to extract symbol" 95548292847cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9555c2939121Smrg echo "*** not find such a program. So, this module is probably useless." 95568292847cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9557c2939121Smrg fi 95588292847cSmrg if test no = "$build_old_libs"; then 95598292847cSmrg oldlibs=$output_objdir/$libname.$libext 9560c2939121Smrg build_libtool_libs=module 9561c2939121Smrg build_old_libs=yes 9562c2939121Smrg else 9563c2939121Smrg build_libtool_libs=no 9564c2939121Smrg fi 9565c2939121Smrg else 9566c2939121Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9567c2939121Smrg echo "*** automatically added whenever a program is linked with this library" 9568c2939121Smrg echo "*** or is declared to -dlopen it." 9569c2939121Smrg 95708292847cSmrg if test no = "$allow_undefined"; then 9571c2939121Smrg echo 9572c2939121Smrg echo "*** Since this library must not contain undefined symbols," 9573c2939121Smrg echo "*** because either the platform does not support them or" 9574c2939121Smrg echo "*** it was explicitly requested with -no-undefined," 9575c2939121Smrg echo "*** libtool will only create a static version of it." 95768292847cSmrg if test no = "$build_old_libs"; then 95778292847cSmrg oldlibs=$output_objdir/$libname.$libext 9578c2939121Smrg build_libtool_libs=module 9579c2939121Smrg build_old_libs=yes 9580c2939121Smrg else 9581c2939121Smrg build_libtool_libs=no 9582c2939121Smrg fi 9583c2939121Smrg fi 9584c2939121Smrg fi 9585c2939121Smrg fi 9586c2939121Smrg # Done checking deplibs! 9587c2939121Smrg deplibs=$newdeplibs 9588c2939121Smrg fi 9589c2939121Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9590c2939121Smrg case $host in 9591c2939121Smrg *-*-darwin*) 9592c2939121Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9593c2939121Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9594c2939121Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9595c2939121Smrg ;; 9596c2939121Smrg esac 9597c2939121Smrg 9598c2939121Smrg # move library search paths that coincide with paths to not yet 9599c2939121Smrg # installed libraries to the beginning of the library search list 9600c2939121Smrg new_libs= 9601c2939121Smrg for path in $notinst_path; do 9602c2939121Smrg case " $new_libs " in 9603c2939121Smrg *" -L$path/$objdir "*) ;; 9604c2939121Smrg *) 9605c2939121Smrg case " $deplibs " in 9606c2939121Smrg *" -L$path/$objdir "*) 96072836776bSmrg func_append new_libs " -L$path/$objdir" ;; 9608c2939121Smrg esac 9609c2939121Smrg ;; 9610c2939121Smrg esac 9611c2939121Smrg done 9612c2939121Smrg for deplib in $deplibs; do 9613c2939121Smrg case $deplib in 9614c2939121Smrg -L*) 9615c2939121Smrg case " $new_libs " in 9616c2939121Smrg *" $deplib "*) ;; 96172836776bSmrg *) func_append new_libs " $deplib" ;; 9618c2939121Smrg esac 9619c2939121Smrg ;; 96202836776bSmrg *) func_append new_libs " $deplib" ;; 9621c2939121Smrg esac 9622c2939121Smrg done 96238292847cSmrg deplibs=$new_libs 9624c2939121Smrg 9625c2939121Smrg # All the library-specific variables (install_libdir is set above). 9626c2939121Smrg library_names= 9627c2939121Smrg old_library= 9628c2939121Smrg dlname= 9629c2939121Smrg 9630c2939121Smrg # Test again, we may have decided not to build it any more 96318292847cSmrg if test yes = "$build_libtool_libs"; then 96328292847cSmrg # Remove $wl instances when linking with ld. 96332836776bSmrg # FIXME: should test the right _cmds variable. 96342836776bSmrg case $archive_cmds in 96352836776bSmrg *\$LD\ *) wl= ;; 96362836776bSmrg esac 96378292847cSmrg if test yes = "$hardcode_into_libs"; then 9638c2939121Smrg # Hardcode the library paths 9639c2939121Smrg hardcode_libdirs= 9640c2939121Smrg dep_rpath= 96418292847cSmrg rpath=$finalize_rpath 96428292847cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9643c2939121Smrg for libdir in $rpath; do 9644c2939121Smrg if test -n "$hardcode_libdir_flag_spec"; then 9645c2939121Smrg if test -n "$hardcode_libdir_separator"; then 96462836776bSmrg func_replace_sysroot "$libdir" 96472836776bSmrg libdir=$func_replace_sysroot_result 9648c2939121Smrg if test -z "$hardcode_libdirs"; then 96498292847cSmrg hardcode_libdirs=$libdir 9650c2939121Smrg else 9651c2939121Smrg # Just accumulate the unique libdirs. 9652c2939121Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9653c2939121Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9654c2939121Smrg ;; 9655c2939121Smrg *) 96562836776bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9657c2939121Smrg ;; 9658c2939121Smrg esac 9659c2939121Smrg fi 9660c2939121Smrg else 9661c2939121Smrg eval flag=\"$hardcode_libdir_flag_spec\" 96622836776bSmrg func_append dep_rpath " $flag" 9663c2939121Smrg fi 9664c2939121Smrg elif test -n "$runpath_var"; then 9665c2939121Smrg case "$perm_rpath " in 9666c2939121Smrg *" $libdir "*) ;; 96672836776bSmrg *) func_append perm_rpath " $libdir" ;; 9668c2939121Smrg esac 9669c2939121Smrg fi 9670c2939121Smrg done 9671c2939121Smrg # Substitute the hardcoded libdirs into the rpath. 9672c2939121Smrg if test -n "$hardcode_libdir_separator" && 9673c2939121Smrg test -n "$hardcode_libdirs"; then 96748292847cSmrg libdir=$hardcode_libdirs 96752836776bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9676c2939121Smrg fi 9677c2939121Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9678c2939121Smrg # We should set the runpath_var. 9679c2939121Smrg rpath= 9680c2939121Smrg for dir in $perm_rpath; do 96812836776bSmrg func_append rpath "$dir:" 9682c2939121Smrg done 9683c2939121Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9684c2939121Smrg fi 9685c2939121Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9686c2939121Smrg fi 9687c76ae52dSmrg 96888292847cSmrg shlibpath=$finalize_shlibpath 96898292847cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9690c2939121Smrg if test -n "$shlibpath"; then 9691c2939121Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9692c2939121Smrg fi 9693c76ae52dSmrg 9694c2939121Smrg # Get the real and link names of the library. 9695c2939121Smrg eval shared_ext=\"$shrext_cmds\" 9696c2939121Smrg eval library_names=\"$library_names_spec\" 9697c2939121Smrg set dummy $library_names 9698c2939121Smrg shift 96998292847cSmrg realname=$1 9700c2939121Smrg shift 9701c76ae52dSmrg 9702c2939121Smrg if test -n "$soname_spec"; then 9703c2939121Smrg eval soname=\"$soname_spec\" 9704c2939121Smrg else 97058292847cSmrg soname=$realname 9706c2939121Smrg fi 9707c2939121Smrg if test -z "$dlname"; then 9708c2939121Smrg dlname=$soname 9709c2939121Smrg fi 9710c76ae52dSmrg 97118292847cSmrg lib=$output_objdir/$realname 9712c2939121Smrg linknames= 9713c2939121Smrg for link 9714c2939121Smrg do 97152836776bSmrg func_append linknames " $link" 9716c2939121Smrg done 9717c76ae52dSmrg 9718c2939121Smrg # Use standard objects if they are pic 9719c2939121Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9720c2939121Smrg test "X$libobjs" = "X " && libobjs= 9721c76ae52dSmrg 9722c2939121Smrg delfiles= 9723c2939121Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9724c2939121Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 97258292847cSmrg export_symbols=$output_objdir/$libname.uexp 97262836776bSmrg func_append delfiles " $export_symbols" 9727c2939121Smrg fi 9728c76ae52dSmrg 9729c2939121Smrg orig_export_symbols= 9730c2939121Smrg case $host_os in 9731c2939121Smrg cygwin* | mingw* | cegcc*) 9732c2939121Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9733c2939121Smrg # exporting using user supplied symfile 97348292847cSmrg func_dll_def_p "$export_symbols" || { 9735c2939121Smrg # and it's NOT already a .def file. Must figure out 9736c2939121Smrg # which of the given symbols are data symbols and tag 9737c2939121Smrg # them as such. So, trigger use of export_symbols_cmds. 9738c2939121Smrg # export_symbols gets reassigned inside the "prepare 9739c2939121Smrg # the list of exported symbols" if statement, so the 9740c2939121Smrg # include_expsyms logic still works. 97418292847cSmrg orig_export_symbols=$export_symbols 9742c2939121Smrg export_symbols= 9743c2939121Smrg always_export_symbols=yes 97448292847cSmrg } 9745c2939121Smrg fi 9746c2939121Smrg ;; 9747c2939121Smrg esac 9748c76ae52dSmrg 9749c2939121Smrg # Prepare the list of exported symbols 9750c2939121Smrg if test -z "$export_symbols"; then 97518292847cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 97528292847cSmrg func_verbose "generating symbol list for '$libname.la'" 97538292847cSmrg export_symbols=$output_objdir/$libname.exp 9754c2939121Smrg $opt_dry_run || $RM $export_symbols 9755c2939121Smrg cmds=$export_symbols_cmds 97568292847cSmrg save_ifs=$IFS; IFS='~' 97572836776bSmrg for cmd1 in $cmds; do 97588292847cSmrg IFS=$save_ifs 97592836776bSmrg # Take the normal branch if the nm_file_list_spec branch 97602836776bSmrg # doesn't work or if tool conversion is not needed. 97612836776bSmrg case $nm_file_list_spec~$to_tool_file_cmd in 97622836776bSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 97632836776bSmrg try_normal_branch=yes 97642836776bSmrg eval cmd=\"$cmd1\" 97652836776bSmrg func_len " $cmd" 97662836776bSmrg len=$func_len_result 97672836776bSmrg ;; 97682836776bSmrg *) 97692836776bSmrg try_normal_branch=no 97702836776bSmrg ;; 97712836776bSmrg esac 97728292847cSmrg if test yes = "$try_normal_branch" \ 97732836776bSmrg && { test "$len" -lt "$max_cmd_len" \ 97742836776bSmrg || test "$max_cmd_len" -le -1; } 97752836776bSmrg then 97762836776bSmrg func_show_eval "$cmd" 'exit $?' 97772836776bSmrg skipped_export=false 97782836776bSmrg elif test -n "$nm_file_list_spec"; then 97792836776bSmrg func_basename "$output" 97802836776bSmrg output_la=$func_basename_result 97812836776bSmrg save_libobjs=$libobjs 97822836776bSmrg save_output=$output 97838292847cSmrg output=$output_objdir/$output_la.nm 97842836776bSmrg func_to_tool_file "$output" 97852836776bSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 97862836776bSmrg func_append delfiles " $output" 97872836776bSmrg func_verbose "creating $NM input file list: $output" 97882836776bSmrg for obj in $save_libobjs; do 97892836776bSmrg func_to_tool_file "$obj" 97902836776bSmrg $ECHO "$func_to_tool_file_result" 97912836776bSmrg done > "$output" 97922836776bSmrg eval cmd=\"$cmd1\" 9793c2939121Smrg func_show_eval "$cmd" 'exit $?' 97942836776bSmrg output=$save_output 97952836776bSmrg libobjs=$save_libobjs 9796c2939121Smrg skipped_export=false 9797c2939121Smrg else 9798c2939121Smrg # The command line is too long to execute in one step. 9799c2939121Smrg func_verbose "using reloadable object file for export list..." 9800c2939121Smrg skipped_export=: 9801c2939121Smrg # Break out early, otherwise skipped_export may be 9802c2939121Smrg # set to false by a later but shorter cmd. 9803c2939121Smrg break 9804c2939121Smrg fi 9805c2939121Smrg done 98068292847cSmrg IFS=$save_ifs 98078292847cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9808c2939121Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9809c2939121Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9810c2939121Smrg fi 9811c2939121Smrg fi 9812c2939121Smrg fi 9813c76ae52dSmrg 9814c2939121Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 98158292847cSmrg tmp_export_symbols=$export_symbols 98168292847cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9817c2939121Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9818c2939121Smrg fi 9819c76ae52dSmrg 98208292847cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9821c2939121Smrg # The given exports_symbols file has to be filtered, so filter it. 98228292847cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9823c2939121Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 98248292847cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9825c2939121Smrg # though. Also, the filter scales superlinearly with the number of 9826c2939121Smrg # global variables. join(1) would be nice here, but unfortunately 9827c2939121Smrg # isn't a blessed tool. 9828c2939121Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 98292836776bSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9830c2939121Smrg export_symbols=$output_objdir/$libname.def 9831c2939121Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9832c76ae52dSmrg fi 9833c76ae52dSmrg 9834c2939121Smrg tmp_deplibs= 9835c2939121Smrg for test_deplib in $deplibs; do 9836c2939121Smrg case " $convenience " in 9837c2939121Smrg *" $test_deplib "*) ;; 9838c2939121Smrg *) 98392836776bSmrg func_append tmp_deplibs " $test_deplib" 9840c2939121Smrg ;; 9841c2939121Smrg esac 9842c2939121Smrg done 98438292847cSmrg deplibs=$tmp_deplibs 9844c76ae52dSmrg 9845c2939121Smrg if test -n "$convenience"; then 9846c2939121Smrg if test -n "$whole_archive_flag_spec" && 98478292847cSmrg test yes = "$compiler_needs_object" && 9848c2939121Smrg test -z "$libobjs"; then 9849c2939121Smrg # extract the archives, so we have objects to list. 9850c2939121Smrg # TODO: could optimize this to just extract one archive. 9851c2939121Smrg whole_archive_flag_spec= 9852c2939121Smrg fi 9853c2939121Smrg if test -n "$whole_archive_flag_spec"; then 9854c2939121Smrg save_libobjs=$libobjs 9855c2939121Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9856c2939121Smrg test "X$libobjs" = "X " && libobjs= 9857c2939121Smrg else 98588292847cSmrg gentop=$output_objdir/${outputname}x 98592836776bSmrg func_append generated " $gentop" 9860c76ae52dSmrg 9861c2939121Smrg func_extract_archives $gentop $convenience 98622836776bSmrg func_append libobjs " $func_extract_archives_result" 9863c2939121Smrg test "X$libobjs" = "X " && libobjs= 9864c2939121Smrg fi 9865c2939121Smrg fi 9866c76ae52dSmrg 98678292847cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9868c2939121Smrg eval flag=\"$thread_safe_flag_spec\" 98692836776bSmrg func_append linker_flags " $flag" 9870c2939121Smrg fi 9871c76ae52dSmrg 9872c2939121Smrg # Make a backup of the uninstalled library when relinking 98738292847cSmrg if test relink = "$opt_mode"; then 9874c2939121Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9875c76ae52dSmrg fi 9876c76ae52dSmrg 9877c2939121Smrg # Do each of the archive commands. 98788292847cSmrg if test yes = "$module" && test -n "$module_cmds"; then 9879c2939121Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9880c2939121Smrg eval test_cmds=\"$module_expsym_cmds\" 9881c2939121Smrg cmds=$module_expsym_cmds 9882c2939121Smrg else 9883c2939121Smrg eval test_cmds=\"$module_cmds\" 9884c2939121Smrg cmds=$module_cmds 9885c2939121Smrg fi 9886c2939121Smrg else 9887c2939121Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9888c2939121Smrg eval test_cmds=\"$archive_expsym_cmds\" 9889c2939121Smrg cmds=$archive_expsym_cmds 9890c2939121Smrg else 9891c2939121Smrg eval test_cmds=\"$archive_cmds\" 9892c2939121Smrg cmds=$archive_cmds 9893c2939121Smrg fi 9894c76ae52dSmrg fi 9895c76ae52dSmrg 98968292847cSmrg if test : != "$skipped_export" && 9897c2939121Smrg func_len " $test_cmds" && 9898c2939121Smrg len=$func_len_result && 9899c2939121Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9900c2939121Smrg : 9901c2939121Smrg else 9902c2939121Smrg # The command line is too long to link in one step, link piecewise 9903c2939121Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9904c2939121Smrg # script. 9905c76ae52dSmrg 9906c2939121Smrg # Save the value of $output and $libobjs because we want to 9907c2939121Smrg # use them later. If we have whole_archive_flag_spec, we 9908c2939121Smrg # want to use save_libobjs as it was before 9909c2939121Smrg # whole_archive_flag_spec was expanded, because we can't 9910c2939121Smrg # assume the linker understands whole_archive_flag_spec. 9911c2939121Smrg # This may have to be revisited, in case too many 9912c2939121Smrg # convenience libraries get linked in and end up exceeding 9913c2939121Smrg # the spec. 9914c2939121Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9915c2939121Smrg save_libobjs=$libobjs 9916c2939121Smrg fi 9917c2939121Smrg save_output=$output 9918c2939121Smrg func_basename "$output" 9919c2939121Smrg output_la=$func_basename_result 9920c76ae52dSmrg 9921c2939121Smrg # Clear the reloadable object creation command queue and 9922c2939121Smrg # initialize k to one. 9923c2939121Smrg test_cmds= 9924c2939121Smrg concat_cmds= 9925c2939121Smrg objlist= 9926c2939121Smrg last_robj= 9927c2939121Smrg k=1 9928c76ae52dSmrg 99298292847cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 99308292847cSmrg output=$output_objdir/$output_la.lnkscript 9931c2939121Smrg func_verbose "creating GNU ld script: $output" 9932c2939121Smrg echo 'INPUT (' > $output 9933c2939121Smrg for obj in $save_libobjs 9934c2939121Smrg do 99352836776bSmrg func_to_tool_file "$obj" 99362836776bSmrg $ECHO "$func_to_tool_file_result" >> $output 9937c2939121Smrg done 9938c2939121Smrg echo ')' >> $output 99392836776bSmrg func_append delfiles " $output" 99402836776bSmrg func_to_tool_file "$output" 99412836776bSmrg output=$func_to_tool_file_result 99428292847cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 99438292847cSmrg output=$output_objdir/$output_la.lnk 9944c2939121Smrg func_verbose "creating linker input file list: $output" 9945c2939121Smrg : > $output 9946c2939121Smrg set x $save_libobjs 9947c2939121Smrg shift 9948c2939121Smrg firstobj= 99498292847cSmrg if test yes = "$compiler_needs_object"; then 9950c2939121Smrg firstobj="$1 " 9951c2939121Smrg shift 9952c2939121Smrg fi 9953c2939121Smrg for obj 9954c2939121Smrg do 99552836776bSmrg func_to_tool_file "$obj" 99562836776bSmrg $ECHO "$func_to_tool_file_result" >> $output 9957c2939121Smrg done 99582836776bSmrg func_append delfiles " $output" 99592836776bSmrg func_to_tool_file "$output" 99602836776bSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9961c2939121Smrg else 9962c2939121Smrg if test -n "$save_libobjs"; then 9963c2939121Smrg func_verbose "creating reloadable object files..." 99648292847cSmrg output=$output_objdir/$output_la-$k.$objext 9965c2939121Smrg eval test_cmds=\"$reload_cmds\" 9966c2939121Smrg func_len " $test_cmds" 9967c2939121Smrg len0=$func_len_result 9968c2939121Smrg len=$len0 9969c2939121Smrg 9970c2939121Smrg # Loop over the list of objects to be linked. 9971c2939121Smrg for obj in $save_libobjs 9972c2939121Smrg do 9973c2939121Smrg func_len " $obj" 9974c2939121Smrg func_arith $len + $func_len_result 9975c2939121Smrg len=$func_arith_result 99768292847cSmrg if test -z "$objlist" || 9977c2939121Smrg test "$len" -lt "$max_cmd_len"; then 9978c2939121Smrg func_append objlist " $obj" 9979c2939121Smrg else 9980c2939121Smrg # The command $test_cmds is almost too long, add a 9981c2939121Smrg # command to the queue. 99828292847cSmrg if test 1 -eq "$k"; then 9983c2939121Smrg # The first file doesn't have a previous command to add. 9984c2939121Smrg reload_objs=$objlist 9985c2939121Smrg eval concat_cmds=\"$reload_cmds\" 9986c2939121Smrg else 9987c2939121Smrg # All subsequent reloadable object files will link in 9988c2939121Smrg # the last one created. 9989c2939121Smrg reload_objs="$objlist $last_robj" 9990c2939121Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9991c2939121Smrg fi 99928292847cSmrg last_robj=$output_objdir/$output_la-$k.$objext 9993c2939121Smrg func_arith $k + 1 9994c2939121Smrg k=$func_arith_result 99958292847cSmrg output=$output_objdir/$output_la-$k.$objext 9996c2939121Smrg objlist=" $obj" 9997c2939121Smrg func_len " $last_robj" 9998c2939121Smrg func_arith $len0 + $func_len_result 9999c2939121Smrg len=$func_arith_result 10000c2939121Smrg fi 10001c2939121Smrg done 10002c2939121Smrg # Handle the remaining objects by creating one last 10003c2939121Smrg # reloadable object file. All subsequent reloadable object 10004c2939121Smrg # files will link in the last one created. 10005c2939121Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10006c2939121Smrg reload_objs="$objlist $last_robj" 100078292847cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10008c2939121Smrg if test -n "$last_robj"; then 100098292847cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10010c2939121Smrg fi 100112836776bSmrg func_append delfiles " $output" 10012c2939121Smrg 10013c2939121Smrg else 10014c2939121Smrg output= 10015c2939121Smrg fi 10016c76ae52dSmrg 100178292847cSmrg ${skipped_export-false} && { 100188292847cSmrg func_verbose "generating symbol list for '$libname.la'" 100198292847cSmrg export_symbols=$output_objdir/$libname.exp 10020c2939121Smrg $opt_dry_run || $RM $export_symbols 10021c2939121Smrg libobjs=$output 10022c2939121Smrg # Append the command to create the export file. 10023c2939121Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10024c2939121Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10025c2939121Smrg if test -n "$last_robj"; then 10026c2939121Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10027c2939121Smrg fi 100288292847cSmrg } 10029c76ae52dSmrg 10030c2939121Smrg test -n "$save_libobjs" && 10031c2939121Smrg func_verbose "creating a temporary reloadable object file: $output" 10032c76ae52dSmrg 10033c2939121Smrg # Loop through the commands generated above and execute them. 100348292847cSmrg save_ifs=$IFS; IFS='~' 10035c2939121Smrg for cmd in $concat_cmds; do 100368292847cSmrg IFS=$save_ifs 100378292847cSmrg $opt_quiet || { 10038c2939121Smrg func_quote_for_expand "$cmd" 10039c2939121Smrg eval "func_echo $func_quote_for_expand_result" 10040c2939121Smrg } 10041c2939121Smrg $opt_dry_run || eval "$cmd" || { 10042c2939121Smrg lt_exit=$? 10043c2939121Smrg 10044c2939121Smrg # Restore the uninstalled library and exit 100458292847cSmrg if test relink = "$opt_mode"; then 10046c2939121Smrg ( cd "$output_objdir" && \ 10047c2939121Smrg $RM "${realname}T" && \ 10048c2939121Smrg $MV "${realname}U" "$realname" ) 10049c2939121Smrg fi 10050c76ae52dSmrg 10051c2939121Smrg exit $lt_exit 10052c2939121Smrg } 10053c2939121Smrg done 100548292847cSmrg IFS=$save_ifs 10055c76ae52dSmrg 10056c2939121Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10057c2939121Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10058c2939121Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10059c76ae52dSmrg fi 10060c76ae52dSmrg fi 10061c76ae52dSmrg 100628292847cSmrg ${skipped_export-false} && { 10063c2939121Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 100648292847cSmrg tmp_export_symbols=$export_symbols 100658292847cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10066c2939121Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10067c2939121Smrg fi 10068c76ae52dSmrg 10069c2939121Smrg if test -n "$orig_export_symbols"; then 10070c2939121Smrg # The given exports_symbols file has to be filtered, so filter it. 100718292847cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10072c2939121Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100738292847cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10074c2939121Smrg # though. Also, the filter scales superlinearly with the number of 10075c2939121Smrg # global variables. join(1) would be nice here, but unfortunately 10076c2939121Smrg # isn't a blessed tool. 10077c2939121Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100782836776bSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10079c2939121Smrg export_symbols=$output_objdir/$libname.def 10080c2939121Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10081c2939121Smrg fi 100828292847cSmrg } 10083c76ae52dSmrg 10084c2939121Smrg libobjs=$output 10085c2939121Smrg # Restore the value of output. 10086c2939121Smrg output=$save_output 10087c76ae52dSmrg 10088c2939121Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10089c2939121Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10090c2939121Smrg test "X$libobjs" = "X " && libobjs= 10091c2939121Smrg fi 10092c2939121Smrg # Expand the library linking commands again to reset the 10093c2939121Smrg # value of $libobjs for piecewise linking. 10094c2939121Smrg 10095c2939121Smrg # Do each of the archive commands. 100968292847cSmrg if test yes = "$module" && test -n "$module_cmds"; then 10097c2939121Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10098c2939121Smrg cmds=$module_expsym_cmds 10099c76ae52dSmrg else 10100c2939121Smrg cmds=$module_cmds 10101c76ae52dSmrg fi 10102c76ae52dSmrg else 10103c2939121Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10104c2939121Smrg cmds=$archive_expsym_cmds 10105c2939121Smrg else 10106c2939121Smrg cmds=$archive_cmds 10107c2939121Smrg fi 10108c76ae52dSmrg fi 10109c76ae52dSmrg fi 10110c76ae52dSmrg 10111c2939121Smrg if test -n "$delfiles"; then 10112c2939121Smrg # Append the command to remove temporary files to $cmds. 10113c2939121Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10114c2939121Smrg fi 10115c76ae52dSmrg 10116c2939121Smrg # Add any objects from preloaded convenience libraries 10117c2939121Smrg if test -n "$dlprefiles"; then 101188292847cSmrg gentop=$output_objdir/${outputname}x 101192836776bSmrg func_append generated " $gentop" 10120c76ae52dSmrg 10121c2939121Smrg func_extract_archives $gentop $dlprefiles 101222836776bSmrg func_append libobjs " $func_extract_archives_result" 10123c2939121Smrg test "X$libobjs" = "X " && libobjs= 10124c76ae52dSmrg fi 10125c76ae52dSmrg 101268292847cSmrg save_ifs=$IFS; IFS='~' 10127c2939121Smrg for cmd in $cmds; do 101288292847cSmrg IFS=$sp$nl 10129c2939121Smrg eval cmd=\"$cmd\" 101308292847cSmrg IFS=$save_ifs 101318292847cSmrg $opt_quiet || { 10132c2939121Smrg func_quote_for_expand "$cmd" 10133c2939121Smrg eval "func_echo $func_quote_for_expand_result" 10134c2939121Smrg } 10135c2939121Smrg $opt_dry_run || eval "$cmd" || { 10136c2939121Smrg lt_exit=$? 10137c76ae52dSmrg 10138c2939121Smrg # Restore the uninstalled library and exit 101398292847cSmrg if test relink = "$opt_mode"; then 10140c2939121Smrg ( cd "$output_objdir" && \ 10141c2939121Smrg $RM "${realname}T" && \ 10142c2939121Smrg $MV "${realname}U" "$realname" ) 10143c76ae52dSmrg fi 10144c76ae52dSmrg 10145c2939121Smrg exit $lt_exit 10146c2939121Smrg } 10147c2939121Smrg done 101488292847cSmrg IFS=$save_ifs 10149c76ae52dSmrg 10150c2939121Smrg # Restore the uninstalled library and exit 101518292847cSmrg if test relink = "$opt_mode"; then 10152c2939121Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10153c76ae52dSmrg 10154c2939121Smrg if test -n "$convenience"; then 10155c2939121Smrg if test -z "$whole_archive_flag_spec"; then 10156c2939121Smrg func_show_eval '${RM}r "$gentop"' 10157c2939121Smrg fi 10158c2939121Smrg fi 10159c76ae52dSmrg 10160c2939121Smrg exit $EXIT_SUCCESS 10161c2939121Smrg fi 10162c76ae52dSmrg 10163c2939121Smrg # Create links to the real library. 10164c2939121Smrg for linkname in $linknames; do 10165c2939121Smrg if test "$realname" != "$linkname"; then 10166c2939121Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10167c2939121Smrg fi 10168c2939121Smrg done 10169c76ae52dSmrg 10170c2939121Smrg # If -module or -export-dynamic was specified, set the dlname. 101718292847cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10172c2939121Smrg # On all known operating systems, these are identical. 101738292847cSmrg dlname=$soname 10174c2939121Smrg fi 10175c2939121Smrg fi 10176c2939121Smrg ;; 10177c76ae52dSmrg 10178c2939121Smrg obj) 101798292847cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 101808292847cSmrg func_warning "'-dlopen' is ignored for objects" 10181c2939121Smrg fi 10182c76ae52dSmrg 10183c2939121Smrg case " $deplibs" in 10184c2939121Smrg *\ -l* | *\ -L*) 101858292847cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10186c2939121Smrg esac 10187c76ae52dSmrg 10188c2939121Smrg test -n "$rpath" && \ 101898292847cSmrg func_warning "'-rpath' is ignored for objects" 10190c76ae52dSmrg 10191c2939121Smrg test -n "$xrpath" && \ 101928292847cSmrg func_warning "'-R' is ignored for objects" 10193c2939121Smrg 10194c2939121Smrg test -n "$vinfo" && \ 101958292847cSmrg func_warning "'-version-info' is ignored for objects" 10196c76ae52dSmrg 10197c2939121Smrg test -n "$release" && \ 101988292847cSmrg func_warning "'-release' is ignored for objects" 10199c76ae52dSmrg 10200c2939121Smrg case $output in 10201c2939121Smrg *.lo) 10202c2939121Smrg test -n "$objs$old_deplibs" && \ 102038292847cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10204c2939121Smrg 10205c2939121Smrg libobj=$output 10206c2939121Smrg func_lo2o "$libobj" 10207c2939121Smrg obj=$func_lo2o_result 10208c2939121Smrg ;; 10209c2939121Smrg *) 10210c2939121Smrg libobj= 102118292847cSmrg obj=$output 10212c76ae52dSmrg ;; 10213c76ae52dSmrg esac 10214c76ae52dSmrg 10215c2939121Smrg # Delete the old objects. 10216c2939121Smrg $opt_dry_run || $RM $obj $libobj 10217c76ae52dSmrg 10218c2939121Smrg # Objects from convenience libraries. This assumes 10219c2939121Smrg # single-version convenience libraries. Whenever we create 10220c2939121Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10221c2939121Smrg # the extraction. 10222c2939121Smrg reload_conv_objs= 10223c2939121Smrg gentop= 102248292847cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 102258292847cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 102268292847cSmrg # into space. 102278292847cSmrg case $reload_cmds in 102288292847cSmrg *\$LD[\ \$]*) wl= ;; 102298292847cSmrg esac 10230c2939121Smrg if test -n "$convenience"; then 10231c2939121Smrg if test -n "$whole_archive_flag_spec"; then 10232c2939121Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 102338292847cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 102348292847cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10235c76ae52dSmrg else 102368292847cSmrg gentop=$output_objdir/${obj}x 102372836776bSmrg func_append generated " $gentop" 10238c2939121Smrg 10239c2939121Smrg func_extract_archives $gentop $convenience 10240c2939121Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10241c76ae52dSmrg fi 10242c2939121Smrg fi 10243c76ae52dSmrg 102442836776bSmrg # If we're not building shared, we need to use non_pic_objs 102458292847cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 102462836776bSmrg 10247c2939121Smrg # Create the old-style object. 102488292847cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10249c76ae52dSmrg 102508292847cSmrg output=$obj 10251c2939121Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10252c76ae52dSmrg 10253c2939121Smrg # Exit if we aren't doing a library object file. 10254c2939121Smrg if test -z "$libobj"; then 10255c2939121Smrg if test -n "$gentop"; then 10256c2939121Smrg func_show_eval '${RM}r "$gentop"' 10257c2939121Smrg fi 10258c76ae52dSmrg 10259c2939121Smrg exit $EXIT_SUCCESS 10260c76ae52dSmrg fi 10261c76ae52dSmrg 102628292847cSmrg test yes = "$build_libtool_libs" || { 10263c2939121Smrg if test -n "$gentop"; then 10264c2939121Smrg func_show_eval '${RM}r "$gentop"' 10265c2939121Smrg fi 10266c76ae52dSmrg 10267c2939121Smrg # Create an invalid libtool object if no PIC, so that we don't 10268c2939121Smrg # accidentally link it into a program. 10269c2939121Smrg # $show "echo timestamp > $libobj" 10270c2939121Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10271c2939121Smrg exit $EXIT_SUCCESS 102728292847cSmrg } 10273c76ae52dSmrg 102748292847cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10275c2939121Smrg # Only do commands if we really have different PIC objects. 10276c2939121Smrg reload_objs="$libobjs $reload_conv_objs" 102778292847cSmrg output=$libobj 10278c2939121Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10279c76ae52dSmrg fi 10280c2939121Smrg 10281c2939121Smrg if test -n "$gentop"; then 10282c2939121Smrg func_show_eval '${RM}r "$gentop"' 10283c2939121Smrg fi 10284c2939121Smrg 10285c2939121Smrg exit $EXIT_SUCCESS 10286c76ae52dSmrg ;; 10287c76ae52dSmrg 10288c2939121Smrg prog) 10289c2939121Smrg case $host in 10290c2939121Smrg *cygwin*) func_stripname '' '.exe' "$output" 10291c2939121Smrg output=$func_stripname_result.exe;; 10292c2939121Smrg esac 10293c2939121Smrg test -n "$vinfo" && \ 102948292847cSmrg func_warning "'-version-info' is ignored for programs" 10295c76ae52dSmrg 10296c2939121Smrg test -n "$release" && \ 102978292847cSmrg func_warning "'-release' is ignored for programs" 10298c76ae52dSmrg 102998292847cSmrg $preload \ 103008292847cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 103018292847cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10302c2939121Smrg 10303c2939121Smrg case $host in 10304c2939121Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10305c2939121Smrg # On Rhapsody replace the C library is the System framework 10306c2939121Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10307c2939121Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10308c76ae52dSmrg ;; 10309c2939121Smrg esac 10310c76ae52dSmrg 10311c2939121Smrg case $host in 10312c2939121Smrg *-*-darwin*) 10313c2939121Smrg # Don't allow lazy linking, it breaks C++ global constructors 10314c2939121Smrg # But is supposedly fixed on 10.4 or later (yay!). 103158292847cSmrg if test CXX = "$tagname"; then 10316c2939121Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10317c2939121Smrg 10.[0123]) 103188292847cSmrg func_append compile_command " $wl-bind_at_load" 103198292847cSmrg func_append finalize_command " $wl-bind_at_load" 10320c2939121Smrg ;; 10321c2939121Smrg esac 10322c76ae52dSmrg fi 10323c2939121Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10324c2939121Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10325c2939121Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10326c2939121Smrg ;; 10327c2939121Smrg esac 10328c76ae52dSmrg 10329c76ae52dSmrg 10330c2939121Smrg # move library search paths that coincide with paths to not yet 10331c2939121Smrg # installed libraries to the beginning of the library search list 10332c2939121Smrg new_libs= 10333c2939121Smrg for path in $notinst_path; do 10334c2939121Smrg case " $new_libs " in 10335c2939121Smrg *" -L$path/$objdir "*) ;; 10336c2939121Smrg *) 10337c2939121Smrg case " $compile_deplibs " in 10338c2939121Smrg *" -L$path/$objdir "*) 103392836776bSmrg func_append new_libs " -L$path/$objdir" ;; 10340c76ae52dSmrg esac 10341c2939121Smrg ;; 10342c2939121Smrg esac 10343c2939121Smrg done 10344c2939121Smrg for deplib in $compile_deplibs; do 10345c2939121Smrg case $deplib in 10346c2939121Smrg -L*) 10347c2939121Smrg case " $new_libs " in 10348c2939121Smrg *" $deplib "*) ;; 103492836776bSmrg *) func_append new_libs " $deplib" ;; 10350c76ae52dSmrg esac 10351c2939121Smrg ;; 103522836776bSmrg *) func_append new_libs " $deplib" ;; 10353c2939121Smrg esac 10354c2939121Smrg done 103558292847cSmrg compile_deplibs=$new_libs 10356c76ae52dSmrg 10357c76ae52dSmrg 103582836776bSmrg func_append compile_command " $compile_deplibs" 103592836776bSmrg func_append finalize_command " $finalize_deplibs" 10360c76ae52dSmrg 10361c2939121Smrg if test -n "$rpath$xrpath"; then 10362c2939121Smrg # If the user specified any rpath flags, then add them. 10363c2939121Smrg for libdir in $rpath $xrpath; do 10364c2939121Smrg # This is the magic to use -rpath. 10365c2939121Smrg case "$finalize_rpath " in 10366c2939121Smrg *" $libdir "*) ;; 103672836776bSmrg *) func_append finalize_rpath " $libdir" ;; 10368c2939121Smrg esac 10369c2939121Smrg done 10370c2939121Smrg fi 10371c76ae52dSmrg 10372c2939121Smrg # Now hardcode the library paths 10373c2939121Smrg rpath= 10374c2939121Smrg hardcode_libdirs= 10375c2939121Smrg for libdir in $compile_rpath $finalize_rpath; do 10376c2939121Smrg if test -n "$hardcode_libdir_flag_spec"; then 10377c2939121Smrg if test -n "$hardcode_libdir_separator"; then 10378c2939121Smrg if test -z "$hardcode_libdirs"; then 103798292847cSmrg hardcode_libdirs=$libdir 10380c2939121Smrg else 10381c2939121Smrg # Just accumulate the unique libdirs. 10382c2939121Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10383c2939121Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10384c2939121Smrg ;; 10385c2939121Smrg *) 103862836776bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10387c2939121Smrg ;; 10388c2939121Smrg esac 10389c2939121Smrg fi 10390c76ae52dSmrg else 10391c2939121Smrg eval flag=\"$hardcode_libdir_flag_spec\" 103922836776bSmrg func_append rpath " $flag" 10393c76ae52dSmrg fi 10394c2939121Smrg elif test -n "$runpath_var"; then 10395c2939121Smrg case "$perm_rpath " in 10396c2939121Smrg *" $libdir "*) ;; 103972836776bSmrg *) func_append perm_rpath " $libdir" ;; 10398c2939121Smrg esac 10399c2939121Smrg fi 10400c2939121Smrg case $host in 10401c2939121Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 104028292847cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10403c2939121Smrg case :$dllsearchpath: in 10404c2939121Smrg *":$libdir:"*) ;; 10405c2939121Smrg ::) dllsearchpath=$libdir;; 104062836776bSmrg *) func_append dllsearchpath ":$libdir";; 10407c2939121Smrg esac 10408c2939121Smrg case :$dllsearchpath: in 10409c2939121Smrg *":$testbindir:"*) ;; 10410c2939121Smrg ::) dllsearchpath=$testbindir;; 104112836776bSmrg *) func_append dllsearchpath ":$testbindir";; 10412c2939121Smrg esac 10413c2939121Smrg ;; 10414c2939121Smrg esac 10415c2939121Smrg done 10416c2939121Smrg # Substitute the hardcoded libdirs into the rpath. 10417c2939121Smrg if test -n "$hardcode_libdir_separator" && 10418c2939121Smrg test -n "$hardcode_libdirs"; then 104198292847cSmrg libdir=$hardcode_libdirs 10420c2939121Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10421c2939121Smrg fi 104228292847cSmrg compile_rpath=$rpath 10423c76ae52dSmrg 10424c2939121Smrg rpath= 10425c2939121Smrg hardcode_libdirs= 10426c2939121Smrg for libdir in $finalize_rpath; do 10427c2939121Smrg if test -n "$hardcode_libdir_flag_spec"; then 10428c2939121Smrg if test -n "$hardcode_libdir_separator"; then 10429c2939121Smrg if test -z "$hardcode_libdirs"; then 104308292847cSmrg hardcode_libdirs=$libdir 10431c2939121Smrg else 10432c2939121Smrg # Just accumulate the unique libdirs. 10433c2939121Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10434c2939121Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10435c2939121Smrg ;; 10436c2939121Smrg *) 104372836776bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10438c2939121Smrg ;; 10439c2939121Smrg esac 10440c2939121Smrg fi 10441c76ae52dSmrg else 10442c2939121Smrg eval flag=\"$hardcode_libdir_flag_spec\" 104432836776bSmrg func_append rpath " $flag" 10444c76ae52dSmrg fi 10445c2939121Smrg elif test -n "$runpath_var"; then 10446c2939121Smrg case "$finalize_perm_rpath " in 10447c2939121Smrg *" $libdir "*) ;; 104482836776bSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10449c2939121Smrg esac 10450c76ae52dSmrg fi 10451c2939121Smrg done 10452c2939121Smrg # Substitute the hardcoded libdirs into the rpath. 10453c2939121Smrg if test -n "$hardcode_libdir_separator" && 10454c2939121Smrg test -n "$hardcode_libdirs"; then 104558292847cSmrg libdir=$hardcode_libdirs 10456c2939121Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10457c2939121Smrg fi 104588292847cSmrg finalize_rpath=$rpath 10459c76ae52dSmrg 104608292847cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10461c2939121Smrg # Transform all the library objects into standard objects. 10462c2939121Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10463c2939121Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10464c2939121Smrg fi 10465c76ae52dSmrg 104668292847cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10467c76ae52dSmrg 10468c2939121Smrg # template prelinking step 10469c2939121Smrg if test -n "$prelink_cmds"; then 10470c2939121Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10471c2939121Smrg fi 10472c76ae52dSmrg 104738292847cSmrg wrappers_required=: 10474c2939121Smrg case $host in 10475c2939121Smrg *cegcc* | *mingw32ce*) 10476c2939121Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 104778292847cSmrg wrappers_required=false 10478c2939121Smrg ;; 10479c2939121Smrg *cygwin* | *mingw* ) 104808292847cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10481c2939121Smrg ;; 10482c2939121Smrg *) 104838292847cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 104848292847cSmrg wrappers_required=false 10485c2939121Smrg fi 10486c2939121Smrg ;; 10487c2939121Smrg esac 104888292847cSmrg $wrappers_required || { 10489c2939121Smrg # Replace the output file specification. 10490c2939121Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104918292847cSmrg link_command=$compile_command$compile_rpath 10492c76ae52dSmrg 10493c2939121Smrg # We have no uninstalled library dependencies, so finalize right now. 10494c2939121Smrg exit_status=0 10495c2939121Smrg func_show_eval "$link_command" 'exit_status=$?' 10496c76ae52dSmrg 104972836776bSmrg if test -n "$postlink_cmds"; then 104982836776bSmrg func_to_tool_file "$output" 104992836776bSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 105002836776bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 105012836776bSmrg fi 105022836776bSmrg 10503c2939121Smrg # Delete the generated files. 105048292847cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 105058292847cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10506c76ae52dSmrg fi 10507c76ae52dSmrg 10508c2939121Smrg exit $exit_status 105098292847cSmrg } 10510c76ae52dSmrg 10511c2939121Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10512c2939121Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10513c2939121Smrg fi 10514c2939121Smrg if test -n "$finalize_shlibpath"; then 10515c2939121Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10516c2939121Smrg fi 10517c76ae52dSmrg 10518c2939121Smrg compile_var= 10519c2939121Smrg finalize_var= 10520c2939121Smrg if test -n "$runpath_var"; then 10521c2939121Smrg if test -n "$perm_rpath"; then 10522c2939121Smrg # We should set the runpath_var. 10523c2939121Smrg rpath= 10524c2939121Smrg for dir in $perm_rpath; do 105252836776bSmrg func_append rpath "$dir:" 10526c2939121Smrg done 10527c2939121Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10528c76ae52dSmrg fi 10529c2939121Smrg if test -n "$finalize_perm_rpath"; then 10530c2939121Smrg # We should set the runpath_var. 10531c2939121Smrg rpath= 10532c2939121Smrg for dir in $finalize_perm_rpath; do 105332836776bSmrg func_append rpath "$dir:" 10534c2939121Smrg done 10535c2939121Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10536c76ae52dSmrg fi 10537c2939121Smrg fi 10538c76ae52dSmrg 105398292847cSmrg if test yes = "$no_install"; then 10540c2939121Smrg # We don't need to create a wrapper script. 105418292847cSmrg link_command=$compile_var$compile_command$compile_rpath 10542c2939121Smrg # Replace the output file specification. 10543c2939121Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10544c2939121Smrg # Delete the old output file. 10545c2939121Smrg $opt_dry_run || $RM $output 10546c2939121Smrg # Link the executable and exit 10547c2939121Smrg func_show_eval "$link_command" 'exit $?' 105482836776bSmrg 105492836776bSmrg if test -n "$postlink_cmds"; then 105502836776bSmrg func_to_tool_file "$output" 105512836776bSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 105522836776bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 105532836776bSmrg fi 105542836776bSmrg 10555c76ae52dSmrg exit $EXIT_SUCCESS 10556c2939121Smrg fi 10557c76ae52dSmrg 105588292847cSmrg case $hardcode_action,$fast_install in 105598292847cSmrg relink,*) 105608292847cSmrg # Fast installation is not supported 105618292847cSmrg link_command=$compile_var$compile_command$compile_rpath 105628292847cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10563c2939121Smrg 105648292847cSmrg func_warning "this platform does not like uninstalled shared libraries" 105658292847cSmrg func_warning "'$output' will be relinked during installation" 105668292847cSmrg ;; 105678292847cSmrg *,yes) 105688292847cSmrg link_command=$finalize_var$compile_command$finalize_rpath 105698292847cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 105708292847cSmrg ;; 105718292847cSmrg *,no) 105728292847cSmrg link_command=$compile_var$compile_command$compile_rpath 105738292847cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 105748292847cSmrg ;; 105758292847cSmrg *,needless) 105768292847cSmrg link_command=$finalize_var$compile_command$finalize_rpath 105778292847cSmrg relink_command= 105788292847cSmrg ;; 105798292847cSmrg esac 10580c76ae52dSmrg 10581c2939121Smrg # Replace the output file specification. 10582c2939121Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10583c76ae52dSmrg 10584c2939121Smrg # Delete the old output files. 10585c2939121Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10586c76ae52dSmrg 10587c2939121Smrg func_show_eval "$link_command" 'exit $?' 10588c76ae52dSmrg 105892836776bSmrg if test -n "$postlink_cmds"; then 105902836776bSmrg func_to_tool_file "$output_objdir/$outputname" 105912836776bSmrg 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'` 105922836776bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 105932836776bSmrg fi 105942836776bSmrg 10595c2939121Smrg # Now create the wrapper script. 10596c2939121Smrg func_verbose "creating $output" 10597c76ae52dSmrg 10598c2939121Smrg # Quote the relink command for shipping. 10599c2939121Smrg if test -n "$relink_command"; then 10600c2939121Smrg # Preserve any variables that may affect compiler behavior 10601c2939121Smrg for var in $variables_saved_for_relink; do 10602c2939121Smrg if eval test -z \"\${$var+set}\"; then 10603c2939121Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10604c2939121Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10605c2939121Smrg relink_command="$var=; export $var; $relink_command" 10606c76ae52dSmrg else 10607c2939121Smrg func_quote_for_eval "$var_value" 10608c2939121Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10609c76ae52dSmrg fi 10610c2939121Smrg done 10611c2939121Smrg relink_command="(cd `pwd`; $relink_command)" 10612c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10613c2939121Smrg fi 10614c76ae52dSmrg 10615c2939121Smrg # Only actually do things if not in dry run mode. 10616c2939121Smrg $opt_dry_run || { 10617c2939121Smrg # win32 will think the script is a binary if it has 10618c2939121Smrg # a .exe suffix, so we strip it off here. 10619c2939121Smrg case $output in 10620c2939121Smrg *.exe) func_stripname '' '.exe' "$output" 10621c2939121Smrg output=$func_stripname_result ;; 10622c2939121Smrg esac 10623c2939121Smrg # test for cygwin because mv fails w/o .exe extensions 10624c2939121Smrg case $host in 10625c2939121Smrg *cygwin*) 10626c2939121Smrg exeext=.exe 10627c2939121Smrg func_stripname '' '.exe' "$outputname" 10628c2939121Smrg outputname=$func_stripname_result ;; 10629c2939121Smrg *) exeext= ;; 10630c76ae52dSmrg esac 10631c2939121Smrg case $host in 10632c2939121Smrg *cygwin* | *mingw* ) 10633c2939121Smrg func_dirname_and_basename "$output" "" "." 10634c2939121Smrg output_name=$func_basename_result 10635c2939121Smrg output_path=$func_dirname_result 106368292847cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 106378292847cSmrg cwrapper=$output_path/$output_name.exe 10638c2939121Smrg $RM $cwrappersource $cwrapper 10639c2939121Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10640c2939121Smrg 10641c2939121Smrg func_emit_cwrapperexe_src > $cwrappersource 10642c2939121Smrg 10643c2939121Smrg # The wrapper executable is built using the $host compiler, 10644c2939121Smrg # because it contains $host paths and files. If cross- 10645c2939121Smrg # compiling, it, like the target executable, must be 10646c2939121Smrg # executed on the $host or under an emulation environment. 10647c2939121Smrg $opt_dry_run || { 10648c2939121Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10649c2939121Smrg $STRIP $cwrapper 10650c2939121Smrg } 10651c76ae52dSmrg 10652c2939121Smrg # Now, create the wrapper script for func_source use: 10653c2939121Smrg func_ltwrapper_scriptname $cwrapper 10654c2939121Smrg $RM $func_ltwrapper_scriptname_result 10655c2939121Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10656c2939121Smrg $opt_dry_run || { 10657c2939121Smrg # note: this script will not be executed, so do not chmod. 106588292847cSmrg if test "x$build" = "x$host"; then 10659c2939121Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10660c2939121Smrg else 10661c2939121Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10662c2939121Smrg fi 10663c2939121Smrg } 10664c2939121Smrg ;; 10665c2939121Smrg * ) 10666c2939121Smrg $RM $output 10667c2939121Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10668c76ae52dSmrg 10669c2939121Smrg func_emit_wrapper no > $output 10670c2939121Smrg chmod +x $output 10671c2939121Smrg ;; 10672c2939121Smrg esac 10673c2939121Smrg } 10674c2939121Smrg exit $EXIT_SUCCESS 10675c2939121Smrg ;; 10676c2939121Smrg esac 10677c76ae52dSmrg 10678c2939121Smrg # See if we need to build an old-fashioned archive. 10679c2939121Smrg for oldlib in $oldlibs; do 10680c76ae52dSmrg 106818292847cSmrg case $build_libtool_libs in 106828292847cSmrg convenience) 106838292847cSmrg oldobjs="$libobjs_save $symfileobj" 106848292847cSmrg addlibs=$convenience 10685c2939121Smrg build_libtool_libs=no 106868292847cSmrg ;; 106878292847cSmrg module) 106888292847cSmrg oldobjs=$libobjs_save 106898292847cSmrg addlibs=$old_convenience 106908292847cSmrg build_libtool_libs=no 106918292847cSmrg ;; 106928292847cSmrg *) 10693c2939121Smrg oldobjs="$old_deplibs $non_pic_objects" 106948292847cSmrg $preload && test -f "$symfileobj" \ 106958292847cSmrg && func_append oldobjs " $symfileobj" 106968292847cSmrg addlibs=$old_convenience 106978292847cSmrg ;; 106988292847cSmrg esac 10699c76ae52dSmrg 10700c2939121Smrg if test -n "$addlibs"; then 107018292847cSmrg gentop=$output_objdir/${outputname}x 107022836776bSmrg func_append generated " $gentop" 10703c76ae52dSmrg 10704c2939121Smrg func_extract_archives $gentop $addlibs 107052836776bSmrg func_append oldobjs " $func_extract_archives_result" 10706c2939121Smrg fi 10707c76ae52dSmrg 10708c2939121Smrg # Do each command in the archive commands. 107098292847cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10710c2939121Smrg cmds=$old_archive_from_new_cmds 10711c2939121Smrg else 10712c76ae52dSmrg 10713c2939121Smrg # Add any objects from preloaded convenience libraries 10714c2939121Smrg if test -n "$dlprefiles"; then 107158292847cSmrg gentop=$output_objdir/${outputname}x 107162836776bSmrg func_append generated " $gentop" 10717c76ae52dSmrg 10718c2939121Smrg func_extract_archives $gentop $dlprefiles 107192836776bSmrg func_append oldobjs " $func_extract_archives_result" 10720c2939121Smrg fi 10721c76ae52dSmrg 10722c2939121Smrg # POSIX demands no paths to be encoded in archives. We have 10723c2939121Smrg # to avoid creating archives with duplicate basenames if we 10724c2939121Smrg # might have to extract them afterwards, e.g., when creating a 10725c2939121Smrg # static archive out of a convenience library, or when linking 10726c2939121Smrg # the entirety of a libtool archive into another (currently 10727c2939121Smrg # not supported by libtool). 10728c2939121Smrg if (for obj in $oldobjs 10729c2939121Smrg do 10730c2939121Smrg func_basename "$obj" 10731c2939121Smrg $ECHO "$func_basename_result" 10732c2939121Smrg done | sort | sort -uc >/dev/null 2>&1); then 10733c2939121Smrg : 10734c2939121Smrg else 10735c2939121Smrg echo "copying selected object files to avoid basename conflicts..." 107368292847cSmrg gentop=$output_objdir/${outputname}x 107372836776bSmrg func_append generated " $gentop" 10738c2939121Smrg func_mkdir_p "$gentop" 10739c2939121Smrg save_oldobjs=$oldobjs 10740c2939121Smrg oldobjs= 10741c2939121Smrg counter=1 10742c2939121Smrg for obj in $save_oldobjs 10743c2939121Smrg do 10744c2939121Smrg func_basename "$obj" 107458292847cSmrg objbase=$func_basename_result 10746c2939121Smrg case " $oldobjs " in 10747c2939121Smrg " ") oldobjs=$obj ;; 10748c2939121Smrg *[\ /]"$objbase "*) 10749c2939121Smrg while :; do 10750c2939121Smrg # Make sure we don't pick an alternate name that also 10751c2939121Smrg # overlaps. 10752c2939121Smrg newobj=lt$counter-$objbase 10753c2939121Smrg func_arith $counter + 1 10754c2939121Smrg counter=$func_arith_result 10755c2939121Smrg case " $oldobjs " in 10756c2939121Smrg *[\ /]"$newobj "*) ;; 10757c2939121Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10758c2939121Smrg esac 10759c2939121Smrg done 10760c2939121Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 107612836776bSmrg func_append oldobjs " $gentop/$newobj" 10762c2939121Smrg ;; 107632836776bSmrg *) func_append oldobjs " $obj" ;; 10764c2939121Smrg esac 10765c76ae52dSmrg done 10766c76ae52dSmrg fi 107672836776bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 107682836776bSmrg tool_oldlib=$func_to_tool_file_result 10769c2939121Smrg eval cmds=\"$old_archive_cmds\" 10770c76ae52dSmrg 10771c2939121Smrg func_len " $cmds" 10772c2939121Smrg len=$func_len_result 10773c2939121Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10774c2939121Smrg cmds=$old_archive_cmds 107752836776bSmrg elif test -n "$archiver_list_spec"; then 107762836776bSmrg func_verbose "using command file archive linking..." 107772836776bSmrg for obj in $oldobjs 107782836776bSmrg do 107792836776bSmrg func_to_tool_file "$obj" 107802836776bSmrg $ECHO "$func_to_tool_file_result" 107812836776bSmrg done > $output_objdir/$libname.libcmd 107822836776bSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 107832836776bSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 107842836776bSmrg cmds=$old_archive_cmds 10785c2939121Smrg else 10786c2939121Smrg # the command line is too long to link in one step, link in parts 10787c2939121Smrg func_verbose "using piecewise archive linking..." 10788c2939121Smrg save_RANLIB=$RANLIB 10789c2939121Smrg RANLIB=: 10790c2939121Smrg objlist= 10791c2939121Smrg concat_cmds= 10792c2939121Smrg save_oldobjs=$oldobjs 10793c2939121Smrg oldobjs= 10794c2939121Smrg # Is there a better way of finding the last object in the list? 10795c2939121Smrg for obj in $save_oldobjs 10796c2939121Smrg do 10797c2939121Smrg last_oldobj=$obj 10798c2939121Smrg done 10799c2939121Smrg eval test_cmds=\"$old_archive_cmds\" 10800c2939121Smrg func_len " $test_cmds" 10801c2939121Smrg len0=$func_len_result 10802c2939121Smrg len=$len0 10803c2939121Smrg for obj in $save_oldobjs 10804c2939121Smrg do 10805c2939121Smrg func_len " $obj" 10806c2939121Smrg func_arith $len + $func_len_result 10807c2939121Smrg len=$func_arith_result 10808c2939121Smrg func_append objlist " $obj" 10809c2939121Smrg if test "$len" -lt "$max_cmd_len"; then 10810c2939121Smrg : 10811c2939121Smrg else 10812c2939121Smrg # the above command should be used before it gets too long 10813c2939121Smrg oldobjs=$objlist 108148292847cSmrg if test "$obj" = "$last_oldobj"; then 10815c2939121Smrg RANLIB=$save_RANLIB 10816c2939121Smrg fi 10817c2939121Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 108188292847cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10819c2939121Smrg objlist= 10820c2939121Smrg len=$len0 10821c2939121Smrg fi 10822c2939121Smrg done 10823c2939121Smrg RANLIB=$save_RANLIB 10824c2939121Smrg oldobjs=$objlist 108258292847cSmrg if test -z "$oldobjs"; then 10826c2939121Smrg eval cmds=\"\$concat_cmds\" 10827c2939121Smrg else 10828c2939121Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10829c2939121Smrg fi 10830c2939121Smrg fi 10831c2939121Smrg fi 10832c2939121Smrg func_execute_cmds "$cmds" 'exit $?' 10833c76ae52dSmrg done 10834c76ae52dSmrg 10835c2939121Smrg test -n "$generated" && \ 10836c2939121Smrg func_show_eval "${RM}r$generated" 10837c76ae52dSmrg 10838c2939121Smrg # Now create the libtool archive. 10839c2939121Smrg case $output in 10840c2939121Smrg *.la) 10841c2939121Smrg old_library= 108428292847cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10843c2939121Smrg func_verbose "creating $output" 10844c76ae52dSmrg 10845c2939121Smrg # Preserve any variables that may affect compiler behavior 10846c2939121Smrg for var in $variables_saved_for_relink; do 10847c2939121Smrg if eval test -z \"\${$var+set}\"; then 10848c2939121Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10849c2939121Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10850c2939121Smrg relink_command="$var=; export $var; $relink_command" 10851c76ae52dSmrg else 10852c2939121Smrg func_quote_for_eval "$var_value" 10853c2939121Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10854c76ae52dSmrg fi 10855c2939121Smrg done 10856c2939121Smrg # Quote the link command for shipping. 108578292847cSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10858c2939121Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 108598292847cSmrg if test yes = "$hardcode_automatic"; then 10860c2939121Smrg relink_command= 10861c2939121Smrg fi 10862c76ae52dSmrg 10863c2939121Smrg # Only create the output if not a dry run. 10864c2939121Smrg $opt_dry_run || { 10865c2939121Smrg for installed in no yes; do 108668292847cSmrg if test yes = "$installed"; then 10867c2939121Smrg if test -z "$install_libdir"; then 10868c2939121Smrg break 10869c2939121Smrg fi 108708292847cSmrg output=$output_objdir/${outputname}i 10871c2939121Smrg # Replace all uninstalled libtool libraries with the installed ones 10872c2939121Smrg newdependency_libs= 10873c2939121Smrg for deplib in $dependency_libs; do 10874c2939121Smrg case $deplib in 10875c2939121Smrg *.la) 10876c2939121Smrg func_basename "$deplib" 108778292847cSmrg name=$func_basename_result 108782836776bSmrg func_resolve_sysroot "$deplib" 108798292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10880c2939121Smrg test -z "$libdir" && \ 108818292847cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 108822836776bSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 108832836776bSmrg ;; 108842836776bSmrg -L*) 108852836776bSmrg func_stripname -L '' "$deplib" 108862836776bSmrg func_replace_sysroot "$func_stripname_result" 108872836776bSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 108882836776bSmrg ;; 108892836776bSmrg -R*) 108902836776bSmrg func_stripname -R '' "$deplib" 108912836776bSmrg func_replace_sysroot "$func_stripname_result" 108922836776bSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10893c2939121Smrg ;; 108942836776bSmrg *) func_append newdependency_libs " $deplib" ;; 10895c2939121Smrg esac 10896c2939121Smrg done 108978292847cSmrg dependency_libs=$newdependency_libs 10898c2939121Smrg newdlfiles= 10899c2939121Smrg 10900c2939121Smrg for lib in $dlfiles; do 10901c2939121Smrg case $lib in 10902c2939121Smrg *.la) 10903c2939121Smrg func_basename "$lib" 109048292847cSmrg name=$func_basename_result 109058292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10906c2939121Smrg test -z "$libdir" && \ 109078292847cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 109082836776bSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10909c2939121Smrg ;; 109102836776bSmrg *) func_append newdlfiles " $lib" ;; 10911c2939121Smrg esac 10912c2939121Smrg done 109138292847cSmrg dlfiles=$newdlfiles 10914c2939121Smrg newdlprefiles= 10915c2939121Smrg for lib in $dlprefiles; do 10916c2939121Smrg case $lib in 10917c2939121Smrg *.la) 10918c2939121Smrg # Only pass preopened files to the pseudo-archive (for 10919c2939121Smrg # eventual linking with the app. that links it) if we 10920c2939121Smrg # didn't already link the preopened objects directly into 10921c2939121Smrg # the library: 10922c2939121Smrg func_basename "$lib" 109238292847cSmrg name=$func_basename_result 109248292847cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10925c2939121Smrg test -z "$libdir" && \ 109268292847cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 109272836776bSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10928c2939121Smrg ;; 10929c2939121Smrg esac 10930c2939121Smrg done 109318292847cSmrg dlprefiles=$newdlprefiles 10932c2939121Smrg else 10933c2939121Smrg newdlfiles= 10934c2939121Smrg for lib in $dlfiles; do 10935c2939121Smrg case $lib in 109368292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10937c2939121Smrg *) abs=`pwd`"/$lib" ;; 10938c2939121Smrg esac 109392836776bSmrg func_append newdlfiles " $abs" 10940c2939121Smrg done 109418292847cSmrg dlfiles=$newdlfiles 10942c2939121Smrg newdlprefiles= 10943c2939121Smrg for lib in $dlprefiles; do 10944c2939121Smrg case $lib in 109458292847cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10946c2939121Smrg *) abs=`pwd`"/$lib" ;; 10947c2939121Smrg esac 109482836776bSmrg func_append newdlprefiles " $abs" 10949c2939121Smrg done 109508292847cSmrg dlprefiles=$newdlprefiles 10951c2939121Smrg fi 10952c2939121Smrg $RM $output 10953c2939121Smrg # place dlname in correct position for cygwin 10954c2939121Smrg # In fact, it would be nice if we could use this code for all target 10955c2939121Smrg # systems that can't hard-code library paths into their executables 10956c2939121Smrg # and that have no shared library path variable independent of PATH, 10957c2939121Smrg # but it turns out we can't easily determine that from inspecting 10958c2939121Smrg # libtool variables, so we have to hard-code the OSs to which it 10959c2939121Smrg # applies here; at the moment, that means platforms that use the PE 10960c2939121Smrg # object format with DLL files. See the long comment at the top of 10961c2939121Smrg # tests/bindir.at for full details. 10962c2939121Smrg tdlname=$dlname 10963c2939121Smrg case $host,$output,$installed,$module,$dlname in 10964c2939121Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10965c2939121Smrg # If a -bindir argument was supplied, place the dll there. 109668292847cSmrg if test -n "$bindir"; then 10967c2939121Smrg func_relative_path "$install_libdir" "$bindir" 109688292847cSmrg tdlname=$func_relative_path_result/$dlname 10969c2939121Smrg else 10970c2939121Smrg # Otherwise fall back on heuristic. 10971c2939121Smrg tdlname=../bin/$dlname 10972c2939121Smrg fi 10973c2939121Smrg ;; 10974c2939121Smrg esac 10975c2939121Smrg $ECHO > $output "\ 10976c2939121Smrg# $outputname - a libtool library file 109778292847cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10978c2939121Smrg# 10979c2939121Smrg# Please DO NOT delete this file! 10980c2939121Smrg# It is necessary for linking the library. 10981c76ae52dSmrg 10982c2939121Smrg# The name that we can dlopen(3). 10983c2939121Smrgdlname='$tdlname' 10984c76ae52dSmrg 10985c2939121Smrg# Names of this library. 10986c2939121Smrglibrary_names='$library_names' 10987c76ae52dSmrg 10988c2939121Smrg# The name of the static archive. 10989c2939121Smrgold_library='$old_library' 10990c76ae52dSmrg 109918292847cSmrg# Linker flags that cannot go in dependency_libs. 10992c2939121Smrginherited_linker_flags='$new_inherited_linker_flags' 10993c76ae52dSmrg 10994c2939121Smrg# Libraries that this one depends upon. 10995c2939121Smrgdependency_libs='$dependency_libs' 10996c76ae52dSmrg 10997c2939121Smrg# Names of additional weak libraries provided by this library 10998c2939121Smrgweak_library_names='$weak_libs' 10999c76ae52dSmrg 11000c2939121Smrg# Version information for $libname. 11001c2939121Smrgcurrent=$current 11002c2939121Smrgage=$age 11003c2939121Smrgrevision=$revision 11004c76ae52dSmrg 11005c2939121Smrg# Is this an already installed library? 11006c2939121Smrginstalled=$installed 11007c76ae52dSmrg 11008c2939121Smrg# Should we warn about portability when linking against -modules? 11009c2939121Smrgshouldnotlink=$module 11010c76ae52dSmrg 11011c2939121Smrg# Files to dlopen/dlpreopen 11012c2939121Smrgdlopen='$dlfiles' 11013c2939121Smrgdlpreopen='$dlprefiles' 11014c76ae52dSmrg 11015c2939121Smrg# Directory that this library needs to be installed in: 11016c2939121Smrglibdir='$install_libdir'" 110178292847cSmrg if test no,yes = "$installed,$need_relink"; then 11018c2939121Smrg $ECHO >> $output "\ 11019c2939121Smrgrelink_command=\"$relink_command\"" 11020c2939121Smrg fi 11021c2939121Smrg done 11022c2939121Smrg } 11023c76ae52dSmrg 11024c2939121Smrg # Do a symbolic link so that the libtool archive can be found in 11025c2939121Smrg # LD_LIBRARY_PATH before the program is installed. 11026c2939121Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11027c2939121Smrg ;; 11028c2939121Smrg esac 11029c2939121Smrg exit $EXIT_SUCCESS 11030c2939121Smrg} 11031c76ae52dSmrg 110328292847cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 110338292847cSmrg func_mode_link ${1+"$@"} 110348292847cSmrgfi 11035c76ae52dSmrg 11036c76ae52dSmrg 11037c2939121Smrg# func_mode_uninstall arg... 11038c2939121Smrgfunc_mode_uninstall () 11039c2939121Smrg{ 110408292847cSmrg $debug_cmd 110418292847cSmrg 110428292847cSmrg RM=$nonopt 11043c76ae52dSmrg files= 110448292847cSmrg rmforce=false 11045c76ae52dSmrg exit_status=0 11046c76ae52dSmrg 11047c76ae52dSmrg # This variable tells wrapper scripts just to set variables rather 11048c76ae52dSmrg # than running their programs. 110498292847cSmrg libtool_install_magic=$magic 11050c76ae52dSmrg 11051c76ae52dSmrg for arg 11052c76ae52dSmrg do 11053c76ae52dSmrg case $arg in 110548292847cSmrg -f) func_append RM " $arg"; rmforce=: ;; 110552836776bSmrg -*) func_append RM " $arg" ;; 110562836776bSmrg *) func_append files " $arg" ;; 11057c76ae52dSmrg esac 11058c76ae52dSmrg done 11059c76ae52dSmrg 11060c2939121Smrg test -z "$RM" && \ 11061c2939121Smrg func_fatal_help "you must specify an RM program" 11062c76ae52dSmrg 11063c76ae52dSmrg rmdirs= 11064c76ae52dSmrg 11065c76ae52dSmrg for file in $files; do 11066c2939121Smrg func_dirname "$file" "" "." 110678292847cSmrg dir=$func_dirname_result 110688292847cSmrg if test . = "$dir"; then 110698292847cSmrg odir=$objdir 11070c76ae52dSmrg else 110718292847cSmrg odir=$dir/$objdir 11072c76ae52dSmrg fi 11073c2939121Smrg func_basename "$file" 110748292847cSmrg name=$func_basename_result 110758292847cSmrg test uninstall = "$opt_mode" && odir=$dir 11076c76ae52dSmrg 110772836776bSmrg # Remember odir for removal later, being careful to avoid duplicates 110788292847cSmrg if test clean = "$opt_mode"; then 11079c76ae52dSmrg case " $rmdirs " in 110802836776bSmrg *" $odir "*) ;; 110812836776bSmrg *) func_append rmdirs " $odir" ;; 11082c76ae52dSmrg esac 11083c76ae52dSmrg fi 11084c76ae52dSmrg 11085c76ae52dSmrg # Don't error if the file doesn't exist and rm -f was used. 11086c2939121Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11087c2939121Smrg { test -h "$file"; } >/dev/null 2>&1 || 11088c2939121Smrg test -f "$file"; then 11089c76ae52dSmrg : 11090c76ae52dSmrg elif test -d "$file"; then 11091c76ae52dSmrg exit_status=1 11092c76ae52dSmrg continue 110938292847cSmrg elif $rmforce; then 11094c76ae52dSmrg continue 11095c76ae52dSmrg fi 11096c76ae52dSmrg 110978292847cSmrg rmfiles=$file 11098c76ae52dSmrg 11099c76ae52dSmrg case $name in 11100c76ae52dSmrg *.la) 11101c76ae52dSmrg # Possibly a libtool archive, so verify it. 11102c2939121Smrg if func_lalib_p "$file"; then 11103c2939121Smrg func_source $dir/$name 11104c76ae52dSmrg 11105c76ae52dSmrg # Delete the libtool libraries and symlinks. 11106c76ae52dSmrg for n in $library_names; do 111072836776bSmrg func_append rmfiles " $odir/$n" 11108c76ae52dSmrg done 111092836776bSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11110c76ae52dSmrg 111118292847cSmrg case $opt_mode in 11112c76ae52dSmrg clean) 111132836776bSmrg case " $library_names " in 11114c76ae52dSmrg *" $dlname "*) ;; 111152836776bSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11116c76ae52dSmrg esac 111172836776bSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11118c76ae52dSmrg ;; 11119c76ae52dSmrg uninstall) 11120c76ae52dSmrg if test -n "$library_names"; then 11121c76ae52dSmrg # Do each command in the postuninstall commands. 111228292847cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11123c76ae52dSmrg fi 11124c76ae52dSmrg 11125c76ae52dSmrg if test -n "$old_library"; then 11126c76ae52dSmrg # Do each command in the old_postuninstall commands. 111278292847cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11128c76ae52dSmrg fi 11129c76ae52dSmrg # FIXME: should reinstall the best remaining shared library. 11130c76ae52dSmrg ;; 11131c76ae52dSmrg esac 11132c76ae52dSmrg fi 11133c76ae52dSmrg ;; 11134c76ae52dSmrg 11135c76ae52dSmrg *.lo) 11136c76ae52dSmrg # Possibly a libtool object, so verify it. 11137c2939121Smrg if func_lalib_p "$file"; then 11138c76ae52dSmrg 11139c76ae52dSmrg # Read the .lo file 11140c2939121Smrg func_source $dir/$name 11141c76ae52dSmrg 11142c76ae52dSmrg # Add PIC object to the list of files to remove. 111438292847cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 111442836776bSmrg func_append rmfiles " $dir/$pic_object" 11145c76ae52dSmrg fi 11146c76ae52dSmrg 11147c76ae52dSmrg # Add non-PIC object to the list of files to remove. 111488292847cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 111492836776bSmrg func_append rmfiles " $dir/$non_pic_object" 11150c76ae52dSmrg fi 11151c76ae52dSmrg fi 11152c76ae52dSmrg ;; 11153c76ae52dSmrg 11154c76ae52dSmrg *) 111558292847cSmrg if test clean = "$opt_mode"; then 11156c76ae52dSmrg noexename=$name 11157c76ae52dSmrg case $file in 11158c76ae52dSmrg *.exe) 11159c2939121Smrg func_stripname '' '.exe' "$file" 11160c2939121Smrg file=$func_stripname_result 11161c2939121Smrg func_stripname '' '.exe' "$name" 11162c2939121Smrg noexename=$func_stripname_result 11163c76ae52dSmrg # $file with .exe has already been added to rmfiles, 11164c76ae52dSmrg # add $file without .exe 111652836776bSmrg func_append rmfiles " $file" 11166c76ae52dSmrg ;; 11167c76ae52dSmrg esac 11168c76ae52dSmrg # Do a test to see if this is a libtool program. 11169c2939121Smrg if func_ltwrapper_p "$file"; then 11170c2939121Smrg if func_ltwrapper_executable_p "$file"; then 11171c2939121Smrg func_ltwrapper_scriptname "$file" 11172c2939121Smrg relink_command= 11173c2939121Smrg func_source $func_ltwrapper_scriptname_result 111742836776bSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11175c2939121Smrg else 11176c2939121Smrg relink_command= 11177c2939121Smrg func_source $dir/$noexename 11178c2939121Smrg fi 11179c76ae52dSmrg 11180c76ae52dSmrg # note $name still contains .exe if it was in $file originally 11181c76ae52dSmrg # as does the version of $file that was added into $rmfiles 111828292847cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 111838292847cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 111842836776bSmrg func_append rmfiles " $odir/lt-$name" 11185c76ae52dSmrg fi 111868292847cSmrg if test "X$noexename" != "X$name"; then 111878292847cSmrg func_append rmfiles " $odir/lt-$noexename.c" 11188c76ae52dSmrg fi 11189c76ae52dSmrg fi 11190c76ae52dSmrg fi 11191c76ae52dSmrg ;; 11192c76ae52dSmrg esac 11193c2939121Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11194c76ae52dSmrg done 11195c76ae52dSmrg 111968292847cSmrg # Try to remove the $objdir's in the directories where we deleted files 11197c76ae52dSmrg for dir in $rmdirs; do 11198c76ae52dSmrg if test -d "$dir"; then 11199c2939121Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11200c76ae52dSmrg fi 11201c76ae52dSmrg done 11202c76ae52dSmrg 11203c76ae52dSmrg exit $exit_status 11204c2939121Smrg} 11205c76ae52dSmrg 112068292847cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 112078292847cSmrg func_mode_uninstall ${1+"$@"} 112088292847cSmrgfi 11209c76ae52dSmrg 112102836776bSmrgtest -z "$opt_mode" && { 112118292847cSmrg help=$generic_help 11212c2939121Smrg func_fatal_help "you must specify a MODE" 11213c2939121Smrg} 11214c2939121Smrg 11215c2939121Smrgtest -z "$exec_cmd" && \ 112168292847cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11217c76ae52dSmrg 11218c76ae52dSmrgif test -n "$exec_cmd"; then 11219c2939121Smrg eval exec "$exec_cmd" 11220c76ae52dSmrg exit $EXIT_FAILURE 11221c76ae52dSmrgfi 11222c76ae52dSmrg 11223c2939121Smrgexit $exit_status 11224c76ae52dSmrg 11225c76ae52dSmrg 11226c76ae52dSmrg# The TAGs below are defined such that we never get into a situation 112278292847cSmrg# where we disable both kinds of libraries. Given conflicting 11228c76ae52dSmrg# choices, we go for a static library, that is the most portable, 11229c76ae52dSmrg# since we can't tell whether shared libraries were disabled because 11230c76ae52dSmrg# the user asked for that or because the platform doesn't support 11231c76ae52dSmrg# them. This is particularly important on AIX, because we don't 11232c76ae52dSmrg# support having both static and shared libraries enabled at the same 11233c76ae52dSmrg# time on that platform, so we default to a shared-only configuration. 11234c76ae52dSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11235c76ae52dSmrg# configuration. But we'll never go from static-only to shared-only. 11236c76ae52dSmrg 11237c76ae52dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11238c2939121Smrgbuild_libtool_libs=no 11239c2939121Smrgbuild_old_libs=yes 11240c76ae52dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11241c76ae52dSmrg 11242c76ae52dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11243c2939121Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11244c76ae52dSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11245c76ae52dSmrg 11246c76ae52dSmrg# Local Variables: 11247c76ae52dSmrg# mode:shell-script 11248c76ae52dSmrg# sh-indentation:2 11249c76ae52dSmrg# End: 11250