18fc2d0c6Smrg#! /usr/bin/env sh 20a392d7eSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 38fc2d0c6Smrg## by inline-source v2019-02-19.15 454b44505Smrg 58fc2d0c6Smrg# libtool (GNU libtool) 2.4.7 60a392d7eSmrg# Provide generalized library-building support services. 754b44505Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 854b44505Smrg 98fc2d0c6Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 1054b44505Smrg# This is free software; see the source for copying conditions. There is NO 1154b44505Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1254b44505Smrg 1354b44505Smrg# GNU Libtool is free software; you can redistribute it and/or modify 144a041c5bSmacallan# it under the terms of the GNU General Public License as published by 154a041c5bSmacallan# the Free Software Foundation; either version 2 of the License, or 164a041c5bSmacallan# (at your option) any later version. 174a041c5bSmacallan# 1854b44505Smrg# As a special exception to the GNU General Public License, 1954b44505Smrg# if you distribute this file as part of a program or library that 2054b44505Smrg# is built using GNU Libtool, you may include this file under the 2154b44505Smrg# same distribution terms that you use for the rest of that program. 2254b44505Smrg# 2354b44505Smrg# GNU Libtool is distributed in the hope that it will be useful, but 244a041c5bSmacallan# WITHOUT ANY WARRANTY; without even the implied warranty of 254a041c5bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 264a041c5bSmacallan# General Public License for more details. 274a041c5bSmacallan# 284a041c5bSmacallan# You should have received a copy of the GNU General Public License 290a392d7eSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 304a041c5bSmacallan 314a041c5bSmacallan 3254b44505SmrgPROGRAM=libtool 334a041c5bSmacallanPACKAGE=libtool 348fc2d0c6SmrgVERSION=2.4.7 358fc2d0c6Smrgpackage_revision=2.4.7 364a041c5bSmacallan 370a392d7eSmrg 380a392d7eSmrg## ------ ## 390a392d7eSmrg## Usage. ## 400a392d7eSmrg## ------ ## 410a392d7eSmrg 420a392d7eSmrg# Run './libtool --help' for help with using this script from the 430a392d7eSmrg# command line. 440a392d7eSmrg 450a392d7eSmrg 460a392d7eSmrg## ------------------------------- ## 470a392d7eSmrg## User overridable command paths. ## 480a392d7eSmrg## ------------------------------- ## 490a392d7eSmrg 500a392d7eSmrg# After configure completes, it has a better idea of some of the 510a392d7eSmrg# shell tools we need than the defaults used by the functions shared 520a392d7eSmrg# with bootstrap, so set those here where they can still be over- 530a392d7eSmrg# ridden by the user, but otherwise take precedence. 540a392d7eSmrg 550a392d7eSmrg: ${AUTOCONF="autoconf"} 560a392d7eSmrg: ${AUTOMAKE="automake"} 570a392d7eSmrg 580a392d7eSmrg 590a392d7eSmrg## -------------------------- ## 600a392d7eSmrg## Source external libraries. ## 610a392d7eSmrg## -------------------------- ## 620a392d7eSmrg 630a392d7eSmrg# Much of our low-level functionality needs to be sourced from external 640a392d7eSmrg# libraries, which are installed to $pkgauxdir. 650a392d7eSmrg 660a392d7eSmrg# Set a version string for this script. 678fc2d0c6Smrgscriptversion=2019-02-19.15; # UTC 680a392d7eSmrg 690a392d7eSmrg# General shell script boiler plate, and helper functions. 700a392d7eSmrg# Written by Gary V. Vaughan, 2004 710a392d7eSmrg 728fc2d0c6Smrg# This is free software. There is NO warranty; not even for 738fc2d0c6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 748fc2d0c6Smrg# 758fc2d0c6Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 768fc2d0c6Smrg# 778fc2d0c6Smrg# This file is dual licensed under the terms of the MIT license 788fc2d0c6Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 798fc2d0c6Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 808fc2d0c6Smrg# these licenses when using or redistributing this software or any of 818fc2d0c6Smrg# the files within it. See the URLs above, or the file `LICENSE` 828fc2d0c6Smrg# included in the Bootstrap distribution for the full license texts. 830a392d7eSmrg 848fc2d0c6Smrg# Please report bugs or propose patches to: 858fc2d0c6Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 860a392d7eSmrg 870a392d7eSmrg 880a392d7eSmrg## ------ ## 890a392d7eSmrg## Usage. ## 900a392d7eSmrg## ------ ## 910a392d7eSmrg 920a392d7eSmrg# Evaluate this file near the top of your script to gain access to 930a392d7eSmrg# the functions and variables defined here: 940a392d7eSmrg# 950a392d7eSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 960a392d7eSmrg# 970a392d7eSmrg# If you need to override any of the default environment variable 980a392d7eSmrg# settings, do that before evaluating this file. 990a392d7eSmrg 1000a392d7eSmrg 1010a392d7eSmrg## -------------------- ## 1020a392d7eSmrg## Shell normalisation. ## 1030a392d7eSmrg## -------------------- ## 1040a392d7eSmrg 1050a392d7eSmrg# Some shells need a little help to be as Bourne compatible as possible. 1060a392d7eSmrg# Before doing anything else, make sure all that help has been provided! 1070a392d7eSmrg 1080a392d7eSmrgDUALCASE=1; export DUALCASE # for MKS sh 1090a392d7eSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1104a041c5bSmacallan emulate sh 1114a041c5bSmacallan NULLCMD=: 1120a392d7eSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1134a041c5bSmacallan # is contrary to our usage. Disable this feature. 1144a041c5bSmacallan alias -g '${1+"$@"}'='"$@"' 1154a041c5bSmacallan setopt NO_GLOB_SUBST 1164a041c5bSmacallanelse 1170a392d7eSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1184a041c5bSmacallanfi 1194a041c5bSmacallan 1200a392d7eSmrg# NLS nuisances: We save the old values in case they are required later. 1210a392d7eSmrg_G_user_locale= 1220a392d7eSmrg_G_safe_locale= 1230a392d7eSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1244a041c5bSmacallando 1250a392d7eSmrg eval "if test set = \"\${$_G_var+set}\"; then 1260a392d7eSmrg save_$_G_var=\$$_G_var 1270a392d7eSmrg $_G_var=C 1280a392d7eSmrg export $_G_var 1290a392d7eSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1300a392d7eSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1314a041c5bSmacallan fi" 1324a041c5bSmacallandone 1338fc2d0c6Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1348fc2d0c6Smrg# in case the environment reset is needed later and the $save_* variant is not 1358fc2d0c6Smrg# defined (see the code above). 1368fc2d0c6SmrgLC_ALL=C 1378fc2d0c6SmrgLANGUAGE=C 1388fc2d0c6Smrgexport LANGUAGE LC_ALL 1394a041c5bSmacallan 1400a392d7eSmrg# Make sure IFS has a sensible default 1410a392d7eSmrgsp=' ' 1420a392d7eSmrgnl=' 1430a392d7eSmrg' 1440a392d7eSmrgIFS="$sp $nl" 1450a392d7eSmrg 1460a392d7eSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1470a392d7eSmrgif test "${PATH_SEPARATOR+set}" != set; then 1480a392d7eSmrg PATH_SEPARATOR=: 1490a392d7eSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1500a392d7eSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1510a392d7eSmrg PATH_SEPARATOR=';' 1520a392d7eSmrg } 1530a392d7eSmrgfi 15454b44505Smrg 15554b44505Smrg 1568fc2d0c6Smrg# func_unset VAR 1578fc2d0c6Smrg# -------------- 1588fc2d0c6Smrg# Portably unset VAR. 1598fc2d0c6Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1608fc2d0c6Smrg# status if VAR is already unset, which might be problematic if the 1618fc2d0c6Smrg# statement is used at the end of a function (thus poisoning its return 1628fc2d0c6Smrg# value) or when 'set -e' is active (causing even a spurious abort of 1638fc2d0c6Smrg# the script in this case). 1648fc2d0c6Smrgfunc_unset () 1658fc2d0c6Smrg{ 1668fc2d0c6Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1678fc2d0c6Smrg} 1688fc2d0c6Smrg 1698fc2d0c6Smrg 1708fc2d0c6Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1718fc2d0c6Smrgfunc_unset CDPATH 1728fc2d0c6Smrg 1738fc2d0c6Smrg# Make sure ${,E,F}GREP behave sanely. 1748fc2d0c6Smrgfunc_unset GREP_OPTIONS 1758fc2d0c6Smrg 17654b44505Smrg 1770a392d7eSmrg## ------------------------- ## 1780a392d7eSmrg## Locate command utilities. ## 1790a392d7eSmrg## ------------------------- ## 1800a392d7eSmrg 1810a392d7eSmrg 1820a392d7eSmrg# func_executable_p FILE 1830a392d7eSmrg# ---------------------- 1840a392d7eSmrg# Check that FILE is an executable regular file. 1850a392d7eSmrgfunc_executable_p () 1860a392d7eSmrg{ 1870a392d7eSmrg test -f "$1" && test -x "$1" 1880a392d7eSmrg} 1890a392d7eSmrg 1900a392d7eSmrg 1910a392d7eSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1920a392d7eSmrg# -------------------------------------------- 1930a392d7eSmrg# Search for either a program that responds to --version with output 1940a392d7eSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1950a392d7eSmrg# trying all the directories in PATH with each of the elements of 1960a392d7eSmrg# PROGS_LIST. 1970a392d7eSmrg# 1980a392d7eSmrg# CHECK_FUNC should accept the path to a candidate program, and 1990a392d7eSmrg# set $func_check_prog_result if it truncates its output less than 2000a392d7eSmrg# $_G_path_prog_max characters. 2010a392d7eSmrgfunc_path_progs () 2020a392d7eSmrg{ 2030a392d7eSmrg _G_progs_list=$1 2040a392d7eSmrg _G_check_func=$2 2050a392d7eSmrg _G_PATH=${3-"$PATH"} 2060a392d7eSmrg 2070a392d7eSmrg _G_path_prog_max=0 2080a392d7eSmrg _G_path_prog_found=false 2090a392d7eSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2100a392d7eSmrg for _G_dir in $_G_PATH; do 2110a392d7eSmrg IFS=$_G_save_IFS 2120a392d7eSmrg test -z "$_G_dir" && _G_dir=. 2130a392d7eSmrg for _G_prog_name in $_G_progs_list; do 2140a392d7eSmrg for _exeext in '' .EXE; do 2150a392d7eSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2160a392d7eSmrg func_executable_p "$_G_path_prog" || continue 2170a392d7eSmrg case `"$_G_path_prog" --version 2>&1` in 2180a392d7eSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2190a392d7eSmrg *) $_G_check_func $_G_path_prog 2200a392d7eSmrg func_path_progs_result=$func_check_prog_result 2210a392d7eSmrg ;; 2220a392d7eSmrg esac 2230a392d7eSmrg $_G_path_prog_found && break 3 2240a392d7eSmrg done 2250a392d7eSmrg done 2260a392d7eSmrg done 2270a392d7eSmrg IFS=$_G_save_IFS 2280a392d7eSmrg test -z "$func_path_progs_result" && { 2290a392d7eSmrg echo "no acceptable sed could be found in \$PATH" >&2 2300a392d7eSmrg exit 1 2310a392d7eSmrg } 2320a392d7eSmrg} 2330a392d7eSmrg 2340a392d7eSmrg 2350a392d7eSmrg# We want to be able to use the functions in this file before configure 2360a392d7eSmrg# has figured out where the best binaries are kept, which means we have 2370a392d7eSmrg# to search for them ourselves - except when the results are already set 2380a392d7eSmrg# where we skip the searches. 2390a392d7eSmrg 2400a392d7eSmrg# Unless the user overrides by setting SED, search the path for either GNU 2410a392d7eSmrg# sed, or the sed that truncates its output the least. 2420a392d7eSmrgtest -z "$SED" && { 2430a392d7eSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2440a392d7eSmrg for _G_i in 1 2 3 4 5 6 7; do 2450a392d7eSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2460a392d7eSmrg done 2470a392d7eSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2480a392d7eSmrg _G_sed_script= 2490a392d7eSmrg 2500a392d7eSmrg func_check_prog_sed () 2510a392d7eSmrg { 2520a392d7eSmrg _G_path_prog=$1 2530a392d7eSmrg 2540a392d7eSmrg _G_count=0 2550a392d7eSmrg printf 0123456789 >conftest.in 2560a392d7eSmrg while : 2570a392d7eSmrg do 2580a392d7eSmrg cat conftest.in conftest.in >conftest.tmp 2590a392d7eSmrg mv conftest.tmp conftest.in 2600a392d7eSmrg cp conftest.in conftest.nl 2610a392d7eSmrg echo '' >> conftest.nl 2620a392d7eSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2630a392d7eSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2640a392d7eSmrg _G_count=`expr $_G_count + 1` 2650a392d7eSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2660a392d7eSmrg # Best one so far, save it but keep looking for a better one 2670a392d7eSmrg func_check_prog_result=$_G_path_prog 2680a392d7eSmrg _G_path_prog_max=$_G_count 2690a392d7eSmrg fi 2700a392d7eSmrg # 10*(2^10) chars as input seems more than enough 2710a392d7eSmrg test 10 -lt "$_G_count" && break 2720a392d7eSmrg done 2730a392d7eSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2740a392d7eSmrg } 2750a392d7eSmrg 2768fc2d0c6Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2770a392d7eSmrg rm -f conftest.sed 2780a392d7eSmrg SED=$func_path_progs_result 2790a392d7eSmrg} 2800a392d7eSmrg 2810a392d7eSmrg 2820a392d7eSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2830a392d7eSmrg# grep, or the grep that truncates its output the least. 2840a392d7eSmrgtest -z "$GREP" && { 2850a392d7eSmrg func_check_prog_grep () 2860a392d7eSmrg { 2870a392d7eSmrg _G_path_prog=$1 2880a392d7eSmrg 2890a392d7eSmrg _G_count=0 2900a392d7eSmrg _G_path_prog_max=0 2910a392d7eSmrg printf 0123456789 >conftest.in 2920a392d7eSmrg while : 2930a392d7eSmrg do 2940a392d7eSmrg cat conftest.in conftest.in >conftest.tmp 2950a392d7eSmrg mv conftest.tmp conftest.in 2960a392d7eSmrg cp conftest.in conftest.nl 2970a392d7eSmrg echo 'GREP' >> conftest.nl 2980a392d7eSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2990a392d7eSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3000a392d7eSmrg _G_count=`expr $_G_count + 1` 3010a392d7eSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3020a392d7eSmrg # Best one so far, save it but keep looking for a better one 3030a392d7eSmrg func_check_prog_result=$_G_path_prog 3040a392d7eSmrg _G_path_prog_max=$_G_count 3050a392d7eSmrg fi 3060a392d7eSmrg # 10*(2^10) chars as input seems more than enough 3070a392d7eSmrg test 10 -lt "$_G_count" && break 3080a392d7eSmrg done 3090a392d7eSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3100a392d7eSmrg } 3110a392d7eSmrg 3128fc2d0c6Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3130a392d7eSmrg GREP=$func_path_progs_result 3140a392d7eSmrg} 3150a392d7eSmrg 3160a392d7eSmrg 3170a392d7eSmrg## ------------------------------- ## 3180a392d7eSmrg## User overridable command paths. ## 3190a392d7eSmrg## ------------------------------- ## 3200a392d7eSmrg 3210a392d7eSmrg# All uppercase variable names are used for environment variables. These 3220a392d7eSmrg# variables can be overridden by the user before calling a script that 3230a392d7eSmrg# uses them if a suitable command of that name is not already available 3240a392d7eSmrg# in the command search PATH. 32554b44505Smrg 32654b44505Smrg: ${CP="cp -f"} 3270a392d7eSmrg: ${ECHO="printf %s\n"} 3280a392d7eSmrg: ${EGREP="$GREP -E"} 3290a392d7eSmrg: ${FGREP="$GREP -F"} 33054b44505Smrg: ${LN_S="ln -s"} 33154b44505Smrg: ${MAKE="make"} 33254b44505Smrg: ${MKDIR="mkdir"} 33354b44505Smrg: ${MV="mv -f"} 33454b44505Smrg: ${RM="rm -f"} 33554b44505Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3364a041c5bSmacallan 3374a041c5bSmacallan 3380a392d7eSmrg## -------------------- ## 3390a392d7eSmrg## Useful sed snippets. ## 3400a392d7eSmrg## -------------------- ## 34154b44505Smrg 3420a392d7eSmrgsed_dirname='s|/[^/]*$||' 3430a392d7eSmrgsed_basename='s|^.*/||' 34454b44505Smrg 3450a392d7eSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3460a392d7eSmrg# metacharacters that are still active within double-quoted strings. 3470a392d7eSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 34854b44505Smrg 3490a392d7eSmrg# Same as above, but do not quote variable references. 3500a392d7eSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 35154b44505Smrg 3520a392d7eSmrg# Sed substitution that turns a string into a regex matching for the 3530a392d7eSmrg# string literally. 3540a392d7eSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 35554b44505Smrg 3560a392d7eSmrg# Sed substitution that converts a w32 file name or path 3570a392d7eSmrg# that contains forward slashes, into one that contains 3580a392d7eSmrg# (escaped) backslashes. A very naive implementation. 3590a392d7eSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3600a392d7eSmrg 3610a392d7eSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3620a392d7eSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3630a392d7eSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3640a392d7eSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3650a392d7eSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3660a392d7eSmrg_G_bs='\\' 3670a392d7eSmrg_G_bs2='\\\\' 3680a392d7eSmrg_G_bs4='\\\\\\\\' 3690a392d7eSmrg_G_dollar='\$' 3700a392d7eSmrgsed_double_backslash="\ 3710a392d7eSmrg s/$_G_bs4/&\\ 3720a392d7eSmrg/g 3730a392d7eSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3740a392d7eSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3750a392d7eSmrg s/\n//g" 37654b44505Smrg 3778fc2d0c6Smrg# require_check_ifs_backslash 3788fc2d0c6Smrg# --------------------------- 3798fc2d0c6Smrg# Check if we can use backslash as IFS='\' separator, and set 3808fc2d0c6Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 3818fc2d0c6Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3828fc2d0c6Smrgfunc_require_check_ifs_backslash () 3838fc2d0c6Smrg{ 3848fc2d0c6Smrg _G_save_IFS=$IFS 3858fc2d0c6Smrg IFS='\' 3868fc2d0c6Smrg _G_check_ifs_backshlash='a\\b' 3878fc2d0c6Smrg for _G_i in $_G_check_ifs_backshlash 3888fc2d0c6Smrg do 3898fc2d0c6Smrg case $_G_i in 3908fc2d0c6Smrg a) 3918fc2d0c6Smrg check_ifs_backshlash_broken=false 3928fc2d0c6Smrg ;; 3938fc2d0c6Smrg '') 3948fc2d0c6Smrg break 3958fc2d0c6Smrg ;; 3968fc2d0c6Smrg *) 3978fc2d0c6Smrg check_ifs_backshlash_broken=: 3988fc2d0c6Smrg break 3998fc2d0c6Smrg ;; 4008fc2d0c6Smrg esac 4018fc2d0c6Smrg done 4028fc2d0c6Smrg IFS=$_G_save_IFS 4038fc2d0c6Smrg require_check_ifs_backslash=: 4048fc2d0c6Smrg} 4058fc2d0c6Smrg 40654b44505Smrg 4070a392d7eSmrg## ----------------- ## 4080a392d7eSmrg## Global variables. ## 4090a392d7eSmrg## ----------------- ## 41054b44505Smrg 4110a392d7eSmrg# Except for the global variables explicitly listed below, the following 4120a392d7eSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4130a392d7eSmrg# variables initialised in the 'Resource management' section, sourcing 4140a392d7eSmrg# this file will not pollute your global namespace with anything 4150a392d7eSmrg# else. There's no portable way to scope variables in Bourne shell 4160a392d7eSmrg# though, so actually running these functions will sometimes place 4170a392d7eSmrg# results into a variable named after the function, and often use 4180a392d7eSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4190a392d7eSmrg# avoid using those namespaces casually in your sourcing script, things 4200a392d7eSmrg# should continue to work as you expect. And, of course, you can freely 4210a392d7eSmrg# overwrite any of the functions or variables defined here before 4220a392d7eSmrg# calling anything to customize them. 42354b44505Smrg 4240a392d7eSmrgEXIT_SUCCESS=0 4250a392d7eSmrgEXIT_FAILURE=1 4260a392d7eSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4270a392d7eSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42854b44505Smrg 4290a392d7eSmrg# Allow overriding, eg assuming that you follow the convention of 4300a392d7eSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4310a392d7eSmrg# bash to show function call trace with: 4320a392d7eSmrg# 4330a392d7eSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4340a392d7eSmrgdebug_cmd=${debug_cmd-":"} 4350a392d7eSmrgexit_cmd=: 43654b44505Smrg 4370a392d7eSmrg# By convention, finish your script with: 4380a392d7eSmrg# 4390a392d7eSmrg# exit $exit_status 4400a392d7eSmrg# 4410a392d7eSmrg# so that you can set exit_status to non-zero if you want to indicate 4420a392d7eSmrg# something went wrong during execution without actually bailing out at 4430a392d7eSmrg# the point of failure. 4440a392d7eSmrgexit_status=$EXIT_SUCCESS 44554b44505Smrg 4460a392d7eSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4470a392d7eSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4480a392d7eSmrg# the _XPG environment variable is not equal to 1 (one), the special 4490a392d7eSmrg# positional parameter $0, within a function call, is the name of the 4500a392d7eSmrg# function. 4510a392d7eSmrgprogpath=$0 45254b44505Smrg 4530a392d7eSmrg# The name of this program. 4540a392d7eSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 45554b44505Smrg 4560a392d7eSmrg# Make sure we have an absolute progpath for reexecution: 45754b44505Smrgcase $progpath in 45854b44505Smrg [\\/]*|[A-Za-z]:\\*) ;; 45954b44505Smrg *[\\/]*) 4600a392d7eSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 46154b44505Smrg progdir=`cd "$progdir" && pwd` 4620a392d7eSmrg progpath=$progdir/$progname 46354b44505Smrg ;; 46454b44505Smrg *) 4650a392d7eSmrg _G_IFS=$IFS 4660a392d7eSmrg IFS=${PATH_SEPARATOR-:} 46754b44505Smrg for progdir in $PATH; do 4680a392d7eSmrg IFS=$_G_IFS 46954b44505Smrg test -x "$progdir/$progname" && break 47054b44505Smrg done 4710a392d7eSmrg IFS=$_G_IFS 47254b44505Smrg test -n "$progdir" || progdir=`pwd` 4730a392d7eSmrg progpath=$progdir/$progname 47454b44505Smrg ;; 47554b44505Smrgesac 47654b44505Smrg 47754b44505Smrg 4780a392d7eSmrg## ----------------- ## 4790a392d7eSmrg## Standard options. ## 4800a392d7eSmrg## ----------------- ## 48154b44505Smrg 4820a392d7eSmrg# The following options affect the operation of the functions defined 4830a392d7eSmrg# below, and should be set appropriately depending on run-time para- 4840a392d7eSmrg# meters passed on the command line. 48554b44505Smrg 48654b44505Smrgopt_dry_run=false 48754b44505Smrgopt_quiet=false 48854b44505Smrgopt_verbose=false 48954b44505Smrg 4900a392d7eSmrg# Categories 'all' and 'none' are always available. Append any others 4910a392d7eSmrg# you will pass as the first argument to func_warning from your own 4920a392d7eSmrg# code. 4930a392d7eSmrgwarning_categories= 49454b44505Smrg 4950a392d7eSmrg# By default, display warnings according to 'opt_warning_types'. Set 4960a392d7eSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4970a392d7eSmrg# treat the next displayed warning as a fatal error. 4980a392d7eSmrgwarning_func=func_warn_and_continue 49954b44505Smrg 5000a392d7eSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5010a392d7eSmrg# warnings, or a space delimited list of some subset of 5020a392d7eSmrg# 'warning_categories' to display only the listed warnings. 5030a392d7eSmrgopt_warning_types=all 50454b44505Smrg 50554b44505Smrg 5060a392d7eSmrg## -------------------- ## 5070a392d7eSmrg## Resource management. ## 5080a392d7eSmrg## -------------------- ## 50954b44505Smrg 5100a392d7eSmrg# This section contains definitions for functions that each ensure a 5110a392d7eSmrg# particular resource (a file, or a non-empty configuration variable for 5120a392d7eSmrg# example) is available, and if appropriate to extract default values 5130a392d7eSmrg# from pertinent package files. Call them using their associated 5140a392d7eSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5150a392d7eSmrg# 5160a392d7eSmrg# It's entirely deliberate that calling these functions can set 5170a392d7eSmrg# variables that don't obey the namespace limitations obeyed by the rest 5180a392d7eSmrg# of this file, in order that that they be as useful as possible to 5190a392d7eSmrg# callers. 52054b44505Smrg 52154b44505Smrg 5220a392d7eSmrg# require_term_colors 5230a392d7eSmrg# ------------------- 5240a392d7eSmrg# Allow display of bold text on terminals that support it. 5250a392d7eSmrgrequire_term_colors=func_require_term_colors 5260a392d7eSmrgfunc_require_term_colors () 52754b44505Smrg{ 5280a392d7eSmrg $debug_cmd 5290a392d7eSmrg 5300a392d7eSmrg test -t 1 && { 5310a392d7eSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5320a392d7eSmrg # precedence, because most terminfo databases neglect to describe 5330a392d7eSmrg # whether color sequences are supported. 5340a392d7eSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5350a392d7eSmrg 5360a392d7eSmrg if test 1 = "$USE_ANSI_COLORS"; then 5370a392d7eSmrg # Standard ANSI escape sequences 5380a392d7eSmrg tc_reset='[0m' 5390a392d7eSmrg tc_bold='[1m'; tc_standout='[7m' 5400a392d7eSmrg tc_red='[31m'; tc_green='[32m' 5410a392d7eSmrg tc_blue='[34m'; tc_cyan='[36m' 5420a392d7eSmrg else 5430a392d7eSmrg # Otherwise trust the terminfo database after all. 5440a392d7eSmrg test -n "`tput sgr0 2>/dev/null`" && { 5450a392d7eSmrg tc_reset=`tput sgr0` 5460a392d7eSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5470a392d7eSmrg tc_standout=$tc_bold 5480a392d7eSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5490a392d7eSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5500a392d7eSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5510a392d7eSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5520a392d7eSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5530a392d7eSmrg } 5540a392d7eSmrg fi 5550a392d7eSmrg } 55654b44505Smrg 5570a392d7eSmrg require_term_colors=: 55854b44505Smrg} 55954b44505Smrg 56054b44505Smrg 5610a392d7eSmrg## ----------------- ## 5620a392d7eSmrg## Function library. ## 5630a392d7eSmrg## ----------------- ## 5640a392d7eSmrg 5650a392d7eSmrg# This section contains a variety of useful functions to call in your 5660a392d7eSmrg# scripts. Take note of the portable wrappers for features provided by 5670a392d7eSmrg# some modern shells, which will fall back to slower equivalents on 5680a392d7eSmrg# less featureful shells. 5690a392d7eSmrg 5700a392d7eSmrg 5710a392d7eSmrg# func_append VAR VALUE 5720a392d7eSmrg# --------------------- 5730a392d7eSmrg# Append VALUE onto the existing contents of VAR. 5740a392d7eSmrg 5750a392d7eSmrg # We should try to minimise forks, especially on Windows where they are 5760a392d7eSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5770a392d7eSmrg # being used: 5780a392d7eSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5790a392d7eSmrg : ${_G_HAVE_ARITH_OP="yes"} 5800a392d7eSmrg : ${_G_HAVE_XSI_OPS="yes"} 5810a392d7eSmrg # The += operator was introduced in bash 3.1 5820a392d7eSmrg case $BASH_VERSION in 5830a392d7eSmrg [12].* | 3.0 | 3.0*) ;; 5840a392d7eSmrg *) 5850a392d7eSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5860a392d7eSmrg ;; 5870a392d7eSmrg esac 5880a392d7eSmrg fi 5890a392d7eSmrg 5900a392d7eSmrg # _G_HAVE_PLUSEQ_OP 5910a392d7eSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5920a392d7eSmrg # useable or anything else if it does not work. 5930a392d7eSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5940a392d7eSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5950a392d7eSmrg && _G_HAVE_PLUSEQ_OP=yes 5960a392d7eSmrg 5970a392d7eSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5980a392d7eSmrgthen 5990a392d7eSmrg # This is an XSI compatible shell, allowing a faster implementation... 6000a392d7eSmrg eval 'func_append () 6010a392d7eSmrg { 6020a392d7eSmrg $debug_cmd 6030a392d7eSmrg 6040a392d7eSmrg eval "$1+=\$2" 6050a392d7eSmrg }' 6060a392d7eSmrgelse 6070a392d7eSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6080a392d7eSmrg func_append () 6090a392d7eSmrg { 6100a392d7eSmrg $debug_cmd 6110a392d7eSmrg 6120a392d7eSmrg eval "$1=\$$1\$2" 6130a392d7eSmrg } 6140a392d7eSmrgfi 6150a392d7eSmrg 6160a392d7eSmrg 6170a392d7eSmrg# func_append_quoted VAR VALUE 6180a392d7eSmrg# ---------------------------- 6190a392d7eSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6200a392d7eSmrg# by a space. 6210a392d7eSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6220a392d7eSmrg eval 'func_append_quoted () 6230a392d7eSmrg { 6240a392d7eSmrg $debug_cmd 6250a392d7eSmrg 6268fc2d0c6Smrg func_quote_arg pretty "$2" 6278fc2d0c6Smrg eval "$1+=\\ \$func_quote_arg_result" 6280a392d7eSmrg }' 6290a392d7eSmrgelse 6300a392d7eSmrg func_append_quoted () 6310a392d7eSmrg { 6320a392d7eSmrg $debug_cmd 6330a392d7eSmrg 6348fc2d0c6Smrg func_quote_arg pretty "$2" 6358fc2d0c6Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 6360a392d7eSmrg } 6370a392d7eSmrgfi 6380a392d7eSmrg 6390a392d7eSmrg 6400a392d7eSmrg# func_append_uniq VAR VALUE 6410a392d7eSmrg# -------------------------- 6420a392d7eSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6430a392d7eSmrg# entries are delimited by the first character of VALUE. For example: 6440a392d7eSmrg# 6450a392d7eSmrg# func_append_uniq options " --another-option option-argument" 6460a392d7eSmrg# 6470a392d7eSmrg# will only append to $options if " --another-option option-argument " 6480a392d7eSmrg# is not already present somewhere in $options already (note spaces at 6490a392d7eSmrg# each end implied by leading space in second argument). 6500a392d7eSmrgfunc_append_uniq () 6510a392d7eSmrg{ 6520a392d7eSmrg $debug_cmd 6530a392d7eSmrg 6540a392d7eSmrg eval _G_current_value='`$ECHO $'$1'`' 6550a392d7eSmrg _G_delim=`expr "$2" : '\(.\)'` 6560a392d7eSmrg 6570a392d7eSmrg case $_G_delim$_G_current_value$_G_delim in 6580a392d7eSmrg *"$2$_G_delim"*) ;; 6590a392d7eSmrg *) func_append "$@" ;; 6600a392d7eSmrg esac 6610a392d7eSmrg} 6620a392d7eSmrg 6630a392d7eSmrg 6640a392d7eSmrg# func_arith TERM... 6650a392d7eSmrg# ------------------ 6660a392d7eSmrg# Set func_arith_result to the result of evaluating TERMs. 6670a392d7eSmrg test -z "$_G_HAVE_ARITH_OP" \ 6680a392d7eSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6690a392d7eSmrg && _G_HAVE_ARITH_OP=yes 6700a392d7eSmrg 6710a392d7eSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6720a392d7eSmrg eval 'func_arith () 6730a392d7eSmrg { 6740a392d7eSmrg $debug_cmd 6750a392d7eSmrg 6760a392d7eSmrg func_arith_result=$(( $* )) 6770a392d7eSmrg }' 6780a392d7eSmrgelse 6790a392d7eSmrg func_arith () 6800a392d7eSmrg { 6810a392d7eSmrg $debug_cmd 6820a392d7eSmrg 6830a392d7eSmrg func_arith_result=`expr "$@"` 6840a392d7eSmrg } 6850a392d7eSmrgfi 6860a392d7eSmrg 6870a392d7eSmrg 6880a392d7eSmrg# func_basename FILE 6890a392d7eSmrg# ------------------ 6900a392d7eSmrg# Set func_basename_result to FILE with everything up to and including 6910a392d7eSmrg# the last / stripped. 6920a392d7eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6930a392d7eSmrg # If this shell supports suffix pattern removal, then use it to avoid 6940a392d7eSmrg # forking. Hide the definitions single quotes in case the shell chokes 6950a392d7eSmrg # on unsupported syntax... 6960a392d7eSmrg _b='func_basename_result=${1##*/}' 6970a392d7eSmrg _d='case $1 in 6980a392d7eSmrg */*) func_dirname_result=${1%/*}$2 ;; 6990a392d7eSmrg * ) func_dirname_result=$3 ;; 7000a392d7eSmrg esac' 7010a392d7eSmrg 7020a392d7eSmrgelse 7030a392d7eSmrg # ...otherwise fall back to using sed. 7040a392d7eSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7050a392d7eSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7060a392d7eSmrg if test "X$func_dirname_result" = "X$1"; then 7070a392d7eSmrg func_dirname_result=$3 7080a392d7eSmrg else 7090a392d7eSmrg func_append func_dirname_result "$2" 7100a392d7eSmrg fi' 7110a392d7eSmrgfi 7120a392d7eSmrg 7130a392d7eSmrgeval 'func_basename () 7140a392d7eSmrg{ 7150a392d7eSmrg $debug_cmd 7160a392d7eSmrg 7170a392d7eSmrg '"$_b"' 7180a392d7eSmrg}' 7190a392d7eSmrg 7200a392d7eSmrg 7210a392d7eSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7220a392d7eSmrg# ------------------------------------------- 7230a392d7eSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7240a392d7eSmrg# otherwise set result to NONDIR_REPLACEMENT. 7250a392d7eSmrgeval 'func_dirname () 7260a392d7eSmrg{ 7270a392d7eSmrg $debug_cmd 7280a392d7eSmrg 7290a392d7eSmrg '"$_d"' 7300a392d7eSmrg}' 7310a392d7eSmrg 7320a392d7eSmrg 7330a392d7eSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7340a392d7eSmrg# -------------------------------------------------------- 7350a392d7eSmrg# Perform func_basename and func_dirname in a single function 7360a392d7eSmrg# call: 7370a392d7eSmrg# dirname: Compute the dirname of FILE. If nonempty, 7380a392d7eSmrg# add APPEND to the result, otherwise set result 7390a392d7eSmrg# to NONDIR_REPLACEMENT. 7400a392d7eSmrg# value returned in "$func_dirname_result" 7410a392d7eSmrg# basename: Compute filename of FILE. 7420a392d7eSmrg# value retuned in "$func_basename_result" 7430a392d7eSmrg# For efficiency, we do not delegate to the functions above but instead 7440a392d7eSmrg# duplicate the functionality here. 7450a392d7eSmrgeval 'func_dirname_and_basename () 7460a392d7eSmrg{ 7470a392d7eSmrg $debug_cmd 7480a392d7eSmrg 7490a392d7eSmrg '"$_b"' 7500a392d7eSmrg '"$_d"' 7510a392d7eSmrg}' 7520a392d7eSmrg 7530a392d7eSmrg 7540a392d7eSmrg# func_echo ARG... 7550a392d7eSmrg# ---------------- 7560a392d7eSmrg# Echo program name prefixed message. 7570a392d7eSmrgfunc_echo () 7580a392d7eSmrg{ 7590a392d7eSmrg $debug_cmd 7600a392d7eSmrg 7610a392d7eSmrg _G_message=$* 7620a392d7eSmrg 7630a392d7eSmrg func_echo_IFS=$IFS 7640a392d7eSmrg IFS=$nl 7650a392d7eSmrg for _G_line in $_G_message; do 7660a392d7eSmrg IFS=$func_echo_IFS 7670a392d7eSmrg $ECHO "$progname: $_G_line" 7680a392d7eSmrg done 7690a392d7eSmrg IFS=$func_echo_IFS 7700a392d7eSmrg} 7710a392d7eSmrg 7720a392d7eSmrg 7730a392d7eSmrg# func_echo_all ARG... 7740a392d7eSmrg# -------------------- 7750a392d7eSmrg# Invoke $ECHO with all args, space-separated. 7760a392d7eSmrgfunc_echo_all () 7770a392d7eSmrg{ 7780a392d7eSmrg $ECHO "$*" 7790a392d7eSmrg} 7800a392d7eSmrg 7810a392d7eSmrg 7820a392d7eSmrg# func_echo_infix_1 INFIX ARG... 7830a392d7eSmrg# ------------------------------ 7840a392d7eSmrg# Echo program name, followed by INFIX on the first line, with any 7850a392d7eSmrg# additional lines not showing INFIX. 7860a392d7eSmrgfunc_echo_infix_1 () 7870a392d7eSmrg{ 7880a392d7eSmrg $debug_cmd 7890a392d7eSmrg 7900a392d7eSmrg $require_term_colors 7910a392d7eSmrg 7920a392d7eSmrg _G_infix=$1; shift 7930a392d7eSmrg _G_indent=$_G_infix 7940a392d7eSmrg _G_prefix="$progname: $_G_infix: " 7950a392d7eSmrg _G_message=$* 7960a392d7eSmrg 7970a392d7eSmrg # Strip color escape sequences before counting printable length 7980a392d7eSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7990a392d7eSmrg do 8000a392d7eSmrg test -n "$_G_tc" && { 8010a392d7eSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8020a392d7eSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8030a392d7eSmrg } 8040a392d7eSmrg done 8050a392d7eSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8060a392d7eSmrg 8070a392d7eSmrg func_echo_infix_1_IFS=$IFS 8080a392d7eSmrg IFS=$nl 8090a392d7eSmrg for _G_line in $_G_message; do 8100a392d7eSmrg IFS=$func_echo_infix_1_IFS 8110a392d7eSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8120a392d7eSmrg _G_prefix=$_G_indent 8130a392d7eSmrg done 8140a392d7eSmrg IFS=$func_echo_infix_1_IFS 8150a392d7eSmrg} 8160a392d7eSmrg 8170a392d7eSmrg 8180a392d7eSmrg# func_error ARG... 8190a392d7eSmrg# ----------------- 8200a392d7eSmrg# Echo program name prefixed message to standard error. 8210a392d7eSmrgfunc_error () 8220a392d7eSmrg{ 8230a392d7eSmrg $debug_cmd 8240a392d7eSmrg 8250a392d7eSmrg $require_term_colors 8260a392d7eSmrg 8270a392d7eSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8280a392d7eSmrg} 8290a392d7eSmrg 8300a392d7eSmrg 8310a392d7eSmrg# func_fatal_error ARG... 8320a392d7eSmrg# ----------------------- 8330a392d7eSmrg# Echo program name prefixed message to standard error, and exit. 8340a392d7eSmrgfunc_fatal_error () 8350a392d7eSmrg{ 8360a392d7eSmrg $debug_cmd 8370a392d7eSmrg 8380a392d7eSmrg func_error "$*" 8390a392d7eSmrg exit $EXIT_FAILURE 8400a392d7eSmrg} 8410a392d7eSmrg 8420a392d7eSmrg 8430a392d7eSmrg# func_grep EXPRESSION FILENAME 8440a392d7eSmrg# ----------------------------- 84554b44505Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84654b44505Smrgfunc_grep () 84754b44505Smrg{ 8480a392d7eSmrg $debug_cmd 8490a392d7eSmrg 85054b44505Smrg $GREP "$1" "$2" >/dev/null 2>&1 85154b44505Smrg} 85254b44505Smrg 85354b44505Smrg 8540a392d7eSmrg# func_len STRING 8550a392d7eSmrg# --------------- 8560a392d7eSmrg# Set func_len_result to the length of STRING. STRING may not 8570a392d7eSmrg# start with a hyphen. 8580a392d7eSmrg test -z "$_G_HAVE_XSI_OPS" \ 8590a392d7eSmrg && (eval 'x=a/b/c; 8600a392d7eSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8610a392d7eSmrg && _G_HAVE_XSI_OPS=yes 8620a392d7eSmrg 8630a392d7eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8640a392d7eSmrg eval 'func_len () 8650a392d7eSmrg { 8660a392d7eSmrg $debug_cmd 8670a392d7eSmrg 8680a392d7eSmrg func_len_result=${#1} 8690a392d7eSmrg }' 8700a392d7eSmrgelse 8710a392d7eSmrg func_len () 8720a392d7eSmrg { 8730a392d7eSmrg $debug_cmd 8740a392d7eSmrg 8750a392d7eSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8760a392d7eSmrg } 8770a392d7eSmrgfi 8780a392d7eSmrg 8790a392d7eSmrg 8800a392d7eSmrg# func_mkdir_p DIRECTORY-PATH 8810a392d7eSmrg# --------------------------- 88254b44505Smrg# Make sure the entire path to DIRECTORY-PATH is available. 88354b44505Smrgfunc_mkdir_p () 88454b44505Smrg{ 8850a392d7eSmrg $debug_cmd 8860a392d7eSmrg 8870a392d7eSmrg _G_directory_path=$1 8880a392d7eSmrg _G_dir_list= 88954b44505Smrg 8900a392d7eSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89154b44505Smrg 8920a392d7eSmrg # Protect directory names starting with '-' 8930a392d7eSmrg case $_G_directory_path in 8940a392d7eSmrg -*) _G_directory_path=./$_G_directory_path ;; 89554b44505Smrg esac 89654b44505Smrg 89754b44505Smrg # While some portion of DIR does not yet exist... 8980a392d7eSmrg while test ! -d "$_G_directory_path"; do 89954b44505Smrg # ...make a list in topmost first order. Use a colon delimited 90054b44505Smrg # list incase some portion of path contains whitespace. 9010a392d7eSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 90254b44505Smrg 90354b44505Smrg # If the last portion added has no slash in it, the list is done 9040a392d7eSmrg case $_G_directory_path in */*) ;; *) break ;; esac 90554b44505Smrg 90654b44505Smrg # ...otherwise throw away the child directory and loop 9070a392d7eSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 90854b44505Smrg done 9090a392d7eSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 91054b44505Smrg 9110a392d7eSmrg func_mkdir_p_IFS=$IFS; IFS=: 9120a392d7eSmrg for _G_dir in $_G_dir_list; do 9130a392d7eSmrg IFS=$func_mkdir_p_IFS 9140a392d7eSmrg # mkdir can fail with a 'File exist' error if two processes 91554b44505Smrg # try to create one of the directories concurrently. Don't 91654b44505Smrg # stop in that case! 9170a392d7eSmrg $MKDIR "$_G_dir" 2>/dev/null || : 91854b44505Smrg done 9190a392d7eSmrg IFS=$func_mkdir_p_IFS 92054b44505Smrg 92154b44505Smrg # Bail out if we (or some other process) failed to create a directory. 9220a392d7eSmrg test -d "$_G_directory_path" || \ 9230a392d7eSmrg func_fatal_error "Failed to create '$1'" 92454b44505Smrg fi 92554b44505Smrg} 9264a041c5bSmacallan 9274a041c5bSmacallan 9280a392d7eSmrg# func_mktempdir [BASENAME] 9290a392d7eSmrg# ------------------------- 9304a041c5bSmacallan# Make a temporary directory that won't clash with other running 9314a041c5bSmacallan# libtool processes, and avoids race conditions if possible. If 9320a392d7eSmrg# given, BASENAME is the basename for that directory. 9334a041c5bSmacallanfunc_mktempdir () 9344a041c5bSmacallan{ 9350a392d7eSmrg $debug_cmd 9364a041c5bSmacallan 9370a392d7eSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9380a392d7eSmrg 9390a392d7eSmrg if test : = "$opt_dry_run"; then 9404a041c5bSmacallan # Return a directory name, but don't create it in dry-run mode 9410a392d7eSmrg _G_tmpdir=$_G_template-$$ 9424a041c5bSmacallan else 9434a041c5bSmacallan 9444a041c5bSmacallan # If mktemp works, use that first and foremost 9450a392d7eSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9464a041c5bSmacallan 9470a392d7eSmrg if test ! -d "$_G_tmpdir"; then 94854b44505Smrg # Failing that, at least try and use $RANDOM to avoid a race 9490a392d7eSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9504a041c5bSmacallan 9510a392d7eSmrg func_mktempdir_umask=`umask` 95254b44505Smrg umask 0077 9530a392d7eSmrg $MKDIR "$_G_tmpdir" 9540a392d7eSmrg umask $func_mktempdir_umask 9554a041c5bSmacallan fi 9564a041c5bSmacallan 9574a041c5bSmacallan # If we're not in dry-run mode, bomb out on failure 9580a392d7eSmrg test -d "$_G_tmpdir" || \ 9590a392d7eSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9604a041c5bSmacallan fi 9614a041c5bSmacallan 9620a392d7eSmrg $ECHO "$_G_tmpdir" 9634a041c5bSmacallan} 9644a041c5bSmacallan 9654a041c5bSmacallan 9660a392d7eSmrg# func_normal_abspath PATH 9670a392d7eSmrg# ------------------------ 9680a392d7eSmrg# Remove doubled-up and trailing slashes, "." path components, 9690a392d7eSmrg# and cancel out any ".." path components in PATH after making 9700a392d7eSmrg# it an absolute path. 9710a392d7eSmrgfunc_normal_abspath () 9720a392d7eSmrg{ 9730a392d7eSmrg $debug_cmd 9740a392d7eSmrg 9750a392d7eSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9760a392d7eSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9770a392d7eSmrg _G_pathcdr='s|^/[^/]*||' 9780a392d7eSmrg _G_removedotparts=':dotsl 9790a392d7eSmrg s|/\./|/|g 9800a392d7eSmrg t dotsl 9810a392d7eSmrg s|/\.$|/|' 9820a392d7eSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9830a392d7eSmrg _G_finalslash='s|/*$|/|' 9840a392d7eSmrg 9850a392d7eSmrg # Start from root dir and reassemble the path. 9860a392d7eSmrg func_normal_abspath_result= 9870a392d7eSmrg func_normal_abspath_tpath=$1 9880a392d7eSmrg func_normal_abspath_altnamespace= 9890a392d7eSmrg case $func_normal_abspath_tpath in 9900a392d7eSmrg "") 9910a392d7eSmrg # Empty path, that just means $cwd. 9920a392d7eSmrg func_stripname '' '/' "`pwd`" 9930a392d7eSmrg func_normal_abspath_result=$func_stripname_result 9940a392d7eSmrg return 9950a392d7eSmrg ;; 9960a392d7eSmrg # The next three entries are used to spot a run of precisely 9970a392d7eSmrg # two leading slashes without using negated character classes; 9980a392d7eSmrg # we take advantage of case's first-match behaviour. 9990a392d7eSmrg ///*) 10000a392d7eSmrg # Unusual form of absolute path, do nothing. 10010a392d7eSmrg ;; 10020a392d7eSmrg //*) 10030a392d7eSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10040a392d7eSmrg # and for example Cygwin uses it to access remote file shares 10050a392d7eSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10060a392d7eSmrg func_normal_abspath_altnamespace=/ 10070a392d7eSmrg ;; 10080a392d7eSmrg /*) 10090a392d7eSmrg # Absolute path, do nothing. 10100a392d7eSmrg ;; 10110a392d7eSmrg *) 10120a392d7eSmrg # Relative path, prepend $cwd. 10130a392d7eSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10140a392d7eSmrg ;; 10150a392d7eSmrg esac 10160a392d7eSmrg 10170a392d7eSmrg # Cancel out all the simple stuff to save iterations. We also want 10180a392d7eSmrg # the path to end with a slash for ease of parsing, so make sure 10190a392d7eSmrg # there is one (and only one) here. 10200a392d7eSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10210a392d7eSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10220a392d7eSmrg while :; do 10230a392d7eSmrg # Processed it all yet? 10240a392d7eSmrg if test / = "$func_normal_abspath_tpath"; then 10250a392d7eSmrg # If we ascended to the root using ".." the result may be empty now. 10260a392d7eSmrg if test -z "$func_normal_abspath_result"; then 10270a392d7eSmrg func_normal_abspath_result=/ 10280a392d7eSmrg fi 10290a392d7eSmrg break 10300a392d7eSmrg fi 10310a392d7eSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10320a392d7eSmrg -e "$_G_pathcar"` 10330a392d7eSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10340a392d7eSmrg -e "$_G_pathcdr"` 10350a392d7eSmrg # Figure out what to do with it 10360a392d7eSmrg case $func_normal_abspath_tcomponent in 10370a392d7eSmrg "") 10380a392d7eSmrg # Trailing empty path component, ignore it. 10390a392d7eSmrg ;; 10400a392d7eSmrg ..) 10410a392d7eSmrg # Parent dir; strip last assembled component from result. 10420a392d7eSmrg func_dirname "$func_normal_abspath_result" 10430a392d7eSmrg func_normal_abspath_result=$func_dirname_result 10440a392d7eSmrg ;; 10450a392d7eSmrg *) 10460a392d7eSmrg # Actual path component, append it. 10470a392d7eSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10480a392d7eSmrg ;; 10490a392d7eSmrg esac 10500a392d7eSmrg done 10510a392d7eSmrg # Restore leading double-slash if one was found on entry. 10520a392d7eSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10530a392d7eSmrg} 10540a392d7eSmrg 10550a392d7eSmrg 10560a392d7eSmrg# func_notquiet ARG... 10570a392d7eSmrg# -------------------- 10580a392d7eSmrg# Echo program name prefixed message only when not in quiet mode. 10590a392d7eSmrgfunc_notquiet () 10600a392d7eSmrg{ 10610a392d7eSmrg $debug_cmd 10620a392d7eSmrg 10630a392d7eSmrg $opt_quiet || func_echo ${1+"$@"} 10640a392d7eSmrg 10650a392d7eSmrg # A bug in bash halts the script if the last line of a function 10660a392d7eSmrg # fails when set -e is in force, so we need another command to 10670a392d7eSmrg # work around that: 10680a392d7eSmrg : 10690a392d7eSmrg} 10700a392d7eSmrg 10710a392d7eSmrg 10720a392d7eSmrg# func_relative_path SRCDIR DSTDIR 10730a392d7eSmrg# -------------------------------- 10740a392d7eSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10750a392d7eSmrgfunc_relative_path () 10760a392d7eSmrg{ 10770a392d7eSmrg $debug_cmd 10780a392d7eSmrg 10790a392d7eSmrg func_relative_path_result= 10800a392d7eSmrg func_normal_abspath "$1" 10810a392d7eSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10820a392d7eSmrg func_normal_abspath "$2" 10830a392d7eSmrg func_relative_path_tbindir=$func_normal_abspath_result 10840a392d7eSmrg 10850a392d7eSmrg # Ascend the tree starting from libdir 10860a392d7eSmrg while :; do 10870a392d7eSmrg # check if we have found a prefix of bindir 10880a392d7eSmrg case $func_relative_path_tbindir in 10890a392d7eSmrg $func_relative_path_tlibdir) 10900a392d7eSmrg # found an exact match 10910a392d7eSmrg func_relative_path_tcancelled= 10920a392d7eSmrg break 10930a392d7eSmrg ;; 10940a392d7eSmrg $func_relative_path_tlibdir*) 10950a392d7eSmrg # found a matching prefix 10960a392d7eSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10970a392d7eSmrg func_relative_path_tcancelled=$func_stripname_result 10980a392d7eSmrg if test -z "$func_relative_path_result"; then 10990a392d7eSmrg func_relative_path_result=. 11000a392d7eSmrg fi 11010a392d7eSmrg break 11020a392d7eSmrg ;; 11030a392d7eSmrg *) 11040a392d7eSmrg func_dirname $func_relative_path_tlibdir 11050a392d7eSmrg func_relative_path_tlibdir=$func_dirname_result 11060a392d7eSmrg if test -z "$func_relative_path_tlibdir"; then 11070a392d7eSmrg # Have to descend all the way to the root! 11080a392d7eSmrg func_relative_path_result=../$func_relative_path_result 11090a392d7eSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11100a392d7eSmrg break 11110a392d7eSmrg fi 11120a392d7eSmrg func_relative_path_result=../$func_relative_path_result 11130a392d7eSmrg ;; 11140a392d7eSmrg esac 11150a392d7eSmrg done 11160a392d7eSmrg 11170a392d7eSmrg # Now calculate path; take care to avoid doubling-up slashes. 11180a392d7eSmrg func_stripname '' '/' "$func_relative_path_result" 11190a392d7eSmrg func_relative_path_result=$func_stripname_result 11200a392d7eSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11210a392d7eSmrg if test -n "$func_stripname_result"; then 11220a392d7eSmrg func_append func_relative_path_result "/$func_stripname_result" 11230a392d7eSmrg fi 11240a392d7eSmrg 11250a392d7eSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11260a392d7eSmrg if test -n "$func_relative_path_result"; then 11270a392d7eSmrg func_stripname './' '' "$func_relative_path_result" 11280a392d7eSmrg func_relative_path_result=$func_stripname_result 11290a392d7eSmrg fi 11300a392d7eSmrg 11310a392d7eSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11320a392d7eSmrg 11330a392d7eSmrg : 11340a392d7eSmrg} 11350a392d7eSmrg 11360a392d7eSmrg 11378fc2d0c6Smrg# func_quote_portable EVAL ARG 11388fc2d0c6Smrg# ---------------------------- 11398fc2d0c6Smrg# Internal function to portably implement func_quote_arg. Note that we still 11408fc2d0c6Smrg# keep attention to performance here so we as much as possible try to avoid 11418fc2d0c6Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11428fc2d0c6Smrgfunc_quote_portable () 11434a041c5bSmacallan{ 11440a392d7eSmrg $debug_cmd 11450a392d7eSmrg 11468fc2d0c6Smrg $require_check_ifs_backslash 11478fc2d0c6Smrg 11488fc2d0c6Smrg func_quote_portable_result=$2 11498fc2d0c6Smrg 11508fc2d0c6Smrg # one-time-loop (easy break) 11518fc2d0c6Smrg while true 11528fc2d0c6Smrg do 11538fc2d0c6Smrg if $1; then 11548fc2d0c6Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11558fc2d0c6Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11568fc2d0c6Smrg break 11570a392d7eSmrg fi 11580a392d7eSmrg 11598fc2d0c6Smrg # Quote for eval. 11608fc2d0c6Smrg case $func_quote_portable_result in 11618fc2d0c6Smrg *[\\\`\"\$]*) 11628fc2d0c6Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11638fc2d0c6Smrg # contains the shell wildcard characters. 11648fc2d0c6Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11658fc2d0c6Smrg :*|*[\[\*\?]*) 11668fc2d0c6Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11678fc2d0c6Smrg | $SED "$sed_quote_subst"` 11688fc2d0c6Smrg break 11698fc2d0c6Smrg ;; 11708fc2d0c6Smrg esac 11718fc2d0c6Smrg 11728fc2d0c6Smrg func_quote_portable_old_IFS=$IFS 11738fc2d0c6Smrg for _G_char in '\' '`' '"' '$' 11748fc2d0c6Smrg do 11758fc2d0c6Smrg # STATE($1) PREV($2) SEPARATOR($3) 11768fc2d0c6Smrg set start "" "" 11778fc2d0c6Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11788fc2d0c6Smrg IFS=$_G_char 11798fc2d0c6Smrg for _G_part in $func_quote_portable_result 11808fc2d0c6Smrg do 11818fc2d0c6Smrg case $1 in 11828fc2d0c6Smrg quote) 11838fc2d0c6Smrg func_append func_quote_portable_result "$3$2" 11848fc2d0c6Smrg set quote "$_G_part" "\\$_G_char" 11858fc2d0c6Smrg ;; 11868fc2d0c6Smrg start) 11878fc2d0c6Smrg set first "" "" 11888fc2d0c6Smrg func_quote_portable_result= 11898fc2d0c6Smrg ;; 11908fc2d0c6Smrg first) 11918fc2d0c6Smrg set quote "$_G_part" "" 11928fc2d0c6Smrg ;; 11938fc2d0c6Smrg esac 11948fc2d0c6Smrg done 11958fc2d0c6Smrg done 11968fc2d0c6Smrg IFS=$func_quote_portable_old_IFS 11970a392d7eSmrg ;; 11988fc2d0c6Smrg *) ;; 11990a392d7eSmrg esac 12008fc2d0c6Smrg break 12010a392d7eSmrg done 12028fc2d0c6Smrg 12038fc2d0c6Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 12048fc2d0c6Smrg case $func_quote_portable_result in 12058fc2d0c6Smrg # double-quote args containing shell metacharacters to delay 12068fc2d0c6Smrg # word splitting, command substitution and variable expansion 12078fc2d0c6Smrg # for a subsequent eval. 12088fc2d0c6Smrg # many bourne shells cannot handle close brackets correctly 12098fc2d0c6Smrg # in scan sets, so we specify it separately. 12108fc2d0c6Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12118fc2d0c6Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12128fc2d0c6Smrg ;; 12138fc2d0c6Smrg esac 12140a392d7eSmrg} 12150a392d7eSmrg 12160a392d7eSmrg 12178fc2d0c6Smrg# func_quotefast_eval ARG 12188fc2d0c6Smrg# ----------------------- 12198fc2d0c6Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12208fc2d0c6Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12218fc2d0c6Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12228fc2d0c6Smrg printf -v _GL_test_printf_tilde %q '~' 12238fc2d0c6Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12248fc2d0c6Smrg func_quotefast_eval () 12258fc2d0c6Smrg { 12268fc2d0c6Smrg printf -v func_quotefast_eval_result %q "$1" 12278fc2d0c6Smrg } 12288fc2d0c6Smrg else 12298fc2d0c6Smrg # Broken older Bash implementations. Make those faster too if possible. 12308fc2d0c6Smrg func_quotefast_eval () 12318fc2d0c6Smrg { 12328fc2d0c6Smrg case $1 in 12338fc2d0c6Smrg '~'*) 12348fc2d0c6Smrg func_quote_portable false "$1" 12358fc2d0c6Smrg func_quotefast_eval_result=$func_quote_portable_result 12368fc2d0c6Smrg ;; 12378fc2d0c6Smrg *) 12388fc2d0c6Smrg printf -v func_quotefast_eval_result %q "$1" 12398fc2d0c6Smrg ;; 12408fc2d0c6Smrg esac 12418fc2d0c6Smrg } 12428fc2d0c6Smrg fi 12438fc2d0c6Smrgelse 12448fc2d0c6Smrg func_quotefast_eval () 12458fc2d0c6Smrg { 12468fc2d0c6Smrg func_quote_portable false "$1" 12478fc2d0c6Smrg func_quotefast_eval_result=$func_quote_portable_result 12488fc2d0c6Smrg } 12498fc2d0c6Smrgfi 12500a392d7eSmrg 12518fc2d0c6Smrg 12528fc2d0c6Smrg# func_quote_arg MODEs ARG 12538fc2d0c6Smrg# ------------------------ 12548fc2d0c6Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12558fc2d0c6Smrg# specifiers listed below separated by ',' character. This function returns two 12568fc2d0c6Smrg# values: 12578fc2d0c6Smrg# i) func_quote_arg_result 12588fc2d0c6Smrg# double-quoted (when needed), suitable for a subsequent eval 12598fc2d0c6Smrg# ii) func_quote_arg_unquoted_result 12608fc2d0c6Smrg# has all characters that are still active within double 12618fc2d0c6Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12628fc2d0c6Smrg# 12638fc2d0c6Smrg# Available modes: 12648fc2d0c6Smrg# ---------------- 12658fc2d0c6Smrg# 'eval' (default) 12668fc2d0c6Smrg# - escape shell special characters 12678fc2d0c6Smrg# 'expand' 12688fc2d0c6Smrg# - the same as 'eval'; but do not quote variable references 12698fc2d0c6Smrg# 'pretty' 12708fc2d0c6Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12718fc2d0c6Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12728fc2d0c6Smrg# of 'echo a\ b'. This is slower than default on some shells. 12738fc2d0c6Smrg# 'unquoted' 12748fc2d0c6Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12758fc2d0c6Smrg# wrapping double-quotes. 12768fc2d0c6Smrg# 12778fc2d0c6Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12788fc2d0c6Smrg# 12798fc2d0c6Smrg# string | *_result | *_unquoted_result 12808fc2d0c6Smrg# ------------+-----------------------+------------------- 12818fc2d0c6Smrg# " | \" | \" 12828fc2d0c6Smrg# a b | "a b" | a b 12838fc2d0c6Smrg# "a b" | "\"a b\"" | \"a b\" 12848fc2d0c6Smrg# * | "*" | * 12858fc2d0c6Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12868fc2d0c6Smrg# 12878fc2d0c6Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12888fc2d0c6Smrg# 12898fc2d0c6Smrg# string | *_result | *_unquoted_result 12908fc2d0c6Smrg# --------------+---------------------+-------------------- 12918fc2d0c6Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12928fc2d0c6Smrgfunc_quote_arg () 12938fc2d0c6Smrg{ 12948fc2d0c6Smrg _G_quote_expand=false 12958fc2d0c6Smrg case ,$1, in 12968fc2d0c6Smrg *,expand,*) 12978fc2d0c6Smrg _G_quote_expand=: 12988fc2d0c6Smrg ;; 129954b44505Smrg esac 130054b44505Smrg 13018fc2d0c6Smrg case ,$1, in 13028fc2d0c6Smrg *,pretty,*|*,expand,*|*,unquoted,*) 13038fc2d0c6Smrg func_quote_portable $_G_quote_expand "$2" 13048fc2d0c6Smrg func_quote_arg_result=$func_quote_portable_result 13058fc2d0c6Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13068fc2d0c6Smrg ;; 13078fc2d0c6Smrg *) 13088fc2d0c6Smrg # Faster quote-for-eval for some shells. 13098fc2d0c6Smrg func_quotefast_eval "$2" 13108fc2d0c6Smrg func_quote_arg_result=$func_quotefast_eval_result 131154b44505Smrg ;; 131254b44505Smrg esac 13138fc2d0c6Smrg} 13148fc2d0c6Smrg 13150a392d7eSmrg 13168fc2d0c6Smrg# func_quote MODEs ARGs... 13178fc2d0c6Smrg# ------------------------ 13188fc2d0c6Smrg# Quote all ARGs to be evaled later and join them into single command. See 13198fc2d0c6Smrg# func_quote_arg's description for more info. 13208fc2d0c6Smrgfunc_quote () 13218fc2d0c6Smrg{ 13228fc2d0c6Smrg $debug_cmd 13238fc2d0c6Smrg _G_func_quote_mode=$1 ; shift 13248fc2d0c6Smrg func_quote_result= 13258fc2d0c6Smrg while test 0 -lt $#; do 13268fc2d0c6Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13278fc2d0c6Smrg if test -n "$func_quote_result"; then 13288fc2d0c6Smrg func_append func_quote_result " $func_quote_arg_result" 13298fc2d0c6Smrg else 13308fc2d0c6Smrg func_append func_quote_result "$func_quote_arg_result" 13318fc2d0c6Smrg fi 13328fc2d0c6Smrg shift 13338fc2d0c6Smrg done 13340a392d7eSmrg} 13350a392d7eSmrg 13360a392d7eSmrg 13370a392d7eSmrg# func_stripname PREFIX SUFFIX NAME 13380a392d7eSmrg# --------------------------------- 13390a392d7eSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13400a392d7eSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13410a392d7eSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13420a392d7eSmrg# dot (in which case that matches only a dot). 13430a392d7eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13440a392d7eSmrg eval 'func_stripname () 13450a392d7eSmrg { 13460a392d7eSmrg $debug_cmd 13470a392d7eSmrg 13480a392d7eSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13490a392d7eSmrg # positional parameters, so assign one to ordinary variable first. 13500a392d7eSmrg func_stripname_result=$3 13510a392d7eSmrg func_stripname_result=${func_stripname_result#"$1"} 13520a392d7eSmrg func_stripname_result=${func_stripname_result%"$2"} 13530a392d7eSmrg }' 13540a392d7eSmrgelse 13550a392d7eSmrg func_stripname () 13560a392d7eSmrg { 13570a392d7eSmrg $debug_cmd 13580a392d7eSmrg 13590a392d7eSmrg case $2 in 13600a392d7eSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13610a392d7eSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13620a392d7eSmrg esac 13630a392d7eSmrg } 13640a392d7eSmrgfi 13650a392d7eSmrg 13660a392d7eSmrg 13670a392d7eSmrg# func_show_eval CMD [FAIL_EXP] 13680a392d7eSmrg# ----------------------------- 13690a392d7eSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13700a392d7eSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13710a392d7eSmrg# is given, then evaluate it. 13720a392d7eSmrgfunc_show_eval () 13730a392d7eSmrg{ 13740a392d7eSmrg $debug_cmd 13750a392d7eSmrg 13760a392d7eSmrg _G_cmd=$1 13770a392d7eSmrg _G_fail_exp=${2-':'} 13780a392d7eSmrg 13798fc2d0c6Smrg func_quote_arg pretty,expand "$_G_cmd" 13808fc2d0c6Smrg eval "func_notquiet $func_quote_arg_result" 13810a392d7eSmrg 13820a392d7eSmrg $opt_dry_run || { 13830a392d7eSmrg eval "$_G_cmd" 13840a392d7eSmrg _G_status=$? 13850a392d7eSmrg if test 0 -ne "$_G_status"; then 13860a392d7eSmrg eval "(exit $_G_status); $_G_fail_exp" 13870a392d7eSmrg fi 13880a392d7eSmrg } 13890a392d7eSmrg} 13900a392d7eSmrg 13910a392d7eSmrg 13920a392d7eSmrg# func_show_eval_locale CMD [FAIL_EXP] 13930a392d7eSmrg# ------------------------------------ 13940a392d7eSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13950a392d7eSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13960a392d7eSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13970a392d7eSmrgfunc_show_eval_locale () 13980a392d7eSmrg{ 13990a392d7eSmrg $debug_cmd 14000a392d7eSmrg 14010a392d7eSmrg _G_cmd=$1 14020a392d7eSmrg _G_fail_exp=${2-':'} 14030a392d7eSmrg 14040a392d7eSmrg $opt_quiet || { 14058fc2d0c6Smrg func_quote_arg expand,pretty "$_G_cmd" 14068fc2d0c6Smrg eval "func_echo $func_quote_arg_result" 14070a392d7eSmrg } 14080a392d7eSmrg 14090a392d7eSmrg $opt_dry_run || { 14100a392d7eSmrg eval "$_G_user_locale 14110a392d7eSmrg $_G_cmd" 14120a392d7eSmrg _G_status=$? 14130a392d7eSmrg eval "$_G_safe_locale" 14140a392d7eSmrg if test 0 -ne "$_G_status"; then 14150a392d7eSmrg eval "(exit $_G_status); $_G_fail_exp" 14160a392d7eSmrg fi 14170a392d7eSmrg } 14180a392d7eSmrg} 14190a392d7eSmrg 14200a392d7eSmrg 14210a392d7eSmrg# func_tr_sh 14220a392d7eSmrg# ---------- 14230a392d7eSmrg# Turn $1 into a string suitable for a shell variable name. 14240a392d7eSmrg# Result is stored in $func_tr_sh_result. All characters 14250a392d7eSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14260a392d7eSmrg# if $1 begins with a digit, a '_' is prepended as well. 14270a392d7eSmrgfunc_tr_sh () 14280a392d7eSmrg{ 14290a392d7eSmrg $debug_cmd 14300a392d7eSmrg 14310a392d7eSmrg case $1 in 14320a392d7eSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14330a392d7eSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14340a392d7eSmrg ;; 14350a392d7eSmrg * ) 14360a392d7eSmrg func_tr_sh_result=$1 14370a392d7eSmrg ;; 14380a392d7eSmrg esac 14390a392d7eSmrg} 14400a392d7eSmrg 14410a392d7eSmrg 14420a392d7eSmrg# func_verbose ARG... 14430a392d7eSmrg# ------------------- 14440a392d7eSmrg# Echo program name prefixed message in verbose mode only. 14450a392d7eSmrgfunc_verbose () 14460a392d7eSmrg{ 14470a392d7eSmrg $debug_cmd 14480a392d7eSmrg 14490a392d7eSmrg $opt_verbose && func_echo "$*" 14500a392d7eSmrg 14510a392d7eSmrg : 14520a392d7eSmrg} 14530a392d7eSmrg 14540a392d7eSmrg 14550a392d7eSmrg# func_warn_and_continue ARG... 14560a392d7eSmrg# ----------------------------- 14570a392d7eSmrg# Echo program name prefixed warning message to standard error. 14580a392d7eSmrgfunc_warn_and_continue () 14590a392d7eSmrg{ 14600a392d7eSmrg $debug_cmd 14610a392d7eSmrg 14620a392d7eSmrg $require_term_colors 14630a392d7eSmrg 14640a392d7eSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14650a392d7eSmrg} 14660a392d7eSmrg 14670a392d7eSmrg 14680a392d7eSmrg# func_warning CATEGORY ARG... 14690a392d7eSmrg# ---------------------------- 14700a392d7eSmrg# Echo program name prefixed warning message to standard error. Warning 14710a392d7eSmrg# messages can be filtered according to CATEGORY, where this function 14720a392d7eSmrg# elides messages where CATEGORY is not listed in the global variable 14730a392d7eSmrg# 'opt_warning_types'. 14740a392d7eSmrgfunc_warning () 14750a392d7eSmrg{ 14760a392d7eSmrg $debug_cmd 14770a392d7eSmrg 14780a392d7eSmrg # CATEGORY must be in the warning_categories list! 14790a392d7eSmrg case " $warning_categories " in 14800a392d7eSmrg *" $1 "*) ;; 14810a392d7eSmrg *) func_internal_error "invalid warning category '$1'" ;; 14820a392d7eSmrg esac 14830a392d7eSmrg 14840a392d7eSmrg _G_category=$1 14850a392d7eSmrg shift 14860a392d7eSmrg 14870a392d7eSmrg case " $opt_warning_types " in 14880a392d7eSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14890a392d7eSmrg esac 14900a392d7eSmrg} 14910a392d7eSmrg 14920a392d7eSmrg 14930a392d7eSmrg# func_sort_ver VER1 VER2 14940a392d7eSmrg# ----------------------- 14950a392d7eSmrg# 'sort -V' is not generally available. 14960a392d7eSmrg# Note this deviates from the version comparison in automake 14970a392d7eSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14980a392d7eSmrg# but this should suffice as we won't be specifying old 14990a392d7eSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15000a392d7eSmrg# If we did want full compatibility then we should probably 15010a392d7eSmrg# use m4_version_compare from autoconf. 15020a392d7eSmrgfunc_sort_ver () 15030a392d7eSmrg{ 15040a392d7eSmrg $debug_cmd 15050a392d7eSmrg 15060a392d7eSmrg printf '%s\n%s\n' "$1" "$2" \ 15070a392d7eSmrg | 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 15080a392d7eSmrg} 15090a392d7eSmrg 15100a392d7eSmrg# func_lt_ver PREV CURR 15110a392d7eSmrg# --------------------- 15120a392d7eSmrg# Return true if PREV and CURR are in the correct order according to 15130a392d7eSmrg# func_sort_ver, otherwise false. Use it like this: 15140a392d7eSmrg# 15150a392d7eSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15160a392d7eSmrgfunc_lt_ver () 15170a392d7eSmrg{ 15180a392d7eSmrg $debug_cmd 15190a392d7eSmrg 15200a392d7eSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15210a392d7eSmrg} 15220a392d7eSmrg 15230a392d7eSmrg 15240a392d7eSmrg# Local variables: 15250a392d7eSmrg# mode: shell-script 15260a392d7eSmrg# sh-indentation: 2 15270a392d7eSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15280a392d7eSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15290a392d7eSmrg# time-stamp-time-zone: "UTC" 15300a392d7eSmrg# End: 15310a392d7eSmrg#! /bin/sh 15320a392d7eSmrg 15330a392d7eSmrg# A portable, pluggable option parser for Bourne shell. 15340a392d7eSmrg# Written by Gary V. Vaughan, 2010 15350a392d7eSmrg 15368fc2d0c6Smrg# This is free software. There is NO warranty; not even for 15378fc2d0c6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15388fc2d0c6Smrg# 15398fc2d0c6Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15408fc2d0c6Smrg# 15418fc2d0c6Smrg# This file is dual licensed under the terms of the MIT license 15428fc2d0c6Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15438fc2d0c6Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15448fc2d0c6Smrg# these licenses when using or redistributing this software or any of 15458fc2d0c6Smrg# the files within it. See the URLs above, or the file `LICENSE` 15468fc2d0c6Smrg# included in the Bootstrap distribution for the full license texts. 15470a392d7eSmrg 15488fc2d0c6Smrg# Please report bugs or propose patches to: 15498fc2d0c6Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 15500a392d7eSmrg 15518fc2d0c6Smrg# Set a version string for this script. 15528fc2d0c6Smrgscriptversion=2019-02-19.15; # UTC 15530a392d7eSmrg 15540a392d7eSmrg 15550a392d7eSmrg## ------ ## 15560a392d7eSmrg## Usage. ## 15570a392d7eSmrg## ------ ## 15580a392d7eSmrg 15590a392d7eSmrg# This file is a library for parsing options in your shell scripts along 15600a392d7eSmrg# with assorted other useful supporting features that you can make use 15610a392d7eSmrg# of too. 15620a392d7eSmrg# 15630a392d7eSmrg# For the simplest scripts you might need only: 15640a392d7eSmrg# 15650a392d7eSmrg# #!/bin/sh 15660a392d7eSmrg# . relative/path/to/funclib.sh 15670a392d7eSmrg# . relative/path/to/options-parser 15680a392d7eSmrg# scriptversion=1.0 15690a392d7eSmrg# func_options ${1+"$@"} 15700a392d7eSmrg# eval set dummy "$func_options_result"; shift 15710a392d7eSmrg# ...rest of your script... 15720a392d7eSmrg# 15730a392d7eSmrg# In order for the '--version' option to work, you will need to have a 15740a392d7eSmrg# suitably formatted comment like the one at the top of this file 15758fc2d0c6Smrg# starting with '# Written by ' and ending with '# Copyright'. 15760a392d7eSmrg# 15770a392d7eSmrg# For '-h' and '--help' to work, you will also need a one line 15780a392d7eSmrg# description of your script's purpose in a comment directly above the 15790a392d7eSmrg# '# Written by ' line, like the one at the top of this file. 15800a392d7eSmrg# 15810a392d7eSmrg# The default options also support '--debug', which will turn on shell 15820a392d7eSmrg# execution tracing (see the comment above debug_cmd below for another 15830a392d7eSmrg# use), and '--verbose' and the func_verbose function to allow your script 15840a392d7eSmrg# to display verbose messages only when your user has specified 15850a392d7eSmrg# '--verbose'. 15860a392d7eSmrg# 15878fc2d0c6Smrg# After sourcing this file, you can plug in processing for additional 15880a392d7eSmrg# options by amending the variables from the 'Configuration' section 15890a392d7eSmrg# below, and following the instructions in the 'Option parsing' 15900a392d7eSmrg# section further down. 15910a392d7eSmrg 15920a392d7eSmrg## -------------- ## 15930a392d7eSmrg## Configuration. ## 15940a392d7eSmrg## -------------- ## 15950a392d7eSmrg 15960a392d7eSmrg# You should override these variables in your script after sourcing this 15970a392d7eSmrg# file so that they reflect the customisations you have added to the 15980a392d7eSmrg# option parser. 15990a392d7eSmrg 16000a392d7eSmrg# The usage line for option parsing errors and the start of '-h' and 16010a392d7eSmrg# '--help' output messages. You can embed shell variables for delayed 16020a392d7eSmrg# expansion at the time the message is displayed, but you will need to 16030a392d7eSmrg# quote other shell meta-characters carefully to prevent them being 16040a392d7eSmrg# expanded when the contents are evaled. 16050a392d7eSmrgusage='$progpath [OPTION]...' 16060a392d7eSmrg 16070a392d7eSmrg# Short help message in response to '-h' and '--help'. Add to this or 16080a392d7eSmrg# override it after sourcing this library to reflect the full set of 16090a392d7eSmrg# options your script accepts. 16100a392d7eSmrgusage_message="\ 16110a392d7eSmrg --debug enable verbose shell tracing 16120a392d7eSmrg -W, --warnings=CATEGORY 16130a392d7eSmrg report the warnings falling in CATEGORY [all] 16140a392d7eSmrg -v, --verbose verbosely report processing 16150a392d7eSmrg --version print version information and exit 16160a392d7eSmrg -h, --help print short or long help message and exit 16170a392d7eSmrg" 16180a392d7eSmrg 16190a392d7eSmrg# Additional text appended to 'usage_message' in response to '--help'. 16200a392d7eSmrglong_help_message=" 16210a392d7eSmrgWarning categories include: 16220a392d7eSmrg 'all' show all warnings 16230a392d7eSmrg 'none' turn off all the warnings 16240a392d7eSmrg 'error' warnings are treated as fatal errors" 16250a392d7eSmrg 16260a392d7eSmrg# Help message printed before fatal option parsing errors. 16270a392d7eSmrgfatal_help="Try '\$progname --help' for more information." 16280a392d7eSmrg 16290a392d7eSmrg 16300a392d7eSmrg 16310a392d7eSmrg## ------------------------- ## 16320a392d7eSmrg## Hook function management. ## 16330a392d7eSmrg## ------------------------- ## 16340a392d7eSmrg 16350a392d7eSmrg# This section contains functions for adding, removing, and running hooks 16368fc2d0c6Smrg# in the main code. A hook is just a list of function names that can be 16378fc2d0c6Smrg# run in order later on. 16380a392d7eSmrg 16390a392d7eSmrg# func_hookable FUNC_NAME 16400a392d7eSmrg# ----------------------- 16410a392d7eSmrg# Declare that FUNC_NAME will run hooks added with 16420a392d7eSmrg# 'func_add_hook FUNC_NAME ...'. 16430a392d7eSmrgfunc_hookable () 16440a392d7eSmrg{ 16450a392d7eSmrg $debug_cmd 16460a392d7eSmrg 16470a392d7eSmrg func_append hookable_fns " $1" 16480a392d7eSmrg} 16490a392d7eSmrg 16500a392d7eSmrg 16510a392d7eSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16520a392d7eSmrg# --------------------------------- 16530a392d7eSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16540a392d7eSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16550a392d7eSmrgfunc_add_hook () 16560a392d7eSmrg{ 16570a392d7eSmrg $debug_cmd 16580a392d7eSmrg 16590a392d7eSmrg case " $hookable_fns " in 16600a392d7eSmrg *" $1 "*) ;; 16610a392d7eSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16620a392d7eSmrg esac 16630a392d7eSmrg 16640a392d7eSmrg eval func_append ${1}_hooks '" $2"' 16650a392d7eSmrg} 16660a392d7eSmrg 16670a392d7eSmrg 16680a392d7eSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16690a392d7eSmrg# ------------------------------------ 16708fc2d0c6Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16718fc2d0c6Smrg# FUNC_NAME. 16720a392d7eSmrgfunc_remove_hook () 16730a392d7eSmrg{ 16740a392d7eSmrg $debug_cmd 16750a392d7eSmrg 16760a392d7eSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16770a392d7eSmrg} 16780a392d7eSmrg 16790a392d7eSmrg 16808fc2d0c6Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16818fc2d0c6Smrg# --------------------------------------------- 16828fc2d0c6Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16838fc2d0c6Smrg# *_result variable of FUNC_NAME_B. 16848fc2d0c6Smrgfunc_propagate_result () 16858fc2d0c6Smrg{ 16868fc2d0c6Smrg $debug_cmd 16878fc2d0c6Smrg 16888fc2d0c6Smrg func_propagate_result_result=: 16898fc2d0c6Smrg if eval "test \"\${${1}_result+set}\" = set" 16908fc2d0c6Smrg then 16918fc2d0c6Smrg eval "${2}_result=\$${1}_result" 16928fc2d0c6Smrg else 16938fc2d0c6Smrg func_propagate_result_result=false 16948fc2d0c6Smrg fi 16958fc2d0c6Smrg} 16968fc2d0c6Smrg 16978fc2d0c6Smrg 16980a392d7eSmrg# func_run_hooks FUNC_NAME [ARG]... 16990a392d7eSmrg# --------------------------------- 17000a392d7eSmrg# Run all hook functions registered to FUNC_NAME. 17018fc2d0c6Smrg# It's assumed that the list of hook functions contains nothing more 17020a392d7eSmrg# than a whitespace-delimited list of legal shell function names, and 17030a392d7eSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17040a392d7eSmrg# whitespace. 17050a392d7eSmrgfunc_run_hooks () 17060a392d7eSmrg{ 17070a392d7eSmrg $debug_cmd 17080a392d7eSmrg 17090a392d7eSmrg case " $hookable_fns " in 17100a392d7eSmrg *" $1 "*) ;; 17118fc2d0c6Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 17120a392d7eSmrg esac 17130a392d7eSmrg 17140a392d7eSmrg eval _G_hook_fns=\$$1_hooks; shift 17150a392d7eSmrg 17160a392d7eSmrg for _G_hook in $_G_hook_fns; do 17178fc2d0c6Smrg func_unset "${_G_hook}_result" 17188fc2d0c6Smrg eval $_G_hook '${1+"$@"}' 17198fc2d0c6Smrg func_propagate_result $_G_hook func_run_hooks 17208fc2d0c6Smrg if $func_propagate_result_result; then 17218fc2d0c6Smrg eval set dummy "$func_run_hooks_result"; shift 17228fc2d0c6Smrg fi 17230a392d7eSmrg done 17240a392d7eSmrg} 17250a392d7eSmrg 17260a392d7eSmrg 17270a392d7eSmrg 17280a392d7eSmrg## --------------- ## 17290a392d7eSmrg## Option parsing. ## 17300a392d7eSmrg## --------------- ## 17310a392d7eSmrg 17320a392d7eSmrg# In order to add your own option parsing hooks, you must accept the 17338fc2d0c6Smrg# full positional parameter list from your hook function. You may remove 17348fc2d0c6Smrg# or edit any options that you action, and then pass back the remaining 17358fc2d0c6Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17368fc2d0c6Smrg# suitably for 'eval'. 17378fc2d0c6Smrg# 17388fc2d0c6Smrg# The '<hooked_function_name>_result' variable is automatically unset 17398fc2d0c6Smrg# before your hook gets called; for best performance, only set the 17408fc2d0c6Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17418fc2d0c6Smrg# function unnecessarily because it can be an expensive operation on some 17428fc2d0c6Smrg# machines). 17438fc2d0c6Smrg# 17448fc2d0c6Smrg# Like this: 17450a392d7eSmrg# 17460a392d7eSmrg# my_options_prep () 17470a392d7eSmrg# { 17480a392d7eSmrg# $debug_cmd 17490a392d7eSmrg# 17500a392d7eSmrg# # Extend the existing usage message. 17510a392d7eSmrg# usage_message=$usage_message' 17520a392d7eSmrg# -s, --silent don'\''t print informational messages 17530a392d7eSmrg# ' 17548fc2d0c6Smrg# # No change in '$@' (ignored completely by this hook). Leave 17558fc2d0c6Smrg# # my_options_prep_result variable intact. 17560a392d7eSmrg# } 17570a392d7eSmrg# func_add_hook func_options_prep my_options_prep 17580a392d7eSmrg# 17590a392d7eSmrg# 17600a392d7eSmrg# my_silent_option () 17610a392d7eSmrg# { 17620a392d7eSmrg# $debug_cmd 17630a392d7eSmrg# 17648fc2d0c6Smrg# args_changed=false 17658fc2d0c6Smrg# 17668fc2d0c6Smrg# # Note that, for efficiency, we parse as many options as we can 17670a392d7eSmrg# # recognise in a loop before passing the remainder back to the 17680a392d7eSmrg# # caller on the first unrecognised argument we encounter. 17690a392d7eSmrg# while test $# -gt 0; do 17700a392d7eSmrg# opt=$1; shift 17710a392d7eSmrg# case $opt in 17728fc2d0c6Smrg# --silent|-s) opt_silent=: 17738fc2d0c6Smrg# args_changed=: 17748fc2d0c6Smrg# ;; 17750a392d7eSmrg# # Separate non-argument short options: 17760a392d7eSmrg# -s*) func_split_short_opt "$_G_opt" 17770a392d7eSmrg# set dummy "$func_split_short_opt_name" \ 17780a392d7eSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17790a392d7eSmrg# shift 17808fc2d0c6Smrg# args_changed=: 17810a392d7eSmrg# ;; 17828fc2d0c6Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17838fc2d0c6Smrg# # is added back to "$@" in case we need it later, 17848fc2d0c6Smrg# # if $args_changed was set to 'true'. 17858fc2d0c6Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17860a392d7eSmrg# esac 17870a392d7eSmrg# done 17880a392d7eSmrg# 17898fc2d0c6Smrg# # Only call 'func_quote' here if we processed at least one argument. 17908fc2d0c6Smrg# if $args_changed; then 17918fc2d0c6Smrg# func_quote eval ${1+"$@"} 17928fc2d0c6Smrg# my_silent_option_result=$func_quote_result 17938fc2d0c6Smrg# fi 17940a392d7eSmrg# } 17950a392d7eSmrg# func_add_hook func_parse_options my_silent_option 17960a392d7eSmrg# 17970a392d7eSmrg# 17980a392d7eSmrg# my_option_validation () 17990a392d7eSmrg# { 18000a392d7eSmrg# $debug_cmd 18010a392d7eSmrg# 18020a392d7eSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18030a392d7eSmrg# '--silent' and '--verbose' options are mutually exclusive." 18040a392d7eSmrg# } 18050a392d7eSmrg# func_add_hook func_validate_options my_option_validation 18060a392d7eSmrg# 18078fc2d0c6Smrg# You'll also need to manually amend $usage_message to reflect the extra 18080a392d7eSmrg# options you parse. It's preferable to append if you can, so that 18090a392d7eSmrg# multiple option parsing hooks can be added safely. 18100a392d7eSmrg 18110a392d7eSmrg 18128fc2d0c6Smrg# func_options_finish [ARG]... 18138fc2d0c6Smrg# ---------------------------- 18148fc2d0c6Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18158fc2d0c6Smrgfunc_options_finish () 18168fc2d0c6Smrg{ 18178fc2d0c6Smrg $debug_cmd 18188fc2d0c6Smrg 18198fc2d0c6Smrg func_run_hooks func_options ${1+"$@"} 18208fc2d0c6Smrg func_propagate_result func_run_hooks func_options_finish 18218fc2d0c6Smrg} 18228fc2d0c6Smrg 18238fc2d0c6Smrg 18240a392d7eSmrg# func_options [ARG]... 18250a392d7eSmrg# --------------------- 18260a392d7eSmrg# All the functions called inside func_options are hookable. See the 18270a392d7eSmrg# individual implementations for details. 18280a392d7eSmrgfunc_hookable func_options 18290a392d7eSmrgfunc_options () 18300a392d7eSmrg{ 18310a392d7eSmrg $debug_cmd 18320a392d7eSmrg 18338fc2d0c6Smrg _G_options_quoted=false 18340a392d7eSmrg 18358fc2d0c6Smrg for my_func in options_prep parse_options validate_options options_finish 18368fc2d0c6Smrg do 18378fc2d0c6Smrg func_unset func_${my_func}_result 18388fc2d0c6Smrg func_unset func_run_hooks_result 18398fc2d0c6Smrg eval func_$my_func '${1+"$@"}' 18408fc2d0c6Smrg func_propagate_result func_$my_func func_options 18418fc2d0c6Smrg if $func_propagate_result_result; then 18428fc2d0c6Smrg eval set dummy "$func_options_result"; shift 18438fc2d0c6Smrg _G_options_quoted=: 18448fc2d0c6Smrg fi 18458fc2d0c6Smrg done 18460a392d7eSmrg 18478fc2d0c6Smrg $_G_options_quoted || { 18488fc2d0c6Smrg # As we (func_options) are top-level options-parser function and 18498fc2d0c6Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18508fc2d0c6Smrg # caller. 18518fc2d0c6Smrg func_quote eval ${1+"$@"} 18528fc2d0c6Smrg func_options_result=$func_quote_result 18538fc2d0c6Smrg } 185454b44505Smrg} 185554b44505Smrg 185654b44505Smrg 18570a392d7eSmrg# func_options_prep [ARG]... 18580a392d7eSmrg# -------------------------- 18590a392d7eSmrg# All initialisations required before starting the option parse loop. 18600a392d7eSmrg# Note that when calling hook functions, we pass through the list of 18610a392d7eSmrg# positional parameters. If a hook function modifies that list, and 18628fc2d0c6Smrg# needs to propagate that back to rest of this script, then the complete 18638fc2d0c6Smrg# modified list must be put in 'func_run_hooks_result' before returning. 18640a392d7eSmrgfunc_hookable func_options_prep 18650a392d7eSmrgfunc_options_prep () 186654b44505Smrg{ 18670a392d7eSmrg $debug_cmd 186854b44505Smrg 18690a392d7eSmrg # Option defaults: 18700a392d7eSmrg opt_verbose=false 18710a392d7eSmrg opt_warning_types= 18720a392d7eSmrg 18730a392d7eSmrg func_run_hooks func_options_prep ${1+"$@"} 18748fc2d0c6Smrg func_propagate_result func_run_hooks func_options_prep 187554b44505Smrg} 187654b44505Smrg 187754b44505Smrg 18780a392d7eSmrg# func_parse_options [ARG]... 18790a392d7eSmrg# --------------------------- 18800a392d7eSmrg# The main option parsing loop. 18810a392d7eSmrgfunc_hookable func_parse_options 18820a392d7eSmrgfunc_parse_options () 188354b44505Smrg{ 18840a392d7eSmrg $debug_cmd 188554b44505Smrg 18868fc2d0c6Smrg _G_parse_options_requote=false 18870a392d7eSmrg # this just eases exit handling 18880a392d7eSmrg while test $# -gt 0; do 18890a392d7eSmrg # Defer to hook functions for initial option parsing, so they 18900a392d7eSmrg # get priority in the event of reusing an option name. 18910a392d7eSmrg func_run_hooks func_parse_options ${1+"$@"} 18928fc2d0c6Smrg func_propagate_result func_run_hooks func_parse_options 18938fc2d0c6Smrg if $func_propagate_result_result; then 18948fc2d0c6Smrg eval set dummy "$func_parse_options_result"; shift 18958fc2d0c6Smrg # Even though we may have changed "$@", we passed the "$@" array 18968fc2d0c6Smrg # down into the hook and it quoted it for us (because we are in 18978fc2d0c6Smrg # this if-branch). No need to quote it again. 18988fc2d0c6Smrg _G_parse_options_requote=false 18998fc2d0c6Smrg fi 190054b44505Smrg 19010a392d7eSmrg # Break out of the loop if we already parsed every option. 19020a392d7eSmrg test $# -gt 0 || break 190354b44505Smrg 19048fc2d0c6Smrg # We expect that one of the options parsed in this function matches 19058fc2d0c6Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 19068fc2d0c6Smrg _G_match_parse_options=: 19070a392d7eSmrg _G_opt=$1 19080a392d7eSmrg shift 19090a392d7eSmrg case $_G_opt in 19100a392d7eSmrg --debug|-x) debug_cmd='set -x' 19118fc2d0c6Smrg func_echo "enabling shell trace mode" >&2 19120a392d7eSmrg $debug_cmd 19130a392d7eSmrg ;; 19140a392d7eSmrg 19150a392d7eSmrg --no-warnings|--no-warning|--no-warn) 19160a392d7eSmrg set dummy --warnings none ${1+"$@"} 19170a392d7eSmrg shift 19180a392d7eSmrg ;; 191954b44505Smrg 19200a392d7eSmrg --warnings|--warning|-W) 19218fc2d0c6Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19228fc2d0c6Smrg _G_parse_options_requote=: 19238fc2d0c6Smrg break 19248fc2d0c6Smrg fi 19250a392d7eSmrg case " $warning_categories $1" in 19260a392d7eSmrg *" $1 "*) 19270a392d7eSmrg # trailing space prevents matching last $1 above 19280a392d7eSmrg func_append_uniq opt_warning_types " $1" 19290a392d7eSmrg ;; 19300a392d7eSmrg *all) 19310a392d7eSmrg opt_warning_types=$warning_categories 19320a392d7eSmrg ;; 19330a392d7eSmrg *none) 19340a392d7eSmrg opt_warning_types=none 19350a392d7eSmrg warning_func=: 19360a392d7eSmrg ;; 19370a392d7eSmrg *error) 19380a392d7eSmrg opt_warning_types=$warning_categories 19390a392d7eSmrg warning_func=func_fatal_error 19400a392d7eSmrg ;; 19410a392d7eSmrg *) 19420a392d7eSmrg func_fatal_error \ 19430a392d7eSmrg "unsupported warning category: '$1'" 19440a392d7eSmrg ;; 19450a392d7eSmrg esac 19460a392d7eSmrg shift 19470a392d7eSmrg ;; 19480a392d7eSmrg 19490a392d7eSmrg --verbose|-v) opt_verbose=: ;; 19500a392d7eSmrg --version) func_version ;; 19510a392d7eSmrg -\?|-h) func_usage ;; 19520a392d7eSmrg --help) func_help ;; 19530a392d7eSmrg 19540a392d7eSmrg # Separate optargs to long options (plugins may need this): 19550a392d7eSmrg --*=*) func_split_equals "$_G_opt" 19560a392d7eSmrg set dummy "$func_split_equals_lhs" \ 19570a392d7eSmrg "$func_split_equals_rhs" ${1+"$@"} 19580a392d7eSmrg shift 19590a392d7eSmrg ;; 19600a392d7eSmrg 19610a392d7eSmrg # Separate optargs to short options: 19620a392d7eSmrg -W*) 19630a392d7eSmrg func_split_short_opt "$_G_opt" 19640a392d7eSmrg set dummy "$func_split_short_opt_name" \ 19650a392d7eSmrg "$func_split_short_opt_arg" ${1+"$@"} 19660a392d7eSmrg shift 19670a392d7eSmrg ;; 19680a392d7eSmrg 19690a392d7eSmrg # Separate non-argument short options: 19700a392d7eSmrg -\?*|-h*|-v*|-x*) 19710a392d7eSmrg func_split_short_opt "$_G_opt" 19720a392d7eSmrg set dummy "$func_split_short_opt_name" \ 19730a392d7eSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19740a392d7eSmrg shift 19750a392d7eSmrg ;; 19760a392d7eSmrg 19778fc2d0c6Smrg --) _G_parse_options_requote=: ; break ;; 19780a392d7eSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19798fc2d0c6Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19808fc2d0c6Smrg _G_match_parse_options=false 19818fc2d0c6Smrg break 19828fc2d0c6Smrg ;; 19830a392d7eSmrg esac 19848fc2d0c6Smrg 19858fc2d0c6Smrg if $_G_match_parse_options; then 19868fc2d0c6Smrg _G_parse_options_requote=: 19878fc2d0c6Smrg fi 19880a392d7eSmrg done 198954b44505Smrg 19908fc2d0c6Smrg if $_G_parse_options_requote; then 19918fc2d0c6Smrg # save modified positional parameters for caller 19928fc2d0c6Smrg func_quote eval ${1+"$@"} 19938fc2d0c6Smrg func_parse_options_result=$func_quote_result 19948fc2d0c6Smrg fi 19954a041c5bSmacallan} 19964a041c5bSmacallan 19974a041c5bSmacallan 19980a392d7eSmrg# func_validate_options [ARG]... 19990a392d7eSmrg# ------------------------------ 20000a392d7eSmrg# Perform any sanity checks on option settings and/or unconsumed 20010a392d7eSmrg# arguments. 20020a392d7eSmrgfunc_hookable func_validate_options 20030a392d7eSmrgfunc_validate_options () 20044a041c5bSmacallan{ 20050a392d7eSmrg $debug_cmd 200654b44505Smrg 20070a392d7eSmrg # Display all warnings if -W was not given. 20080a392d7eSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20090a392d7eSmrg 20100a392d7eSmrg func_run_hooks func_validate_options ${1+"$@"} 20118fc2d0c6Smrg func_propagate_result func_run_hooks func_validate_options 20120a392d7eSmrg 20130a392d7eSmrg # Bail if the options were screwed! 20140a392d7eSmrg $exit_cmd $EXIT_FAILURE 20154a041c5bSmacallan} 20164a041c5bSmacallan 20170a392d7eSmrg 20180a392d7eSmrg 20190a392d7eSmrg## ----------------- ## 20200a392d7eSmrg## Helper functions. ## 20210a392d7eSmrg## ----------------- ## 20220a392d7eSmrg 20230a392d7eSmrg# This section contains the helper functions used by the rest of the 20240a392d7eSmrg# hookable option parser framework in ascii-betical order. 20250a392d7eSmrg 20260a392d7eSmrg 20270a392d7eSmrg# func_fatal_help ARG... 20280a392d7eSmrg# ---------------------- 20290a392d7eSmrg# Echo program name prefixed message to standard error, followed by 20300a392d7eSmrg# a help hint, and exit. 20310a392d7eSmrgfunc_fatal_help () 20324a041c5bSmacallan{ 20330a392d7eSmrg $debug_cmd 203454b44505Smrg 20350a392d7eSmrg eval \$ECHO \""Usage: $usage"\" 20360a392d7eSmrg eval \$ECHO \""$fatal_help"\" 20370a392d7eSmrg func_error ${1+"$@"} 20380a392d7eSmrg exit $EXIT_FAILURE 20394a041c5bSmacallan} 20404a041c5bSmacallan 20410a392d7eSmrg 20420a392d7eSmrg# func_help 20430a392d7eSmrg# --------- 20440a392d7eSmrg# Echo long help message to standard output and exit. 204554b44505Smrgfunc_help () 20464a041c5bSmacallan{ 20470a392d7eSmrg $debug_cmd 20480a392d7eSmrg 20490a392d7eSmrg func_usage_message 20500a392d7eSmrg $ECHO "$long_help_message" 20510a392d7eSmrg exit 0 205254b44505Smrg} 20534a041c5bSmacallan 20540a392d7eSmrg 20550a392d7eSmrg# func_missing_arg ARGNAME 20560a392d7eSmrg# ------------------------ 205754b44505Smrg# Echo program name prefixed message to standard error and set global 205854b44505Smrg# exit_cmd. 205954b44505Smrgfunc_missing_arg () 206054b44505Smrg{ 20610a392d7eSmrg $debug_cmd 20624a041c5bSmacallan 20630a392d7eSmrg func_error "Missing argument for '$1'." 206454b44505Smrg exit_cmd=exit 20654a041c5bSmacallan} 20664a041c5bSmacallan 20674a041c5bSmacallan 20680a392d7eSmrg# func_split_equals STRING 20690a392d7eSmrg# ------------------------ 20708fc2d0c6Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20718fc2d0c6Smrg# after splitting STRING at the '=' sign. 20720a392d7eSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20730a392d7eSmrg && (eval 'x=a/b/c; 20740a392d7eSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20750a392d7eSmrg && _G_HAVE_XSI_OPS=yes 20760a392d7eSmrg 20770a392d7eSmrgif test yes = "$_G_HAVE_XSI_OPS" 20780a392d7eSmrgthen 20790a392d7eSmrg # This is an XSI compatible shell, allowing a faster implementation... 20800a392d7eSmrg eval 'func_split_equals () 20810a392d7eSmrg { 20820a392d7eSmrg $debug_cmd 20830a392d7eSmrg 20840a392d7eSmrg func_split_equals_lhs=${1%%=*} 20850a392d7eSmrg func_split_equals_rhs=${1#*=} 20868fc2d0c6Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20878fc2d0c6Smrg func_split_equals_rhs= 20888fc2d0c6Smrg fi 20890a392d7eSmrg }' 20900a392d7eSmrgelse 20910a392d7eSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20920a392d7eSmrg func_split_equals () 20930a392d7eSmrg { 20940a392d7eSmrg $debug_cmd 20950a392d7eSmrg 20960a392d7eSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20970a392d7eSmrg func_split_equals_rhs= 20988fc2d0c6Smrg test "x$func_split_equals_lhs=" = "x$1" \ 20990a392d7eSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21000a392d7eSmrg } 21010a392d7eSmrgfi #func_split_equals 21020a392d7eSmrg 21030a392d7eSmrg 21040a392d7eSmrg# func_split_short_opt SHORTOPT 21050a392d7eSmrg# ----------------------------- 210654b44505Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 210754b44505Smrg# variables after splitting SHORTOPT after the 2nd character. 21080a392d7eSmrgif test yes = "$_G_HAVE_XSI_OPS" 21090a392d7eSmrgthen 21100a392d7eSmrg # This is an XSI compatible shell, allowing a faster implementation... 21110a392d7eSmrg eval 'func_split_short_opt () 21120a392d7eSmrg { 21130a392d7eSmrg $debug_cmd 21140a392d7eSmrg 21150a392d7eSmrg func_split_short_opt_arg=${1#??} 21160a392d7eSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21170a392d7eSmrg }' 21180a392d7eSmrgelse 21190a392d7eSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21200a392d7eSmrg func_split_short_opt () 21210a392d7eSmrg { 21220a392d7eSmrg $debug_cmd 21230a392d7eSmrg 21248fc2d0c6Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21250a392d7eSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21260a392d7eSmrg } 21270a392d7eSmrgfi #func_split_short_opt 21280a392d7eSmrg 21290a392d7eSmrg 21300a392d7eSmrg# func_usage 21310a392d7eSmrg# ---------- 21320a392d7eSmrg# Echo short help message to standard output and exit. 21330a392d7eSmrgfunc_usage () 213454b44505Smrg{ 21350a392d7eSmrg $debug_cmd 213654b44505Smrg 21370a392d7eSmrg func_usage_message 21380a392d7eSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21390a392d7eSmrg exit 0 21400a392d7eSmrg} 21414a041c5bSmacallan 21424a041c5bSmacallan 21430a392d7eSmrg# func_usage_message 21440a392d7eSmrg# ------------------ 21450a392d7eSmrg# Echo short help message to standard output. 21460a392d7eSmrgfunc_usage_message () 214754b44505Smrg{ 21480a392d7eSmrg $debug_cmd 21494a041c5bSmacallan 21500a392d7eSmrg eval \$ECHO \""Usage: $usage"\" 21510a392d7eSmrg echo 21520a392d7eSmrg $SED -n 's|^# || 21530a392d7eSmrg /^Written by/{ 21540a392d7eSmrg x;p;x 21550a392d7eSmrg } 21560a392d7eSmrg h 21570a392d7eSmrg /^Written by/q' < "$progpath" 21580a392d7eSmrg echo 21590a392d7eSmrg eval \$ECHO \""$usage_message"\" 21600a392d7eSmrg} 21614a041c5bSmacallan 21624a041c5bSmacallan 21630a392d7eSmrg# func_version 21640a392d7eSmrg# ------------ 21650a392d7eSmrg# Echo version message to standard output and exit. 21668fc2d0c6Smrg# The version message is extracted from the calling file's header 21678fc2d0c6Smrg# comments, with leading '# ' stripped: 21688fc2d0c6Smrg# 1. First display the progname and version 21698fc2d0c6Smrg# 2. Followed by the header comment line matching /^# Written by / 21708fc2d0c6Smrg# 3. Then a blank line followed by the first following line matching 21718fc2d0c6Smrg# /^# Copyright / 21728fc2d0c6Smrg# 4. Immediately followed by any lines between the previous matches, 21738fc2d0c6Smrg# except lines preceding the intervening completely blank line. 21748fc2d0c6Smrg# For example, see the header comments of this file. 21750a392d7eSmrgfunc_version () 21760a392d7eSmrg{ 21770a392d7eSmrg $debug_cmd 21784a041c5bSmacallan 21790a392d7eSmrg printf '%s\n' "$progname $scriptversion" 21800a392d7eSmrg $SED -n ' 21818fc2d0c6Smrg /^# Written by /!b 21828fc2d0c6Smrg s|^# ||; p; n 21838fc2d0c6Smrg 21848fc2d0c6Smrg :fwd2blnk 21858fc2d0c6Smrg /./ { 21868fc2d0c6Smrg n 21878fc2d0c6Smrg b fwd2blnk 21880a392d7eSmrg } 21898fc2d0c6Smrg p; n 21908fc2d0c6Smrg 21918fc2d0c6Smrg :holdwrnt 21928fc2d0c6Smrg s|^# || 21938fc2d0c6Smrg s|^# *$|| 21948fc2d0c6Smrg /^Copyright /!{ 21958fc2d0c6Smrg /./H 21968fc2d0c6Smrg n 21978fc2d0c6Smrg b holdwrnt 21980a392d7eSmrg } 21998fc2d0c6Smrg 22008fc2d0c6Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22018fc2d0c6Smrg G 22028fc2d0c6Smrg s|\(\n\)\n*|\1|g 22038fc2d0c6Smrg p; q' < "$progpath" 22044a041c5bSmacallan 22050a392d7eSmrg exit $? 22060a392d7eSmrg} 22074a041c5bSmacallan 22084a041c5bSmacallan 22090a392d7eSmrg# Local variables: 22100a392d7eSmrg# mode: shell-script 22110a392d7eSmrg# sh-indentation: 2 22120a392d7eSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 22138fc2d0c6Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22140a392d7eSmrg# time-stamp-time-zone: "UTC" 22150a392d7eSmrg# End: 221654b44505Smrg 22170a392d7eSmrg# Set a version string. 22188fc2d0c6Smrgscriptversion='(GNU libtool) 2.4.7' 221954b44505Smrg 222054b44505Smrg 22210a392d7eSmrg# func_echo ARG... 22220a392d7eSmrg# ---------------- 22230a392d7eSmrg# Libtool also displays the current mode in messages, so override 22240a392d7eSmrg# funclib.sh func_echo with this custom definition. 22250a392d7eSmrgfunc_echo () 222654b44505Smrg{ 22270a392d7eSmrg $debug_cmd 222854b44505Smrg 22290a392d7eSmrg _G_message=$* 22300a392d7eSmrg 22310a392d7eSmrg func_echo_IFS=$IFS 22320a392d7eSmrg IFS=$nl 22330a392d7eSmrg for _G_line in $_G_message; do 22340a392d7eSmrg IFS=$func_echo_IFS 22350a392d7eSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22360a392d7eSmrg done 22370a392d7eSmrg IFS=$func_echo_IFS 22380a392d7eSmrg} 223954b44505Smrg 224054b44505Smrg 22410a392d7eSmrg# func_warning ARG... 22420a392d7eSmrg# ------------------- 22430a392d7eSmrg# Libtool warnings are not categorized, so override funclib.sh 22440a392d7eSmrg# func_warning with this simpler definition. 22450a392d7eSmrgfunc_warning () 224654b44505Smrg{ 22470a392d7eSmrg $debug_cmd 224854b44505Smrg 22490a392d7eSmrg $warning_func ${1+"$@"} 22500a392d7eSmrg} 225154b44505Smrg 225254b44505Smrg 22530a392d7eSmrg## ---------------- ## 22540a392d7eSmrg## Options parsing. ## 22550a392d7eSmrg## ---------------- ## 22560a392d7eSmrg 22570a392d7eSmrg# Hook in the functions to make sure our own options are parsed during 22580a392d7eSmrg# the option parsing loop. 22590a392d7eSmrg 22600a392d7eSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22610a392d7eSmrg 22620a392d7eSmrg# Short help message in response to '-h'. 22630a392d7eSmrgusage_message="Options: 22640a392d7eSmrg --config show all configuration variables 22650a392d7eSmrg --debug enable verbose shell tracing 22660a392d7eSmrg -n, --dry-run display commands without modifying any files 22670a392d7eSmrg --features display basic configuration information and exit 22680a392d7eSmrg --mode=MODE use operation mode MODE 22690a392d7eSmrg --no-warnings equivalent to '-Wnone' 22700a392d7eSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22710a392d7eSmrg --quiet, --silent don't print informational messages 22720a392d7eSmrg --tag=TAG use configuration variables from tag TAG 22730a392d7eSmrg -v, --verbose print more informational messages than default 22740a392d7eSmrg --version print version information 22750a392d7eSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22760a392d7eSmrg -h, --help, --help-all print short, long, or detailed help message 22770a392d7eSmrg" 227854b44505Smrg 22790a392d7eSmrg# Additional text appended to 'usage_message' in response to '--help'. 22800a392d7eSmrgfunc_help () 228154b44505Smrg{ 22820a392d7eSmrg $debug_cmd 22830a392d7eSmrg 22840a392d7eSmrg func_usage_message 22850a392d7eSmrg $ECHO "$long_help_message 22860a392d7eSmrg 22870a392d7eSmrgMODE must be one of the following: 22880a392d7eSmrg 22890a392d7eSmrg clean remove files from the build directory 22900a392d7eSmrg compile compile a source file into a libtool object 22910a392d7eSmrg execute automatically set library path, then run a program 22920a392d7eSmrg finish complete the installation of libtool libraries 22930a392d7eSmrg install install libraries or executables 22940a392d7eSmrg link create a library or an executable 22950a392d7eSmrg uninstall remove libraries from an installed directory 22960a392d7eSmrg 22970a392d7eSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22980a392d7eSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22990a392d7eSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23000a392d7eSmrg 23010a392d7eSmrgWhen reporting a bug, please describe a test case to reproduce it and 23020a392d7eSmrginclude the following information: 23030a392d7eSmrg 23040a392d7eSmrg host-triplet: $host 23050a392d7eSmrg shell: $SHELL 23060a392d7eSmrg compiler: $LTCC 23070a392d7eSmrg compiler flags: $LTCFLAGS 23080a392d7eSmrg linker: $LD (gnu? $with_gnu_ld) 23098fc2d0c6Smrg version: $progname (GNU libtool) 2.4.7 23100a392d7eSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23110a392d7eSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23120a392d7eSmrg 23130a392d7eSmrgReport bugs to <bug-libtool@gnu.org>. 23140a392d7eSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23150a392d7eSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23160a392d7eSmrg exit 0 23170a392d7eSmrg} 231854b44505Smrg 231954b44505Smrg 23200a392d7eSmrg# func_lo2o OBJECT-NAME 23210a392d7eSmrg# --------------------- 23220a392d7eSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23230a392d7eSmrg# object suffix. 23240a392d7eSmrg 23250a392d7eSmrglo2o=s/\\.lo\$/.$objext/ 23260a392d7eSmrgo2lo=s/\\.$objext\$/.lo/ 23270a392d7eSmrg 23280a392d7eSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23290a392d7eSmrg eval 'func_lo2o () 23300a392d7eSmrg { 23310a392d7eSmrg case $1 in 23320a392d7eSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23330a392d7eSmrg * ) func_lo2o_result=$1 ;; 23340a392d7eSmrg esac 23350a392d7eSmrg }' 23360a392d7eSmrg 23370a392d7eSmrg # func_xform LIBOBJ-OR-SOURCE 23380a392d7eSmrg # --------------------------- 23390a392d7eSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23400a392d7eSmrg # suffix to a '.lo' libtool-object suffix. 23410a392d7eSmrg eval 'func_xform () 23420a392d7eSmrg { 23430a392d7eSmrg func_xform_result=${1%.*}.lo 23440a392d7eSmrg }' 23450a392d7eSmrgelse 23460a392d7eSmrg # ...otherwise fall back to using sed. 23470a392d7eSmrg func_lo2o () 23480a392d7eSmrg { 23490a392d7eSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23500a392d7eSmrg } 23510a392d7eSmrg 23520a392d7eSmrg func_xform () 23530a392d7eSmrg { 23540a392d7eSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23550a392d7eSmrg } 23560a392d7eSmrgfi 235754b44505Smrg 235854b44505Smrg 23590a392d7eSmrg# func_fatal_configuration ARG... 23600a392d7eSmrg# ------------------------------- 236154b44505Smrg# Echo program name prefixed message to standard error, followed by 236254b44505Smrg# a configuration failure hint, and exit. 236354b44505Smrgfunc_fatal_configuration () 236454b44505Smrg{ 23658fc2d0c6Smrg func_fatal_error ${1+"$@"} \ 23660a392d7eSmrg "See the $PACKAGE documentation for more information." \ 23670a392d7eSmrg "Fatal configuration error." 236854b44505Smrg} 236954b44505Smrg 237054b44505Smrg 237154b44505Smrg# func_config 23720a392d7eSmrg# ----------- 237354b44505Smrg# Display the configuration for all the tags in this script. 237454b44505Smrgfunc_config () 237554b44505Smrg{ 237654b44505Smrg re_begincf='^# ### BEGIN LIBTOOL' 237754b44505Smrg re_endcf='^# ### END LIBTOOL' 237854b44505Smrg 237954b44505Smrg # Default configuration. 238054b44505Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 238154b44505Smrg 23824a041c5bSmacallan # Now print the configurations for the tags. 23834a041c5bSmacallan for tagname in $taglist; do 238454b44505Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23854a041c5bSmacallan done 23864a041c5bSmacallan 238754b44505Smrg exit $? 238854b44505Smrg} 23894a041c5bSmacallan 23900a392d7eSmrg 239154b44505Smrg# func_features 23920a392d7eSmrg# ------------- 239354b44505Smrg# Display the features supported by this script. 239454b44505Smrgfunc_features () 239554b44505Smrg{ 239654b44505Smrg echo "host: $host" 23970a392d7eSmrg if test yes = "$build_libtool_libs"; then 239854b44505Smrg echo "enable shared libraries" 23994a041c5bSmacallan else 240054b44505Smrg echo "disable shared libraries" 24014a041c5bSmacallan fi 24020a392d7eSmrg if test yes = "$build_old_libs"; then 240354b44505Smrg echo "enable static libraries" 24044a041c5bSmacallan else 240554b44505Smrg echo "disable static libraries" 24064a041c5bSmacallan fi 24074a041c5bSmacallan 240854b44505Smrg exit $? 240954b44505Smrg} 24104a041c5bSmacallan 24110a392d7eSmrg 24120a392d7eSmrg# func_enable_tag TAGNAME 24130a392d7eSmrg# ----------------------- 241454b44505Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 241554b44505Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 241654b44505Smrg# variable here. 241754b44505Smrgfunc_enable_tag () 241854b44505Smrg{ 24190a392d7eSmrg # Global variable: 24200a392d7eSmrg tagname=$1 24214a041c5bSmacallan 24220a392d7eSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24230a392d7eSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24240a392d7eSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24254a041c5bSmacallan 24260a392d7eSmrg # Validate tagname. 24270a392d7eSmrg case $tagname in 24280a392d7eSmrg *[!-_A-Za-z0-9,/]*) 24290a392d7eSmrg func_fatal_error "invalid tag name: $tagname" 24300a392d7eSmrg ;; 24310a392d7eSmrg esac 24324a041c5bSmacallan 24330a392d7eSmrg # Don't test for the "default" C tag, as we know it's 24340a392d7eSmrg # there but not specially marked. 24350a392d7eSmrg case $tagname in 24360a392d7eSmrg CC) ;; 243754b44505Smrg *) 24380a392d7eSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24390a392d7eSmrg taglist="$taglist $tagname" 24400a392d7eSmrg 24410a392d7eSmrg # Evaluate the configuration. Be careful to quote the path 24420a392d7eSmrg # and the sed script, to avoid splitting on whitespace, but 24430a392d7eSmrg # also don't use non-portable quotes within backquotes within 24440a392d7eSmrg # quotes we have to do it in 2 steps: 24450a392d7eSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24460a392d7eSmrg eval "$extractedcf" 24470a392d7eSmrg else 24480a392d7eSmrg func_error "ignoring unknown tag $tagname" 24490a392d7eSmrg fi 24500a392d7eSmrg ;; 24510a392d7eSmrg esac 245254b44505Smrg} 24534a041c5bSmacallan 24540a392d7eSmrg 245554b44505Smrg# func_check_version_match 24560a392d7eSmrg# ------------------------ 245754b44505Smrg# Ensure that we are using m4 macros, and libtool script from the same 245854b44505Smrg# release of libtool. 245954b44505Smrgfunc_check_version_match () 246054b44505Smrg{ 24610a392d7eSmrg if test "$package_revision" != "$macro_revision"; then 24620a392d7eSmrg if test "$VERSION" != "$macro_version"; then 24630a392d7eSmrg if test -z "$macro_version"; then 24640a392d7eSmrg cat >&2 <<_LT_EOF 246554b44505Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 246654b44505Smrg$progname: definition of this LT_INIT comes from an older release. 246754b44505Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 246854b44505Smrg$progname: and run autoconf again. 246954b44505Smrg_LT_EOF 24700a392d7eSmrg else 24710a392d7eSmrg cat >&2 <<_LT_EOF 247254b44505Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 247354b44505Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 247454b44505Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 247554b44505Smrg$progname: and run autoconf again. 247654b44505Smrg_LT_EOF 24770a392d7eSmrg fi 24780a392d7eSmrg else 24790a392d7eSmrg cat >&2 <<_LT_EOF 248054b44505Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 248154b44505Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 248254b44505Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 248354b44505Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 248454b44505Smrg_LT_EOF 24850a392d7eSmrg fi 24864a041c5bSmacallan 24870a392d7eSmrg exit $EXIT_MISMATCH 24880a392d7eSmrg fi 248954b44505Smrg} 24904a041c5bSmacallan 24914a041c5bSmacallan 24920a392d7eSmrg# libtool_options_prep [ARG]... 24930a392d7eSmrg# ----------------------------- 24940a392d7eSmrg# Preparation for options parsed by libtool. 24950a392d7eSmrglibtool_options_prep () 24960a392d7eSmrg{ 24970a392d7eSmrg $debug_mode 24984a041c5bSmacallan 24990a392d7eSmrg # Option defaults: 25000a392d7eSmrg opt_config=false 25010a392d7eSmrg opt_dlopen= 25020a392d7eSmrg opt_dry_run=false 25030a392d7eSmrg opt_help=false 25040a392d7eSmrg opt_mode= 25050a392d7eSmrg opt_preserve_dup_deps=false 25060a392d7eSmrg opt_quiet=false 25074a041c5bSmacallan 25080a392d7eSmrg nonopt= 25090a392d7eSmrg preserve_args= 25104a041c5bSmacallan 25118fc2d0c6Smrg _G_rc_lt_options_prep=: 25128fc2d0c6Smrg 25130a392d7eSmrg # Shorthand for --mode=foo, only valid as the first argument 25140a392d7eSmrg case $1 in 25150a392d7eSmrg clean|clea|cle|cl) 25160a392d7eSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25170a392d7eSmrg ;; 25180a392d7eSmrg compile|compil|compi|comp|com|co|c) 25190a392d7eSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25200a392d7eSmrg ;; 25210a392d7eSmrg execute|execut|execu|exec|exe|ex|e) 25220a392d7eSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25230a392d7eSmrg ;; 25240a392d7eSmrg finish|finis|fini|fin|fi|f) 25250a392d7eSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25260a392d7eSmrg ;; 25270a392d7eSmrg install|instal|insta|inst|ins|in|i) 25280a392d7eSmrg shift; set dummy --mode install ${1+"$@"}; shift 25290a392d7eSmrg ;; 25300a392d7eSmrg link|lin|li|l) 25310a392d7eSmrg shift; set dummy --mode link ${1+"$@"}; shift 25320a392d7eSmrg ;; 25330a392d7eSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25340a392d7eSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25350a392d7eSmrg ;; 25368fc2d0c6Smrg *) 25378fc2d0c6Smrg _G_rc_lt_options_prep=false 25388fc2d0c6Smrg ;; 25390a392d7eSmrg esac 25400a392d7eSmrg 25418fc2d0c6Smrg if $_G_rc_lt_options_prep; then 25428fc2d0c6Smrg # Pass back the list of options. 25438fc2d0c6Smrg func_quote eval ${1+"$@"} 25448fc2d0c6Smrg libtool_options_prep_result=$func_quote_result 25458fc2d0c6Smrg fi 25460a392d7eSmrg} 25470a392d7eSmrgfunc_add_hook func_options_prep libtool_options_prep 25484a041c5bSmacallan 254954b44505Smrg 25500a392d7eSmrg# libtool_parse_options [ARG]... 25510a392d7eSmrg# --------------------------------- 25520a392d7eSmrg# Provide handling for libtool specific options. 25530a392d7eSmrglibtool_parse_options () 255454b44505Smrg{ 25550a392d7eSmrg $debug_cmd 25564a041c5bSmacallan 25578fc2d0c6Smrg _G_rc_lt_parse_options=false 25588fc2d0c6Smrg 25590a392d7eSmrg # Perform our own loop to consume as many options as possible in 25600a392d7eSmrg # each iteration. 25610a392d7eSmrg while test $# -gt 0; do 25628fc2d0c6Smrg _G_match_lt_parse_options=: 25630a392d7eSmrg _G_opt=$1 25640a392d7eSmrg shift 25650a392d7eSmrg case $_G_opt in 25660a392d7eSmrg --dry-run|--dryrun|-n) 25670a392d7eSmrg opt_dry_run=: 25680a392d7eSmrg ;; 25690a392d7eSmrg 25700a392d7eSmrg --config) func_config ;; 25710a392d7eSmrg 25720a392d7eSmrg --dlopen|-dlopen) 25730a392d7eSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25740a392d7eSmrg}$1" 25750a392d7eSmrg shift 25760a392d7eSmrg ;; 25770a392d7eSmrg 25780a392d7eSmrg --preserve-dup-deps) 25790a392d7eSmrg opt_preserve_dup_deps=: ;; 25800a392d7eSmrg 25810a392d7eSmrg --features) func_features ;; 25820a392d7eSmrg 25830a392d7eSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25840a392d7eSmrg 25850a392d7eSmrg --help) opt_help=: ;; 25860a392d7eSmrg 25870a392d7eSmrg --help-all) opt_help=': help-all' ;; 25880a392d7eSmrg 25890a392d7eSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25900a392d7eSmrg opt_mode=$1 25910a392d7eSmrg case $1 in 25920a392d7eSmrg # Valid mode arguments: 25930a392d7eSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25940a392d7eSmrg 25950a392d7eSmrg # Catch anything else as an error 25960a392d7eSmrg *) func_error "invalid argument for $_G_opt" 25970a392d7eSmrg exit_cmd=exit 25980a392d7eSmrg break 25990a392d7eSmrg ;; 26000a392d7eSmrg esac 26010a392d7eSmrg shift 26020a392d7eSmrg ;; 26030a392d7eSmrg 26040a392d7eSmrg --no-silent|--no-quiet) 26050a392d7eSmrg opt_quiet=false 26060a392d7eSmrg func_append preserve_args " $_G_opt" 26070a392d7eSmrg ;; 26080a392d7eSmrg 26090a392d7eSmrg --no-warnings|--no-warning|--no-warn) 26100a392d7eSmrg opt_warning=false 26110a392d7eSmrg func_append preserve_args " $_G_opt" 26120a392d7eSmrg ;; 26130a392d7eSmrg 26140a392d7eSmrg --no-verbose) 26150a392d7eSmrg opt_verbose=false 26160a392d7eSmrg func_append preserve_args " $_G_opt" 26170a392d7eSmrg ;; 26180a392d7eSmrg 26190a392d7eSmrg --silent|--quiet) 26200a392d7eSmrg opt_quiet=: 26210a392d7eSmrg opt_verbose=false 26220a392d7eSmrg func_append preserve_args " $_G_opt" 26230a392d7eSmrg ;; 26240a392d7eSmrg 26250a392d7eSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26260a392d7eSmrg opt_tag=$1 26270a392d7eSmrg func_append preserve_args " $_G_opt $1" 26280a392d7eSmrg func_enable_tag "$1" 26290a392d7eSmrg shift 26300a392d7eSmrg ;; 26310a392d7eSmrg 26320a392d7eSmrg --verbose|-v) opt_quiet=false 26330a392d7eSmrg opt_verbose=: 26340a392d7eSmrg func_append preserve_args " $_G_opt" 26350a392d7eSmrg ;; 26360a392d7eSmrg 26378fc2d0c6Smrg # An option not handled by this hook function: 26388fc2d0c6Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26398fc2d0c6Smrg _G_match_lt_parse_options=false 26408fc2d0c6Smrg break 26418fc2d0c6Smrg ;; 26420a392d7eSmrg esac 26438fc2d0c6Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26440a392d7eSmrg done 264554b44505Smrg 26468fc2d0c6Smrg if $_G_rc_lt_parse_options; then 26478fc2d0c6Smrg # save modified positional parameters for caller 26488fc2d0c6Smrg func_quote eval ${1+"$@"} 26498fc2d0c6Smrg libtool_parse_options_result=$func_quote_result 26508fc2d0c6Smrg fi 26510a392d7eSmrg} 26520a392d7eSmrgfunc_add_hook func_parse_options libtool_parse_options 26534a041c5bSmacallan 26544a041c5bSmacallan 26554a041c5bSmacallan 26560a392d7eSmrg# libtool_validate_options [ARG]... 26570a392d7eSmrg# --------------------------------- 26580a392d7eSmrg# Perform any sanity checks on option settings and/or unconsumed 26590a392d7eSmrg# arguments. 26600a392d7eSmrglibtool_validate_options () 26610a392d7eSmrg{ 26620a392d7eSmrg # save first non-option argument 26630a392d7eSmrg if test 0 -lt $#; then 26640a392d7eSmrg nonopt=$1 26650a392d7eSmrg shift 266654b44505Smrg fi 26674a041c5bSmacallan 26680a392d7eSmrg # preserve --debug 26690a392d7eSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26704a041c5bSmacallan 26710a392d7eSmrg case $host in 26720a392d7eSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26730a392d7eSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26740a392d7eSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26750a392d7eSmrg # don't eliminate duplications in $postdeps and $predeps 26760a392d7eSmrg opt_duplicate_compiler_generated_deps=: 26770a392d7eSmrg ;; 26780a392d7eSmrg *) 26790a392d7eSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26800a392d7eSmrg ;; 26810a392d7eSmrg esac 26824a041c5bSmacallan 26830a392d7eSmrg $opt_help || { 26840a392d7eSmrg # Sanity checks first: 26850a392d7eSmrg func_check_version_match 26860a392d7eSmrg 26870a392d7eSmrg test yes != "$build_libtool_libs" \ 26880a392d7eSmrg && test yes != "$build_old_libs" \ 26890a392d7eSmrg && func_fatal_configuration "not configured to build any kind of library" 26904a041c5bSmacallan 26910a392d7eSmrg # Darwin sucks 26920a392d7eSmrg eval std_shrext=\"$shrext_cmds\" 26934a041c5bSmacallan 26940a392d7eSmrg # Only execute mode is allowed to have -dlopen flags. 26950a392d7eSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26960a392d7eSmrg func_error "unrecognized option '-dlopen'" 26970a392d7eSmrg $ECHO "$help" 1>&2 26980a392d7eSmrg exit $EXIT_FAILURE 26990a392d7eSmrg fi 27000a392d7eSmrg 27010a392d7eSmrg # Change the help message to a mode-specific one. 27020a392d7eSmrg generic_help=$help 27030a392d7eSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27040a392d7eSmrg } 27050a392d7eSmrg 27060a392d7eSmrg # Pass back the unparsed argument list 27078fc2d0c6Smrg func_quote eval ${1+"$@"} 27088fc2d0c6Smrg libtool_validate_options_result=$func_quote_result 270954b44505Smrg} 27100a392d7eSmrgfunc_add_hook func_validate_options libtool_validate_options 27114a041c5bSmacallan 27124a041c5bSmacallan 27130a392d7eSmrg# Process options as early as possible so that --help and --version 27140a392d7eSmrg# can return quickly. 27150a392d7eSmrgfunc_options ${1+"$@"} 27160a392d7eSmrgeval set dummy "$func_options_result"; shift 27170a392d7eSmrg 27184a041c5bSmacallan 27194a041c5bSmacallan 272054b44505Smrg## ----------- ## 272154b44505Smrg## Main. ## 272254b44505Smrg## ----------- ## 27234a041c5bSmacallan 27240a392d7eSmrgmagic='%%%MAGIC variable%%%' 27250a392d7eSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27260a392d7eSmrg 27270a392d7eSmrg# Global variables. 27280a392d7eSmrgextracted_archives= 27290a392d7eSmrgextracted_serial=0 27300a392d7eSmrg 27310a392d7eSmrg# If this variable is set in any of the actions, the command in it 27320a392d7eSmrg# will be execed at the end. This prevents here-documents from being 27330a392d7eSmrg# left over by shells. 27340a392d7eSmrgexec_cmd= 27350a392d7eSmrg 27360a392d7eSmrg 27370a392d7eSmrg# A function that is used when there is no print builtin or printf. 27380a392d7eSmrgfunc_fallback_echo () 27390a392d7eSmrg{ 27400a392d7eSmrg eval 'cat <<_LTECHO_EOF 27410a392d7eSmrg$1 27420a392d7eSmrg_LTECHO_EOF' 27430a392d7eSmrg} 27440a392d7eSmrg 27450a392d7eSmrg# func_generated_by_libtool 27460a392d7eSmrg# True iff stdin has been generated by Libtool. This function is only 27470a392d7eSmrg# a basic sanity check; it will hardly flush out determined imposters. 27480a392d7eSmrgfunc_generated_by_libtool_p () 27490a392d7eSmrg{ 27500a392d7eSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27510a392d7eSmrg} 27520a392d7eSmrg 275354b44505Smrg# func_lalib_p file 27540a392d7eSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 275554b44505Smrg# This function is only a basic sanity check; it will hardly flush out 275654b44505Smrg# determined imposters. 275754b44505Smrgfunc_lalib_p () 275854b44505Smrg{ 275954b44505Smrg test -f "$1" && 27600a392d7eSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 276154b44505Smrg} 27624a041c5bSmacallan 276354b44505Smrg# func_lalib_unsafe_p file 27640a392d7eSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 276554b44505Smrg# This function implements the same check as func_lalib_p without 276654b44505Smrg# resorting to external programs. To this end, it redirects stdin and 276754b44505Smrg# closes it afterwards, without saving the original file descriptor. 276854b44505Smrg# As a safety measure, use it only where a negative result would be 27690a392d7eSmrg# fatal anyway. Works if 'file' does not exist. 277054b44505Smrgfunc_lalib_unsafe_p () 277154b44505Smrg{ 277254b44505Smrg lalib_p=no 277354b44505Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 277454b44505Smrg for lalib_p_l in 1 2 3 4 277554b44505Smrg do 277654b44505Smrg read lalib_p_line 27770a392d7eSmrg case $lalib_p_line in 277854b44505Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 277954b44505Smrg esac 278054b44505Smrg done 278154b44505Smrg exec 0<&5 5<&- 278254b44505Smrg fi 27830a392d7eSmrg test yes = "$lalib_p" 278454b44505Smrg} 27854a041c5bSmacallan 278654b44505Smrg# func_ltwrapper_script_p file 278754b44505Smrg# True iff FILE is a libtool wrapper script 278854b44505Smrg# This function is only a basic sanity check; it will hardly flush out 278954b44505Smrg# determined imposters. 279054b44505Smrgfunc_ltwrapper_script_p () 279154b44505Smrg{ 27920a392d7eSmrg test -f "$1" && 27930a392d7eSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 279454b44505Smrg} 27954a041c5bSmacallan 279654b44505Smrg# func_ltwrapper_executable_p file 279754b44505Smrg# True iff FILE is a libtool wrapper executable 279854b44505Smrg# This function is only a basic sanity check; it will hardly flush out 279954b44505Smrg# determined imposters. 280054b44505Smrgfunc_ltwrapper_executable_p () 280154b44505Smrg{ 280254b44505Smrg func_ltwrapper_exec_suffix= 280354b44505Smrg case $1 in 280454b44505Smrg *.exe) ;; 280554b44505Smrg *) func_ltwrapper_exec_suffix=.exe ;; 28064a041c5bSmacallan esac 280754b44505Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 280854b44505Smrg} 28094a041c5bSmacallan 281054b44505Smrg# func_ltwrapper_scriptname file 281154b44505Smrg# Assumes file is an ltwrapper_executable 281254b44505Smrg# uses $file to determine the appropriate filename for a 281354b44505Smrg# temporary ltwrapper_script. 281454b44505Smrgfunc_ltwrapper_scriptname () 281554b44505Smrg{ 281654b44505Smrg func_dirname_and_basename "$1" "" "." 281754b44505Smrg func_stripname '' '.exe' "$func_basename_result" 28180a392d7eSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 281954b44505Smrg} 28204a041c5bSmacallan 282154b44505Smrg# func_ltwrapper_p file 282254b44505Smrg# True iff FILE is a libtool wrapper script or wrapper executable 282354b44505Smrg# This function is only a basic sanity check; it will hardly flush out 282454b44505Smrg# determined imposters. 282554b44505Smrgfunc_ltwrapper_p () 282654b44505Smrg{ 282754b44505Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 282854b44505Smrg} 28294a041c5bSmacallan 28304a041c5bSmacallan 283154b44505Smrg# func_execute_cmds commands fail_cmd 283254b44505Smrg# Execute tilde-delimited COMMANDS. 283354b44505Smrg# If FAIL_CMD is given, eval that upon failure. 283454b44505Smrg# FAIL_CMD may read-access the current command in variable CMD! 283554b44505Smrgfunc_execute_cmds () 283654b44505Smrg{ 28370a392d7eSmrg $debug_cmd 28380a392d7eSmrg 283954b44505Smrg save_ifs=$IFS; IFS='~' 284054b44505Smrg for cmd in $1; do 28410a392d7eSmrg IFS=$sp$nl 284254b44505Smrg eval cmd=\"$cmd\" 28430a392d7eSmrg IFS=$save_ifs 284454b44505Smrg func_show_eval "$cmd" "${2-:}" 28454a041c5bSmacallan done 284654b44505Smrg IFS=$save_ifs 284754b44505Smrg} 28484a041c5bSmacallan 28494a041c5bSmacallan 285054b44505Smrg# func_source file 285154b44505Smrg# Source FILE, adding directory component if necessary. 285254b44505Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 285354b44505Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 285454b44505Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28550a392d7eSmrg# 'FILE.' does not work on cygwin managed mounts. 285654b44505Smrgfunc_source () 285754b44505Smrg{ 28580a392d7eSmrg $debug_cmd 28590a392d7eSmrg 286054b44505Smrg case $1 in 286154b44505Smrg */* | *\\*) . "$1" ;; 286254b44505Smrg *) . "./$1" ;; 286354b44505Smrg esac 286454b44505Smrg} 28654a041c5bSmacallan 28664a041c5bSmacallan 286754b44505Smrg# func_resolve_sysroot PATH 286854b44505Smrg# Replace a leading = in PATH with a sysroot. Store the result into 286954b44505Smrg# func_resolve_sysroot_result 287054b44505Smrgfunc_resolve_sysroot () 287154b44505Smrg{ 287254b44505Smrg func_resolve_sysroot_result=$1 287354b44505Smrg case $func_resolve_sysroot_result in 287454b44505Smrg =*) 287554b44505Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 287654b44505Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 287754b44505Smrg ;; 287854b44505Smrg esac 287954b44505Smrg} 28804a041c5bSmacallan 288154b44505Smrg# func_replace_sysroot PATH 288254b44505Smrg# If PATH begins with the sysroot, replace it with = and 288354b44505Smrg# store the result into func_replace_sysroot_result. 288454b44505Smrgfunc_replace_sysroot () 288554b44505Smrg{ 28860a392d7eSmrg case $lt_sysroot:$1 in 288754b44505Smrg ?*:"$lt_sysroot"*) 288854b44505Smrg func_stripname "$lt_sysroot" '' "$1" 28890a392d7eSmrg func_replace_sysroot_result='='$func_stripname_result 289054b44505Smrg ;; 289154b44505Smrg *) 289254b44505Smrg # Including no sysroot. 289354b44505Smrg func_replace_sysroot_result=$1 289454b44505Smrg ;; 289554b44505Smrg esac 289654b44505Smrg} 28974a041c5bSmacallan 289854b44505Smrg# func_infer_tag arg 289954b44505Smrg# Infer tagged configuration to use if any are available and 290054b44505Smrg# if one wasn't chosen via the "--tag" command line option. 290154b44505Smrg# Only attempt this if the compiler in the base compile 290254b44505Smrg# command doesn't match the default compiler. 290354b44505Smrg# arg is usually of the form 'gcc ...' 290454b44505Smrgfunc_infer_tag () 290554b44505Smrg{ 29060a392d7eSmrg $debug_cmd 29070a392d7eSmrg 290854b44505Smrg if test -n "$available_tags" && test -z "$tagname"; then 290954b44505Smrg CC_quoted= 291054b44505Smrg for arg in $CC; do 291154b44505Smrg func_append_quoted CC_quoted "$arg" 291254b44505Smrg done 291354b44505Smrg CC_expanded=`func_echo_all $CC` 291454b44505Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 291554b44505Smrg case $@ in 291654b44505Smrg # Blanks in the command may have been stripped by the calling shell, 291754b44505Smrg # but not from the CC environment variable when configure was run. 291854b44505Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 291954b44505Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 292054b44505Smrg # Blanks at the start of $base_compile will cause this to fail 292154b44505Smrg # if we don't check for them as well. 292254b44505Smrg *) 292354b44505Smrg for z in $available_tags; do 292454b44505Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 292554b44505Smrg # Evaluate the configuration. 29260a392d7eSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 292754b44505Smrg CC_quoted= 292854b44505Smrg for arg in $CC; do 292954b44505Smrg # Double-quote args containing other shell metacharacters. 293054b44505Smrg func_append_quoted CC_quoted "$arg" 293154b44505Smrg done 293254b44505Smrg CC_expanded=`func_echo_all $CC` 293354b44505Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 293454b44505Smrg case "$@ " in 293554b44505Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 293654b44505Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 293754b44505Smrg # The compiler in the base compile command matches 293854b44505Smrg # the one in the tagged configuration. 293954b44505Smrg # Assume this is the tagged configuration we want. 294054b44505Smrg tagname=$z 294154b44505Smrg break 294254b44505Smrg ;; 294354b44505Smrg esac 294454b44505Smrg fi 294554b44505Smrg done 294654b44505Smrg # If $tagname still isn't set, then no tagged configuration 294754b44505Smrg # was found and let the user know that the "--tag" command 294854b44505Smrg # line option must be used. 294954b44505Smrg if test -z "$tagname"; then 295054b44505Smrg func_echo "unable to infer tagged configuration" 29510a392d7eSmrg func_fatal_error "specify a tag with '--tag'" 295254b44505Smrg# else 295354b44505Smrg# func_verbose "using $tagname tagged configuration" 295454b44505Smrg fi 295554b44505Smrg ;; 295654b44505Smrg esac 29574a041c5bSmacallan fi 295854b44505Smrg} 29594a041c5bSmacallan 29604a041c5bSmacallan 29614a041c5bSmacallan 296254b44505Smrg# func_write_libtool_object output_name pic_name nonpic_name 296354b44505Smrg# Create a libtool object file (analogous to a ".la" file), 296454b44505Smrg# but don't create it if we're doing a dry run. 296554b44505Smrgfunc_write_libtool_object () 296654b44505Smrg{ 29670a392d7eSmrg write_libobj=$1 29680a392d7eSmrg if test yes = "$build_libtool_libs"; then 29690a392d7eSmrg write_lobj=\'$2\' 297054b44505Smrg else 297154b44505Smrg write_lobj=none 29724a041c5bSmacallan fi 29734a041c5bSmacallan 29740a392d7eSmrg if test yes = "$build_old_libs"; then 29750a392d7eSmrg write_oldobj=\'$3\' 297654b44505Smrg else 297754b44505Smrg write_oldobj=none 29784a041c5bSmacallan fi 29794a041c5bSmacallan 298054b44505Smrg $opt_dry_run || { 298154b44505Smrg cat >${write_libobj}T <<EOF 298254b44505Smrg# $write_libobj - a libtool object file 29830a392d7eSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29844a041c5bSmacallan# 29854a041c5bSmacallan# Please DO NOT delete this file! 29864a041c5bSmacallan# It is necessary for linking the library. 29874a041c5bSmacallan 29884a041c5bSmacallan# Name of the PIC object. 298954b44505Smrgpic_object=$write_lobj 29904a041c5bSmacallan 299154b44505Smrg# Name of the non-PIC object 299254b44505Smrgnon_pic_object=$write_oldobj 29934a041c5bSmacallan 299454b44505SmrgEOF 29950a392d7eSmrg $MV "${write_libobj}T" "$write_libobj" 299654b44505Smrg } 299754b44505Smrg} 29984a041c5bSmacallan 29994a041c5bSmacallan 300054b44505Smrg################################################## 300154b44505Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 300254b44505Smrg################################################## 30034a041c5bSmacallan 300454b44505Smrg# func_convert_core_file_wine_to_w32 ARG 300554b44505Smrg# Helper function used by file name conversion functions when $build is *nix, 300654b44505Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 300754b44505Smrg# correctly configured wine environment available, with the winepath program 300854b44505Smrg# in $build's $PATH. 300954b44505Smrg# 301054b44505Smrg# ARG is the $build file name to be converted to w32 format. 301154b44505Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 301254b44505Smrg# be empty on error (or when ARG is empty) 301354b44505Smrgfunc_convert_core_file_wine_to_w32 () 301454b44505Smrg{ 30150a392d7eSmrg $debug_cmd 30160a392d7eSmrg 30170a392d7eSmrg func_convert_core_file_wine_to_w32_result=$1 301854b44505Smrg if test -n "$1"; then 301954b44505Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 302054b44505Smrg # are forced to check the contents of stdout. On the other hand, if the 302154b44505Smrg # command is not found, the shell will set an exit code of 127 and print 302254b44505Smrg # *an error message* to stdout. So we must check for both error code of 302354b44505Smrg # zero AND non-empty stdout, which explains the odd construction: 302454b44505Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30250a392d7eSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 302654b44505Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30270a392d7eSmrg $SED -e "$sed_naive_backslashify"` 302854b44505Smrg else 302954b44505Smrg func_convert_core_file_wine_to_w32_result= 303054b44505Smrg fi 303154b44505Smrg fi 303254b44505Smrg} 303354b44505Smrg# end: func_convert_core_file_wine_to_w32 30344a041c5bSmacallan 303554b44505Smrg 303654b44505Smrg# func_convert_core_path_wine_to_w32 ARG 303754b44505Smrg# Helper function used by path conversion functions when $build is *nix, and 303854b44505Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 303954b44505Smrg# configured wine environment available, with the winepath program in $build's 304054b44505Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 304154b44505Smrg# 304254b44505Smrg# ARG is path to be converted from $build format to win32. 304354b44505Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 304454b44505Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 304554b44505Smrg# are convertible, then the result may be empty. 304654b44505Smrgfunc_convert_core_path_wine_to_w32 () 304754b44505Smrg{ 30480a392d7eSmrg $debug_cmd 30490a392d7eSmrg 305054b44505Smrg # unfortunately, winepath doesn't convert paths, only file names 30510a392d7eSmrg func_convert_core_path_wine_to_w32_result= 305254b44505Smrg if test -n "$1"; then 305354b44505Smrg oldIFS=$IFS 305454b44505Smrg IFS=: 305554b44505Smrg for func_convert_core_path_wine_to_w32_f in $1; do 305654b44505Smrg IFS=$oldIFS 305754b44505Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30580a392d7eSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 305954b44505Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30600a392d7eSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 306154b44505Smrg else 306254b44505Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 306354b44505Smrg fi 30644a041c5bSmacallan fi 306554b44505Smrg done 306654b44505Smrg IFS=$oldIFS 306754b44505Smrg fi 306854b44505Smrg} 306954b44505Smrg# end: func_convert_core_path_wine_to_w32 307054b44505Smrg 307154b44505Smrg 307254b44505Smrg# func_cygpath ARGS... 307354b44505Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 307454b44505Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 307554b44505Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 307654b44505Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 307754b44505Smrg# file name or path is assumed to be in w32 format, as previously converted 307854b44505Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 307954b44505Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 308054b44505Smrg# Cygwin format). Returns an empty string on error. 308154b44505Smrg# 308254b44505Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 308354b44505Smrg# be converted. 308454b44505Smrg# 308554b44505Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 308654b44505Smrg# environment variable; do not put it in $PATH. 308754b44505Smrgfunc_cygpath () 308854b44505Smrg{ 30890a392d7eSmrg $debug_cmd 30900a392d7eSmrg 309154b44505Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 309254b44505Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 309354b44505Smrg if test "$?" -ne 0; then 309454b44505Smrg # on failure, ensure result is empty 309554b44505Smrg func_cygpath_result= 309654b44505Smrg fi 309754b44505Smrg else 309854b44505Smrg func_cygpath_result= 30990a392d7eSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 310054b44505Smrg fi 310154b44505Smrg} 310254b44505Smrg#end: func_cygpath 31034a041c5bSmacallan 31044a041c5bSmacallan 310554b44505Smrg# func_convert_core_msys_to_w32 ARG 310654b44505Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 310754b44505Smrg# result in func_convert_core_msys_to_w32_result. 310854b44505Smrgfunc_convert_core_msys_to_w32 () 310954b44505Smrg{ 31100a392d7eSmrg $debug_cmd 31110a392d7eSmrg 311254b44505Smrg # awkward: cmd appends spaces to result 311354b44505Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31140a392d7eSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 311554b44505Smrg} 311654b44505Smrg#end: func_convert_core_msys_to_w32 31174a041c5bSmacallan 31184a041c5bSmacallan 311954b44505Smrg# func_convert_file_check ARG1 ARG2 312054b44505Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 312154b44505Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 312254b44505Smrg# func_to_host_file_result to ARG1). 312354b44505Smrgfunc_convert_file_check () 312454b44505Smrg{ 31250a392d7eSmrg $debug_cmd 31260a392d7eSmrg 31270a392d7eSmrg if test -z "$2" && test -n "$1"; then 312854b44505Smrg func_error "Could not determine host file name corresponding to" 31290a392d7eSmrg func_error " '$1'" 313054b44505Smrg func_error "Continuing, but uninstalled executables may not work." 313154b44505Smrg # Fallback: 31320a392d7eSmrg func_to_host_file_result=$1 313354b44505Smrg fi 313454b44505Smrg} 313554b44505Smrg# end func_convert_file_check 31364a041c5bSmacallan 31374a041c5bSmacallan 313854b44505Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 313954b44505Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 314054b44505Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 314154b44505Smrg# func_to_host_file_result to a simplistic fallback value (see below). 314254b44505Smrgfunc_convert_path_check () 314354b44505Smrg{ 31440a392d7eSmrg $debug_cmd 31450a392d7eSmrg 314654b44505Smrg if test -z "$4" && test -n "$3"; then 314754b44505Smrg func_error "Could not determine the host path corresponding to" 31480a392d7eSmrg func_error " '$3'" 314954b44505Smrg func_error "Continuing, but uninstalled executables may not work." 315054b44505Smrg # Fallback. This is a deliberately simplistic "conversion" and 315154b44505Smrg # should not be "improved". See libtool.info. 315254b44505Smrg if test "x$1" != "x$2"; then 315354b44505Smrg lt_replace_pathsep_chars="s|$1|$2|g" 315454b44505Smrg func_to_host_path_result=`echo "$3" | 315554b44505Smrg $SED -e "$lt_replace_pathsep_chars"` 315654b44505Smrg else 31570a392d7eSmrg func_to_host_path_result=$3 315854b44505Smrg fi 315954b44505Smrg fi 316054b44505Smrg} 316154b44505Smrg# end func_convert_path_check 31624a041c5bSmacallan 31634a041c5bSmacallan 316454b44505Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 316554b44505Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 316654b44505Smrg# and appending REPL if ORIG matches BACKPAT. 316754b44505Smrgfunc_convert_path_front_back_pathsep () 316854b44505Smrg{ 31690a392d7eSmrg $debug_cmd 31700a392d7eSmrg 317154b44505Smrg case $4 in 31720a392d7eSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 317354b44505Smrg ;; 317454b44505Smrg esac 317554b44505Smrg case $4 in 317654b44505Smrg $2 ) func_append func_to_host_path_result "$3" 317754b44505Smrg ;; 317854b44505Smrg esac 317954b44505Smrg} 318054b44505Smrg# end func_convert_path_front_back_pathsep 31814a041c5bSmacallan 31824a041c5bSmacallan 318354b44505Smrg################################################## 318454b44505Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 318554b44505Smrg################################################## 31860a392d7eSmrg# invoked via '$to_host_file_cmd ARG' 318754b44505Smrg# 318854b44505Smrg# In each case, ARG is the path to be converted from $build to $host format. 318954b44505Smrg# Result will be available in $func_to_host_file_result. 31904a041c5bSmacallan 31914a041c5bSmacallan 319254b44505Smrg# func_to_host_file ARG 319354b44505Smrg# Converts the file name ARG from $build format to $host format. Return result 319454b44505Smrg# in func_to_host_file_result. 319554b44505Smrgfunc_to_host_file () 319654b44505Smrg{ 31970a392d7eSmrg $debug_cmd 31980a392d7eSmrg 319954b44505Smrg $to_host_file_cmd "$1" 320054b44505Smrg} 320154b44505Smrg# end func_to_host_file 32024a041c5bSmacallan 32034a041c5bSmacallan 320454b44505Smrg# func_to_tool_file ARG LAZY 320554b44505Smrg# converts the file name ARG from $build format to toolchain format. Return 320654b44505Smrg# result in func_to_tool_file_result. If the conversion in use is listed 320754b44505Smrg# in (the comma separated) LAZY, no conversion takes place. 320854b44505Smrgfunc_to_tool_file () 320954b44505Smrg{ 32100a392d7eSmrg $debug_cmd 32110a392d7eSmrg 321254b44505Smrg case ,$2, in 321354b44505Smrg *,"$to_tool_file_cmd",*) 321454b44505Smrg func_to_tool_file_result=$1 321554b44505Smrg ;; 321654b44505Smrg *) 321754b44505Smrg $to_tool_file_cmd "$1" 321854b44505Smrg func_to_tool_file_result=$func_to_host_file_result 321954b44505Smrg ;; 322054b44505Smrg esac 322154b44505Smrg} 322254b44505Smrg# end func_to_tool_file 32234a041c5bSmacallan 32244a041c5bSmacallan 322554b44505Smrg# func_convert_file_noop ARG 322654b44505Smrg# Copy ARG to func_to_host_file_result. 322754b44505Smrgfunc_convert_file_noop () 322854b44505Smrg{ 32290a392d7eSmrg func_to_host_file_result=$1 323054b44505Smrg} 323154b44505Smrg# end func_convert_file_noop 32324a041c5bSmacallan 32334a041c5bSmacallan 323454b44505Smrg# func_convert_file_msys_to_w32 ARG 323554b44505Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 323654b44505Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 323754b44505Smrg# func_to_host_file_result. 323854b44505Smrgfunc_convert_file_msys_to_w32 () 323954b44505Smrg{ 32400a392d7eSmrg $debug_cmd 32410a392d7eSmrg 32420a392d7eSmrg func_to_host_file_result=$1 324354b44505Smrg if test -n "$1"; then 324454b44505Smrg func_convert_core_msys_to_w32 "$1" 32450a392d7eSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 324654b44505Smrg fi 324754b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 324854b44505Smrg} 324954b44505Smrg# end func_convert_file_msys_to_w32 32504a041c5bSmacallan 32514a041c5bSmacallan 325254b44505Smrg# func_convert_file_cygwin_to_w32 ARG 325354b44505Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 325454b44505Smrg# func_to_host_file_result. 325554b44505Smrgfunc_convert_file_cygwin_to_w32 () 325654b44505Smrg{ 32570a392d7eSmrg $debug_cmd 32580a392d7eSmrg 32590a392d7eSmrg func_to_host_file_result=$1 326054b44505Smrg if test -n "$1"; then 326154b44505Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 326254b44505Smrg # LT_CYGPATH in this case. 326354b44505Smrg func_to_host_file_result=`cygpath -m "$1"` 326454b44505Smrg fi 326554b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 326654b44505Smrg} 326754b44505Smrg# end func_convert_file_cygwin_to_w32 32684a041c5bSmacallan 32694a041c5bSmacallan 327054b44505Smrg# func_convert_file_nix_to_w32 ARG 327154b44505Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 327254b44505Smrg# and a working winepath. Returns result in func_to_host_file_result. 327354b44505Smrgfunc_convert_file_nix_to_w32 () 327454b44505Smrg{ 32750a392d7eSmrg $debug_cmd 32760a392d7eSmrg 32770a392d7eSmrg func_to_host_file_result=$1 327854b44505Smrg if test -n "$1"; then 327954b44505Smrg func_convert_core_file_wine_to_w32 "$1" 32800a392d7eSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 328154b44505Smrg fi 328254b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 328354b44505Smrg} 328454b44505Smrg# end func_convert_file_nix_to_w32 32854a041c5bSmacallan 32864a041c5bSmacallan 328754b44505Smrg# func_convert_file_msys_to_cygwin ARG 328854b44505Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 328954b44505Smrg# Returns result in func_to_host_file_result. 329054b44505Smrgfunc_convert_file_msys_to_cygwin () 329154b44505Smrg{ 32920a392d7eSmrg $debug_cmd 32930a392d7eSmrg 32940a392d7eSmrg func_to_host_file_result=$1 329554b44505Smrg if test -n "$1"; then 329654b44505Smrg func_convert_core_msys_to_w32 "$1" 329754b44505Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32980a392d7eSmrg func_to_host_file_result=$func_cygpath_result 329954b44505Smrg fi 330054b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 330154b44505Smrg} 330254b44505Smrg# end func_convert_file_msys_to_cygwin 33034a041c5bSmacallan 33044a041c5bSmacallan 330554b44505Smrg# func_convert_file_nix_to_cygwin ARG 330654b44505Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 330754b44505Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 330854b44505Smrg# in func_to_host_file_result. 330954b44505Smrgfunc_convert_file_nix_to_cygwin () 331054b44505Smrg{ 33110a392d7eSmrg $debug_cmd 33120a392d7eSmrg 33130a392d7eSmrg func_to_host_file_result=$1 331454b44505Smrg if test -n "$1"; then 331554b44505Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 331654b44505Smrg func_convert_core_file_wine_to_w32 "$1" 331754b44505Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33180a392d7eSmrg func_to_host_file_result=$func_cygpath_result 331954b44505Smrg fi 332054b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 332154b44505Smrg} 332254b44505Smrg# end func_convert_file_nix_to_cygwin 33234a041c5bSmacallan 33244a041c5bSmacallan 332554b44505Smrg############################################# 332654b44505Smrg# $build to $host PATH CONVERSION FUNCTIONS # 332754b44505Smrg############################################# 33280a392d7eSmrg# invoked via '$to_host_path_cmd ARG' 332954b44505Smrg# 333054b44505Smrg# In each case, ARG is the path to be converted from $build to $host format. 333154b44505Smrg# The result will be available in $func_to_host_path_result. 333254b44505Smrg# 333354b44505Smrg# Path separators are also converted from $build format to $host format. If 333454b44505Smrg# ARG begins or ends with a path separator character, it is preserved (but 333554b44505Smrg# converted to $host format) on output. 333654b44505Smrg# 333754b44505Smrg# All path conversion functions are named using the following convention: 333854b44505Smrg# file name conversion function : func_convert_file_X_to_Y () 333954b44505Smrg# path conversion function : func_convert_path_X_to_Y () 334054b44505Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 334154b44505Smrg# same. If conversion functions are added for new $build/$host combinations, 334254b44505Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 334354b44505Smrg# will break. 334454b44505Smrg 334554b44505Smrg 334654b44505Smrg# func_init_to_host_path_cmd 334754b44505Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 334854b44505Smrg# appropriate value, based on the value of $to_host_file_cmd. 334954b44505Smrgto_host_path_cmd= 335054b44505Smrgfunc_init_to_host_path_cmd () 335154b44505Smrg{ 33520a392d7eSmrg $debug_cmd 33530a392d7eSmrg 335454b44505Smrg if test -z "$to_host_path_cmd"; then 335554b44505Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33560a392d7eSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 335754b44505Smrg fi 335854b44505Smrg} 33594a041c5bSmacallan 33604a041c5bSmacallan 336154b44505Smrg# func_to_host_path ARG 336254b44505Smrg# Converts the path ARG from $build format to $host format. Return result 336354b44505Smrg# in func_to_host_path_result. 336454b44505Smrgfunc_to_host_path () 336554b44505Smrg{ 33660a392d7eSmrg $debug_cmd 33670a392d7eSmrg 336854b44505Smrg func_init_to_host_path_cmd 336954b44505Smrg $to_host_path_cmd "$1" 337054b44505Smrg} 337154b44505Smrg# end func_to_host_path 33724a041c5bSmacallan 33734a041c5bSmacallan 337454b44505Smrg# func_convert_path_noop ARG 337554b44505Smrg# Copy ARG to func_to_host_path_result. 337654b44505Smrgfunc_convert_path_noop () 337754b44505Smrg{ 33780a392d7eSmrg func_to_host_path_result=$1 337954b44505Smrg} 338054b44505Smrg# end func_convert_path_noop 33814a041c5bSmacallan 33824a041c5bSmacallan 338354b44505Smrg# func_convert_path_msys_to_w32 ARG 338454b44505Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 338554b44505Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 338654b44505Smrg# func_to_host_path_result. 338754b44505Smrgfunc_convert_path_msys_to_w32 () 338854b44505Smrg{ 33890a392d7eSmrg $debug_cmd 33900a392d7eSmrg 33910a392d7eSmrg func_to_host_path_result=$1 339254b44505Smrg if test -n "$1"; then 339354b44505Smrg # Remove leading and trailing path separator characters from ARG. MSYS 339454b44505Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 339554b44505Smrg # and winepath ignores them completely. 339654b44505Smrg func_stripname : : "$1" 339754b44505Smrg func_to_host_path_tmp1=$func_stripname_result 339854b44505Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33990a392d7eSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 340054b44505Smrg func_convert_path_check : ";" \ 340154b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 340254b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 340354b44505Smrg fi 340454b44505Smrg} 340554b44505Smrg# end func_convert_path_msys_to_w32 34064a041c5bSmacallan 34074a041c5bSmacallan 340854b44505Smrg# func_convert_path_cygwin_to_w32 ARG 340954b44505Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 341054b44505Smrg# func_to_host_file_result. 341154b44505Smrgfunc_convert_path_cygwin_to_w32 () 341254b44505Smrg{ 34130a392d7eSmrg $debug_cmd 34140a392d7eSmrg 34150a392d7eSmrg func_to_host_path_result=$1 341654b44505Smrg if test -n "$1"; then 341754b44505Smrg # See func_convert_path_msys_to_w32: 341854b44505Smrg func_stripname : : "$1" 341954b44505Smrg func_to_host_path_tmp1=$func_stripname_result 342054b44505Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 342154b44505Smrg func_convert_path_check : ";" \ 342254b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 342354b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 342454b44505Smrg fi 342554b44505Smrg} 342654b44505Smrg# end func_convert_path_cygwin_to_w32 34274a041c5bSmacallan 34284a041c5bSmacallan 342954b44505Smrg# func_convert_path_nix_to_w32 ARG 343054b44505Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 343154b44505Smrg# a working winepath. Returns result in func_to_host_file_result. 343254b44505Smrgfunc_convert_path_nix_to_w32 () 343354b44505Smrg{ 34340a392d7eSmrg $debug_cmd 34350a392d7eSmrg 34360a392d7eSmrg func_to_host_path_result=$1 343754b44505Smrg if test -n "$1"; then 343854b44505Smrg # See func_convert_path_msys_to_w32: 343954b44505Smrg func_stripname : : "$1" 344054b44505Smrg func_to_host_path_tmp1=$func_stripname_result 344154b44505Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34420a392d7eSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 344354b44505Smrg func_convert_path_check : ";" \ 344454b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 344554b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 344654b44505Smrg fi 344754b44505Smrg} 344854b44505Smrg# end func_convert_path_nix_to_w32 34494a041c5bSmacallan 34504a041c5bSmacallan 345154b44505Smrg# func_convert_path_msys_to_cygwin ARG 345254b44505Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 345354b44505Smrg# Returns result in func_to_host_file_result. 345454b44505Smrgfunc_convert_path_msys_to_cygwin () 345554b44505Smrg{ 34560a392d7eSmrg $debug_cmd 34570a392d7eSmrg 34580a392d7eSmrg func_to_host_path_result=$1 345954b44505Smrg if test -n "$1"; then 346054b44505Smrg # See func_convert_path_msys_to_w32: 346154b44505Smrg func_stripname : : "$1" 346254b44505Smrg func_to_host_path_tmp1=$func_stripname_result 346354b44505Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 346454b44505Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34650a392d7eSmrg func_to_host_path_result=$func_cygpath_result 346654b44505Smrg func_convert_path_check : : \ 346754b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 346854b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 346954b44505Smrg fi 347054b44505Smrg} 347154b44505Smrg# end func_convert_path_msys_to_cygwin 34724a041c5bSmacallan 34734a041c5bSmacallan 347454b44505Smrg# func_convert_path_nix_to_cygwin ARG 347554b44505Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 347654b44505Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 347754b44505Smrg# func_to_host_file_result. 347854b44505Smrgfunc_convert_path_nix_to_cygwin () 347954b44505Smrg{ 34800a392d7eSmrg $debug_cmd 34810a392d7eSmrg 34820a392d7eSmrg func_to_host_path_result=$1 348354b44505Smrg if test -n "$1"; then 348454b44505Smrg # Remove leading and trailing path separator characters from 348554b44505Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 348654b44505Smrg # into '.;' and ';.', and winepath ignores them completely. 348754b44505Smrg func_stripname : : "$1" 348854b44505Smrg func_to_host_path_tmp1=$func_stripname_result 348954b44505Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 349054b44505Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34910a392d7eSmrg func_to_host_path_result=$func_cygpath_result 349254b44505Smrg func_convert_path_check : : \ 349354b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 349454b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 349554b44505Smrg fi 349654b44505Smrg} 349754b44505Smrg# end func_convert_path_nix_to_cygwin 34984a041c5bSmacallan 34994a041c5bSmacallan 35000a392d7eSmrg# func_dll_def_p FILE 35010a392d7eSmrg# True iff FILE is a Windows DLL '.def' file. 35020a392d7eSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35030a392d7eSmrgfunc_dll_def_p () 35040a392d7eSmrg{ 35050a392d7eSmrg $debug_cmd 35060a392d7eSmrg 35070a392d7eSmrg func_dll_def_p_tmp=`$SED -n \ 35080a392d7eSmrg -e 's/^[ ]*//' \ 35090a392d7eSmrg -e '/^\(;.*\)*$/d' \ 35100a392d7eSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35110a392d7eSmrg -e q \ 35120a392d7eSmrg "$1"` 35130a392d7eSmrg test DEF = "$func_dll_def_p_tmp" 35140a392d7eSmrg} 35150a392d7eSmrg 35160a392d7eSmrg 351754b44505Smrg# func_mode_compile arg... 351854b44505Smrgfunc_mode_compile () 351954b44505Smrg{ 35200a392d7eSmrg $debug_cmd 35210a392d7eSmrg 352254b44505Smrg # Get the compilation command and the source file. 352354b44505Smrg base_compile= 35240a392d7eSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 352554b44505Smrg suppress_opt=yes 352654b44505Smrg suppress_output= 352754b44505Smrg arg_mode=normal 352854b44505Smrg libobj= 352954b44505Smrg later= 353054b44505Smrg pie_flag= 353154b44505Smrg 353254b44505Smrg for arg 353354b44505Smrg do 353454b44505Smrg case $arg_mode in 353554b44505Smrg arg ) 353654b44505Smrg # do not "continue". Instead, add this to base_compile 35370a392d7eSmrg lastarg=$arg 353854b44505Smrg arg_mode=normal 353954b44505Smrg ;; 354054b44505Smrg 354154b44505Smrg target ) 35420a392d7eSmrg libobj=$arg 354354b44505Smrg arg_mode=normal 354454b44505Smrg continue 354554b44505Smrg ;; 354654b44505Smrg 354754b44505Smrg normal ) 354854b44505Smrg # Accept any command-line options. 354954b44505Smrg case $arg in 355054b44505Smrg -o) 355154b44505Smrg test -n "$libobj" && \ 35520a392d7eSmrg func_fatal_error "you cannot specify '-o' more than once" 355354b44505Smrg arg_mode=target 35544a041c5bSmacallan continue 35554a041c5bSmacallan ;; 355654b44505Smrg 355754b44505Smrg -pie | -fpie | -fPIE) 355854b44505Smrg func_append pie_flag " $arg" 35594a041c5bSmacallan continue 35604a041c5bSmacallan ;; 356154b44505Smrg 356254b44505Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 356354b44505Smrg func_append later " $arg" 35644a041c5bSmacallan continue 35654a041c5bSmacallan ;; 356654b44505Smrg 356754b44505Smrg -no-suppress) 356854b44505Smrg suppress_opt=no 35694a041c5bSmacallan continue 35704a041c5bSmacallan ;; 35714a041c5bSmacallan 357254b44505Smrg -Xcompiler) 357354b44505Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 357454b44505Smrg continue # The current "srcfile" will either be retained or 357554b44505Smrg ;; # replaced later. I would guess that would be a bug. 35764a041c5bSmacallan 357754b44505Smrg -Wc,*) 357854b44505Smrg func_stripname '-Wc,' '' "$arg" 357954b44505Smrg args=$func_stripname_result 358054b44505Smrg lastarg= 35810a392d7eSmrg save_ifs=$IFS; IFS=, 358254b44505Smrg for arg in $args; do 35830a392d7eSmrg IFS=$save_ifs 358454b44505Smrg func_append_quoted lastarg "$arg" 358554b44505Smrg done 35860a392d7eSmrg IFS=$save_ifs 358754b44505Smrg func_stripname ' ' '' "$lastarg" 358854b44505Smrg lastarg=$func_stripname_result 35894a041c5bSmacallan 359054b44505Smrg # Add the arguments to base_compile. 359154b44505Smrg func_append base_compile " $lastarg" 359254b44505Smrg continue 359354b44505Smrg ;; 35944a041c5bSmacallan 359554b44505Smrg *) 359654b44505Smrg # Accept the current argument as the source file. 359754b44505Smrg # The previous "srcfile" becomes the current argument. 359854b44505Smrg # 35990a392d7eSmrg lastarg=$srcfile 36000a392d7eSmrg srcfile=$arg 360154b44505Smrg ;; 360254b44505Smrg esac # case $arg 36034a041c5bSmacallan ;; 360454b44505Smrg esac # case $arg_mode 36054a041c5bSmacallan 360654b44505Smrg # Aesthetically quote the previous argument. 360754b44505Smrg func_append_quoted base_compile "$lastarg" 360854b44505Smrg done # for arg 36094a041c5bSmacallan 361054b44505Smrg case $arg_mode in 361154b44505Smrg arg) 361254b44505Smrg func_fatal_error "you must specify an argument for -Xcompile" 361354b44505Smrg ;; 361454b44505Smrg target) 36150a392d7eSmrg func_fatal_error "you must specify a target with '-o'" 361654b44505Smrg ;; 361754b44505Smrg *) 361854b44505Smrg # Get the name of the library object. 361954b44505Smrg test -z "$libobj" && { 362054b44505Smrg func_basename "$srcfile" 36210a392d7eSmrg libobj=$func_basename_result 362254b44505Smrg } 362354b44505Smrg ;; 362454b44505Smrg esac 36254a041c5bSmacallan 362654b44505Smrg # Recognize several different file suffixes. 362754b44505Smrg # If the user specifies -o file.o, it is replaced with file.lo 362854b44505Smrg case $libobj in 362954b44505Smrg *.[cCFSifmso] | \ 363054b44505Smrg *.ada | *.adb | *.ads | *.asm | \ 363154b44505Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36320a392d7eSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 363354b44505Smrg func_xform "$libobj" 363454b44505Smrg libobj=$func_xform_result 363554b44505Smrg ;; 363654b44505Smrg esac 36374a041c5bSmacallan 363854b44505Smrg case $libobj in 363954b44505Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 364054b44505Smrg *) 36410a392d7eSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 364254b44505Smrg ;; 364354b44505Smrg esac 36444a041c5bSmacallan 364554b44505Smrg func_infer_tag $base_compile 36464a041c5bSmacallan 364754b44505Smrg for arg in $later; do 364854b44505Smrg case $arg in 364954b44505Smrg -shared) 36500a392d7eSmrg test yes = "$build_libtool_libs" \ 36510a392d7eSmrg || func_fatal_configuration "cannot build a shared library" 365254b44505Smrg build_old_libs=no 36534a041c5bSmacallan continue 36544a041c5bSmacallan ;; 36554a041c5bSmacallan 365654b44505Smrg -static) 365754b44505Smrg build_libtool_libs=no 365854b44505Smrg build_old_libs=yes 36594a041c5bSmacallan continue 36604a041c5bSmacallan ;; 36614a041c5bSmacallan 366254b44505Smrg -prefer-pic) 366354b44505Smrg pic_mode=yes 36644a041c5bSmacallan continue 36654a041c5bSmacallan ;; 36664a041c5bSmacallan 366754b44505Smrg -prefer-non-pic) 366854b44505Smrg pic_mode=no 36694a041c5bSmacallan continue 36704a041c5bSmacallan ;; 367154b44505Smrg esac 367254b44505Smrg done 36734a041c5bSmacallan 36748fc2d0c6Smrg func_quote_arg pretty "$libobj" 36758fc2d0c6Smrg test "X$libobj" != "X$func_quote_arg_result" \ 367654b44505Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36770a392d7eSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 367854b44505Smrg func_dirname_and_basename "$obj" "/" "" 36790a392d7eSmrg objname=$func_basename_result 36800a392d7eSmrg xdir=$func_dirname_result 36810a392d7eSmrg lobj=$xdir$objdir/$objname 36824a041c5bSmacallan 368354b44505Smrg test -z "$base_compile" && \ 368454b44505Smrg func_fatal_help "you must specify a compilation command" 36854a041c5bSmacallan 368654b44505Smrg # Delete any leftover library objects. 36870a392d7eSmrg if test yes = "$build_old_libs"; then 368854b44505Smrg removelist="$obj $lobj $libobj ${libobj}T" 368954b44505Smrg else 369054b44505Smrg removelist="$lobj $libobj ${libobj}T" 369154b44505Smrg fi 36924a041c5bSmacallan 369354b44505Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 369454b44505Smrg case $host_os in 369554b44505Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 369654b44505Smrg pic_mode=default 369754b44505Smrg ;; 369854b44505Smrg esac 36990a392d7eSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 370054b44505Smrg # non-PIC code in shared libraries is not supported 370154b44505Smrg pic_mode=default 370254b44505Smrg fi 37034a041c5bSmacallan 370454b44505Smrg # Calculate the filename of the output object if compiler does 370554b44505Smrg # not support -o with -c 37060a392d7eSmrg if test no = "$compiler_c_o"; then 37070a392d7eSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37080a392d7eSmrg lockfile=$output_obj.lock 370954b44505Smrg else 371054b44505Smrg output_obj= 371154b44505Smrg need_locks=no 371254b44505Smrg lockfile= 371354b44505Smrg fi 37144a041c5bSmacallan 371554b44505Smrg # Lock this critical section if it is needed 371654b44505Smrg # We use this script file to make the link, it avoids creating a new file 37170a392d7eSmrg if test yes = "$need_locks"; then 371854b44505Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371954b44505Smrg func_echo "Waiting for $lockfile to be removed" 372054b44505Smrg sleep 2 372154b44505Smrg done 37220a392d7eSmrg elif test warn = "$need_locks"; then 372354b44505Smrg if test -f "$lockfile"; then 372454b44505Smrg $ECHO "\ 372554b44505Smrg*** ERROR, $lockfile exists and contains: 372654b44505Smrg`cat $lockfile 2>/dev/null` 37274a041c5bSmacallan 372854b44505SmrgThis indicates that another process is trying to use the same 372954b44505Smrgtemporary object file, and libtool could not work around it because 37300a392d7eSmrgyour compiler does not support '-c' and '-o' together. If you 373154b44505Smrgrepeat this compilation, it may succeed, by chance, but you had better 373254b44505Smrgavoid parallel builds (make -j) in this platform, or get a better 373354b44505Smrgcompiler." 37344a041c5bSmacallan 373554b44505Smrg $opt_dry_run || $RM $removelist 373654b44505Smrg exit $EXIT_FAILURE 373754b44505Smrg fi 373854b44505Smrg func_append removelist " $output_obj" 373954b44505Smrg $ECHO "$srcfile" > "$lockfile" 374054b44505Smrg fi 37414a041c5bSmacallan 374254b44505Smrg $opt_dry_run || $RM $removelist 374354b44505Smrg func_append removelist " $lockfile" 374454b44505Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37454a041c5bSmacallan 374654b44505Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 374754b44505Smrg srcfile=$func_to_tool_file_result 37488fc2d0c6Smrg func_quote_arg pretty "$srcfile" 37498fc2d0c6Smrg qsrcfile=$func_quote_arg_result 37504a041c5bSmacallan 375154b44505Smrg # Only build a PIC object if we are building libtool libraries. 37520a392d7eSmrg if test yes = "$build_libtool_libs"; then 375354b44505Smrg # Without this assignment, base_compile gets emptied. 375454b44505Smrg fbsd_hideous_sh_bug=$base_compile 37554a041c5bSmacallan 37560a392d7eSmrg if test no != "$pic_mode"; then 375754b44505Smrg command="$base_compile $qsrcfile $pic_flag" 375854b44505Smrg else 375954b44505Smrg # Don't build PIC code 376054b44505Smrg command="$base_compile $qsrcfile" 376154b44505Smrg fi 37624a041c5bSmacallan 376354b44505Smrg func_mkdir_p "$xdir$objdir" 37644a041c5bSmacallan 376554b44505Smrg if test -z "$output_obj"; then 376654b44505Smrg # Place PIC objects in $objdir 376754b44505Smrg func_append command " -o $lobj" 376854b44505Smrg fi 37694a041c5bSmacallan 377054b44505Smrg func_show_eval_locale "$command" \ 377154b44505Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37724a041c5bSmacallan 37730a392d7eSmrg if test warn = "$need_locks" && 377454b44505Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 377554b44505Smrg $ECHO "\ 377654b44505Smrg*** ERROR, $lockfile contains: 377754b44505Smrg`cat $lockfile 2>/dev/null` 37784a041c5bSmacallan 377954b44505Smrgbut it should contain: 378054b44505Smrg$srcfile 37814a041c5bSmacallan 378254b44505SmrgThis indicates that another process is trying to use the same 378354b44505Smrgtemporary object file, and libtool could not work around it because 37840a392d7eSmrgyour compiler does not support '-c' and '-o' together. If you 378554b44505Smrgrepeat this compilation, it may succeed, by chance, but you had better 378654b44505Smrgavoid parallel builds (make -j) in this platform, or get a better 378754b44505Smrgcompiler." 37884a041c5bSmacallan 378954b44505Smrg $opt_dry_run || $RM $removelist 379054b44505Smrg exit $EXIT_FAILURE 379154b44505Smrg fi 37924a041c5bSmacallan 379354b44505Smrg # Just move the object if needed, then go on to compile the next one 379454b44505Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 379554b44505Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 379654b44505Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 379754b44505Smrg fi 37984a041c5bSmacallan 379954b44505Smrg # Allow error messages only from the first compilation. 38000a392d7eSmrg if test yes = "$suppress_opt"; then 380154b44505Smrg suppress_output=' >/dev/null 2>&1' 380254b44505Smrg fi 380354b44505Smrg fi 38044a041c5bSmacallan 380554b44505Smrg # Only build a position-dependent object if we build old libraries. 38060a392d7eSmrg if test yes = "$build_old_libs"; then 38070a392d7eSmrg if test yes != "$pic_mode"; then 380854b44505Smrg # Don't build PIC code 380954b44505Smrg command="$base_compile $qsrcfile$pie_flag" 381054b44505Smrg else 381154b44505Smrg command="$base_compile $qsrcfile $pic_flag" 381254b44505Smrg fi 38130a392d7eSmrg if test yes = "$compiler_c_o"; then 381454b44505Smrg func_append command " -o $obj" 381554b44505Smrg fi 38164a041c5bSmacallan 381754b44505Smrg # Suppress compiler output if we already did a PIC compilation. 381854b44505Smrg func_append command "$suppress_output" 381954b44505Smrg func_show_eval_locale "$command" \ 382054b44505Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38214a041c5bSmacallan 38220a392d7eSmrg if test warn = "$need_locks" && 382354b44505Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 382454b44505Smrg $ECHO "\ 382554b44505Smrg*** ERROR, $lockfile contains: 382654b44505Smrg`cat $lockfile 2>/dev/null` 38274a041c5bSmacallan 382854b44505Smrgbut it should contain: 382954b44505Smrg$srcfile 38304a041c5bSmacallan 383154b44505SmrgThis indicates that another process is trying to use the same 383254b44505Smrgtemporary object file, and libtool could not work around it because 38330a392d7eSmrgyour compiler does not support '-c' and '-o' together. If you 383454b44505Smrgrepeat this compilation, it may succeed, by chance, but you had better 383554b44505Smrgavoid parallel builds (make -j) in this platform, or get a better 383654b44505Smrgcompiler." 38374a041c5bSmacallan 383854b44505Smrg $opt_dry_run || $RM $removelist 383954b44505Smrg exit $EXIT_FAILURE 384054b44505Smrg fi 38414a041c5bSmacallan 384254b44505Smrg # Just move the object if needed 384354b44505Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 384454b44505Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 384554b44505Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 384654b44505Smrg fi 384754b44505Smrg fi 38484a041c5bSmacallan 384954b44505Smrg $opt_dry_run || { 385054b44505Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38514a041c5bSmacallan 385254b44505Smrg # Unlock the critical section if it was locked 38530a392d7eSmrg if test no != "$need_locks"; then 385454b44505Smrg removelist=$lockfile 385554b44505Smrg $RM "$lockfile" 385654b44505Smrg fi 385754b44505Smrg } 38584a041c5bSmacallan 385954b44505Smrg exit $EXIT_SUCCESS 386054b44505Smrg} 38614a041c5bSmacallan 386254b44505Smrg$opt_help || { 38630a392d7eSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 386454b44505Smrg} 38654a041c5bSmacallan 386654b44505Smrgfunc_mode_help () 386754b44505Smrg{ 386854b44505Smrg # We need to display help for each of the modes. 386954b44505Smrg case $opt_mode in 387054b44505Smrg "") 387154b44505Smrg # Generic help is extracted from the usage comments 387254b44505Smrg # at the start of this file. 387354b44505Smrg func_help 387454b44505Smrg ;; 38754a041c5bSmacallan 387654b44505Smrg clean) 387754b44505Smrg $ECHO \ 387854b44505Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38794a041c5bSmacallan 388054b44505SmrgRemove files from the build directory. 38814a041c5bSmacallan 388254b44505SmrgRM is the name of the program to use to delete files associated with each FILE 38830a392d7eSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 388454b44505Smrgto RM. 38854a041c5bSmacallan 388654b44505SmrgIf FILE is a libtool library, object or program, all the files associated 388754b44505Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 388854b44505Smrg ;; 38894a041c5bSmacallan 389054b44505Smrg compile) 389154b44505Smrg $ECHO \ 389254b44505Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38934a041c5bSmacallan 389454b44505SmrgCompile a source file into a libtool library object. 38954a041c5bSmacallan 389654b44505SmrgThis mode accepts the following additional options: 38974a041c5bSmacallan 389854b44505Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 389954b44505Smrg -no-suppress do not suppress compiler output for multiple passes 390054b44505Smrg -prefer-pic try to build PIC objects only 390154b44505Smrg -prefer-non-pic try to build non-PIC objects only 39020a392d7eSmrg -shared do not build a '.o' file suitable for static linking 39030a392d7eSmrg -static only build a '.o' file suitable for static linking 39048fc2d0c6Smrg -Wc,FLAG 39058fc2d0c6Smrg -Xcompiler FLAG pass FLAG directly to the compiler 39064a041c5bSmacallan 39070a392d7eSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 390854b44505Smrgfrom the given SOURCEFILE. 39094a041c5bSmacallan 391054b44505SmrgThe output file name is determined by removing the directory component from 39110a392d7eSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39120a392d7eSmrglibrary object suffix, '.lo'." 391354b44505Smrg ;; 39144a041c5bSmacallan 391554b44505Smrg execute) 391654b44505Smrg $ECHO \ 391754b44505Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39184a041c5bSmacallan 391954b44505SmrgAutomatically set library path, then run a program. 39204a041c5bSmacallan 392154b44505SmrgThis mode accepts the following additional options: 39224a041c5bSmacallan 392354b44505Smrg -dlopen FILE add the directory containing FILE to the library path 39244a041c5bSmacallan 39250a392d7eSmrgThis mode sets the library path environment variable according to '-dlopen' 392654b44505Smrgflags. 39274a041c5bSmacallan 392854b44505SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 392954b44505Smrginto their corresponding uninstalled binary, and any of their required library 393054b44505Smrgdirectories are added to the library path. 39314a041c5bSmacallan 393254b44505SmrgThen, COMMAND is executed, with ARGS as arguments." 393354b44505Smrg ;; 39344a041c5bSmacallan 393554b44505Smrg finish) 393654b44505Smrg $ECHO \ 393754b44505Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39384a041c5bSmacallan 393954b44505SmrgComplete the installation of libtool libraries. 394054b44505Smrg 394154b44505SmrgEach LIBDIR is a directory that contains libtool libraries. 394254b44505Smrg 394354b44505SmrgThe commands that this mode executes may require superuser privileges. Use 39440a392d7eSmrgthe '--dry-run' option if you just want to see what would be executed." 394554b44505Smrg ;; 394654b44505Smrg 394754b44505Smrg install) 394854b44505Smrg $ECHO \ 394954b44505Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 395054b44505Smrg 395154b44505SmrgInstall executables or libraries. 395254b44505Smrg 395354b44505SmrgINSTALL-COMMAND is the installation command. The first component should be 39540a392d7eSmrgeither the 'install' or 'cp' program. 395554b44505Smrg 395654b44505SmrgThe following components of INSTALL-COMMAND are treated specially: 395754b44505Smrg 395854b44505Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 395954b44505Smrg 396054b44505SmrgThe rest of the components are interpreted as arguments to that command (only 396154b44505SmrgBSD-compatible install options are recognized)." 396254b44505Smrg ;; 396354b44505Smrg 396454b44505Smrg link) 396554b44505Smrg $ECHO \ 396654b44505Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 396754b44505Smrg 396854b44505SmrgLink object files or libraries together to form another library, or to 396954b44505Smrgcreate an executable program. 397054b44505Smrg 397154b44505SmrgLINK-COMMAND is a command using the C compiler that you would use to create 397254b44505Smrga program from several object files. 397354b44505Smrg 397454b44505SmrgThe following components of LINK-COMMAND are treated specially: 397554b44505Smrg 397654b44505Smrg -all-static do not do any dynamic linking at all 397754b44505Smrg -avoid-version do not add a version suffix if possible 397854b44505Smrg -bindir BINDIR specify path to binaries directory (for systems where 397954b44505Smrg libraries must be found in the PATH setting at runtime) 39800a392d7eSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 398154b44505Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 398254b44505Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 398354b44505Smrg -export-symbols SYMFILE 398454b44505Smrg try to export only the symbols listed in SYMFILE 398554b44505Smrg -export-symbols-regex REGEX 398654b44505Smrg try to export only the symbols matching REGEX 398754b44505Smrg -LLIBDIR search LIBDIR for required installed libraries 398854b44505Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 398954b44505Smrg -module build a library that can dlopened 399054b44505Smrg -no-fast-install disable the fast-install mode 399154b44505Smrg -no-install link a not-installable executable 399254b44505Smrg -no-undefined declare that a library does not refer to external symbols 399354b44505Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39940a392d7eSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39950a392d7eSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 399654b44505Smrg -precious-files-regex REGEX 399754b44505Smrg don't remove output files matching REGEX 399854b44505Smrg -release RELEASE specify package release information 399954b44505Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 400054b44505Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 400154b44505Smrg -shared only do dynamic linking of libtool libraries 400254b44505Smrg -shrext SUFFIX override the standard shared library file extension 400354b44505Smrg -static do not do any dynamic linking of uninstalled libtool libraries 400454b44505Smrg -static-libtool-libs 400554b44505Smrg do not do any dynamic linking of libtool libraries 400654b44505Smrg -version-info CURRENT[:REVISION[:AGE]] 400754b44505Smrg specify library version info [each variable defaults to 0] 400854b44505Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 400954b44505Smrg -Wc,FLAG 401054b44505Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40118fc2d0c6Smrg -Wa,FLAG 40128fc2d0c6Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 401354b44505Smrg -Wl,FLAG 401454b44505Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 401554b44505Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 401654b44505Smrg 40170a392d7eSmrgAll other options (arguments beginning with '-') are ignored. 401854b44505Smrg 40190a392d7eSmrgEvery other argument is treated as a filename. Files ending in '.la' are 402054b44505Smrgtreated as uninstalled libtool libraries, other files are standard or library 402154b44505Smrgobject files. 402254b44505Smrg 40230a392d7eSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40240a392d7eSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 402554b44505Smrgrequired, except when creating a convenience library. 402654b44505Smrg 40270a392d7eSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40280a392d7eSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 402954b44505Smrg 40300a392d7eSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 403154b44505Smrgis created, otherwise an executable program is created." 403254b44505Smrg ;; 403354b44505Smrg 403454b44505Smrg uninstall) 403554b44505Smrg $ECHO \ 403654b44505Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 403754b44505Smrg 403854b44505SmrgRemove libraries from an installation directory. 403954b44505Smrg 404054b44505SmrgRM is the name of the program to use to delete files associated with each FILE 40410a392d7eSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 404254b44505Smrgto RM. 404354b44505Smrg 404454b44505SmrgIf FILE is a libtool library, all the files associated with it are deleted. 404554b44505SmrgOtherwise, only FILE itself is deleted using RM." 404654b44505Smrg ;; 404754b44505Smrg 404854b44505Smrg *) 40490a392d7eSmrg func_fatal_help "invalid operation mode '$opt_mode'" 405054b44505Smrg ;; 40514a041c5bSmacallan esac 40524a041c5bSmacallan 405354b44505Smrg echo 40540a392d7eSmrg $ECHO "Try '$progname --help' for more information about other modes." 405554b44505Smrg} 40564a041c5bSmacallan 405754b44505Smrg# Now that we've collected a possible --mode arg, show help if necessary 405854b44505Smrgif $opt_help; then 40590a392d7eSmrg if test : = "$opt_help"; then 406054b44505Smrg func_mode_help 406154b44505Smrg else 406254b44505Smrg { 406354b44505Smrg func_help noexit 406454b44505Smrg for opt_mode in compile link execute install finish uninstall clean; do 406554b44505Smrg func_mode_help 406654b44505Smrg done 40670a392d7eSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 406854b44505Smrg { 406954b44505Smrg func_help noexit 407054b44505Smrg for opt_mode in compile link execute install finish uninstall clean; do 407154b44505Smrg echo 407254b44505Smrg func_mode_help 407354b44505Smrg done 407454b44505Smrg } | 40750a392d7eSmrg $SED '1d 407654b44505Smrg /^When reporting/,/^Report/{ 407754b44505Smrg H 407854b44505Smrg d 407954b44505Smrg } 408054b44505Smrg $x 408154b44505Smrg /information about other modes/d 408254b44505Smrg /more detailed .*MODE/d 408354b44505Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 408454b44505Smrg fi 408554b44505Smrg exit $? 408654b44505Smrgfi 40874a041c5bSmacallan 40884a041c5bSmacallan 408954b44505Smrg# func_mode_execute arg... 409054b44505Smrgfunc_mode_execute () 409154b44505Smrg{ 40920a392d7eSmrg $debug_cmd 40930a392d7eSmrg 409454b44505Smrg # The first argument is the command name. 40950a392d7eSmrg cmd=$nonopt 409654b44505Smrg test -z "$cmd" && \ 409754b44505Smrg func_fatal_help "you must specify a COMMAND" 409854b44505Smrg 409954b44505Smrg # Handle -dlopen flags immediately. 410054b44505Smrg for file in $opt_dlopen; do 410154b44505Smrg test -f "$file" \ 41020a392d7eSmrg || func_fatal_help "'$file' is not a file" 410354b44505Smrg 410454b44505Smrg dir= 410554b44505Smrg case $file in 410654b44505Smrg *.la) 410754b44505Smrg func_resolve_sysroot "$file" 410854b44505Smrg file=$func_resolve_sysroot_result 410954b44505Smrg 411054b44505Smrg # Check to see that this really is a libtool archive. 411154b44505Smrg func_lalib_unsafe_p "$file" \ 41120a392d7eSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 411354b44505Smrg 411454b44505Smrg # Read the libtool library. 411554b44505Smrg dlname= 411654b44505Smrg library_names= 411754b44505Smrg func_source "$file" 411854b44505Smrg 411954b44505Smrg # Skip this library if it cannot be dlopened. 412054b44505Smrg if test -z "$dlname"; then 412154b44505Smrg # Warn if it was a shared library. 412254b44505Smrg test -n "$library_names" && \ 41230a392d7eSmrg func_warning "'$file' was not linked with '-export-dynamic'" 412454b44505Smrg continue 412554b44505Smrg fi 412654b44505Smrg 412754b44505Smrg func_dirname "$file" "" "." 41280a392d7eSmrg dir=$func_dirname_result 412954b44505Smrg 413054b44505Smrg if test -f "$dir/$objdir/$dlname"; then 413154b44505Smrg func_append dir "/$objdir" 413254b44505Smrg else 413354b44505Smrg if test ! -f "$dir/$dlname"; then 41340a392d7eSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 413554b44505Smrg fi 413654b44505Smrg fi 41374a041c5bSmacallan ;; 413854b44505Smrg 413954b44505Smrg *.lo) 414054b44505Smrg # Just add the directory containing the .lo file. 414154b44505Smrg func_dirname "$file" "" "." 41420a392d7eSmrg dir=$func_dirname_result 41434a041c5bSmacallan ;; 414454b44505Smrg 414554b44505Smrg *) 41460a392d7eSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 414754b44505Smrg continue 41484a041c5bSmacallan ;; 414954b44505Smrg esac 415054b44505Smrg 415154b44505Smrg # Get the absolute pathname. 415254b44505Smrg absdir=`cd "$dir" && pwd` 41530a392d7eSmrg test -n "$absdir" && dir=$absdir 415454b44505Smrg 415554b44505Smrg # Now add the directory to shlibpath_var. 415654b44505Smrg if eval "test -z \"\$$shlibpath_var\""; then 415754b44505Smrg eval "$shlibpath_var=\"\$dir\"" 415854b44505Smrg else 415954b44505Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41604a041c5bSmacallan fi 416154b44505Smrg done 416254b44505Smrg 416354b44505Smrg # This variable tells wrapper scripts just to set shlibpath_var 416454b44505Smrg # rather than running their programs. 41650a392d7eSmrg libtool_execute_magic=$magic 416654b44505Smrg 416754b44505Smrg # Check if any of the arguments is a wrapper script. 416854b44505Smrg args= 416954b44505Smrg for file 417054b44505Smrg do 417154b44505Smrg case $file in 417254b44505Smrg -* | *.la | *.lo ) ;; 417354b44505Smrg *) 417454b44505Smrg # Do a test to see if this is really a libtool program. 417554b44505Smrg if func_ltwrapper_script_p "$file"; then 417654b44505Smrg func_source "$file" 417754b44505Smrg # Transform arg to wrapped name. 41780a392d7eSmrg file=$progdir/$program 417954b44505Smrg elif func_ltwrapper_executable_p "$file"; then 418054b44505Smrg func_ltwrapper_scriptname "$file" 418154b44505Smrg func_source "$func_ltwrapper_scriptname_result" 418254b44505Smrg # Transform arg to wrapped name. 41830a392d7eSmrg file=$progdir/$program 418454b44505Smrg fi 418554b44505Smrg ;; 418654b44505Smrg esac 418754b44505Smrg # Quote arguments (to preserve shell metacharacters). 418854b44505Smrg func_append_quoted args "$file" 418954b44505Smrg done 419054b44505Smrg 41910a392d7eSmrg if $opt_dry_run; then 41920a392d7eSmrg # Display what would be done. 41930a392d7eSmrg if test -n "$shlibpath_var"; then 41940a392d7eSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41950a392d7eSmrg echo "export $shlibpath_var" 41960a392d7eSmrg fi 41970a392d7eSmrg $ECHO "$cmd$args" 41980a392d7eSmrg exit $EXIT_SUCCESS 41990a392d7eSmrg else 420054b44505Smrg if test -n "$shlibpath_var"; then 420154b44505Smrg # Export the shlibpath_var. 420254b44505Smrg eval "export $shlibpath_var" 42034a041c5bSmacallan fi 420454b44505Smrg 420554b44505Smrg # Restore saved environment variables 420654b44505Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 420754b44505Smrg do 420854b44505Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 420954b44505Smrg $lt_var=\$save_$lt_var; export $lt_var 421054b44505Smrg else 421154b44505Smrg $lt_unset $lt_var 421254b44505Smrg fi" 421354b44505Smrg done 421454b44505Smrg 421554b44505Smrg # Now prepare to actually exec the command. 42160a392d7eSmrg exec_cmd=\$cmd$args 421754b44505Smrg fi 421854b44505Smrg} 42194a041c5bSmacallan 42200a392d7eSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42214a041c5bSmacallan 42224a041c5bSmacallan 422354b44505Smrg# func_mode_finish arg... 422454b44505Smrgfunc_mode_finish () 422554b44505Smrg{ 42260a392d7eSmrg $debug_cmd 42270a392d7eSmrg 422854b44505Smrg libs= 422954b44505Smrg libdirs= 423054b44505Smrg admincmds= 42314a041c5bSmacallan 423254b44505Smrg for opt in "$nonopt" ${1+"$@"} 423354b44505Smrg do 423454b44505Smrg if test -d "$opt"; then 423554b44505Smrg func_append libdirs " $opt" 42364a041c5bSmacallan 423754b44505Smrg elif test -f "$opt"; then 423854b44505Smrg if func_lalib_unsafe_p "$opt"; then 423954b44505Smrg func_append libs " $opt" 424054b44505Smrg else 42410a392d7eSmrg func_warning "'$opt' is not a valid libtool archive" 42424a041c5bSmacallan fi 42434a041c5bSmacallan 424454b44505Smrg else 42450a392d7eSmrg func_fatal_error "invalid argument '$opt'" 424654b44505Smrg fi 424754b44505Smrg done 42484a041c5bSmacallan 424954b44505Smrg if test -n "$libs"; then 425054b44505Smrg if test -n "$lt_sysroot"; then 425154b44505Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 425254b44505Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 425354b44505Smrg else 425454b44505Smrg sysroot_cmd= 425554b44505Smrg fi 42564a041c5bSmacallan 425754b44505Smrg # Remove sysroot references 425854b44505Smrg if $opt_dry_run; then 425954b44505Smrg for lib in $libs; do 42600a392d7eSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 426154b44505Smrg done 426254b44505Smrg else 426354b44505Smrg tmpdir=`func_mktempdir` 426454b44505Smrg for lib in $libs; do 42650a392d7eSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 426654b44505Smrg > $tmpdir/tmp-la 426754b44505Smrg mv -f $tmpdir/tmp-la $lib 42684a041c5bSmacallan done 426954b44505Smrg ${RM}r "$tmpdir" 427054b44505Smrg fi 427154b44505Smrg fi 427254b44505Smrg 427354b44505Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 427454b44505Smrg for libdir in $libdirs; do 427554b44505Smrg if test -n "$finish_cmds"; then 427654b44505Smrg # Do each command in the finish commands. 427754b44505Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 427854b44505Smrg'"$cmd"'"' 42794a041c5bSmacallan fi 428054b44505Smrg if test -n "$finish_eval"; then 428154b44505Smrg # Do the single finish_eval. 428254b44505Smrg eval cmds=\"$finish_eval\" 428354b44505Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 428454b44505Smrg $cmds" 428554b44505Smrg fi 428654b44505Smrg done 428754b44505Smrg fi 42884a041c5bSmacallan 428954b44505Smrg # Exit here if they wanted silent mode. 42900a392d7eSmrg $opt_quiet && exit $EXIT_SUCCESS 42914a041c5bSmacallan 429254b44505Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 429354b44505Smrg echo "----------------------------------------------------------------------" 429454b44505Smrg echo "Libraries have been installed in:" 429554b44505Smrg for libdir in $libdirs; do 429654b44505Smrg $ECHO " $libdir" 429754b44505Smrg done 429854b44505Smrg echo 429954b44505Smrg echo "If you ever happen to want to link against installed libraries" 430054b44505Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43010a392d7eSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 430254b44505Smrg echo "flag during linking and do at least one of the following:" 430354b44505Smrg if test -n "$shlibpath_var"; then 43040a392d7eSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 430554b44505Smrg echo " during execution" 430654b44505Smrg fi 430754b44505Smrg if test -n "$runpath_var"; then 43080a392d7eSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 430954b44505Smrg echo " during linking" 431054b44505Smrg fi 431154b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 431254b44505Smrg libdir=LIBDIR 431354b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 431454b44505Smrg 43150a392d7eSmrg $ECHO " - use the '$flag' linker flag" 431654b44505Smrg fi 431754b44505Smrg if test -n "$admincmds"; then 431854b44505Smrg $ECHO " - have your system administrator run these commands:$admincmds" 431954b44505Smrg fi 432054b44505Smrg if test -f /etc/ld.so.conf; then 43210a392d7eSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 432254b44505Smrg fi 432354b44505Smrg echo 432454b44505Smrg 432554b44505Smrg echo "See any operating system documentation about shared libraries for" 432654b44505Smrg case $host in 432754b44505Smrg solaris2.[6789]|solaris2.1[0-9]) 432854b44505Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 432954b44505Smrg echo "pages." 433054b44505Smrg ;; 43314a041c5bSmacallan *) 433254b44505Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43334a041c5bSmacallan ;; 433454b44505Smrg esac 433554b44505Smrg echo "----------------------------------------------------------------------" 433654b44505Smrg fi 433754b44505Smrg exit $EXIT_SUCCESS 433854b44505Smrg} 43394a041c5bSmacallan 43400a392d7eSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43414a041c5bSmacallan 434254b44505Smrg 434354b44505Smrg# func_mode_install arg... 434454b44505Smrgfunc_mode_install () 434554b44505Smrg{ 43460a392d7eSmrg $debug_cmd 43470a392d7eSmrg 434854b44505Smrg # There may be an optional sh(1) argument at the beginning of 434954b44505Smrg # install_prog (especially on Windows NT). 43500a392d7eSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 435154b44505Smrg # Allow the use of GNU shtool's install command. 43520a392d7eSmrg case $nonopt in *shtool*) :;; *) false;; esac 43530a392d7eSmrg then 435454b44505Smrg # Aesthetically quote it. 43558fc2d0c6Smrg func_quote_arg pretty "$nonopt" 43568fc2d0c6Smrg install_prog="$func_quote_arg_result " 435754b44505Smrg arg=$1 435854b44505Smrg shift 435954b44505Smrg else 436054b44505Smrg install_prog= 436154b44505Smrg arg=$nonopt 436254b44505Smrg fi 436354b44505Smrg 436454b44505Smrg # The real first argument should be the name of the installation program. 436554b44505Smrg # Aesthetically quote it. 43668fc2d0c6Smrg func_quote_arg pretty "$arg" 43678fc2d0c6Smrg func_append install_prog "$func_quote_arg_result" 436854b44505Smrg install_shared_prog=$install_prog 436954b44505Smrg case " $install_prog " in 437054b44505Smrg *[\\\ /]cp\ *) install_cp=: ;; 437154b44505Smrg *) install_cp=false ;; 437254b44505Smrg esac 437354b44505Smrg 437454b44505Smrg # We need to accept at least all the BSD install flags. 437554b44505Smrg dest= 437654b44505Smrg files= 437754b44505Smrg opts= 437854b44505Smrg prev= 437954b44505Smrg install_type= 43800a392d7eSmrg isdir=false 438154b44505Smrg stripme= 438254b44505Smrg no_mode=: 438354b44505Smrg for arg 438454b44505Smrg do 438554b44505Smrg arg2= 438654b44505Smrg if test -n "$dest"; then 438754b44505Smrg func_append files " $dest" 438854b44505Smrg dest=$arg 438954b44505Smrg continue 439054b44505Smrg fi 439154b44505Smrg 439254b44505Smrg case $arg in 43930a392d7eSmrg -d) isdir=: ;; 439454b44505Smrg -f) 439554b44505Smrg if $install_cp; then :; else 439654b44505Smrg prev=$arg 439754b44505Smrg fi 439854b44505Smrg ;; 439954b44505Smrg -g | -m | -o) 440054b44505Smrg prev=$arg 440154b44505Smrg ;; 440254b44505Smrg -s) 440354b44505Smrg stripme=" -s" 440454b44505Smrg continue 440554b44505Smrg ;; 440654b44505Smrg -*) 440754b44505Smrg ;; 440854b44505Smrg *) 440954b44505Smrg # If the previous option needed an argument, then skip it. 441054b44505Smrg if test -n "$prev"; then 44110a392d7eSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 441254b44505Smrg arg2=$install_override_mode 441354b44505Smrg no_mode=false 44144a041c5bSmacallan fi 441554b44505Smrg prev= 441654b44505Smrg else 441754b44505Smrg dest=$arg 44184a041c5bSmacallan continue 44194a041c5bSmacallan fi 442054b44505Smrg ;; 442154b44505Smrg esac 44224a041c5bSmacallan 442354b44505Smrg # Aesthetically quote the argument. 44248fc2d0c6Smrg func_quote_arg pretty "$arg" 44258fc2d0c6Smrg func_append install_prog " $func_quote_arg_result" 442654b44505Smrg if test -n "$arg2"; then 44278fc2d0c6Smrg func_quote_arg pretty "$arg2" 442854b44505Smrg fi 44298fc2d0c6Smrg func_append install_shared_prog " $func_quote_arg_result" 443054b44505Smrg done 44314a041c5bSmacallan 443254b44505Smrg test -z "$install_prog" && \ 443354b44505Smrg func_fatal_help "you must specify an install program" 44344a041c5bSmacallan 443554b44505Smrg test -n "$prev" && \ 44360a392d7eSmrg func_fatal_help "the '$prev' option requires an argument" 44374a041c5bSmacallan 443854b44505Smrg if test -n "$install_override_mode" && $no_mode; then 443954b44505Smrg if $install_cp; then :; else 44408fc2d0c6Smrg func_quote_arg pretty "$install_override_mode" 44418fc2d0c6Smrg func_append install_shared_prog " -m $func_quote_arg_result" 444254b44505Smrg fi 444354b44505Smrg fi 44444a041c5bSmacallan 444554b44505Smrg if test -z "$files"; then 444654b44505Smrg if test -z "$dest"; then 444754b44505Smrg func_fatal_help "no file or destination specified" 444854b44505Smrg else 444954b44505Smrg func_fatal_help "you must specify a destination" 445054b44505Smrg fi 445154b44505Smrg fi 44524a041c5bSmacallan 445354b44505Smrg # Strip any trailing slash from the destination. 445454b44505Smrg func_stripname '' '/' "$dest" 445554b44505Smrg dest=$func_stripname_result 44564a041c5bSmacallan 445754b44505Smrg # Check to see that the destination is a directory. 44580a392d7eSmrg test -d "$dest" && isdir=: 44590a392d7eSmrg if $isdir; then 44600a392d7eSmrg destdir=$dest 446154b44505Smrg destname= 446254b44505Smrg else 446354b44505Smrg func_dirname_and_basename "$dest" "" "." 44640a392d7eSmrg destdir=$func_dirname_result 44650a392d7eSmrg destname=$func_basename_result 44664a041c5bSmacallan 446754b44505Smrg # Not a directory, so check to see that there is only one file specified. 446854b44505Smrg set dummy $files; shift 446954b44505Smrg test "$#" -gt 1 && \ 44700a392d7eSmrg func_fatal_help "'$dest' is not a directory" 447154b44505Smrg fi 447254b44505Smrg case $destdir in 447354b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 447454b44505Smrg *) 447554b44505Smrg for file in $files; do 447654b44505Smrg case $file in 447754b44505Smrg *.lo) ;; 447854b44505Smrg *) 44790a392d7eSmrg func_fatal_help "'$destdir' must be an absolute directory name" 448054b44505Smrg ;; 448154b44505Smrg esac 448254b44505Smrg done 448354b44505Smrg ;; 448454b44505Smrg esac 44854a041c5bSmacallan 448654b44505Smrg # This variable tells wrapper scripts just to set variables rather 448754b44505Smrg # than running their programs. 44880a392d7eSmrg libtool_install_magic=$magic 44894a041c5bSmacallan 449054b44505Smrg staticlibs= 449154b44505Smrg future_libdirs= 449254b44505Smrg current_libdirs= 449354b44505Smrg for file in $files; do 44944a041c5bSmacallan 449554b44505Smrg # Do each installation. 449654b44505Smrg case $file in 449754b44505Smrg *.$libext) 449854b44505Smrg # Do the static libraries later. 449954b44505Smrg func_append staticlibs " $file" 450054b44505Smrg ;; 45014a041c5bSmacallan 450254b44505Smrg *.la) 450354b44505Smrg func_resolve_sysroot "$file" 450454b44505Smrg file=$func_resolve_sysroot_result 45054a041c5bSmacallan 450654b44505Smrg # Check to see that this really is a libtool archive. 450754b44505Smrg func_lalib_unsafe_p "$file" \ 45080a392d7eSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45094a041c5bSmacallan 451054b44505Smrg library_names= 451154b44505Smrg old_library= 451254b44505Smrg relink_command= 451354b44505Smrg func_source "$file" 45144a041c5bSmacallan 451554b44505Smrg # Add the libdir to current_libdirs if it is the destination. 451654b44505Smrg if test "X$destdir" = "X$libdir"; then 451754b44505Smrg case "$current_libdirs " in 451854b44505Smrg *" $libdir "*) ;; 451954b44505Smrg *) func_append current_libdirs " $libdir" ;; 452054b44505Smrg esac 452154b44505Smrg else 452254b44505Smrg # Note the libdir as a future libdir. 452354b44505Smrg case "$future_libdirs " in 452454b44505Smrg *" $libdir "*) ;; 452554b44505Smrg *) func_append future_libdirs " $libdir" ;; 452654b44505Smrg esac 452754b44505Smrg fi 45284a041c5bSmacallan 452954b44505Smrg func_dirname "$file" "/" "" 45300a392d7eSmrg dir=$func_dirname_result 453154b44505Smrg func_append dir "$objdir" 45324a041c5bSmacallan 453354b44505Smrg if test -n "$relink_command"; then 453454b44505Smrg # Determine the prefix the user has applied to our future dir. 453554b44505Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45364a041c5bSmacallan 453754b44505Smrg # Don't allow the user to place us outside of our expected 453854b44505Smrg # location b/c this prevents finding dependent libraries that 453954b44505Smrg # are installed to the same prefix. 454054b44505Smrg # At present, this check doesn't affect windows .dll's that 454154b44505Smrg # are installed into $libdir/../bin (currently, that works fine) 454254b44505Smrg # but it's something to keep an eye on. 454354b44505Smrg test "$inst_prefix_dir" = "$destdir" && \ 45440a392d7eSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 454554b44505Smrg 454654b44505Smrg if test -n "$inst_prefix_dir"; then 454754b44505Smrg # Stick the inst_prefix_dir data into the link command. 454854b44505Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45494a041c5bSmacallan else 455054b44505Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45514a041c5bSmacallan fi 45524a041c5bSmacallan 45530a392d7eSmrg func_warning "relinking '$file'" 455454b44505Smrg func_show_eval "$relink_command" \ 45550a392d7eSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 455654b44505Smrg fi 455754b44505Smrg 455854b44505Smrg # See the names of the shared library. 455954b44505Smrg set dummy $library_names; shift 456054b44505Smrg if test -n "$1"; then 45610a392d7eSmrg realname=$1 456254b44505Smrg shift 456354b44505Smrg 45640a392d7eSmrg srcname=$realname 45650a392d7eSmrg test -n "$relink_command" && srcname=${realname}T 456654b44505Smrg 456754b44505Smrg # Install the shared library and build the symlinks. 456854b44505Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 456954b44505Smrg 'exit $?' 45700a392d7eSmrg tstripme=$stripme 457154b44505Smrg case $host_os in 457254b44505Smrg cygwin* | mingw* | pw32* | cegcc*) 457354b44505Smrg case $realname in 457454b44505Smrg *.dll.a) 45750a392d7eSmrg tstripme= 45760a392d7eSmrg ;; 45770a392d7eSmrg esac 45780a392d7eSmrg ;; 45790a392d7eSmrg os2*) 45800a392d7eSmrg case $realname in 45810a392d7eSmrg *_dll.a) 45820a392d7eSmrg tstripme= 458354b44505Smrg ;; 458454b44505Smrg esac 458554b44505Smrg ;; 458654b44505Smrg esac 458754b44505Smrg if test -n "$tstripme" && test -n "$striplib"; then 458854b44505Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45894a041c5bSmacallan fi 45904a041c5bSmacallan 459154b44505Smrg if test "$#" -gt 0; then 459254b44505Smrg # Delete the old symlinks, and create new ones. 45930a392d7eSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 459454b44505Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 459554b44505Smrg # so we also need to try rm && ln -s. 459654b44505Smrg for linkname 459754b44505Smrg do 459854b44505Smrg test "$linkname" != "$realname" \ 459954b44505Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46004a041c5bSmacallan done 46014a041c5bSmacallan fi 46024a041c5bSmacallan 460354b44505Smrg # Do each command in the postinstall commands. 46040a392d7eSmrg lib=$destdir/$realname 460554b44505Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 460654b44505Smrg fi 46074a041c5bSmacallan 460854b44505Smrg # Install the pseudo-library for information purposes. 460954b44505Smrg func_basename "$file" 46100a392d7eSmrg name=$func_basename_result 46110a392d7eSmrg instname=$dir/${name}i 461254b44505Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46134a041c5bSmacallan 461454b44505Smrg # Maybe install the static library, too. 461554b44505Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 461654b44505Smrg ;; 461754b44505Smrg 461854b44505Smrg *.lo) 461954b44505Smrg # Install (i.e. copy) a libtool object. 462054b44505Smrg 462154b44505Smrg # Figure out destination file name, if it wasn't already specified. 462254b44505Smrg if test -n "$destname"; then 46230a392d7eSmrg destfile=$destdir/$destname 46244a041c5bSmacallan else 462554b44505Smrg func_basename "$file" 46260a392d7eSmrg destfile=$func_basename_result 46270a392d7eSmrg destfile=$destdir/$destfile 46284a041c5bSmacallan fi 462954b44505Smrg 463054b44505Smrg # Deduce the name of the destination old-style object file. 463154b44505Smrg case $destfile in 463254b44505Smrg *.lo) 463354b44505Smrg func_lo2o "$destfile" 463454b44505Smrg staticdest=$func_lo2o_result 463554b44505Smrg ;; 463654b44505Smrg *.$objext) 46370a392d7eSmrg staticdest=$destfile 463854b44505Smrg destfile= 463954b44505Smrg ;; 464054b44505Smrg *) 46410a392d7eSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46424a041c5bSmacallan ;; 46434a041c5bSmacallan esac 46444a041c5bSmacallan 464554b44505Smrg # Install the libtool object if requested. 464654b44505Smrg test -n "$destfile" && \ 464754b44505Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46484a041c5bSmacallan 464954b44505Smrg # Install the old object if enabled. 46500a392d7eSmrg if test yes = "$build_old_libs"; then 465154b44505Smrg # Deduce the name of the old-style object file. 465254b44505Smrg func_lo2o "$file" 465354b44505Smrg staticobj=$func_lo2o_result 465454b44505Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 465554b44505Smrg fi 465654b44505Smrg exit $EXIT_SUCCESS 465754b44505Smrg ;; 46584a041c5bSmacallan 465954b44505Smrg *) 466054b44505Smrg # Figure out destination file name, if it wasn't already specified. 466154b44505Smrg if test -n "$destname"; then 46620a392d7eSmrg destfile=$destdir/$destname 466354b44505Smrg else 466454b44505Smrg func_basename "$file" 46650a392d7eSmrg destfile=$func_basename_result 46660a392d7eSmrg destfile=$destdir/$destfile 466754b44505Smrg fi 46684a041c5bSmacallan 466954b44505Smrg # If the file is missing, and there is a .exe on the end, strip it 467054b44505Smrg # because it is most likely a libtool script we actually want to 467154b44505Smrg # install 46720a392d7eSmrg stripped_ext= 467354b44505Smrg case $file in 467454b44505Smrg *.exe) 467554b44505Smrg if test ! -f "$file"; then 467654b44505Smrg func_stripname '' '.exe' "$file" 467754b44505Smrg file=$func_stripname_result 46780a392d7eSmrg stripped_ext=.exe 467954b44505Smrg fi 468054b44505Smrg ;; 468154b44505Smrg esac 46824a041c5bSmacallan 468354b44505Smrg # Do a test to see if this is really a libtool program. 468454b44505Smrg case $host in 468554b44505Smrg *cygwin* | *mingw*) 468654b44505Smrg if func_ltwrapper_executable_p "$file"; then 468754b44505Smrg func_ltwrapper_scriptname "$file" 468854b44505Smrg wrapper=$func_ltwrapper_scriptname_result 468954b44505Smrg else 469054b44505Smrg func_stripname '' '.exe' "$file" 469154b44505Smrg wrapper=$func_stripname_result 469254b44505Smrg fi 469354b44505Smrg ;; 469454b44505Smrg *) 469554b44505Smrg wrapper=$file 469654b44505Smrg ;; 469754b44505Smrg esac 469854b44505Smrg if func_ltwrapper_script_p "$wrapper"; then 469954b44505Smrg notinst_deplibs= 470054b44505Smrg relink_command= 47014a041c5bSmacallan 470254b44505Smrg func_source "$wrapper" 47034a041c5bSmacallan 470454b44505Smrg # Check the variables that should have been set. 470554b44505Smrg test -z "$generated_by_libtool_version" && \ 47060a392d7eSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47074a041c5bSmacallan 47080a392d7eSmrg finalize=: 470954b44505Smrg for lib in $notinst_deplibs; do 471054b44505Smrg # Check to see that each library is installed. 471154b44505Smrg libdir= 471254b44505Smrg if test -f "$lib"; then 471354b44505Smrg func_source "$lib" 471454b44505Smrg fi 47150a392d7eSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 471654b44505Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47170a392d7eSmrg func_warning "'$lib' has not been installed in '$libdir'" 47180a392d7eSmrg finalize=false 471954b44505Smrg fi 472054b44505Smrg done 47214a041c5bSmacallan 472254b44505Smrg relink_command= 472354b44505Smrg func_source "$wrapper" 472454b44505Smrg 472554b44505Smrg outputname= 47260a392d7eSmrg if test no = "$fast_install" && test -n "$relink_command"; then 472754b44505Smrg $opt_dry_run || { 47280a392d7eSmrg if $finalize; then 472954b44505Smrg tmpdir=`func_mktempdir` 473054b44505Smrg func_basename "$file$stripped_ext" 47310a392d7eSmrg file=$func_basename_result 47320a392d7eSmrg outputname=$tmpdir/$file 473354b44505Smrg # Replace the output file specification. 473454b44505Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 473554b44505Smrg 47360a392d7eSmrg $opt_quiet || { 47378fc2d0c6Smrg func_quote_arg expand,pretty "$relink_command" 47388fc2d0c6Smrg eval "func_echo $func_quote_arg_result" 473954b44505Smrg } 474054b44505Smrg if eval "$relink_command"; then : 474154b44505Smrg else 47420a392d7eSmrg func_error "error: relink '$file' with the above command before installing it" 474354b44505Smrg $opt_dry_run || ${RM}r "$tmpdir" 474454b44505Smrg continue 474554b44505Smrg fi 47460a392d7eSmrg file=$outputname 474754b44505Smrg else 47480a392d7eSmrg func_warning "cannot relink '$file'" 474954b44505Smrg fi 475054b44505Smrg } 475154b44505Smrg else 475254b44505Smrg # Install the binary that we compiled earlier. 475354b44505Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 475454b44505Smrg fi 47554a041c5bSmacallan fi 475654b44505Smrg 475754b44505Smrg # remove .exe since cygwin /usr/bin/install will append another 475854b44505Smrg # one anyway 475954b44505Smrg case $install_prog,$host in 476054b44505Smrg */usr/bin/install*,*cygwin*) 476154b44505Smrg case $file:$destfile in 476254b44505Smrg *.exe:*.exe) 476354b44505Smrg # this is ok 476454b44505Smrg ;; 476554b44505Smrg *.exe:*) 476654b44505Smrg destfile=$destfile.exe 476754b44505Smrg ;; 476854b44505Smrg *:*.exe) 476954b44505Smrg func_stripname '' '.exe' "$destfile" 477054b44505Smrg destfile=$func_stripname_result 477154b44505Smrg ;; 477254b44505Smrg esac 477354b44505Smrg ;; 477454b44505Smrg esac 477554b44505Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 477654b44505Smrg $opt_dry_run || if test -n "$outputname"; then 477754b44505Smrg ${RM}r "$tmpdir" 47784a041c5bSmacallan fi 47794a041c5bSmacallan ;; 47804a041c5bSmacallan esac 478154b44505Smrg done 47824a041c5bSmacallan 478354b44505Smrg for file in $staticlibs; do 478454b44505Smrg func_basename "$file" 47850a392d7eSmrg name=$func_basename_result 47864a041c5bSmacallan 478754b44505Smrg # Set up the ranlib parameters. 47880a392d7eSmrg oldlib=$destdir/$name 47890a392d7eSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47900a392d7eSmrg tool_oldlib=$func_to_tool_file_result 47914a041c5bSmacallan 479254b44505Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 479354b44505Smrg 479454b44505Smrg if test -n "$stripme" && test -n "$old_striplib"; then 47950a392d7eSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47964a041c5bSmacallan fi 47974a041c5bSmacallan 479854b44505Smrg # Do each command in the postinstall commands. 479954b44505Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 480054b44505Smrg done 48014a041c5bSmacallan 480254b44505Smrg test -n "$future_libdirs" && \ 48030a392d7eSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 48044a041c5bSmacallan 480554b44505Smrg if test -n "$current_libdirs"; then 480654b44505Smrg # Maybe just do a dry run. 480754b44505Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48080a392d7eSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 480954b44505Smrg else 481054b44505Smrg exit $EXIT_SUCCESS 481154b44505Smrg fi 481254b44505Smrg} 48134a041c5bSmacallan 48140a392d7eSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48154a041c5bSmacallan 48164a041c5bSmacallan 481754b44505Smrg# func_generate_dlsyms outputname originator pic_p 481854b44505Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 481954b44505Smrg# a dlpreopen symbol table. 482054b44505Smrgfunc_generate_dlsyms () 482154b44505Smrg{ 48220a392d7eSmrg $debug_cmd 48230a392d7eSmrg 48240a392d7eSmrg my_outputname=$1 48250a392d7eSmrg my_originator=$2 48260a392d7eSmrg my_pic_p=${3-false} 48270a392d7eSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 482854b44505Smrg my_dlsyms= 482954b44505Smrg 48300a392d7eSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 483154b44505Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48320a392d7eSmrg my_dlsyms=${my_outputname}S.c 483354b44505Smrg else 483454b44505Smrg func_error "not configured to extract global symbols from dlpreopened files" 483554b44505Smrg fi 483654b44505Smrg fi 48374a041c5bSmacallan 483854b44505Smrg if test -n "$my_dlsyms"; then 483954b44505Smrg case $my_dlsyms in 484054b44505Smrg "") ;; 484154b44505Smrg *.c) 484254b44505Smrg # Discover the nlist of each of the dlfiles. 48430a392d7eSmrg nlist=$output_objdir/$my_outputname.nm 48444a041c5bSmacallan 484554b44505Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48464a041c5bSmacallan 484754b44505Smrg # Parse the name list into a source file. 484854b44505Smrg func_verbose "creating $output_objdir/$my_dlsyms" 48494a041c5bSmacallan 485054b44505Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48510a392d7eSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48520a392d7eSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48534a041c5bSmacallan 485454b44505Smrg#ifdef __cplusplus 485554b44505Smrgextern \"C\" { 485654b44505Smrg#endif 48574a041c5bSmacallan 48580a392d7eSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 485954b44505Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 486054b44505Smrg#endif 48614a041c5bSmacallan 486254b44505Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48630a392d7eSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48640a392d7eSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 486554b44505Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 486654b44505Smrg# define LT_DLSYM_CONST 48670a392d7eSmrg#elif defined __osf__ 486854b44505Smrg/* This system does not cope well with relocations in const data. */ 486954b44505Smrg# define LT_DLSYM_CONST 487054b44505Smrg#else 487154b44505Smrg# define LT_DLSYM_CONST const 487254b44505Smrg#endif 48734a041c5bSmacallan 48740a392d7eSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48750a392d7eSmrg 487654b44505Smrg/* External symbol declarations for the compiler. */\ 487754b44505Smrg" 48784a041c5bSmacallan 48790a392d7eSmrg if test yes = "$dlself"; then 48800a392d7eSmrg func_verbose "generating symbol list for '$output'" 48814a041c5bSmacallan 488254b44505Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48834a041c5bSmacallan 488454b44505Smrg # Add our own program objects to the symbol list. 488554b44505Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 488654b44505Smrg for progfile in $progfiles; do 488754b44505Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48880a392d7eSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 488954b44505Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48904a041c5bSmacallan done 48914a041c5bSmacallan 489254b44505Smrg if test -n "$exclude_expsyms"; then 489354b44505Smrg $opt_dry_run || { 489454b44505Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 489554b44505Smrg eval '$MV "$nlist"T "$nlist"' 489654b44505Smrg } 489754b44505Smrg fi 48984a041c5bSmacallan 489954b44505Smrg if test -n "$export_symbols_regex"; then 490054b44505Smrg $opt_dry_run || { 490154b44505Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 490254b44505Smrg eval '$MV "$nlist"T "$nlist"' 490354b44505Smrg } 490454b44505Smrg fi 49054a041c5bSmacallan 490654b44505Smrg # Prepare the list of exported symbols 490754b44505Smrg if test -z "$export_symbols"; then 49080a392d7eSmrg export_symbols=$output_objdir/$outputname.exp 490954b44505Smrg $opt_dry_run || { 491054b44505Smrg $RM $export_symbols 49110a392d7eSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 491254b44505Smrg case $host in 491354b44505Smrg *cygwin* | *mingw* | *cegcc* ) 491454b44505Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 491554b44505Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 491654b44505Smrg ;; 491754b44505Smrg esac 491854b44505Smrg } 491954b44505Smrg else 492054b44505Smrg $opt_dry_run || { 49210a392d7eSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 492254b44505Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 492354b44505Smrg eval '$MV "$nlist"T "$nlist"' 492454b44505Smrg case $host in 492554b44505Smrg *cygwin* | *mingw* | *cegcc* ) 492654b44505Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 492754b44505Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 492854b44505Smrg ;; 492954b44505Smrg esac 493054b44505Smrg } 493154b44505Smrg fi 493254b44505Smrg fi 49334a041c5bSmacallan 493454b44505Smrg for dlprefile in $dlprefiles; do 49350a392d7eSmrg func_verbose "extracting global C symbols from '$dlprefile'" 493654b44505Smrg func_basename "$dlprefile" 49370a392d7eSmrg name=$func_basename_result 493854b44505Smrg case $host in 493954b44505Smrg *cygwin* | *mingw* | *cegcc* ) 494054b44505Smrg # if an import library, we need to obtain dlname 494154b44505Smrg if func_win32_import_lib_p "$dlprefile"; then 494254b44505Smrg func_tr_sh "$dlprefile" 494354b44505Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49440a392d7eSmrg dlprefile_dlbasename= 494554b44505Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 494654b44505Smrg # Use subshell, to avoid clobbering current variable values 494754b44505Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49480a392d7eSmrg if test -n "$dlprefile_dlname"; then 494954b44505Smrg func_basename "$dlprefile_dlname" 49500a392d7eSmrg dlprefile_dlbasename=$func_basename_result 495154b44505Smrg else 495254b44505Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 495354b44505Smrg $sharedlib_from_linklib_cmd "$dlprefile" 495454b44505Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 495554b44505Smrg fi 495654b44505Smrg fi 495754b44505Smrg $opt_dry_run || { 49580a392d7eSmrg if test -n "$dlprefile_dlbasename"; then 495954b44505Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 496054b44505Smrg else 496154b44505Smrg func_warning "Could not compute DLL name from $name" 496254b44505Smrg eval '$ECHO ": $name " >> "$nlist"' 496354b44505Smrg fi 496454b44505Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 496554b44505Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 496654b44505Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 496754b44505Smrg } 496854b44505Smrg else # not an import lib 496954b44505Smrg $opt_dry_run || { 497054b44505Smrg eval '$ECHO ": $name " >> "$nlist"' 497154b44505Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 497254b44505Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 497354b44505Smrg } 497454b44505Smrg fi 497554b44505Smrg ;; 497654b44505Smrg *) 497754b44505Smrg $opt_dry_run || { 497854b44505Smrg eval '$ECHO ": $name " >> "$nlist"' 497954b44505Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 498054b44505Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 498154b44505Smrg } 498254b44505Smrg ;; 498354b44505Smrg esac 498454b44505Smrg done 49854a041c5bSmacallan 498654b44505Smrg $opt_dry_run || { 498754b44505Smrg # Make sure we have at least an empty file. 498854b44505Smrg test -f "$nlist" || : > "$nlist" 49894a041c5bSmacallan 499054b44505Smrg if test -n "$exclude_expsyms"; then 499154b44505Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 499254b44505Smrg $MV "$nlist"T "$nlist" 499354b44505Smrg fi 49944a041c5bSmacallan 499554b44505Smrg # Try sorting and uniquifying the output. 499654b44505Smrg if $GREP -v "^: " < "$nlist" | 499754b44505Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 499854b44505Smrg sort -k 3 499954b44505Smrg else 500054b44505Smrg sort +2 500154b44505Smrg fi | 500254b44505Smrg uniq > "$nlist"S; then 500354b44505Smrg : 500454b44505Smrg else 500554b44505Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 500654b44505Smrg fi 50074a041c5bSmacallan 500854b44505Smrg if test -f "$nlist"S; then 500954b44505Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 501054b44505Smrg else 501154b44505Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 501254b44505Smrg fi 50134a041c5bSmacallan 50140a392d7eSmrg func_show_eval '$RM "${nlist}I"' 50150a392d7eSmrg if test -n "$global_symbol_to_import"; then 50160a392d7eSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50170a392d7eSmrg fi 50180a392d7eSmrg 501954b44505Smrg echo >> "$output_objdir/$my_dlsyms" "\ 502054b44505Smrg 502154b44505Smrg/* The mapping between symbol names and symbols. */ 502254b44505Smrgtypedef struct { 502354b44505Smrg const char *name; 502454b44505Smrg void *address; 502554b44505Smrg} lt_dlsymlist; 502654b44505Smrgextern LT_DLSYM_CONST lt_dlsymlist 50270a392d7eSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50280a392d7eSmrg" 50290a392d7eSmrg 50300a392d7eSmrg if test -s "$nlist"I; then 50310a392d7eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50320a392d7eSmrgstatic void lt_syminit(void) 50330a392d7eSmrg{ 50340a392d7eSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50350a392d7eSmrg for (; symbol->name; ++symbol) 50360a392d7eSmrg {" 50370a392d7eSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50380a392d7eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50390a392d7eSmrg } 50400a392d7eSmrg}" 50410a392d7eSmrg fi 50420a392d7eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 504354b44505SmrgLT_DLSYM_CONST lt_dlsymlist 504454b44505Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50450a392d7eSmrg{ {\"$my_originator\", (void *) 0}," 50460a392d7eSmrg 50470a392d7eSmrg if test -s "$nlist"I; then 50480a392d7eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50490a392d7eSmrg {\"@INIT@\", (void *) <_syminit}," 50500a392d7eSmrg fi 505154b44505Smrg 505254b44505Smrg case $need_lib_prefix in 505354b44505Smrg no) 505454b44505Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50554a041c5bSmacallan ;; 50564a041c5bSmacallan *) 505754b44505Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50584a041c5bSmacallan ;; 50594a041c5bSmacallan esac 506054b44505Smrg echo >> "$output_objdir/$my_dlsyms" "\ 506154b44505Smrg {0, (void *) 0} 506254b44505Smrg}; 50634a041c5bSmacallan 506454b44505Smrg/* This works around a problem in FreeBSD linker */ 506554b44505Smrg#ifdef FREEBSD_WORKAROUND 506654b44505Smrgstatic const void *lt_preloaded_setup() { 506754b44505Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 506854b44505Smrg} 506954b44505Smrg#endif 50704a041c5bSmacallan 507154b44505Smrg#ifdef __cplusplus 507254b44505Smrg} 507354b44505Smrg#endif\ 507454b44505Smrg" 507554b44505Smrg } # !$opt_dry_run 50764a041c5bSmacallan 507754b44505Smrg pic_flag_for_symtable= 507854b44505Smrg case "$compile_command " in 507954b44505Smrg *" -static "*) ;; 508054b44505Smrg *) 508154b44505Smrg case $host in 508254b44505Smrg # compiling the symbol table file with pic_flag works around 508354b44505Smrg # a FreeBSD bug that causes programs to crash when -lm is 508454b44505Smrg # linked before any other PIC object. But we must not use 508554b44505Smrg # pic_flag when linking with -static. The problem exists in 508654b44505Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50870a392d7eSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 508854b44505Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 508954b44505Smrg *-*-hpux*) 509054b44505Smrg pic_flag_for_symtable=" $pic_flag" ;; 509154b44505Smrg *) 50920a392d7eSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 509354b44505Smrg ;; 509454b44505Smrg esac 509554b44505Smrg ;; 509654b44505Smrg esac 509754b44505Smrg symtab_cflags= 509854b44505Smrg for arg in $LTCFLAGS; do 509954b44505Smrg case $arg in 510054b44505Smrg -pie | -fpie | -fPIE) ;; 510154b44505Smrg *) func_append symtab_cflags " $arg" ;; 51024a041c5bSmacallan esac 51034a041c5bSmacallan done 51044a041c5bSmacallan 510554b44505Smrg # Now compile the dynamic symbol file. 510654b44505Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51074a041c5bSmacallan 510854b44505Smrg # Clean up the generated files. 51090a392d7eSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51104a041c5bSmacallan 511154b44505Smrg # Transform the symbol file into the correct name. 51120a392d7eSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 511354b44505Smrg case $host in 511454b44505Smrg *cygwin* | *mingw* | *cegcc* ) 511554b44505Smrg if test -f "$output_objdir/$my_outputname.def"; then 511654b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511754b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511854b44505Smrg else 511954b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512054b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512154b44505Smrg fi 512254b44505Smrg ;; 512354b44505Smrg *) 512454b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512554b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512654b44505Smrg ;; 512754b44505Smrg esac 512854b44505Smrg ;; 512954b44505Smrg *) 51300a392d7eSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 513154b44505Smrg ;; 513254b44505Smrg esac 513354b44505Smrg else 513454b44505Smrg # We keep going just in case the user didn't refer to 513554b44505Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 513654b44505Smrg # really was required. 51374a041c5bSmacallan 513854b44505Smrg # Nullify the symbol file. 513954b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 514054b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 514154b44505Smrg fi 514254b44505Smrg} 51434a041c5bSmacallan 51440a392d7eSmrg# func_cygming_gnu_implib_p ARG 51450a392d7eSmrg# This predicate returns with zero status (TRUE) if 51460a392d7eSmrg# ARG is a GNU/binutils-style import library. Returns 51470a392d7eSmrg# with nonzero status (FALSE) otherwise. 51480a392d7eSmrgfunc_cygming_gnu_implib_p () 51490a392d7eSmrg{ 51500a392d7eSmrg $debug_cmd 51510a392d7eSmrg 51520a392d7eSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51530a392d7eSmrg 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)$'` 51540a392d7eSmrg test -n "$func_cygming_gnu_implib_tmp" 51550a392d7eSmrg} 51560a392d7eSmrg 51570a392d7eSmrg# func_cygming_ms_implib_p ARG 51580a392d7eSmrg# This predicate returns with zero status (TRUE) if 51590a392d7eSmrg# ARG is an MS-style import library. Returns 51600a392d7eSmrg# with nonzero status (FALSE) otherwise. 51610a392d7eSmrgfunc_cygming_ms_implib_p () 51620a392d7eSmrg{ 51630a392d7eSmrg $debug_cmd 51640a392d7eSmrg 51650a392d7eSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51660a392d7eSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51670a392d7eSmrg test -n "$func_cygming_ms_implib_tmp" 51680a392d7eSmrg} 51690a392d7eSmrg 517054b44505Smrg# func_win32_libid arg 517154b44505Smrg# return the library type of file 'arg' 517254b44505Smrg# 517354b44505Smrg# Need a lot of goo to handle *both* DLLs and import libs 517454b44505Smrg# Has to be a shell function in order to 'eat' the argument 517554b44505Smrg# that is supplied when $file_magic_command is called. 517654b44505Smrg# Despite the name, also deal with 64 bit binaries. 517754b44505Smrgfunc_win32_libid () 517854b44505Smrg{ 51790a392d7eSmrg $debug_cmd 51800a392d7eSmrg 51810a392d7eSmrg win32_libid_type=unknown 518254b44505Smrg win32_fileres=`file -L $1 2>/dev/null` 518354b44505Smrg case $win32_fileres in 518454b44505Smrg *ar\ archive\ import\ library*) # definitely import 518554b44505Smrg win32_libid_type="x86 archive import" 518654b44505Smrg ;; 518754b44505Smrg *ar\ archive*) # could be an import, or static 518854b44505Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 518954b44505Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 519054b44505Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51910a392d7eSmrg case $nm_interface in 51920a392d7eSmrg "MS dumpbin") 51930a392d7eSmrg if func_cygming_ms_implib_p "$1" || 51940a392d7eSmrg func_cygming_gnu_implib_p "$1" 51950a392d7eSmrg then 51960a392d7eSmrg win32_nmres=import 51970a392d7eSmrg else 51980a392d7eSmrg win32_nmres= 51990a392d7eSmrg fi 52000a392d7eSmrg ;; 52010a392d7eSmrg *) 52020a392d7eSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52030a392d7eSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52040a392d7eSmrg $SED -n -e ' 520554b44505Smrg 1,100{ 520654b44505Smrg / I /{ 52070a392d7eSmrg s|.*|import| 520854b44505Smrg p 520954b44505Smrg q 521054b44505Smrg } 521154b44505Smrg }'` 52120a392d7eSmrg ;; 52130a392d7eSmrg esac 521454b44505Smrg case $win32_nmres in 521554b44505Smrg import*) win32_libid_type="x86 archive import";; 521654b44505Smrg *) win32_libid_type="x86 archive static";; 521754b44505Smrg esac 521854b44505Smrg fi 521954b44505Smrg ;; 522054b44505Smrg *DLL*) 522154b44505Smrg win32_libid_type="x86 DLL" 522254b44505Smrg ;; 522354b44505Smrg *executable*) # but shell scripts are "executable" too... 522454b44505Smrg case $win32_fileres in 522554b44505Smrg *MS\ Windows\ PE\ Intel*) 522654b44505Smrg win32_libid_type="x86 DLL" 522754b44505Smrg ;; 522854b44505Smrg esac 522954b44505Smrg ;; 523054b44505Smrg esac 523154b44505Smrg $ECHO "$win32_libid_type" 523254b44505Smrg} 523354b44505Smrg 523454b44505Smrg# func_cygming_dll_for_implib ARG 523554b44505Smrg# 523654b44505Smrg# Platform-specific function to extract the 523754b44505Smrg# name of the DLL associated with the specified 523854b44505Smrg# import library ARG. 523954b44505Smrg# Invoked by eval'ing the libtool variable 524054b44505Smrg# $sharedlib_from_linklib_cmd 524154b44505Smrg# Result is available in the variable 524254b44505Smrg# $sharedlib_from_linklib_result 524354b44505Smrgfunc_cygming_dll_for_implib () 524454b44505Smrg{ 52450a392d7eSmrg $debug_cmd 52460a392d7eSmrg 524754b44505Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 524854b44505Smrg} 524954b44505Smrg 525054b44505Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 525154b44505Smrg# 525254b44505Smrg# The is the core of a fallback implementation of a 525354b44505Smrg# platform-specific function to extract the name of the 525454b44505Smrg# DLL associated with the specified import library LIBNAME. 525554b44505Smrg# 525654b44505Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 525754b44505Smrg# on the platform and compiler that created the implib. 525854b44505Smrg# 525954b44505Smrg# Echos the name of the DLL associated with the 526054b44505Smrg# specified import library. 526154b44505Smrgfunc_cygming_dll_for_implib_fallback_core () 526254b44505Smrg{ 52630a392d7eSmrg $debug_cmd 52640a392d7eSmrg 526554b44505Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 526654b44505Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 526754b44505Smrg $SED '/^Contents of section '"$match_literal"':/{ 526854b44505Smrg # Place marker at beginning of archive member dllname section 526954b44505Smrg s/.*/====MARK====/ 527054b44505Smrg p 527154b44505Smrg d 527254b44505Smrg } 527354b44505Smrg # These lines can sometimes be longer than 43 characters, but 527454b44505Smrg # are always uninteresting 527554b44505Smrg /:[ ]*file format pe[i]\{,1\}-/d 527654b44505Smrg /^In archive [^:]*:/d 527754b44505Smrg # Ensure marker is printed 527854b44505Smrg /^====MARK====/p 527954b44505Smrg # Remove all lines with less than 43 characters 528054b44505Smrg /^.\{43\}/!d 528154b44505Smrg # From remaining lines, remove first 43 characters 528254b44505Smrg s/^.\{43\}//' | 528354b44505Smrg $SED -n ' 528454b44505Smrg # Join marker and all lines until next marker into a single line 528554b44505Smrg /^====MARK====/ b para 528654b44505Smrg H 528754b44505Smrg $ b para 528854b44505Smrg b 528954b44505Smrg :para 529054b44505Smrg x 529154b44505Smrg s/\n//g 529254b44505Smrg # Remove the marker 529354b44505Smrg s/^====MARK====// 529454b44505Smrg # Remove trailing dots and whitespace 529554b44505Smrg s/[\. \t]*$// 529654b44505Smrg # Print 529754b44505Smrg /./p' | 529854b44505Smrg # we now have a list, one entry per line, of the stringified 529954b44505Smrg # contents of the appropriate section of all members of the 53000a392d7eSmrg # archive that possess that section. Heuristic: eliminate 53010a392d7eSmrg # all those that have a first or second character that is 530254b44505Smrg # a '.' (that is, objdump's representation of an unprintable 530354b44505Smrg # character.) This should work for all archives with less than 530454b44505Smrg # 0x302f exports -- but will fail for DLLs whose name actually 530554b44505Smrg # begins with a literal '.' or a single character followed by 530654b44505Smrg # a '.'. 530754b44505Smrg # 530854b44505Smrg # Of those that remain, print the first one. 530954b44505Smrg $SED -e '/^\./d;/^.\./d;q' 531054b44505Smrg} 531154b44505Smrg 531254b44505Smrg# func_cygming_dll_for_implib_fallback ARG 531354b44505Smrg# Platform-specific function to extract the 531454b44505Smrg# name of the DLL associated with the specified 531554b44505Smrg# import library ARG. 531654b44505Smrg# 531754b44505Smrg# This fallback implementation is for use when $DLLTOOL 531854b44505Smrg# does not support the --identify-strict option. 531954b44505Smrg# Invoked by eval'ing the libtool variable 532054b44505Smrg# $sharedlib_from_linklib_cmd 532154b44505Smrg# Result is available in the variable 532254b44505Smrg# $sharedlib_from_linklib_result 532354b44505Smrgfunc_cygming_dll_for_implib_fallback () 532454b44505Smrg{ 53250a392d7eSmrg $debug_cmd 53260a392d7eSmrg 53270a392d7eSmrg if func_cygming_gnu_implib_p "$1"; then 532854b44505Smrg # binutils import library 532954b44505Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53300a392d7eSmrg elif func_cygming_ms_implib_p "$1"; then 533154b44505Smrg # ms-generated import library 533254b44505Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 533354b44505Smrg else 533454b44505Smrg # unknown 53350a392d7eSmrg sharedlib_from_linklib_result= 533654b44505Smrg fi 533754b44505Smrg} 533854b44505Smrg 533954b44505Smrg 534054b44505Smrg# func_extract_an_archive dir oldlib 534154b44505Smrgfunc_extract_an_archive () 534254b44505Smrg{ 53430a392d7eSmrg $debug_cmd 53440a392d7eSmrg 53450a392d7eSmrg f_ex_an_ar_dir=$1; shift 53460a392d7eSmrg f_ex_an_ar_oldlib=$1 53470a392d7eSmrg if test yes = "$lock_old_archive_extraction"; then 534854b44505Smrg lockfile=$f_ex_an_ar_oldlib.lock 534954b44505Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 535054b44505Smrg func_echo "Waiting for $lockfile to be removed" 535154b44505Smrg sleep 2 53524a041c5bSmacallan done 535354b44505Smrg fi 535454b44505Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 535554b44505Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53560a392d7eSmrg if test yes = "$lock_old_archive_extraction"; then 535754b44505Smrg $opt_dry_run || rm -f "$lockfile" 535854b44505Smrg fi 535954b44505Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 536054b44505Smrg : 536154b44505Smrg else 536254b44505Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 536354b44505Smrg fi 536454b44505Smrg} 53654a041c5bSmacallan 536654b44505Smrg 536754b44505Smrg# func_extract_archives gentop oldlib ... 536854b44505Smrgfunc_extract_archives () 536954b44505Smrg{ 53700a392d7eSmrg $debug_cmd 53710a392d7eSmrg 53720a392d7eSmrg my_gentop=$1; shift 537354b44505Smrg my_oldlibs=${1+"$@"} 53740a392d7eSmrg my_oldobjs= 53750a392d7eSmrg my_xlib= 53760a392d7eSmrg my_xabs= 53770a392d7eSmrg my_xdir= 537854b44505Smrg 537954b44505Smrg for my_xlib in $my_oldlibs; do 538054b44505Smrg # Extract the objects. 538154b44505Smrg case $my_xlib in 53820a392d7eSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 538354b44505Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 538454b44505Smrg esac 538554b44505Smrg func_basename "$my_xlib" 53860a392d7eSmrg my_xlib=$func_basename_result 538754b44505Smrg my_xlib_u=$my_xlib 538854b44505Smrg while :; do 538954b44505Smrg case " $extracted_archives " in 539054b44505Smrg *" $my_xlib_u "*) 539154b44505Smrg func_arith $extracted_serial + 1 539254b44505Smrg extracted_serial=$func_arith_result 539354b44505Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 539454b44505Smrg *) break ;; 53954a041c5bSmacallan esac 53964a041c5bSmacallan done 539754b44505Smrg extracted_archives="$extracted_archives $my_xlib_u" 53980a392d7eSmrg my_xdir=$my_gentop/$my_xlib_u 53994a041c5bSmacallan 540054b44505Smrg func_mkdir_p "$my_xdir" 54014a041c5bSmacallan 540254b44505Smrg case $host in 540354b44505Smrg *-darwin*) 540454b44505Smrg func_verbose "Extracting $my_xabs" 540554b44505Smrg # Do not bother doing anything if just a dry run 540654b44505Smrg $opt_dry_run || { 540754b44505Smrg darwin_orig_dir=`pwd` 540854b44505Smrg cd $my_xdir || exit $? 540954b44505Smrg darwin_archive=$my_xabs 541054b44505Smrg darwin_curdir=`pwd` 54110a392d7eSmrg func_basename "$darwin_archive" 54120a392d7eSmrg darwin_base_archive=$func_basename_result 541354b44505Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 541454b44505Smrg if test -n "$darwin_arches"; then 541554b44505Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 541654b44505Smrg darwin_arch= 541754b44505Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54180a392d7eSmrg for darwin_arch in $darwin_arches; do 54190a392d7eSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54200a392d7eSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54210a392d7eSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54220a392d7eSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 542354b44505Smrg cd "$darwin_curdir" 54240a392d7eSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 542554b44505Smrg done # $darwin_arches 542654b44505Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54270a392d7eSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 542854b44505Smrg darwin_file= 542954b44505Smrg darwin_files= 543054b44505Smrg for darwin_file in $darwin_filelist; do 543154b44505Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 543254b44505Smrg $LIPO -create -output "$darwin_file" $darwin_files 543354b44505Smrg done # $darwin_filelist 543454b44505Smrg $RM -rf unfat-$$ 543554b44505Smrg cd "$darwin_orig_dir" 54364a041c5bSmacallan else 543754b44505Smrg cd $darwin_orig_dir 543854b44505Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 543954b44505Smrg fi # $darwin_arches 544054b44505Smrg } # !$opt_dry_run 544154b44505Smrg ;; 544254b44505Smrg *) 544354b44505Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 544454b44505Smrg ;; 544554b44505Smrg esac 544654b44505Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 544754b44505Smrg done 54484a041c5bSmacallan 54490a392d7eSmrg func_extract_archives_result=$my_oldobjs 545054b44505Smrg} 54514a041c5bSmacallan 54524a041c5bSmacallan 545354b44505Smrg# func_emit_wrapper [arg=no] 545454b44505Smrg# 545554b44505Smrg# Emit a libtool wrapper script on stdout. 545654b44505Smrg# Don't directly open a file because we may want to 545754b44505Smrg# incorporate the script contents within a cygwin/mingw 545854b44505Smrg# wrapper executable. Must ONLY be called from within 545954b44505Smrg# func_mode_link because it depends on a number of variables 546054b44505Smrg# set therein. 546154b44505Smrg# 546254b44505Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 546354b44505Smrg# variable will take. If 'yes', then the emitted script 54640a392d7eSmrg# will assume that the directory where it is stored is 546554b44505Smrg# the $objdir directory. This is a cygwin/mingw-specific 546654b44505Smrg# behavior. 546754b44505Smrgfunc_emit_wrapper () 546854b44505Smrg{ 546954b44505Smrg func_emit_wrapper_arg1=${1-no} 54704a041c5bSmacallan 547154b44505Smrg $ECHO "\ 547254b44505Smrg#! $SHELL 54734a041c5bSmacallan 547454b44505Smrg# $output - temporary wrapper script for $objdir/$outputname 54750a392d7eSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 547654b44505Smrg# 547754b44505Smrg# The $output program cannot be directly executed until all the libtool 547854b44505Smrg# libraries that it depends on are installed. 547954b44505Smrg# 548054b44505Smrg# This wrapper script should never be moved out of the build directory. 548154b44505Smrg# If it is, it will not operate correctly. 54824a041c5bSmacallan 548354b44505Smrg# Sed substitution that helps us do robust quoting. It backslashifies 548454b44505Smrg# metacharacters that are still active within double-quoted strings. 548554b44505Smrgsed_quote_subst='$sed_quote_subst' 54864a041c5bSmacallan 548754b44505Smrg# Be Bourne compatible 548854b44505Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 548954b44505Smrg emulate sh 549054b44505Smrg NULLCMD=: 549154b44505Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 549254b44505Smrg # is contrary to our usage. Disable this feature. 549354b44505Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 549454b44505Smrg setopt NO_GLOB_SUBST 549554b44505Smrgelse 549654b44505Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 549754b44505Smrgfi 549854b44505SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 549954b44505SmrgDUALCASE=1; export DUALCASE # for MKS sh 55004a041c5bSmacallan 550154b44505Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 550254b44505Smrg# if CDPATH is set. 550354b44505Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55044a041c5bSmacallan 550554b44505Smrgrelink_command=\"$relink_command\" 55064a041c5bSmacallan 550754b44505Smrg# This environment variable determines our operation mode. 550854b44505Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 550954b44505Smrg # install mode needs the following variables: 551054b44505Smrg generated_by_libtool_version='$macro_version' 551154b44505Smrg notinst_deplibs='$notinst_deplibs' 551254b44505Smrgelse 551354b44505Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 551454b44505Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 551554b44505Smrg file=\"\$0\"" 55164a041c5bSmacallan 55178fc2d0c6Smrg func_quote_arg pretty "$ECHO" 55188fc2d0c6Smrg qECHO=$func_quote_arg_result 551954b44505Smrg $ECHO "\ 55204a041c5bSmacallan 552154b44505Smrg# A function that is used when there is no print builtin or printf. 552254b44505Smrgfunc_fallback_echo () 552354b44505Smrg{ 552454b44505Smrg eval 'cat <<_LTECHO_EOF 552554b44505Smrg\$1 552654b44505Smrg_LTECHO_EOF' 552754b44505Smrg} 55288fc2d0c6Smrg ECHO=$qECHO 552954b44505Smrg fi 55304a041c5bSmacallan 553154b44505Smrg# Very basic option parsing. These options are (a) specific to 553254b44505Smrg# the libtool wrapper, (b) are identical between the wrapper 55330a392d7eSmrg# /script/ and the wrapper /executable/ that is used only on 553454b44505Smrg# windows platforms, and (c) all begin with the string "--lt-" 55350a392d7eSmrg# (application programs are unlikely to have options that match 553654b44505Smrg# this pattern). 553754b44505Smrg# 553854b44505Smrg# There are only two supported options: --lt-debug and 553954b44505Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 554054b44505Smrg# 554154b44505Smrg# The first argument to this parsing function should be the 554254b44505Smrg# script's $0 value, followed by "$@". 554354b44505Smrglt_option_debug= 554454b44505Smrgfunc_parse_lt_options () 554554b44505Smrg{ 554654b44505Smrg lt_script_arg0=\$0 554754b44505Smrg shift 554854b44505Smrg for lt_opt 554954b44505Smrg do 555054b44505Smrg case \"\$lt_opt\" in 555154b44505Smrg --lt-debug) lt_option_debug=1 ;; 555254b44505Smrg --lt-dump-script) 555354b44505Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 555454b44505Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 555554b44505Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 555654b44505Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 555754b44505Smrg exit 0 555854b44505Smrg ;; 555954b44505Smrg --lt-*) 556054b44505Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 556154b44505Smrg exit 1 556254b44505Smrg ;; 556354b44505Smrg esac 556454b44505Smrg done 55654a041c5bSmacallan 556654b44505Smrg # Print the debug banner immediately: 556754b44505Smrg if test -n \"\$lt_option_debug\"; then 55680a392d7eSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 556954b44505Smrg fi 557054b44505Smrg} 55714a041c5bSmacallan 557254b44505Smrg# Used when --lt-debug. Prints its arguments to stdout 557354b44505Smrg# (redirection is the responsibility of the caller) 557454b44505Smrgfunc_lt_dump_args () 557554b44505Smrg{ 557654b44505Smrg lt_dump_args_N=1; 557754b44505Smrg for lt_arg 557854b44505Smrg do 55790a392d7eSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 558054b44505Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 558154b44505Smrg done 558254b44505Smrg} 55834a041c5bSmacallan 558454b44505Smrg# Core function for launching the target application 558554b44505Smrgfunc_exec_program_core () 558654b44505Smrg{ 558754b44505Smrg" 558854b44505Smrg case $host in 558954b44505Smrg # Backslashes separate directories on plain windows 559054b44505Smrg *-*-mingw | *-*-os2* | *-cegcc*) 559154b44505Smrg $ECHO "\ 559254b44505Smrg if test -n \"\$lt_option_debug\"; then 55930a392d7eSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 559454b44505Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 559554b44505Smrg fi 559654b44505Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 559754b44505Smrg" 559854b44505Smrg ;; 55994a041c5bSmacallan 560054b44505Smrg *) 560154b44505Smrg $ECHO "\ 560254b44505Smrg if test -n \"\$lt_option_debug\"; then 56030a392d7eSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 560454b44505Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 560554b44505Smrg fi 560654b44505Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 560754b44505Smrg" 560854b44505Smrg ;; 560954b44505Smrg esac 561054b44505Smrg $ECHO "\ 561154b44505Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 561254b44505Smrg exit 1 561354b44505Smrg} 56144a041c5bSmacallan 561554b44505Smrg# A function to encapsulate launching the target application 561654b44505Smrg# Strips options in the --lt-* namespace from \$@ and 561754b44505Smrg# launches target application with the remaining arguments. 561854b44505Smrgfunc_exec_program () 561954b44505Smrg{ 56200a392d7eSmrg case \" \$* \" in 56210a392d7eSmrg *\\ --lt-*) 56220a392d7eSmrg for lt_wr_arg 56230a392d7eSmrg do 56240a392d7eSmrg case \$lt_wr_arg in 56250a392d7eSmrg --lt-*) ;; 56260a392d7eSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56270a392d7eSmrg esac 56280a392d7eSmrg shift 56290a392d7eSmrg done ;; 56300a392d7eSmrg esac 563154b44505Smrg func_exec_program_core \${1+\"\$@\"} 563254b44505Smrg} 56334a041c5bSmacallan 563454b44505Smrg # Parse options 563554b44505Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56364a041c5bSmacallan 563754b44505Smrg # Find the directory that this script lives in. 563854b44505Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 563954b44505Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56404a041c5bSmacallan 564154b44505Smrg # Follow symbolic links until we get to the real thisdir. 564254b44505Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 564354b44505Smrg while test -n \"\$file\"; do 564454b44505Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56454a041c5bSmacallan 564654b44505Smrg # If there was a directory component, then change thisdir. 564754b44505Smrg if test \"x\$destdir\" != \"x\$file\"; then 564854b44505Smrg case \"\$destdir\" in 564954b44505Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 565054b44505Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 565154b44505Smrg esac 565254b44505Smrg fi 56534a041c5bSmacallan 565454b44505Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 565554b44505Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 565654b44505Smrg done 56574a041c5bSmacallan 565854b44505Smrg # Usually 'no', except on cygwin/mingw when embedded into 565954b44505Smrg # the cwrapper. 566054b44505Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 566154b44505Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 566254b44505Smrg # special case for '.' 566354b44505Smrg if test \"\$thisdir\" = \".\"; then 566454b44505Smrg thisdir=\`pwd\` 566554b44505Smrg fi 566654b44505Smrg # remove .libs from thisdir 566754b44505Smrg case \"\$thisdir\" in 566854b44505Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 566954b44505Smrg $objdir ) thisdir=. ;; 567054b44505Smrg esac 567154b44505Smrg fi 56724a041c5bSmacallan 567354b44505Smrg # Try to get the absolute directory name. 567454b44505Smrg absdir=\`cd \"\$thisdir\" && pwd\` 567554b44505Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 567654b44505Smrg" 56774a041c5bSmacallan 56780a392d7eSmrg if test yes = "$fast_install"; then 567954b44505Smrg $ECHO "\ 568054b44505Smrg program=lt-'$outputname'$exeext 568154b44505Smrg progdir=\"\$thisdir/$objdir\" 56824a041c5bSmacallan 568354b44505Smrg if test ! -f \"\$progdir/\$program\" || 56840a392d7eSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 568554b44505Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56864a041c5bSmacallan 568754b44505Smrg file=\"\$\$-\$program\" 56884a041c5bSmacallan 568954b44505Smrg if test ! -d \"\$progdir\"; then 569054b44505Smrg $MKDIR \"\$progdir\" 569154b44505Smrg else 569254b44505Smrg $RM \"\$progdir/\$file\" 569354b44505Smrg fi" 56944a041c5bSmacallan 569554b44505Smrg $ECHO "\ 56964a041c5bSmacallan 569754b44505Smrg # relink executable if necessary 569854b44505Smrg if test -n \"\$relink_command\"; then 569954b44505Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 570054b44505Smrg else 57010a392d7eSmrg \$ECHO \"\$relink_command_output\" >&2 570254b44505Smrg $RM \"\$progdir/\$file\" 570354b44505Smrg exit 1 570454b44505Smrg fi 570554b44505Smrg fi 57064a041c5bSmacallan 570754b44505Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 570854b44505Smrg { $RM \"\$progdir/\$program\"; 570954b44505Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 571054b44505Smrg $RM \"\$progdir/\$file\" 571154b44505Smrg fi" 571254b44505Smrg else 571354b44505Smrg $ECHO "\ 571454b44505Smrg program='$outputname' 571554b44505Smrg progdir=\"\$thisdir/$objdir\" 571654b44505Smrg" 57174a041c5bSmacallan fi 57184a041c5bSmacallan 571954b44505Smrg $ECHO "\ 57204a041c5bSmacallan 572154b44505Smrg if test -f \"\$progdir/\$program\"; then" 57224a041c5bSmacallan 572354b44505Smrg # fixup the dll searchpath if we need to. 572454b44505Smrg # 572554b44505Smrg # Fix the DLL searchpath if we need to. Do this before prepending 572654b44505Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 572754b44505Smrg # libraries must come first. 572854b44505Smrg if test -n "$dllsearchpath"; then 572954b44505Smrg $ECHO "\ 573054b44505Smrg # Add the dll search path components to the executable PATH 573154b44505Smrg PATH=$dllsearchpath:\$PATH 573254b44505Smrg" 573354b44505Smrg fi 57344a041c5bSmacallan 573554b44505Smrg # Export our shlibpath_var if we have one. 57360a392d7eSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 573754b44505Smrg $ECHO "\ 573854b44505Smrg # Add our own library path to $shlibpath_var 573954b44505Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57404a041c5bSmacallan 574154b44505Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 574254b44505Smrg # The second colon is a workaround for a bug in BeOS R4 sed 574354b44505Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57444a041c5bSmacallan 574554b44505Smrg export $shlibpath_var 574654b44505Smrg" 574754b44505Smrg fi 57484a041c5bSmacallan 574954b44505Smrg $ECHO "\ 575054b44505Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 575154b44505Smrg # Run the actual program with our arguments. 575254b44505Smrg func_exec_program \${1+\"\$@\"} 575354b44505Smrg fi 575454b44505Smrg else 575554b44505Smrg # The program doesn't exist. 57560a392d7eSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 575754b44505Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 575854b44505Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 575954b44505Smrg exit 1 576054b44505Smrg fi 576154b44505Smrgfi\ 576254b44505Smrg" 576354b44505Smrg} 57644a041c5bSmacallan 57654a041c5bSmacallan 576654b44505Smrg# func_emit_cwrapperexe_src 576754b44505Smrg# emit the source code for a wrapper executable on stdout 576854b44505Smrg# Must ONLY be called from within func_mode_link because 576954b44505Smrg# it depends on a number of variable set therein. 577054b44505Smrgfunc_emit_cwrapperexe_src () 577154b44505Smrg{ 577254b44505Smrg cat <<EOF 57734a041c5bSmacallan 577454b44505Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57750a392d7eSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57764a041c5bSmacallan 577754b44505Smrg The $output program cannot be directly executed until all the libtool 577854b44505Smrg libraries that it depends on are installed. 57794a041c5bSmacallan 578054b44505Smrg This wrapper executable should never be moved out of the build directory. 578154b44505Smrg If it is, it will not operate correctly. 578254b44505Smrg*/ 578354b44505SmrgEOF 578454b44505Smrg cat <<"EOF" 578554b44505Smrg#ifdef _MSC_VER 578654b44505Smrg# define _CRT_SECURE_NO_DEPRECATE 1 578754b44505Smrg#endif 578854b44505Smrg#include <stdio.h> 578954b44505Smrg#include <stdlib.h> 579054b44505Smrg#ifdef _MSC_VER 579154b44505Smrg# include <direct.h> 579254b44505Smrg# include <process.h> 579354b44505Smrg# include <io.h> 579454b44505Smrg#else 579554b44505Smrg# include <unistd.h> 579654b44505Smrg# include <stdint.h> 579754b44505Smrg# ifdef __CYGWIN__ 579854b44505Smrg# include <io.h> 579954b44505Smrg# endif 580054b44505Smrg#endif 580154b44505Smrg#include <malloc.h> 580254b44505Smrg#include <stdarg.h> 580354b44505Smrg#include <assert.h> 580454b44505Smrg#include <string.h> 580554b44505Smrg#include <ctype.h> 580654b44505Smrg#include <errno.h> 580754b44505Smrg#include <fcntl.h> 580854b44505Smrg#include <sys/stat.h> 58094a041c5bSmacallan 58100a392d7eSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58110a392d7eSmrg 581254b44505Smrg/* declarations of non-ANSI functions */ 58130a392d7eSmrg#if defined __MINGW32__ 581454b44505Smrg# ifdef __STRICT_ANSI__ 581554b44505Smrgint _putenv (const char *); 581654b44505Smrg# endif 58170a392d7eSmrg#elif defined __CYGWIN__ 581854b44505Smrg# ifdef __STRICT_ANSI__ 581954b44505Smrgchar *realpath (const char *, char *); 582054b44505Smrgint putenv (char *); 582154b44505Smrgint setenv (const char *, const char *, int); 582254b44505Smrg# endif 58230a392d7eSmrg/* #elif defined other_platform || defined ... */ 582454b44505Smrg#endif 58254a041c5bSmacallan 582654b44505Smrg/* portability defines, excluding path handling macros */ 58270a392d7eSmrg#if defined _MSC_VER 582854b44505Smrg# define setmode _setmode 582954b44505Smrg# define stat _stat 583054b44505Smrg# define chmod _chmod 583154b44505Smrg# define getcwd _getcwd 583254b44505Smrg# define putenv _putenv 583354b44505Smrg# define S_IXUSR _S_IEXEC 58340a392d7eSmrg#elif defined __MINGW32__ 583554b44505Smrg# define setmode _setmode 583654b44505Smrg# define stat _stat 583754b44505Smrg# define chmod _chmod 583854b44505Smrg# define getcwd _getcwd 583954b44505Smrg# define putenv _putenv 58400a392d7eSmrg#elif defined __CYGWIN__ 584154b44505Smrg# define HAVE_SETENV 584254b44505Smrg# define FOPEN_WB "wb" 58430a392d7eSmrg/* #elif defined other platforms ... */ 584454b44505Smrg#endif 58454a041c5bSmacallan 58460a392d7eSmrg#if defined PATH_MAX 584754b44505Smrg# define LT_PATHMAX PATH_MAX 58480a392d7eSmrg#elif defined MAXPATHLEN 584954b44505Smrg# define LT_PATHMAX MAXPATHLEN 585054b44505Smrg#else 585154b44505Smrg# define LT_PATHMAX 1024 585254b44505Smrg#endif 58534a041c5bSmacallan 585454b44505Smrg#ifndef S_IXOTH 585554b44505Smrg# define S_IXOTH 0 585654b44505Smrg#endif 585754b44505Smrg#ifndef S_IXGRP 585854b44505Smrg# define S_IXGRP 0 585954b44505Smrg#endif 58604a041c5bSmacallan 586154b44505Smrg/* path handling portability macros */ 586254b44505Smrg#ifndef DIR_SEPARATOR 586354b44505Smrg# define DIR_SEPARATOR '/' 586454b44505Smrg# define PATH_SEPARATOR ':' 586554b44505Smrg#endif 58664a041c5bSmacallan 58670a392d7eSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58680a392d7eSmrg defined __OS2__ 586954b44505Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 587054b44505Smrg# define FOPEN_WB "wb" 587154b44505Smrg# ifndef DIR_SEPARATOR_2 587254b44505Smrg# define DIR_SEPARATOR_2 '\\' 587354b44505Smrg# endif 587454b44505Smrg# ifndef PATH_SEPARATOR_2 587554b44505Smrg# define PATH_SEPARATOR_2 ';' 587654b44505Smrg# endif 587754b44505Smrg#endif 58784a041c5bSmacallan 587954b44505Smrg#ifndef DIR_SEPARATOR_2 588054b44505Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 588154b44505Smrg#else /* DIR_SEPARATOR_2 */ 588254b44505Smrg# define IS_DIR_SEPARATOR(ch) \ 588354b44505Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 588454b44505Smrg#endif /* DIR_SEPARATOR_2 */ 58854a041c5bSmacallan 588654b44505Smrg#ifndef PATH_SEPARATOR_2 588754b44505Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 588854b44505Smrg#else /* PATH_SEPARATOR_2 */ 588954b44505Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 589054b44505Smrg#endif /* PATH_SEPARATOR_2 */ 58914a041c5bSmacallan 589254b44505Smrg#ifndef FOPEN_WB 589354b44505Smrg# define FOPEN_WB "w" 589454b44505Smrg#endif 589554b44505Smrg#ifndef _O_BINARY 589654b44505Smrg# define _O_BINARY 0 589754b44505Smrg#endif 58984a041c5bSmacallan 589954b44505Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 590054b44505Smrg#define XFREE(stale) do { \ 59010a392d7eSmrg if (stale) { free (stale); stale = 0; } \ 590254b44505Smrg} while (0) 59034a041c5bSmacallan 59040a392d7eSmrg#if defined LT_DEBUGWRAPPER 590554b44505Smrgstatic int lt_debug = 1; 590654b44505Smrg#else 590754b44505Smrgstatic int lt_debug = 0; 590854b44505Smrg#endif 59094a041c5bSmacallan 591054b44505Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 591154b44505Smrg 591254b44505Smrgvoid *xmalloc (size_t num); 591354b44505Smrgchar *xstrdup (const char *string); 591454b44505Smrgconst char *base_name (const char *name); 591554b44505Smrgchar *find_executable (const char *wrapper); 591654b44505Smrgchar *chase_symlinks (const char *pathspec); 591754b44505Smrgint make_executable (const char *path); 591854b44505Smrgint check_executable (const char *path); 591954b44505Smrgchar *strendzap (char *str, const char *pat); 592054b44505Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 592154b44505Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 592254b44505Smrgstatic const char *nonnull (const char *s); 592354b44505Smrgstatic const char *nonempty (const char *s); 592454b44505Smrgvoid lt_setenv (const char *name, const char *value); 592554b44505Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 592654b44505Smrgvoid lt_update_exe_path (const char *name, const char *value); 592754b44505Smrgvoid lt_update_lib_path (const char *name, const char *value); 592854b44505Smrgchar **prepare_spawn (char **argv); 592954b44505Smrgvoid lt_dump_script (FILE *f); 593054b44505SmrgEOF 59314a041c5bSmacallan 593254b44505Smrg cat <<EOF 59330a392d7eSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59340a392d7eSmrg# define externally_visible volatile 59350a392d7eSmrg#else 59360a392d7eSmrg# define externally_visible __attribute__((externally_visible)) volatile 59370a392d7eSmrg#endif 59380a392d7eSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 593954b44505Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 594054b44505SmrgEOF 59414a041c5bSmacallan 59420a392d7eSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 594354b44505Smrg func_to_host_path "$temp_rpath" 594454b44505Smrg cat <<EOF 594554b44505Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 594654b44505SmrgEOF 594754b44505Smrg else 594854b44505Smrg cat <<"EOF" 594954b44505Smrgconst char * LIB_PATH_VALUE = ""; 595054b44505SmrgEOF 595154b44505Smrg fi 59524a041c5bSmacallan 595354b44505Smrg if test -n "$dllsearchpath"; then 595454b44505Smrg func_to_host_path "$dllsearchpath:" 595554b44505Smrg cat <<EOF 595654b44505Smrgconst char * EXE_PATH_VARNAME = "PATH"; 595754b44505Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 595854b44505SmrgEOF 595954b44505Smrg else 596054b44505Smrg cat <<"EOF" 596154b44505Smrgconst char * EXE_PATH_VARNAME = ""; 596254b44505Smrgconst char * EXE_PATH_VALUE = ""; 596354b44505SmrgEOF 596454b44505Smrg fi 59654a041c5bSmacallan 59660a392d7eSmrg if test yes = "$fast_install"; then 596754b44505Smrg cat <<EOF 596854b44505Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 596954b44505SmrgEOF 597054b44505Smrg else 597154b44505Smrg cat <<EOF 597254b44505Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 597354b44505SmrgEOF 597454b44505Smrg fi 59754a041c5bSmacallan 59764a041c5bSmacallan 597754b44505Smrg cat <<"EOF" 59784a041c5bSmacallan 597954b44505Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59804a041c5bSmacallan 598154b44505Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 598254b44505Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 598354b44505Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 598454b44505Smrg 598554b44505Smrgint 598654b44505Smrgmain (int argc, char *argv[]) 598754b44505Smrg{ 598854b44505Smrg char **newargz; 598954b44505Smrg int newargc; 599054b44505Smrg char *tmp_pathspec; 599154b44505Smrg char *actual_cwrapper_path; 599254b44505Smrg char *actual_cwrapper_name; 599354b44505Smrg char *target_name; 599454b44505Smrg char *lt_argv_zero; 59950a392d7eSmrg int rval = 127; 599654b44505Smrg 599754b44505Smrg int i; 599854b44505Smrg 599954b44505Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60000a392d7eSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 600154b44505Smrg 600254b44505Smrg /* very simple arg parsing; don't want to rely on getopt 600354b44505Smrg * also, copy all non cwrapper options to newargz, except 600454b44505Smrg * argz[0], which is handled differently 600554b44505Smrg */ 600654b44505Smrg newargc=0; 600754b44505Smrg for (i = 1; i < argc; i++) 600854b44505Smrg { 60090a392d7eSmrg if (STREQ (argv[i], dumpscript_opt)) 601054b44505Smrg { 601154b44505SmrgEOF 60120a392d7eSmrg case $host in 601354b44505Smrg *mingw* | *cygwin* ) 601454b44505Smrg # make stdout use "unix" line endings 601554b44505Smrg echo " setmode(1,_O_BINARY);" 60164a041c5bSmacallan ;; 60174a041c5bSmacallan esac 60184a041c5bSmacallan 601954b44505Smrg cat <<"EOF" 602054b44505Smrg lt_dump_script (stdout); 602154b44505Smrg return 0; 602254b44505Smrg } 60230a392d7eSmrg if (STREQ (argv[i], debug_opt)) 602454b44505Smrg { 602554b44505Smrg lt_debug = 1; 602654b44505Smrg continue; 602754b44505Smrg } 60280a392d7eSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 602954b44505Smrg { 603054b44505Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 603154b44505Smrg namespace, but it is not one of the ones we know about and 603254b44505Smrg have already dealt with, above (inluding dump-script), then 603354b44505Smrg report an error. Otherwise, targets might begin to believe 603454b44505Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 603554b44505Smrg namespace. The first time any user complains about this, we'll 603654b44505Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 603754b44505Smrg or a configure.ac-settable value. 603854b44505Smrg */ 603954b44505Smrg lt_fatal (__FILE__, __LINE__, 604054b44505Smrg "unrecognized %s option: '%s'", 604154b44505Smrg ltwrapper_option_prefix, argv[i]); 604254b44505Smrg } 604354b44505Smrg /* otherwise ... */ 604454b44505Smrg newargz[++newargc] = xstrdup (argv[i]); 604554b44505Smrg } 604654b44505Smrg newargz[++newargc] = NULL; 60474a041c5bSmacallan 604854b44505SmrgEOF 604954b44505Smrg cat <<EOF 605054b44505Smrg /* The GNU banner must be the first non-error debug message */ 60510a392d7eSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 605254b44505SmrgEOF 605354b44505Smrg cat <<"EOF" 605454b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 605554b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 605654b44505Smrg 605754b44505Smrg tmp_pathspec = find_executable (argv[0]); 605854b44505Smrg if (tmp_pathspec == NULL) 605954b44505Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 606054b44505Smrg lt_debugprintf (__FILE__, __LINE__, 606154b44505Smrg "(main) found exe (before symlink chase) at: %s\n", 606254b44505Smrg tmp_pathspec); 606354b44505Smrg 606454b44505Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 606554b44505Smrg lt_debugprintf (__FILE__, __LINE__, 606654b44505Smrg "(main) found exe (after symlink chase) at: %s\n", 606754b44505Smrg actual_cwrapper_path); 606854b44505Smrg XFREE (tmp_pathspec); 606954b44505Smrg 607054b44505Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 607154b44505Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 607254b44505Smrg 607354b44505Smrg /* wrapper name transforms */ 607454b44505Smrg strendzap (actual_cwrapper_name, ".exe"); 607554b44505Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 607654b44505Smrg XFREE (actual_cwrapper_name); 607754b44505Smrg actual_cwrapper_name = tmp_pathspec; 607854b44505Smrg tmp_pathspec = 0; 607954b44505Smrg 608054b44505Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 608154b44505Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 608254b44505Smrg strendzap (target_name, ".exe"); 608354b44505Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 608454b44505Smrg XFREE (target_name); 608554b44505Smrg target_name = tmp_pathspec; 608654b44505Smrg tmp_pathspec = 0; 608754b44505Smrg 608854b44505Smrg lt_debugprintf (__FILE__, __LINE__, 608954b44505Smrg "(main) libtool target name: %s\n", 609054b44505Smrg target_name); 609154b44505SmrgEOF 60924a041c5bSmacallan 609354b44505Smrg cat <<EOF 609454b44505Smrg newargz[0] = 609554b44505Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 609654b44505Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 609754b44505Smrg strcpy (newargz[0], actual_cwrapper_path); 609854b44505Smrg strcat (newargz[0], "$objdir"); 609954b44505Smrg strcat (newargz[0], "/"); 610054b44505SmrgEOF 61014a041c5bSmacallan 610254b44505Smrg cat <<"EOF" 610354b44505Smrg /* stop here, and copy so we don't have to do this twice */ 610454b44505Smrg tmp_pathspec = xstrdup (newargz[0]); 61054a041c5bSmacallan 610654b44505Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 610754b44505Smrg strcat (newargz[0], actual_cwrapper_name); 61084a041c5bSmacallan 610954b44505Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 611054b44505Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 611154b44505Smrg XFREE (tmp_pathspec); 611254b44505Smrg tmp_pathspec = NULL; 611354b44505SmrgEOF 61144a041c5bSmacallan 611554b44505Smrg case $host_os in 611654b44505Smrg mingw*) 611754b44505Smrg cat <<"EOF" 611854b44505Smrg { 611954b44505Smrg char* p; 612054b44505Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 612154b44505Smrg { 612254b44505Smrg *p = '/'; 612354b44505Smrg } 612454b44505Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 612554b44505Smrg { 612654b44505Smrg *p = '/'; 612754b44505Smrg } 612854b44505Smrg } 612954b44505SmrgEOF 613054b44505Smrg ;; 613154b44505Smrg esac 61324a041c5bSmacallan 613354b44505Smrg cat <<"EOF" 613454b44505Smrg XFREE (target_name); 613554b44505Smrg XFREE (actual_cwrapper_path); 613654b44505Smrg XFREE (actual_cwrapper_name); 613754b44505Smrg 613854b44505Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 613954b44505Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 614054b44505Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 614154b44505Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 614254b44505Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 614354b44505Smrg libraries must come first. */ 614454b44505Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 614554b44505Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 614654b44505Smrg 614754b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 614854b44505Smrg nonnull (lt_argv_zero)); 614954b44505Smrg for (i = 0; i < newargc; i++) 615054b44505Smrg { 615154b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 615254b44505Smrg i, nonnull (newargz[i])); 615354b44505Smrg } 61544a041c5bSmacallan 615554b44505SmrgEOF 61564a041c5bSmacallan 615754b44505Smrg case $host_os in 615854b44505Smrg mingw*) 615954b44505Smrg cat <<"EOF" 616054b44505Smrg /* execv doesn't actually work on mingw as expected on unix */ 616154b44505Smrg newargz = prepare_spawn (newargz); 61620a392d7eSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 616354b44505Smrg if (rval == -1) 616454b44505Smrg { 616554b44505Smrg /* failed to start process */ 616654b44505Smrg lt_debugprintf (__FILE__, __LINE__, 616754b44505Smrg "(main) failed to launch target \"%s\": %s\n", 616854b44505Smrg lt_argv_zero, nonnull (strerror (errno))); 616954b44505Smrg return 127; 617054b44505Smrg } 617154b44505Smrg return rval; 617254b44505SmrgEOF 617354b44505Smrg ;; 617454b44505Smrg *) 617554b44505Smrg cat <<"EOF" 617654b44505Smrg execv (lt_argv_zero, newargz); 617754b44505Smrg return rval; /* =127, but avoids unused variable warning */ 617854b44505SmrgEOF 617954b44505Smrg ;; 618054b44505Smrg esac 61814a041c5bSmacallan 618254b44505Smrg cat <<"EOF" 618354b44505Smrg} 61844a041c5bSmacallan 618554b44505Smrgvoid * 618654b44505Smrgxmalloc (size_t num) 618754b44505Smrg{ 618854b44505Smrg void *p = (void *) malloc (num); 618954b44505Smrg if (!p) 619054b44505Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61914a041c5bSmacallan 619254b44505Smrg return p; 619354b44505Smrg} 61944a041c5bSmacallan 619554b44505Smrgchar * 619654b44505Smrgxstrdup (const char *string) 619754b44505Smrg{ 619854b44505Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 619954b44505Smrg string) : NULL; 620054b44505Smrg} 62014a041c5bSmacallan 620254b44505Smrgconst char * 620354b44505Smrgbase_name (const char *name) 620454b44505Smrg{ 620554b44505Smrg const char *base; 62064a041c5bSmacallan 62070a392d7eSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 620854b44505Smrg /* Skip over the disk name in MSDOS pathnames. */ 620954b44505Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 621054b44505Smrg name += 2; 621154b44505Smrg#endif 62124a041c5bSmacallan 621354b44505Smrg for (base = name; *name; name++) 621454b44505Smrg if (IS_DIR_SEPARATOR (*name)) 621554b44505Smrg base = name + 1; 621654b44505Smrg return base; 621754b44505Smrg} 62184a041c5bSmacallan 621954b44505Smrgint 622054b44505Smrgcheck_executable (const char *path) 622154b44505Smrg{ 622254b44505Smrg struct stat st; 62234a041c5bSmacallan 622454b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 622554b44505Smrg nonempty (path)); 622654b44505Smrg if ((!path) || (!*path)) 622754b44505Smrg return 0; 62284a041c5bSmacallan 622954b44505Smrg if ((stat (path, &st) >= 0) 623054b44505Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 623154b44505Smrg return 1; 623254b44505Smrg else 623354b44505Smrg return 0; 623454b44505Smrg} 62354a041c5bSmacallan 623654b44505Smrgint 623754b44505Smrgmake_executable (const char *path) 623854b44505Smrg{ 623954b44505Smrg int rval = 0; 624054b44505Smrg struct stat st; 62414a041c5bSmacallan 624254b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 624354b44505Smrg nonempty (path)); 624454b44505Smrg if ((!path) || (!*path)) 624554b44505Smrg return 0; 62464a041c5bSmacallan 624754b44505Smrg if (stat (path, &st) >= 0) 624854b44505Smrg { 624954b44505Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 625054b44505Smrg } 625154b44505Smrg return rval; 625254b44505Smrg} 62534a041c5bSmacallan 625454b44505Smrg/* Searches for the full path of the wrapper. Returns 625554b44505Smrg newly allocated full path name if found, NULL otherwise 625654b44505Smrg Does not chase symlinks, even on platforms that support them. 625754b44505Smrg*/ 625854b44505Smrgchar * 625954b44505Smrgfind_executable (const char *wrapper) 626054b44505Smrg{ 626154b44505Smrg int has_slash = 0; 626254b44505Smrg const char *p; 626354b44505Smrg const char *p_next; 626454b44505Smrg /* static buffer for getcwd */ 626554b44505Smrg char tmp[LT_PATHMAX + 1]; 62660a392d7eSmrg size_t tmp_len; 626754b44505Smrg char *concat_name; 62684a041c5bSmacallan 626954b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 627054b44505Smrg nonempty (wrapper)); 62714a041c5bSmacallan 627254b44505Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 627354b44505Smrg return NULL; 62744a041c5bSmacallan 627554b44505Smrg /* Absolute path? */ 62760a392d7eSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 627754b44505Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 627854b44505Smrg { 627954b44505Smrg concat_name = xstrdup (wrapper); 628054b44505Smrg if (check_executable (concat_name)) 628154b44505Smrg return concat_name; 628254b44505Smrg XFREE (concat_name); 628354b44505Smrg } 628454b44505Smrg else 628554b44505Smrg { 628654b44505Smrg#endif 628754b44505Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 628854b44505Smrg { 628954b44505Smrg concat_name = xstrdup (wrapper); 629054b44505Smrg if (check_executable (concat_name)) 629154b44505Smrg return concat_name; 629254b44505Smrg XFREE (concat_name); 629354b44505Smrg } 62940a392d7eSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 629554b44505Smrg } 629654b44505Smrg#endif 62974a041c5bSmacallan 629854b44505Smrg for (p = wrapper; *p; p++) 629954b44505Smrg if (*p == '/') 630054b44505Smrg { 630154b44505Smrg has_slash = 1; 630254b44505Smrg break; 630354b44505Smrg } 630454b44505Smrg if (!has_slash) 630554b44505Smrg { 630654b44505Smrg /* no slashes; search PATH */ 630754b44505Smrg const char *path = getenv ("PATH"); 630854b44505Smrg if (path != NULL) 630954b44505Smrg { 631054b44505Smrg for (p = path; *p; p = p_next) 631154b44505Smrg { 631254b44505Smrg const char *q; 631354b44505Smrg size_t p_len; 631454b44505Smrg for (q = p; *q; q++) 631554b44505Smrg if (IS_PATH_SEPARATOR (*q)) 631654b44505Smrg break; 63170a392d7eSmrg p_len = (size_t) (q - p); 631854b44505Smrg p_next = (*q == '\0' ? q : q + 1); 631954b44505Smrg if (p_len == 0) 632054b44505Smrg { 632154b44505Smrg /* empty path: current directory */ 632254b44505Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 632354b44505Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 632454b44505Smrg nonnull (strerror (errno))); 632554b44505Smrg tmp_len = strlen (tmp); 632654b44505Smrg concat_name = 632754b44505Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 632854b44505Smrg memcpy (concat_name, tmp, tmp_len); 632954b44505Smrg concat_name[tmp_len] = '/'; 633054b44505Smrg strcpy (concat_name + tmp_len + 1, wrapper); 633154b44505Smrg } 633254b44505Smrg else 633354b44505Smrg { 633454b44505Smrg concat_name = 633554b44505Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 633654b44505Smrg memcpy (concat_name, p, p_len); 633754b44505Smrg concat_name[p_len] = '/'; 633854b44505Smrg strcpy (concat_name + p_len + 1, wrapper); 633954b44505Smrg } 634054b44505Smrg if (check_executable (concat_name)) 634154b44505Smrg return concat_name; 634254b44505Smrg XFREE (concat_name); 634354b44505Smrg } 634454b44505Smrg } 634554b44505Smrg /* not found in PATH; assume curdir */ 634654b44505Smrg } 634754b44505Smrg /* Relative path | not found in path: prepend cwd */ 634854b44505Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 634954b44505Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 635054b44505Smrg nonnull (strerror (errno))); 635154b44505Smrg tmp_len = strlen (tmp); 635254b44505Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 635354b44505Smrg memcpy (concat_name, tmp, tmp_len); 635454b44505Smrg concat_name[tmp_len] = '/'; 635554b44505Smrg strcpy (concat_name + tmp_len + 1, wrapper); 635654b44505Smrg 635754b44505Smrg if (check_executable (concat_name)) 635854b44505Smrg return concat_name; 635954b44505Smrg XFREE (concat_name); 636054b44505Smrg return NULL; 63614a041c5bSmacallan} 63624a041c5bSmacallan 636354b44505Smrgchar * 636454b44505Smrgchase_symlinks (const char *pathspec) 636554b44505Smrg{ 636654b44505Smrg#ifndef S_ISLNK 636754b44505Smrg return xstrdup (pathspec); 636854b44505Smrg#else 636954b44505Smrg char buf[LT_PATHMAX]; 637054b44505Smrg struct stat s; 637154b44505Smrg char *tmp_pathspec = xstrdup (pathspec); 637254b44505Smrg char *p; 637354b44505Smrg int has_symlinks = 0; 637454b44505Smrg while (strlen (tmp_pathspec) && !has_symlinks) 637554b44505Smrg { 637654b44505Smrg lt_debugprintf (__FILE__, __LINE__, 637754b44505Smrg "checking path component for symlinks: %s\n", 637854b44505Smrg tmp_pathspec); 637954b44505Smrg if (lstat (tmp_pathspec, &s) == 0) 638054b44505Smrg { 638154b44505Smrg if (S_ISLNK (s.st_mode) != 0) 638254b44505Smrg { 638354b44505Smrg has_symlinks = 1; 638454b44505Smrg break; 638554b44505Smrg } 63864a041c5bSmacallan 638754b44505Smrg /* search backwards for last DIR_SEPARATOR */ 638854b44505Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 638954b44505Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639054b44505Smrg p--; 639154b44505Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639254b44505Smrg { 639354b44505Smrg /* no more DIR_SEPARATORS left */ 639454b44505Smrg break; 639554b44505Smrg } 639654b44505Smrg *p = '\0'; 639754b44505Smrg } 639854b44505Smrg else 639954b44505Smrg { 640054b44505Smrg lt_fatal (__FILE__, __LINE__, 640154b44505Smrg "error accessing file \"%s\": %s", 640254b44505Smrg tmp_pathspec, nonnull (strerror (errno))); 640354b44505Smrg } 640454b44505Smrg } 640554b44505Smrg XFREE (tmp_pathspec); 64064a041c5bSmacallan 640754b44505Smrg if (!has_symlinks) 640854b44505Smrg { 640954b44505Smrg return xstrdup (pathspec); 641054b44505Smrg } 64114a041c5bSmacallan 641254b44505Smrg tmp_pathspec = realpath (pathspec, buf); 641354b44505Smrg if (tmp_pathspec == 0) 641454b44505Smrg { 641554b44505Smrg lt_fatal (__FILE__, __LINE__, 641654b44505Smrg "could not follow symlinks for %s", pathspec); 641754b44505Smrg } 641854b44505Smrg return xstrdup (tmp_pathspec); 641954b44505Smrg#endif 64204a041c5bSmacallan} 64214a041c5bSmacallan 642254b44505Smrgchar * 642354b44505Smrgstrendzap (char *str, const char *pat) 642454b44505Smrg{ 642554b44505Smrg size_t len, patlen; 64264a041c5bSmacallan 642754b44505Smrg assert (str != NULL); 642854b44505Smrg assert (pat != NULL); 64294a041c5bSmacallan 643054b44505Smrg len = strlen (str); 643154b44505Smrg patlen = strlen (pat); 64324a041c5bSmacallan 643354b44505Smrg if (patlen <= len) 643454b44505Smrg { 643554b44505Smrg str += len - patlen; 64360a392d7eSmrg if (STREQ (str, pat)) 643754b44505Smrg *str = '\0'; 643854b44505Smrg } 643954b44505Smrg return str; 644054b44505Smrg} 64414a041c5bSmacallan 644254b44505Smrgvoid 644354b44505Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 644454b44505Smrg{ 644554b44505Smrg va_list args; 644654b44505Smrg if (lt_debug) 644754b44505Smrg { 644854b44505Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 644954b44505Smrg va_start (args, fmt); 645054b44505Smrg (void) vfprintf (stderr, fmt, args); 645154b44505Smrg va_end (args); 645254b44505Smrg } 645354b44505Smrg} 64544a041c5bSmacallan 645554b44505Smrgstatic void 645654b44505Smrglt_error_core (int exit_status, const char *file, 645754b44505Smrg int line, const char *mode, 645854b44505Smrg const char *message, va_list ap) 645954b44505Smrg{ 646054b44505Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 646154b44505Smrg vfprintf (stderr, message, ap); 646254b44505Smrg fprintf (stderr, ".\n"); 64634a041c5bSmacallan 646454b44505Smrg if (exit_status >= 0) 646554b44505Smrg exit (exit_status); 646654b44505Smrg} 64674a041c5bSmacallan 646854b44505Smrgvoid 646954b44505Smrglt_fatal (const char *file, int line, const char *message, ...) 647054b44505Smrg{ 647154b44505Smrg va_list ap; 647254b44505Smrg va_start (ap, message); 647354b44505Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 647454b44505Smrg va_end (ap); 647554b44505Smrg} 64764a041c5bSmacallan 647754b44505Smrgstatic const char * 647854b44505Smrgnonnull (const char *s) 647954b44505Smrg{ 648054b44505Smrg return s ? s : "(null)"; 648154b44505Smrg} 64824a041c5bSmacallan 648354b44505Smrgstatic const char * 648454b44505Smrgnonempty (const char *s) 648554b44505Smrg{ 648654b44505Smrg return (s && !*s) ? "(empty)" : nonnull (s); 648754b44505Smrg} 64884a041c5bSmacallan 648954b44505Smrgvoid 649054b44505Smrglt_setenv (const char *name, const char *value) 649154b44505Smrg{ 649254b44505Smrg lt_debugprintf (__FILE__, __LINE__, 649354b44505Smrg "(lt_setenv) setting '%s' to '%s'\n", 649454b44505Smrg nonnull (name), nonnull (value)); 649554b44505Smrg { 649654b44505Smrg#ifdef HAVE_SETENV 649754b44505Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 649854b44505Smrg char *str = xstrdup (value); 649954b44505Smrg setenv (name, str, 1); 65004a041c5bSmacallan#else 65010a392d7eSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 650254b44505Smrg char *str = XMALLOC (char, len); 650354b44505Smrg sprintf (str, "%s=%s", name, value); 650454b44505Smrg if (putenv (str) != EXIT_SUCCESS) 650554b44505Smrg { 650654b44505Smrg XFREE (str); 650754b44505Smrg } 65084a041c5bSmacallan#endif 650954b44505Smrg } 651054b44505Smrg} 65114a041c5bSmacallan 651254b44505Smrgchar * 651354b44505Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 651454b44505Smrg{ 651554b44505Smrg char *new_value; 651654b44505Smrg if (orig_value && *orig_value) 651754b44505Smrg { 65180a392d7eSmrg size_t orig_value_len = strlen (orig_value); 65190a392d7eSmrg size_t add_len = strlen (add); 652054b44505Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 652154b44505Smrg if (to_end) 652254b44505Smrg { 652354b44505Smrg strcpy (new_value, orig_value); 652454b44505Smrg strcpy (new_value + orig_value_len, add); 652554b44505Smrg } 652654b44505Smrg else 652754b44505Smrg { 652854b44505Smrg strcpy (new_value, add); 652954b44505Smrg strcpy (new_value + add_len, orig_value); 653054b44505Smrg } 653154b44505Smrg } 653254b44505Smrg else 653354b44505Smrg { 653454b44505Smrg new_value = xstrdup (add); 653554b44505Smrg } 653654b44505Smrg return new_value; 653754b44505Smrg} 65384a041c5bSmacallan 653954b44505Smrgvoid 654054b44505Smrglt_update_exe_path (const char *name, const char *value) 654154b44505Smrg{ 654254b44505Smrg lt_debugprintf (__FILE__, __LINE__, 654354b44505Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 654454b44505Smrg nonnull (name), nonnull (value)); 65454a041c5bSmacallan 654654b44505Smrg if (name && *name && value && *value) 654754b44505Smrg { 654854b44505Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 654954b44505Smrg /* some systems can't cope with a ':'-terminated path #' */ 65500a392d7eSmrg size_t len = strlen (new_value); 65510a392d7eSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 655254b44505Smrg { 65530a392d7eSmrg new_value[--len] = '\0'; 655454b44505Smrg } 655554b44505Smrg lt_setenv (name, new_value); 655654b44505Smrg XFREE (new_value); 655754b44505Smrg } 655854b44505Smrg} 65594a041c5bSmacallan 656054b44505Smrgvoid 656154b44505Smrglt_update_lib_path (const char *name, const char *value) 65624a041c5bSmacallan{ 656354b44505Smrg lt_debugprintf (__FILE__, __LINE__, 656454b44505Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 656554b44505Smrg nonnull (name), nonnull (value)); 65664a041c5bSmacallan 656754b44505Smrg if (name && *name && value && *value) 656854b44505Smrg { 656954b44505Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 657054b44505Smrg lt_setenv (name, new_value); 657154b44505Smrg XFREE (new_value); 657254b44505Smrg } 657354b44505Smrg} 65744a041c5bSmacallan 65754a041c5bSmacallanEOF 657654b44505Smrg case $host_os in 657754b44505Smrg mingw*) 657854b44505Smrg cat <<"EOF" 657954b44505Smrg 658054b44505Smrg/* Prepares an argument vector before calling spawn(). 658154b44505Smrg Note that spawn() does not by itself call the command interpreter 658254b44505Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 658354b44505Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 658454b44505Smrg GetVersionEx(&v); 658554b44505Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 658654b44505Smrg }) ? "cmd.exe" : "command.com"). 658754b44505Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 658854b44505Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 658954b44505Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 659054b44505Smrg special way: 659154b44505Smrg - Space and tab are interpreted as delimiters. They are not treated as 659254b44505Smrg delimiters if they are surrounded by double quotes: "...". 659354b44505Smrg - Unescaped double quotes are removed from the input. Their only effect is 659454b44505Smrg that within double quotes, space and tab are treated like normal 659554b44505Smrg characters. 659654b44505Smrg - Backslashes not followed by double quotes are not special. 659754b44505Smrg - But 2*n+1 backslashes followed by a double quote become 659854b44505Smrg n backslashes followed by a double quote (n >= 0): 659954b44505Smrg \" -> " 660054b44505Smrg \\\" -> \" 660154b44505Smrg \\\\\" -> \\" 660254b44505Smrg */ 660354b44505Smrg#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" 660454b44505Smrg#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" 660554b44505Smrgchar ** 660654b44505Smrgprepare_spawn (char **argv) 660754b44505Smrg{ 660854b44505Smrg size_t argc; 660954b44505Smrg char **new_argv; 661054b44505Smrg size_t i; 66114a041c5bSmacallan 661254b44505Smrg /* Count number of arguments. */ 661354b44505Smrg for (argc = 0; argv[argc] != NULL; argc++) 66144a041c5bSmacallan ; 66154a041c5bSmacallan 661654b44505Smrg /* Allocate new argument vector. */ 661754b44505Smrg new_argv = XMALLOC (char *, argc + 1); 66184a041c5bSmacallan 661954b44505Smrg /* Put quoted arguments into the new argument vector. */ 662054b44505Smrg for (i = 0; i < argc; i++) 662154b44505Smrg { 662254b44505Smrg const char *string = argv[i]; 662354b44505Smrg 662454b44505Smrg if (string[0] == '\0') 662554b44505Smrg new_argv[i] = xstrdup ("\"\""); 662654b44505Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 662754b44505Smrg { 662854b44505Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 662954b44505Smrg size_t length; 663054b44505Smrg unsigned int backslashes; 663154b44505Smrg const char *s; 663254b44505Smrg char *quoted_string; 663354b44505Smrg char *p; 663454b44505Smrg 663554b44505Smrg length = 0; 663654b44505Smrg backslashes = 0; 663754b44505Smrg if (quote_around) 663854b44505Smrg length++; 663954b44505Smrg for (s = string; *s != '\0'; s++) 664054b44505Smrg { 664154b44505Smrg char c = *s; 664254b44505Smrg if (c == '"') 664354b44505Smrg length += backslashes + 1; 664454b44505Smrg length++; 664554b44505Smrg if (c == '\\') 664654b44505Smrg backslashes++; 664754b44505Smrg else 664854b44505Smrg backslashes = 0; 664954b44505Smrg } 665054b44505Smrg if (quote_around) 665154b44505Smrg length += backslashes + 1; 665254b44505Smrg 665354b44505Smrg quoted_string = XMALLOC (char, length + 1); 665454b44505Smrg 665554b44505Smrg p = quoted_string; 665654b44505Smrg backslashes = 0; 665754b44505Smrg if (quote_around) 665854b44505Smrg *p++ = '"'; 665954b44505Smrg for (s = string; *s != '\0'; s++) 666054b44505Smrg { 666154b44505Smrg char c = *s; 666254b44505Smrg if (c == '"') 666354b44505Smrg { 666454b44505Smrg unsigned int j; 666554b44505Smrg for (j = backslashes + 1; j > 0; j--) 666654b44505Smrg *p++ = '\\'; 666754b44505Smrg } 666854b44505Smrg *p++ = c; 666954b44505Smrg if (c == '\\') 667054b44505Smrg backslashes++; 667154b44505Smrg else 667254b44505Smrg backslashes = 0; 667354b44505Smrg } 667454b44505Smrg if (quote_around) 667554b44505Smrg { 667654b44505Smrg unsigned int j; 667754b44505Smrg for (j = backslashes; j > 0; j--) 667854b44505Smrg *p++ = '\\'; 667954b44505Smrg *p++ = '"'; 668054b44505Smrg } 668154b44505Smrg *p = '\0'; 668254b44505Smrg 668354b44505Smrg new_argv[i] = quoted_string; 668454b44505Smrg } 668554b44505Smrg else 668654b44505Smrg new_argv[i] = (char *) string; 668754b44505Smrg } 668854b44505Smrg new_argv[argc] = NULL; 66894a041c5bSmacallan 669054b44505Smrg return new_argv; 66914a041c5bSmacallan} 669254b44505SmrgEOF 669354b44505Smrg ;; 669454b44505Smrg esac 66954a041c5bSmacallan 669654b44505Smrg cat <<"EOF" 669754b44505Smrgvoid lt_dump_script (FILE* f) 66984a041c5bSmacallan{ 669954b44505SmrgEOF 670054b44505Smrg func_emit_wrapper yes | 67010a392d7eSmrg $SED -n -e ' 67020a392d7eSmrgs/^\(.\{79\}\)\(..*\)/\1\ 67030a392d7eSmrg\2/ 67040a392d7eSmrgh 67050a392d7eSmrgs/\([\\"]\)/\\\1/g 67060a392d7eSmrgs/$/\\n/ 67070a392d7eSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67080a392d7eSmrgg 67090a392d7eSmrgD' 671054b44505Smrg cat <<"EOF" 67114a041c5bSmacallan} 671254b44505SmrgEOF 67134a041c5bSmacallan} 671454b44505Smrg# end: func_emit_cwrapperexe_src 67154a041c5bSmacallan 671654b44505Smrg# func_win32_import_lib_p ARG 671754b44505Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 671854b44505Smrgfunc_win32_import_lib_p () 67194a041c5bSmacallan{ 67200a392d7eSmrg $debug_cmd 67210a392d7eSmrg 672254b44505Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 672354b44505Smrg *import*) : ;; 672454b44505Smrg *) false ;; 672554b44505Smrg esac 67264a041c5bSmacallan} 67274a041c5bSmacallan 67280a392d7eSmrg# func_suncc_cstd_abi 67290a392d7eSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67300a392d7eSmrg# Several compiler flags select an ABI that is incompatible with the 67310a392d7eSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67320a392d7eSmrgfunc_suncc_cstd_abi () 67330a392d7eSmrg{ 67340a392d7eSmrg $debug_cmd 67350a392d7eSmrg 67360a392d7eSmrg case " $compile_command " in 67370a392d7eSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67380a392d7eSmrg suncc_use_cstd_abi=no 67390a392d7eSmrg ;; 67400a392d7eSmrg *) 67410a392d7eSmrg suncc_use_cstd_abi=yes 67420a392d7eSmrg ;; 67430a392d7eSmrg esac 67440a392d7eSmrg} 67450a392d7eSmrg 674654b44505Smrg# func_mode_link arg... 674754b44505Smrgfunc_mode_link () 67484a041c5bSmacallan{ 67490a392d7eSmrg $debug_cmd 67500a392d7eSmrg 675154b44505Smrg case $host in 675254b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 675354b44505Smrg # It is impossible to link a dll without this setting, and 675454b44505Smrg # we shouldn't force the makefile maintainer to figure out 67550a392d7eSmrg # what system we are compiling for in order to pass an extra 675654b44505Smrg # flag for every libtool invocation. 675754b44505Smrg # allow_undefined=no 67584a041c5bSmacallan 675954b44505Smrg # FIXME: Unfortunately, there are problems with the above when trying 67600a392d7eSmrg # to make a dll that has undefined symbols, in which case not 676154b44505Smrg # even a static library is built. For now, we need to specify 676254b44505Smrg # -no-undefined on the libtool link line when we can be certain 676354b44505Smrg # that all symbols are satisfied, otherwise we get a static library. 676454b44505Smrg allow_undefined=yes 676554b44505Smrg ;; 676654b44505Smrg *) 676754b44505Smrg allow_undefined=yes 676854b44505Smrg ;; 676954b44505Smrg esac 677054b44505Smrg libtool_args=$nonopt 677154b44505Smrg base_compile="$nonopt $@" 677254b44505Smrg compile_command=$nonopt 677354b44505Smrg finalize_command=$nonopt 67744a041c5bSmacallan 677554b44505Smrg compile_rpath= 677654b44505Smrg finalize_rpath= 677754b44505Smrg compile_shlibpath= 677854b44505Smrg finalize_shlibpath= 677954b44505Smrg convenience= 678054b44505Smrg old_convenience= 678154b44505Smrg deplibs= 678254b44505Smrg old_deplibs= 678354b44505Smrg compiler_flags= 678454b44505Smrg linker_flags= 678554b44505Smrg dllsearchpath= 678654b44505Smrg lib_search_path=`pwd` 678754b44505Smrg inst_prefix_dir= 678854b44505Smrg new_inherited_linker_flags= 67894a041c5bSmacallan 679054b44505Smrg avoid_version=no 679154b44505Smrg bindir= 679254b44505Smrg dlfiles= 679354b44505Smrg dlprefiles= 679454b44505Smrg dlself=no 679554b44505Smrg export_dynamic=no 679654b44505Smrg export_symbols= 679754b44505Smrg export_symbols_regex= 679854b44505Smrg generated= 679954b44505Smrg libobjs= 680054b44505Smrg ltlibs= 680154b44505Smrg module=no 680254b44505Smrg no_install=no 680354b44505Smrg objs= 68040a392d7eSmrg os2dllname= 680554b44505Smrg non_pic_objects= 680654b44505Smrg precious_files_regex= 680754b44505Smrg prefer_static_libs=no 68080a392d7eSmrg preload=false 680954b44505Smrg prev= 681054b44505Smrg prevarg= 681154b44505Smrg release= 681254b44505Smrg rpath= 681354b44505Smrg xrpath= 681454b44505Smrg perm_rpath= 681554b44505Smrg temp_rpath= 681654b44505Smrg thread_safe=no 681754b44505Smrg vinfo= 681854b44505Smrg vinfo_number=no 681954b44505Smrg weak_libs= 68200a392d7eSmrg single_module=$wl-single_module 682154b44505Smrg func_infer_tag $base_compile 68224a041c5bSmacallan 682354b44505Smrg # We need to know -static, to get the right output filenames. 682454b44505Smrg for arg 682554b44505Smrg do 682654b44505Smrg case $arg in 682754b44505Smrg -shared) 68280a392d7eSmrg test yes != "$build_libtool_libs" \ 68290a392d7eSmrg && func_fatal_configuration "cannot build a shared library" 683054b44505Smrg build_old_libs=no 683154b44505Smrg break 683254b44505Smrg ;; 683354b44505Smrg -all-static | -static | -static-libtool-libs) 683454b44505Smrg case $arg in 683554b44505Smrg -all-static) 68360a392d7eSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 683754b44505Smrg func_warning "complete static linking is impossible in this configuration" 683854b44505Smrg fi 683954b44505Smrg if test -n "$link_static_flag"; then 684054b44505Smrg dlopen_self=$dlopen_self_static 684154b44505Smrg fi 684254b44505Smrg prefer_static_libs=yes 684354b44505Smrg ;; 684454b44505Smrg -static) 684554b44505Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 684654b44505Smrg dlopen_self=$dlopen_self_static 684754b44505Smrg fi 684854b44505Smrg prefer_static_libs=built 684954b44505Smrg ;; 685054b44505Smrg -static-libtool-libs) 685154b44505Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 685254b44505Smrg dlopen_self=$dlopen_self_static 685354b44505Smrg fi 685454b44505Smrg prefer_static_libs=yes 685554b44505Smrg ;; 685654b44505Smrg esac 685754b44505Smrg build_libtool_libs=no 685854b44505Smrg build_old_libs=yes 685954b44505Smrg break 686054b44505Smrg ;; 686154b44505Smrg esac 686254b44505Smrg done 68634a041c5bSmacallan 686454b44505Smrg # See if our shared archives depend on static archives. 686554b44505Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68664a041c5bSmacallan 686754b44505Smrg # Go through the arguments, transforming them on the way. 686854b44505Smrg while test "$#" -gt 0; do 68690a392d7eSmrg arg=$1 687054b44505Smrg shift 68718fc2d0c6Smrg func_quote_arg pretty,unquoted "$arg" 68728fc2d0c6Smrg qarg=$func_quote_arg_unquoted_result 68738fc2d0c6Smrg func_append libtool_args " $func_quote_arg_result" 68744a041c5bSmacallan 687554b44505Smrg # If the previous option needs an argument, assign it. 687654b44505Smrg if test -n "$prev"; then 687754b44505Smrg case $prev in 687854b44505Smrg output) 687954b44505Smrg func_append compile_command " @OUTPUT@" 688054b44505Smrg func_append finalize_command " @OUTPUT@" 688154b44505Smrg ;; 688254b44505Smrg esac 68834a041c5bSmacallan 688454b44505Smrg case $prev in 688554b44505Smrg bindir) 68860a392d7eSmrg bindir=$arg 688754b44505Smrg prev= 688854b44505Smrg continue 688954b44505Smrg ;; 689054b44505Smrg dlfiles|dlprefiles) 68910a392d7eSmrg $preload || { 689254b44505Smrg # Add the symbol object into the linking commands. 689354b44505Smrg func_append compile_command " @SYMFILE@" 689454b44505Smrg func_append finalize_command " @SYMFILE@" 68950a392d7eSmrg preload=: 68960a392d7eSmrg } 689754b44505Smrg case $arg in 689854b44505Smrg *.la | *.lo) ;; # We handle these cases below. 689954b44505Smrg force) 69000a392d7eSmrg if test no = "$dlself"; then 690154b44505Smrg dlself=needless 690254b44505Smrg export_dynamic=yes 690354b44505Smrg fi 690454b44505Smrg prev= 690554b44505Smrg continue 690654b44505Smrg ;; 690754b44505Smrg self) 69080a392d7eSmrg if test dlprefiles = "$prev"; then 690954b44505Smrg dlself=yes 69100a392d7eSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 691154b44505Smrg dlself=yes 691254b44505Smrg else 691354b44505Smrg dlself=needless 691454b44505Smrg export_dynamic=yes 691554b44505Smrg fi 691654b44505Smrg prev= 691754b44505Smrg continue 691854b44505Smrg ;; 691954b44505Smrg *) 69200a392d7eSmrg if test dlfiles = "$prev"; then 692154b44505Smrg func_append dlfiles " $arg" 692254b44505Smrg else 692354b44505Smrg func_append dlprefiles " $arg" 692454b44505Smrg fi 692554b44505Smrg prev= 692654b44505Smrg continue 692754b44505Smrg ;; 692854b44505Smrg esac 692954b44505Smrg ;; 693054b44505Smrg expsyms) 69310a392d7eSmrg export_symbols=$arg 693254b44505Smrg test -f "$arg" \ 69330a392d7eSmrg || func_fatal_error "symbol file '$arg' does not exist" 693454b44505Smrg prev= 693554b44505Smrg continue 693654b44505Smrg ;; 693754b44505Smrg expsyms_regex) 69380a392d7eSmrg export_symbols_regex=$arg 693954b44505Smrg prev= 694054b44505Smrg continue 694154b44505Smrg ;; 694254b44505Smrg framework) 694354b44505Smrg case $host in 694454b44505Smrg *-*-darwin*) 694554b44505Smrg case "$deplibs " in 694654b44505Smrg *" $qarg.ltframework "*) ;; 694754b44505Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 694854b44505Smrg ;; 694954b44505Smrg esac 695054b44505Smrg ;; 695154b44505Smrg esac 695254b44505Smrg prev= 695354b44505Smrg continue 695454b44505Smrg ;; 695554b44505Smrg inst_prefix) 69560a392d7eSmrg inst_prefix_dir=$arg 69570a392d7eSmrg prev= 69580a392d7eSmrg continue 69590a392d7eSmrg ;; 69600a392d7eSmrg mllvm) 69610a392d7eSmrg # Clang does not use LLVM to link, so we can simply discard any 69620a392d7eSmrg # '-mllvm $arg' options when doing the link step. 696354b44505Smrg prev= 696454b44505Smrg continue 696554b44505Smrg ;; 696654b44505Smrg objectlist) 696754b44505Smrg if test -f "$arg"; then 696854b44505Smrg save_arg=$arg 696954b44505Smrg moreargs= 697054b44505Smrg for fil in `cat "$save_arg"` 697154b44505Smrg do 697254b44505Smrg# func_append moreargs " $fil" 697354b44505Smrg arg=$fil 697454b44505Smrg # A libtool-controlled object. 69754a041c5bSmacallan 697654b44505Smrg # Check to see that this really is a libtool object. 697754b44505Smrg if func_lalib_unsafe_p "$arg"; then 697854b44505Smrg pic_object= 697954b44505Smrg non_pic_object= 69804a041c5bSmacallan 698154b44505Smrg # Read the .lo file 698254b44505Smrg func_source "$arg" 69834a041c5bSmacallan 698454b44505Smrg if test -z "$pic_object" || 698554b44505Smrg test -z "$non_pic_object" || 69860a392d7eSmrg test none = "$pic_object" && 69870a392d7eSmrg test none = "$non_pic_object"; then 69880a392d7eSmrg func_fatal_error "cannot find name of object for '$arg'" 698954b44505Smrg fi 69904a041c5bSmacallan 699154b44505Smrg # Extract subdirectory from the argument. 699254b44505Smrg func_dirname "$arg" "/" "" 69930a392d7eSmrg xdir=$func_dirname_result 69944a041c5bSmacallan 69950a392d7eSmrg if test none != "$pic_object"; then 699654b44505Smrg # Prepend the subdirectory the object is found in. 69970a392d7eSmrg pic_object=$xdir$pic_object 69984a041c5bSmacallan 69990a392d7eSmrg if test dlfiles = "$prev"; then 70000a392d7eSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 700154b44505Smrg func_append dlfiles " $pic_object" 700254b44505Smrg prev= 700354b44505Smrg continue 700454b44505Smrg else 700554b44505Smrg # If libtool objects are unsupported, then we need to preload. 700654b44505Smrg prev=dlprefiles 700754b44505Smrg fi 700854b44505Smrg fi 70094a041c5bSmacallan 701054b44505Smrg # CHECK ME: I think I busted this. -Ossama 70110a392d7eSmrg if test dlprefiles = "$prev"; then 701254b44505Smrg # Preload the old-style object. 701354b44505Smrg func_append dlprefiles " $pic_object" 701454b44505Smrg prev= 701554b44505Smrg fi 70164a041c5bSmacallan 701754b44505Smrg # A PIC object. 701854b44505Smrg func_append libobjs " $pic_object" 70190a392d7eSmrg arg=$pic_object 702054b44505Smrg fi 70214a041c5bSmacallan 702254b44505Smrg # Non-PIC object. 70230a392d7eSmrg if test none != "$non_pic_object"; then 702454b44505Smrg # Prepend the subdirectory the object is found in. 70250a392d7eSmrg non_pic_object=$xdir$non_pic_object 70264a041c5bSmacallan 702754b44505Smrg # A standard non-PIC object 702854b44505Smrg func_append non_pic_objects " $non_pic_object" 70290a392d7eSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70300a392d7eSmrg arg=$non_pic_object 703154b44505Smrg fi 703254b44505Smrg else 703354b44505Smrg # If the PIC object exists, use it instead. 703454b44505Smrg # $xdir was prepended to $pic_object above. 70350a392d7eSmrg non_pic_object=$pic_object 703654b44505Smrg func_append non_pic_objects " $non_pic_object" 703754b44505Smrg fi 703854b44505Smrg else 703954b44505Smrg # Only an error if not doing a dry-run. 704054b44505Smrg if $opt_dry_run; then 704154b44505Smrg # Extract subdirectory from the argument. 704254b44505Smrg func_dirname "$arg" "/" "" 70430a392d7eSmrg xdir=$func_dirname_result 704454b44505Smrg 704554b44505Smrg func_lo2o "$arg" 704654b44505Smrg pic_object=$xdir$objdir/$func_lo2o_result 704754b44505Smrg non_pic_object=$xdir$func_lo2o_result 704854b44505Smrg func_append libobjs " $pic_object" 704954b44505Smrg func_append non_pic_objects " $non_pic_object" 705054b44505Smrg else 70510a392d7eSmrg func_fatal_error "'$arg' is not a valid libtool object" 705254b44505Smrg fi 705354b44505Smrg fi 705454b44505Smrg done 705554b44505Smrg else 70560a392d7eSmrg func_fatal_error "link input file '$arg' does not exist" 705754b44505Smrg fi 705854b44505Smrg arg=$save_arg 705954b44505Smrg prev= 706054b44505Smrg continue 706154b44505Smrg ;; 70620a392d7eSmrg os2dllname) 70630a392d7eSmrg os2dllname=$arg 70640a392d7eSmrg prev= 70650a392d7eSmrg continue 70660a392d7eSmrg ;; 706754b44505Smrg precious_regex) 70680a392d7eSmrg precious_files_regex=$arg 706954b44505Smrg prev= 707054b44505Smrg continue 707154b44505Smrg ;; 707254b44505Smrg release) 70730a392d7eSmrg release=-$arg 707454b44505Smrg prev= 707554b44505Smrg continue 707654b44505Smrg ;; 707754b44505Smrg rpath | xrpath) 707854b44505Smrg # We need an absolute path. 707954b44505Smrg case $arg in 708054b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 708154b44505Smrg *) 708254b44505Smrg func_fatal_error "only absolute run-paths are allowed" 708354b44505Smrg ;; 708454b44505Smrg esac 70850a392d7eSmrg if test rpath = "$prev"; then 708654b44505Smrg case "$rpath " in 708754b44505Smrg *" $arg "*) ;; 708854b44505Smrg *) func_append rpath " $arg" ;; 708954b44505Smrg esac 709054b44505Smrg else 709154b44505Smrg case "$xrpath " in 709254b44505Smrg *" $arg "*) ;; 709354b44505Smrg *) func_append xrpath " $arg" ;; 709454b44505Smrg esac 709554b44505Smrg fi 709654b44505Smrg prev= 709754b44505Smrg continue 709854b44505Smrg ;; 709954b44505Smrg shrext) 71000a392d7eSmrg shrext_cmds=$arg 710154b44505Smrg prev= 710254b44505Smrg continue 710354b44505Smrg ;; 710454b44505Smrg weak) 710554b44505Smrg func_append weak_libs " $arg" 710654b44505Smrg prev= 710754b44505Smrg continue 710854b44505Smrg ;; 71098fc2d0c6Smrg xassembler) 71108fc2d0c6Smrg func_append compiler_flags " -Xassembler $qarg" 71118fc2d0c6Smrg prev= 71128fc2d0c6Smrg func_append compile_command " -Xassembler $qarg" 71138fc2d0c6Smrg func_append finalize_command " -Xassembler $qarg" 71148fc2d0c6Smrg continue 71158fc2d0c6Smrg ;; 711654b44505Smrg xcclinker) 711754b44505Smrg func_append linker_flags " $qarg" 711854b44505Smrg func_append compiler_flags " $qarg" 711954b44505Smrg prev= 712054b44505Smrg func_append compile_command " $qarg" 712154b44505Smrg func_append finalize_command " $qarg" 712254b44505Smrg continue 712354b44505Smrg ;; 712454b44505Smrg xcompiler) 712554b44505Smrg func_append compiler_flags " $qarg" 712654b44505Smrg prev= 712754b44505Smrg func_append compile_command " $qarg" 712854b44505Smrg func_append finalize_command " $qarg" 712954b44505Smrg continue 713054b44505Smrg ;; 713154b44505Smrg xlinker) 713254b44505Smrg func_append linker_flags " $qarg" 713354b44505Smrg func_append compiler_flags " $wl$qarg" 713454b44505Smrg prev= 713554b44505Smrg func_append compile_command " $wl$qarg" 713654b44505Smrg func_append finalize_command " $wl$qarg" 713754b44505Smrg continue 713854b44505Smrg ;; 713954b44505Smrg *) 714054b44505Smrg eval "$prev=\"\$arg\"" 714154b44505Smrg prev= 714254b44505Smrg continue 714354b44505Smrg ;; 714454b44505Smrg esac 714554b44505Smrg fi # test -n "$prev" 71464a041c5bSmacallan 71470a392d7eSmrg prevarg=$arg 71484a041c5bSmacallan 714954b44505Smrg case $arg in 715054b44505Smrg -all-static) 715154b44505Smrg if test -n "$link_static_flag"; then 715254b44505Smrg # See comment for -static flag below, for more details. 715354b44505Smrg func_append compile_command " $link_static_flag" 715454b44505Smrg func_append finalize_command " $link_static_flag" 715554b44505Smrg fi 715654b44505Smrg continue 715754b44505Smrg ;; 71584a041c5bSmacallan 715954b44505Smrg -allow-undefined) 716054b44505Smrg # FIXME: remove this flag sometime in the future. 71610a392d7eSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 716254b44505Smrg ;; 71634a041c5bSmacallan 716454b44505Smrg -avoid-version) 716554b44505Smrg avoid_version=yes 716654b44505Smrg continue 716754b44505Smrg ;; 71684a041c5bSmacallan 716954b44505Smrg -bindir) 717054b44505Smrg prev=bindir 717154b44505Smrg continue 717254b44505Smrg ;; 717354b44505Smrg 717454b44505Smrg -dlopen) 717554b44505Smrg prev=dlfiles 717654b44505Smrg continue 717754b44505Smrg ;; 717854b44505Smrg 717954b44505Smrg -dlpreopen) 718054b44505Smrg prev=dlprefiles 718154b44505Smrg continue 718254b44505Smrg ;; 718354b44505Smrg 718454b44505Smrg -export-dynamic) 718554b44505Smrg export_dynamic=yes 718654b44505Smrg continue 718754b44505Smrg ;; 718854b44505Smrg 718954b44505Smrg -export-symbols | -export-symbols-regex) 719054b44505Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 719154b44505Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 719254b44505Smrg fi 71930a392d7eSmrg if test X-export-symbols = "X$arg"; then 719454b44505Smrg prev=expsyms 719554b44505Smrg else 719654b44505Smrg prev=expsyms_regex 719754b44505Smrg fi 719854b44505Smrg continue 719954b44505Smrg ;; 720054b44505Smrg 720154b44505Smrg -framework) 720254b44505Smrg prev=framework 720354b44505Smrg continue 720454b44505Smrg ;; 720554b44505Smrg 720654b44505Smrg -inst-prefix-dir) 720754b44505Smrg prev=inst_prefix 720854b44505Smrg continue 720954b44505Smrg ;; 721054b44505Smrg 721154b44505Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 721254b44505Smrg # so, if we see these flags be careful not to treat them like -L 721354b44505Smrg -L[A-Z][A-Z]*:*) 721454b44505Smrg case $with_gcc/$host in 721554b44505Smrg no/*-*-irix* | /*-*-irix*) 721654b44505Smrg func_append compile_command " $arg" 721754b44505Smrg func_append finalize_command " $arg" 721854b44505Smrg ;; 721954b44505Smrg esac 722054b44505Smrg continue 722154b44505Smrg ;; 722254b44505Smrg 722354b44505Smrg -L*) 722454b44505Smrg func_stripname "-L" '' "$arg" 722554b44505Smrg if test -z "$func_stripname_result"; then 722654b44505Smrg if test "$#" -gt 0; then 72270a392d7eSmrg func_fatal_error "require no space between '-L' and '$1'" 722854b44505Smrg else 72290a392d7eSmrg func_fatal_error "need path for '-L' option" 723054b44505Smrg fi 723154b44505Smrg fi 723254b44505Smrg func_resolve_sysroot "$func_stripname_result" 723354b44505Smrg dir=$func_resolve_sysroot_result 723454b44505Smrg # We need an absolute path. 723554b44505Smrg case $dir in 723654b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 723754b44505Smrg *) 723854b44505Smrg absdir=`cd "$dir" && pwd` 723954b44505Smrg test -z "$absdir" && \ 72400a392d7eSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72410a392d7eSmrg dir=$absdir 724254b44505Smrg ;; 724354b44505Smrg esac 724454b44505Smrg case "$deplibs " in 724554b44505Smrg *" -L$dir "* | *" $arg "*) 724654b44505Smrg # Will only happen for absolute or sysroot arguments 724754b44505Smrg ;; 724854b44505Smrg *) 724954b44505Smrg # Preserve sysroot, but never include relative directories 725054b44505Smrg case $dir in 725154b44505Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 725254b44505Smrg *) func_append deplibs " -L$dir" ;; 725354b44505Smrg esac 725454b44505Smrg func_append lib_search_path " $dir" 725554b44505Smrg ;; 725654b44505Smrg esac 725754b44505Smrg case $host in 725854b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 725954b44505Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 726054b44505Smrg case :$dllsearchpath: in 726154b44505Smrg *":$dir:"*) ;; 726254b44505Smrg ::) dllsearchpath=$dir;; 726354b44505Smrg *) func_append dllsearchpath ":$dir";; 726454b44505Smrg esac 726554b44505Smrg case :$dllsearchpath: in 726654b44505Smrg *":$testbindir:"*) ;; 726754b44505Smrg ::) dllsearchpath=$testbindir;; 726854b44505Smrg *) func_append dllsearchpath ":$testbindir";; 726954b44505Smrg esac 727054b44505Smrg ;; 727154b44505Smrg esac 727254b44505Smrg continue 727354b44505Smrg ;; 727454b44505Smrg 727554b44505Smrg -l*) 72760a392d7eSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 727754b44505Smrg case $host in 727854b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 727954b44505Smrg # These systems don't actually have a C or math library (as such) 728054b44505Smrg continue 728154b44505Smrg ;; 728254b44505Smrg *-*-os2*) 728354b44505Smrg # These systems don't actually have a C library (as such) 72840a392d7eSmrg test X-lc = "X$arg" && continue 728554b44505Smrg ;; 72868fc2d0c6Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 728754b44505Smrg # Do not include libc due to us having libc/libc_r. 72880a392d7eSmrg test X-lc = "X$arg" && continue 728954b44505Smrg ;; 729054b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 729154b44505Smrg # Rhapsody C and math libraries are in the System framework 729254b44505Smrg func_append deplibs " System.ltframework" 729354b44505Smrg continue 729454b44505Smrg ;; 729554b44505Smrg *-*-sco3.2v5* | *-*-sco5v6*) 729654b44505Smrg # Causes problems with __ctype 72970a392d7eSmrg test X-lc = "X$arg" && continue 729854b44505Smrg ;; 729954b44505Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 730054b44505Smrg # Compiler inserts libc in the correct place for threads to work 73010a392d7eSmrg test X-lc = "X$arg" && continue 730254b44505Smrg ;; 730354b44505Smrg esac 73040a392d7eSmrg elif test X-lc_r = "X$arg"; then 730554b44505Smrg case $host in 73068fc2d0c6Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 730754b44505Smrg # Do not include libc_r directly, use -pthread flag. 730854b44505Smrg continue 730954b44505Smrg ;; 731054b44505Smrg esac 731154b44505Smrg fi 731254b44505Smrg func_append deplibs " $arg" 731354b44505Smrg continue 731454b44505Smrg ;; 731554b44505Smrg 73160a392d7eSmrg -mllvm) 73170a392d7eSmrg prev=mllvm 73180a392d7eSmrg continue 73190a392d7eSmrg ;; 73200a392d7eSmrg 732154b44505Smrg -module) 732254b44505Smrg module=yes 732354b44505Smrg continue 732454b44505Smrg ;; 732554b44505Smrg 732654b44505Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 732754b44505Smrg # classes, name mangling, and exception handling. 732854b44505Smrg # Darwin uses the -arch flag to determine output architecture. 732954b44505Smrg -model|-arch|-isysroot|--sysroot) 733054b44505Smrg func_append compiler_flags " $arg" 733154b44505Smrg func_append compile_command " $arg" 733254b44505Smrg func_append finalize_command " $arg" 733354b44505Smrg prev=xcompiler 733454b44505Smrg continue 733554b44505Smrg ;; 73368fc2d0c6Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73378fc2d0c6Smrg -pthread) 73388fc2d0c6Smrg case $host in 73398fc2d0c6Smrg *solaris2*) ;; 73408fc2d0c6Smrg *) 73418fc2d0c6Smrg case "$new_inherited_linker_flags " in 73428fc2d0c6Smrg *" $arg "*) ;; 73438fc2d0c6Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73448fc2d0c6Smrg esac 73458fc2d0c6Smrg ;; 73468fc2d0c6Smrg esac 73478fc2d0c6Smrg continue 73488fc2d0c6Smrg ;; 73498fc2d0c6Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73500a392d7eSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 735154b44505Smrg func_append compiler_flags " $arg" 735254b44505Smrg func_append compile_command " $arg" 735354b44505Smrg func_append finalize_command " $arg" 735454b44505Smrg case "$new_inherited_linker_flags " in 735554b44505Smrg *" $arg "*) ;; 735654b44505Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 735754b44505Smrg esac 735854b44505Smrg continue 735954b44505Smrg ;; 736054b44505Smrg 736154b44505Smrg -multi_module) 73620a392d7eSmrg single_module=$wl-multi_module 736354b44505Smrg continue 736454b44505Smrg ;; 736554b44505Smrg 736654b44505Smrg -no-fast-install) 736754b44505Smrg fast_install=no 736854b44505Smrg continue 736954b44505Smrg ;; 737054b44505Smrg 737154b44505Smrg -no-install) 737254b44505Smrg case $host in 737354b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 737454b44505Smrg # The PATH hackery in wrapper scripts is required on Windows 737554b44505Smrg # and Darwin in order for the loader to find any dlls it needs. 73760a392d7eSmrg func_warning "'-no-install' is ignored for $host" 73770a392d7eSmrg func_warning "assuming '-no-fast-install' instead" 737854b44505Smrg fast_install=no 737954b44505Smrg ;; 738054b44505Smrg *) no_install=yes ;; 738154b44505Smrg esac 738254b44505Smrg continue 738354b44505Smrg ;; 738454b44505Smrg 738554b44505Smrg -no-undefined) 738654b44505Smrg allow_undefined=no 738754b44505Smrg continue 738854b44505Smrg ;; 738954b44505Smrg 739054b44505Smrg -objectlist) 739154b44505Smrg prev=objectlist 739254b44505Smrg continue 739354b44505Smrg ;; 739454b44505Smrg 73950a392d7eSmrg -os2dllname) 73960a392d7eSmrg prev=os2dllname 73970a392d7eSmrg continue 73980a392d7eSmrg ;; 73990a392d7eSmrg 740054b44505Smrg -o) prev=output ;; 740154b44505Smrg 740254b44505Smrg -precious-files-regex) 740354b44505Smrg prev=precious_regex 740454b44505Smrg continue 740554b44505Smrg ;; 740654b44505Smrg 740754b44505Smrg -release) 740854b44505Smrg prev=release 740954b44505Smrg continue 741054b44505Smrg ;; 741154b44505Smrg 741254b44505Smrg -rpath) 741354b44505Smrg prev=rpath 741454b44505Smrg continue 741554b44505Smrg ;; 741654b44505Smrg 741754b44505Smrg -R) 741854b44505Smrg prev=xrpath 741954b44505Smrg continue 742054b44505Smrg ;; 742154b44505Smrg 742254b44505Smrg -R*) 742354b44505Smrg func_stripname '-R' '' "$arg" 742454b44505Smrg dir=$func_stripname_result 742554b44505Smrg # We need an absolute path. 742654b44505Smrg case $dir in 742754b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 742854b44505Smrg =*) 742954b44505Smrg func_stripname '=' '' "$dir" 743054b44505Smrg dir=$lt_sysroot$func_stripname_result 743154b44505Smrg ;; 743254b44505Smrg *) 743354b44505Smrg func_fatal_error "only absolute run-paths are allowed" 743454b44505Smrg ;; 743554b44505Smrg esac 743654b44505Smrg case "$xrpath " in 743754b44505Smrg *" $dir "*) ;; 743854b44505Smrg *) func_append xrpath " $dir" ;; 743954b44505Smrg esac 744054b44505Smrg continue 744154b44505Smrg ;; 744254b44505Smrg 744354b44505Smrg -shared) 744454b44505Smrg # The effects of -shared are defined in a previous loop. 744554b44505Smrg continue 744654b44505Smrg ;; 744754b44505Smrg 744854b44505Smrg -shrext) 744954b44505Smrg prev=shrext 745054b44505Smrg continue 745154b44505Smrg ;; 745254b44505Smrg 745354b44505Smrg -static | -static-libtool-libs) 745454b44505Smrg # The effects of -static are defined in a previous loop. 745554b44505Smrg # We used to do the same as -all-static on platforms that 745654b44505Smrg # didn't have a PIC flag, but the assumption that the effects 745754b44505Smrg # would be equivalent was wrong. It would break on at least 745854b44505Smrg # Digital Unix and AIX. 745954b44505Smrg continue 746054b44505Smrg ;; 746154b44505Smrg 746254b44505Smrg -thread-safe) 746354b44505Smrg thread_safe=yes 746454b44505Smrg continue 746554b44505Smrg ;; 746654b44505Smrg 746754b44505Smrg -version-info) 746854b44505Smrg prev=vinfo 746954b44505Smrg continue 747054b44505Smrg ;; 747154b44505Smrg 747254b44505Smrg -version-number) 747354b44505Smrg prev=vinfo 747454b44505Smrg vinfo_number=yes 747554b44505Smrg continue 747654b44505Smrg ;; 747754b44505Smrg 747854b44505Smrg -weak) 747954b44505Smrg prev=weak 748054b44505Smrg continue 748154b44505Smrg ;; 748254b44505Smrg 748354b44505Smrg -Wc,*) 748454b44505Smrg func_stripname '-Wc,' '' "$arg" 748554b44505Smrg args=$func_stripname_result 748654b44505Smrg arg= 74870a392d7eSmrg save_ifs=$IFS; IFS=, 748854b44505Smrg for flag in $args; do 74890a392d7eSmrg IFS=$save_ifs 74908fc2d0c6Smrg func_quote_arg pretty "$flag" 74918fc2d0c6Smrg func_append arg " $func_quote_arg_result" 74928fc2d0c6Smrg func_append compiler_flags " $func_quote_arg_result" 749354b44505Smrg done 74940a392d7eSmrg IFS=$save_ifs 749554b44505Smrg func_stripname ' ' '' "$arg" 749654b44505Smrg arg=$func_stripname_result 749754b44505Smrg ;; 749854b44505Smrg 749954b44505Smrg -Wl,*) 750054b44505Smrg func_stripname '-Wl,' '' "$arg" 750154b44505Smrg args=$func_stripname_result 750254b44505Smrg arg= 75030a392d7eSmrg save_ifs=$IFS; IFS=, 750454b44505Smrg for flag in $args; do 75050a392d7eSmrg IFS=$save_ifs 75068fc2d0c6Smrg func_quote_arg pretty "$flag" 75078fc2d0c6Smrg func_append arg " $wl$func_quote_arg_result" 75088fc2d0c6Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75098fc2d0c6Smrg func_append linker_flags " $func_quote_arg_result" 751054b44505Smrg done 75110a392d7eSmrg IFS=$save_ifs 751254b44505Smrg func_stripname ' ' '' "$arg" 751354b44505Smrg arg=$func_stripname_result 751454b44505Smrg ;; 751554b44505Smrg 75168fc2d0c6Smrg -Xassembler) 75178fc2d0c6Smrg prev=xassembler 75188fc2d0c6Smrg continue 75198fc2d0c6Smrg ;; 75208fc2d0c6Smrg 752154b44505Smrg -Xcompiler) 752254b44505Smrg prev=xcompiler 752354b44505Smrg continue 752454b44505Smrg ;; 752554b44505Smrg 752654b44505Smrg -Xlinker) 752754b44505Smrg prev=xlinker 752854b44505Smrg continue 752954b44505Smrg ;; 753054b44505Smrg 753154b44505Smrg -XCClinker) 753254b44505Smrg prev=xcclinker 753354b44505Smrg continue 753454b44505Smrg ;; 753554b44505Smrg 753654b44505Smrg # -msg_* for osf cc 753754b44505Smrg -msg_*) 75388fc2d0c6Smrg func_quote_arg pretty "$arg" 75398fc2d0c6Smrg arg=$func_quote_arg_result 754054b44505Smrg ;; 754154b44505Smrg 754254b44505Smrg # Flags to be passed through unchanged, with rationale: 754354b44505Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 754454b44505Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 754554b44505Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 754654b44505Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 754754b44505Smrg # -q* compiler args for the IBM compiler 754854b44505Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 754954b44505Smrg # -F/path path to uninstalled frameworks, gcc on darwin 755054b44505Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75510a392d7eSmrg # -fstack-protector* stack protector flags for GCC 755254b44505Smrg # @file GCC response files 755354b44505Smrg # -tp=* Portland pgcc target processor selection 755454b44505Smrg # --sysroot=* for sysroot support 75550a392d7eSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75568fc2d0c6Smrg # -specs=* GCC specs files 75570a392d7eSmrg # -stdlib=* select c++ std lib with clang 75588fc2d0c6Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75598fc2d0c6Smrg # -fuse-ld=* Linker select flags for GCC 75608fc2d0c6Smrg # -Wa,* Pass flags directly to the assembler 756154b44505Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 756254b44505Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75638fc2d0c6Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75648fc2d0c6Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75658fc2d0c6Smrg func_quote_arg pretty "$arg" 75668fc2d0c6Smrg arg=$func_quote_arg_result 756754b44505Smrg func_append compile_command " $arg" 756854b44505Smrg func_append finalize_command " $arg" 756954b44505Smrg func_append compiler_flags " $arg" 757054b44505Smrg continue 757154b44505Smrg ;; 757254b44505Smrg 75730a392d7eSmrg -Z*) 75740a392d7eSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75750a392d7eSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75760a392d7eSmrg compiler_flags="$compiler_flags $arg" 75770a392d7eSmrg func_append compile_command " $arg" 75780a392d7eSmrg func_append finalize_command " $arg" 75790a392d7eSmrg case $arg in 75800a392d7eSmrg -Zlinker | -Zstack) 75810a392d7eSmrg prev=xcompiler 75820a392d7eSmrg ;; 75830a392d7eSmrg esac 75840a392d7eSmrg continue 75850a392d7eSmrg else 75860a392d7eSmrg # Otherwise treat like 'Some other compiler flag' below 75878fc2d0c6Smrg func_quote_arg pretty "$arg" 75888fc2d0c6Smrg arg=$func_quote_arg_result 75890a392d7eSmrg fi 75900a392d7eSmrg ;; 75910a392d7eSmrg 759254b44505Smrg # Some other compiler flag. 759354b44505Smrg -* | +*) 75948fc2d0c6Smrg func_quote_arg pretty "$arg" 75958fc2d0c6Smrg arg=$func_quote_arg_result 759654b44505Smrg ;; 759754b44505Smrg 759854b44505Smrg *.$objext) 759954b44505Smrg # A standard object. 760054b44505Smrg func_append objs " $arg" 760154b44505Smrg ;; 760254b44505Smrg 760354b44505Smrg *.lo) 760454b44505Smrg # A libtool-controlled object. 760554b44505Smrg 760654b44505Smrg # Check to see that this really is a libtool object. 760754b44505Smrg if func_lalib_unsafe_p "$arg"; then 760854b44505Smrg pic_object= 760954b44505Smrg non_pic_object= 761054b44505Smrg 761154b44505Smrg # Read the .lo file 761254b44505Smrg func_source "$arg" 761354b44505Smrg 761454b44505Smrg if test -z "$pic_object" || 761554b44505Smrg test -z "$non_pic_object" || 76160a392d7eSmrg test none = "$pic_object" && 76170a392d7eSmrg test none = "$non_pic_object"; then 76180a392d7eSmrg func_fatal_error "cannot find name of object for '$arg'" 761954b44505Smrg fi 762054b44505Smrg 762154b44505Smrg # Extract subdirectory from the argument. 762254b44505Smrg func_dirname "$arg" "/" "" 76230a392d7eSmrg xdir=$func_dirname_result 762454b44505Smrg 76250a392d7eSmrg test none = "$pic_object" || { 762654b44505Smrg # Prepend the subdirectory the object is found in. 76270a392d7eSmrg pic_object=$xdir$pic_object 762854b44505Smrg 76290a392d7eSmrg if test dlfiles = "$prev"; then 76300a392d7eSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 763154b44505Smrg func_append dlfiles " $pic_object" 763254b44505Smrg prev= 763354b44505Smrg continue 763454b44505Smrg else 763554b44505Smrg # If libtool objects are unsupported, then we need to preload. 763654b44505Smrg prev=dlprefiles 763754b44505Smrg fi 763854b44505Smrg fi 763954b44505Smrg 764054b44505Smrg # CHECK ME: I think I busted this. -Ossama 76410a392d7eSmrg if test dlprefiles = "$prev"; then 764254b44505Smrg # Preload the old-style object. 764354b44505Smrg func_append dlprefiles " $pic_object" 764454b44505Smrg prev= 764554b44505Smrg fi 764654b44505Smrg 764754b44505Smrg # A PIC object. 764854b44505Smrg func_append libobjs " $pic_object" 76490a392d7eSmrg arg=$pic_object 76500a392d7eSmrg } 765154b44505Smrg 765254b44505Smrg # Non-PIC object. 76530a392d7eSmrg if test none != "$non_pic_object"; then 765454b44505Smrg # Prepend the subdirectory the object is found in. 76550a392d7eSmrg non_pic_object=$xdir$non_pic_object 765654b44505Smrg 765754b44505Smrg # A standard non-PIC object 765854b44505Smrg func_append non_pic_objects " $non_pic_object" 76590a392d7eSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76600a392d7eSmrg arg=$non_pic_object 766154b44505Smrg fi 766254b44505Smrg else 766354b44505Smrg # If the PIC object exists, use it instead. 766454b44505Smrg # $xdir was prepended to $pic_object above. 76650a392d7eSmrg non_pic_object=$pic_object 766654b44505Smrg func_append non_pic_objects " $non_pic_object" 766754b44505Smrg fi 766854b44505Smrg else 766954b44505Smrg # Only an error if not doing a dry-run. 767054b44505Smrg if $opt_dry_run; then 767154b44505Smrg # Extract subdirectory from the argument. 767254b44505Smrg func_dirname "$arg" "/" "" 76730a392d7eSmrg xdir=$func_dirname_result 767454b44505Smrg 767554b44505Smrg func_lo2o "$arg" 767654b44505Smrg pic_object=$xdir$objdir/$func_lo2o_result 767754b44505Smrg non_pic_object=$xdir$func_lo2o_result 767854b44505Smrg func_append libobjs " $pic_object" 767954b44505Smrg func_append non_pic_objects " $non_pic_object" 768054b44505Smrg else 76810a392d7eSmrg func_fatal_error "'$arg' is not a valid libtool object" 768254b44505Smrg fi 768354b44505Smrg fi 768454b44505Smrg ;; 768554b44505Smrg 768654b44505Smrg *.$libext) 768754b44505Smrg # An archive. 768854b44505Smrg func_append deplibs " $arg" 768954b44505Smrg func_append old_deplibs " $arg" 769054b44505Smrg continue 769154b44505Smrg ;; 769254b44505Smrg 769354b44505Smrg *.la) 769454b44505Smrg # A libtool-controlled library. 769554b44505Smrg 769654b44505Smrg func_resolve_sysroot "$arg" 76970a392d7eSmrg if test dlfiles = "$prev"; then 769854b44505Smrg # This library was specified with -dlopen. 769954b44505Smrg func_append dlfiles " $func_resolve_sysroot_result" 770054b44505Smrg prev= 77010a392d7eSmrg elif test dlprefiles = "$prev"; then 770254b44505Smrg # The library was specified with -dlpreopen. 770354b44505Smrg func_append dlprefiles " $func_resolve_sysroot_result" 770454b44505Smrg prev= 770554b44505Smrg else 770654b44505Smrg func_append deplibs " $func_resolve_sysroot_result" 770754b44505Smrg fi 770854b44505Smrg continue 770954b44505Smrg ;; 771054b44505Smrg 771154b44505Smrg # Some other compiler argument. 771254b44505Smrg *) 771354b44505Smrg # Unknown arguments in both finalize_command and compile_command need 771454b44505Smrg # to be aesthetically quoted because they are evaled later. 77158fc2d0c6Smrg func_quote_arg pretty "$arg" 77168fc2d0c6Smrg arg=$func_quote_arg_result 771754b44505Smrg ;; 771854b44505Smrg esac # arg 771954b44505Smrg 772054b44505Smrg # Now actually substitute the argument into the commands. 772154b44505Smrg if test -n "$arg"; then 772254b44505Smrg func_append compile_command " $arg" 772354b44505Smrg func_append finalize_command " $arg" 772454b44505Smrg fi 772554b44505Smrg done # argument parsing loop 772654b44505Smrg 772754b44505Smrg test -n "$prev" && \ 77280a392d7eSmrg func_fatal_help "the '$prevarg' option requires an argument" 772954b44505Smrg 77300a392d7eSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 773154b44505Smrg eval arg=\"$export_dynamic_flag_spec\" 773254b44505Smrg func_append compile_command " $arg" 773354b44505Smrg func_append finalize_command " $arg" 773454b44505Smrg fi 773554b44505Smrg 773654b44505Smrg oldlibs= 773754b44505Smrg # calculate the name of the file, without its directory 773854b44505Smrg func_basename "$output" 77390a392d7eSmrg outputname=$func_basename_result 77400a392d7eSmrg libobjs_save=$libobjs 774154b44505Smrg 774254b44505Smrg if test -n "$shlibpath_var"; then 774354b44505Smrg # get the directories listed in $shlibpath_var 77440a392d7eSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 774554b44505Smrg else 774654b44505Smrg shlib_search_path= 774754b44505Smrg fi 774854b44505Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 774954b44505Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 775054b44505Smrg 77510a392d7eSmrg # Definition is injected by LT_CONFIG during libtool generation. 77520a392d7eSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77530a392d7eSmrg 775454b44505Smrg func_dirname "$output" "/" "" 77550a392d7eSmrg output_objdir=$func_dirname_result$objdir 775654b44505Smrg func_to_tool_file "$output_objdir/" 775754b44505Smrg tool_output_objdir=$func_to_tool_file_result 775854b44505Smrg # Create the object directory. 775954b44505Smrg func_mkdir_p "$output_objdir" 776054b44505Smrg 776154b44505Smrg # Determine the type of output 776254b44505Smrg case $output in 776354b44505Smrg "") 776454b44505Smrg func_fatal_help "you must specify an output file" 776554b44505Smrg ;; 776654b44505Smrg *.$libext) linkmode=oldlib ;; 776754b44505Smrg *.lo | *.$objext) linkmode=obj ;; 776854b44505Smrg *.la) linkmode=lib ;; 776954b44505Smrg *) linkmode=prog ;; # Anything else should be a program. 777054b44505Smrg esac 777154b44505Smrg 777254b44505Smrg specialdeplibs= 777354b44505Smrg 777454b44505Smrg libs= 777554b44505Smrg # Find all interdependent deplibs by searching for libraries 777654b44505Smrg # that are linked more than once (e.g. -la -lb -la) 777754b44505Smrg for deplib in $deplibs; do 77780a392d7eSmrg if $opt_preserve_dup_deps; then 777954b44505Smrg case "$libs " in 778054b44505Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 778154b44505Smrg esac 778254b44505Smrg fi 778354b44505Smrg func_append libs " $deplib" 778454b44505Smrg done 778554b44505Smrg 77860a392d7eSmrg if test lib = "$linkmode"; then 778754b44505Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 778854b44505Smrg 778954b44505Smrg # Compute libraries that are listed more than once in $predeps 779054b44505Smrg # $postdeps and mark them as special (i.e., whose duplicates are 779154b44505Smrg # not to be eliminated). 779254b44505Smrg pre_post_deps= 779354b44505Smrg if $opt_duplicate_compiler_generated_deps; then 779454b44505Smrg for pre_post_dep in $predeps $postdeps; do 779554b44505Smrg case "$pre_post_deps " in 779654b44505Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 779754b44505Smrg esac 779854b44505Smrg func_append pre_post_deps " $pre_post_dep" 779954b44505Smrg done 780054b44505Smrg fi 780154b44505Smrg pre_post_deps= 780254b44505Smrg fi 780354b44505Smrg 780454b44505Smrg deplibs= 780554b44505Smrg newdependency_libs= 780654b44505Smrg newlib_search_path= 780754b44505Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 780854b44505Smrg notinst_deplibs= # not-installed libtool libraries 780954b44505Smrg notinst_path= # paths that contain not-installed libtool libraries 781054b44505Smrg 781154b44505Smrg case $linkmode in 781254b44505Smrg lib) 781354b44505Smrg passes="conv dlpreopen link" 781454b44505Smrg for file in $dlfiles $dlprefiles; do 781554b44505Smrg case $file in 781654b44505Smrg *.la) ;; 781754b44505Smrg *) 78180a392d7eSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 781954b44505Smrg ;; 782054b44505Smrg esac 782154b44505Smrg done 782254b44505Smrg ;; 782354b44505Smrg prog) 782454b44505Smrg compile_deplibs= 782554b44505Smrg finalize_deplibs= 78260a392d7eSmrg alldeplibs=false 782754b44505Smrg newdlfiles= 782854b44505Smrg newdlprefiles= 782954b44505Smrg passes="conv scan dlopen dlpreopen link" 783054b44505Smrg ;; 783154b44505Smrg *) passes="conv" 783254b44505Smrg ;; 783354b44505Smrg esac 783454b44505Smrg 783554b44505Smrg for pass in $passes; do 783654b44505Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 783754b44505Smrg # so that -L comes before libs that need it for instance... 78380a392d7eSmrg if test lib,link = "$linkmode,$pass"; then 783954b44505Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 784054b44505Smrg ## order, and fix it there properly 784154b44505Smrg tmp_deplibs= 784254b44505Smrg for deplib in $deplibs; do 784354b44505Smrg tmp_deplibs="$deplib $tmp_deplibs" 784454b44505Smrg done 78450a392d7eSmrg deplibs=$tmp_deplibs 784654b44505Smrg fi 784754b44505Smrg 78480a392d7eSmrg if test lib,link = "$linkmode,$pass" || 78490a392d7eSmrg test prog,scan = "$linkmode,$pass"; then 78500a392d7eSmrg libs=$deplibs 785154b44505Smrg deplibs= 785254b44505Smrg fi 78530a392d7eSmrg if test prog = "$linkmode"; then 785454b44505Smrg case $pass in 78550a392d7eSmrg dlopen) libs=$dlfiles ;; 78560a392d7eSmrg dlpreopen) libs=$dlprefiles ;; 785754b44505Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 785854b44505Smrg esac 785954b44505Smrg fi 78600a392d7eSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 786154b44505Smrg # Collect and forward deplibs of preopened libtool libs 786254b44505Smrg for lib in $dlprefiles; do 786354b44505Smrg # Ignore non-libtool-libs 786454b44505Smrg dependency_libs= 786554b44505Smrg func_resolve_sysroot "$lib" 786654b44505Smrg case $lib in 786754b44505Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 786854b44505Smrg esac 786954b44505Smrg 787054b44505Smrg # Collect preopened libtool deplibs, except any this library 787154b44505Smrg # has declared as weak libs 787254b44505Smrg for deplib in $dependency_libs; do 787354b44505Smrg func_basename "$deplib" 787454b44505Smrg deplib_base=$func_basename_result 787554b44505Smrg case " $weak_libs " in 787654b44505Smrg *" $deplib_base "*) ;; 787754b44505Smrg *) func_append deplibs " $deplib" ;; 787854b44505Smrg esac 787954b44505Smrg done 788054b44505Smrg done 78810a392d7eSmrg libs=$dlprefiles 788254b44505Smrg fi 78830a392d7eSmrg if test dlopen = "$pass"; then 788454b44505Smrg # Collect dlpreopened libraries 78850a392d7eSmrg save_deplibs=$deplibs 788654b44505Smrg deplibs= 788754b44505Smrg fi 788854b44505Smrg 788954b44505Smrg for deplib in $libs; do 789054b44505Smrg lib= 78910a392d7eSmrg found=false 789254b44505Smrg case $deplib in 78930a392d7eSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78940a392d7eSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78950a392d7eSmrg if test prog,link = "$linkmode,$pass"; then 789654b44505Smrg compile_deplibs="$deplib $compile_deplibs" 789754b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 789854b44505Smrg else 789954b44505Smrg func_append compiler_flags " $deplib" 79000a392d7eSmrg if test lib = "$linkmode"; then 790154b44505Smrg case "$new_inherited_linker_flags " in 790254b44505Smrg *" $deplib "*) ;; 790354b44505Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 790454b44505Smrg esac 790554b44505Smrg fi 790654b44505Smrg fi 790754b44505Smrg continue 790854b44505Smrg ;; 790954b44505Smrg -l*) 79100a392d7eSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79110a392d7eSmrg func_warning "'-l' is ignored for archives/objects" 791254b44505Smrg continue 791354b44505Smrg fi 791454b44505Smrg func_stripname '-l' '' "$deplib" 791554b44505Smrg name=$func_stripname_result 79160a392d7eSmrg if test lib = "$linkmode"; then 791754b44505Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 791854b44505Smrg else 791954b44505Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 792054b44505Smrg fi 792154b44505Smrg for searchdir in $searchdirs; do 792254b44505Smrg for search_ext in .la $std_shrext .so .a; do 792354b44505Smrg # Search the libtool library 79240a392d7eSmrg lib=$searchdir/lib$name$search_ext 792554b44505Smrg if test -f "$lib"; then 79260a392d7eSmrg if test .la = "$search_ext"; then 79270a392d7eSmrg found=: 792854b44505Smrg else 79290a392d7eSmrg found=false 793054b44505Smrg fi 793154b44505Smrg break 2 793254b44505Smrg fi 793354b44505Smrg done 793454b44505Smrg done 79350a392d7eSmrg if $found; then 79360a392d7eSmrg # deplib is a libtool library 793754b44505Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 793854b44505Smrg # We need to do some special things here, and not later. 79390a392d7eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 794054b44505Smrg case " $predeps $postdeps " in 794154b44505Smrg *" $deplib "*) 794254b44505Smrg if func_lalib_p "$lib"; then 794354b44505Smrg library_names= 794454b44505Smrg old_library= 794554b44505Smrg func_source "$lib" 794654b44505Smrg for l in $old_library $library_names; do 79470a392d7eSmrg ll=$l 794854b44505Smrg done 79490a392d7eSmrg if test "X$ll" = "X$old_library"; then # only static version available 79500a392d7eSmrg found=false 795154b44505Smrg func_dirname "$lib" "" "." 79520a392d7eSmrg ladir=$func_dirname_result 795354b44505Smrg lib=$ladir/$old_library 79540a392d7eSmrg if test prog,link = "$linkmode,$pass"; then 795554b44505Smrg compile_deplibs="$deplib $compile_deplibs" 795654b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 795754b44505Smrg else 795854b44505Smrg deplibs="$deplib $deplibs" 79590a392d7eSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 796054b44505Smrg fi 796154b44505Smrg continue 796254b44505Smrg fi 796354b44505Smrg fi 796454b44505Smrg ;; 796554b44505Smrg *) ;; 796654b44505Smrg esac 796754b44505Smrg fi 79680a392d7eSmrg else 79690a392d7eSmrg # deplib doesn't seem to be a libtool library 79700a392d7eSmrg if test prog,link = "$linkmode,$pass"; then 79710a392d7eSmrg compile_deplibs="$deplib $compile_deplibs" 79720a392d7eSmrg finalize_deplibs="$deplib $finalize_deplibs" 79730a392d7eSmrg else 79740a392d7eSmrg deplibs="$deplib $deplibs" 79750a392d7eSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79760a392d7eSmrg fi 79770a392d7eSmrg continue 797854b44505Smrg fi 797954b44505Smrg ;; # -l 798054b44505Smrg *.ltframework) 79810a392d7eSmrg if test prog,link = "$linkmode,$pass"; then 798254b44505Smrg compile_deplibs="$deplib $compile_deplibs" 798354b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 798454b44505Smrg else 798554b44505Smrg deplibs="$deplib $deplibs" 79860a392d7eSmrg if test lib = "$linkmode"; then 798754b44505Smrg case "$new_inherited_linker_flags " in 798854b44505Smrg *" $deplib "*) ;; 798954b44505Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 799054b44505Smrg esac 799154b44505Smrg fi 799254b44505Smrg fi 799354b44505Smrg continue 799454b44505Smrg ;; 799554b44505Smrg -L*) 799654b44505Smrg case $linkmode in 799754b44505Smrg lib) 799854b44505Smrg deplibs="$deplib $deplibs" 79990a392d7eSmrg test conv = "$pass" && continue 800054b44505Smrg newdependency_libs="$deplib $newdependency_libs" 800154b44505Smrg func_stripname '-L' '' "$deplib" 800254b44505Smrg func_resolve_sysroot "$func_stripname_result" 800354b44505Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 800454b44505Smrg ;; 800554b44505Smrg prog) 80060a392d7eSmrg if test conv = "$pass"; then 800754b44505Smrg deplibs="$deplib $deplibs" 800854b44505Smrg continue 800954b44505Smrg fi 80100a392d7eSmrg if test scan = "$pass"; then 801154b44505Smrg deplibs="$deplib $deplibs" 801254b44505Smrg else 801354b44505Smrg compile_deplibs="$deplib $compile_deplibs" 801454b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 801554b44505Smrg fi 801654b44505Smrg func_stripname '-L' '' "$deplib" 801754b44505Smrg func_resolve_sysroot "$func_stripname_result" 801854b44505Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 801954b44505Smrg ;; 802054b44505Smrg *) 80210a392d7eSmrg func_warning "'-L' is ignored for archives/objects" 802254b44505Smrg ;; 802354b44505Smrg esac # linkmode 802454b44505Smrg continue 802554b44505Smrg ;; # -L 802654b44505Smrg -R*) 80270a392d7eSmrg if test link = "$pass"; then 802854b44505Smrg func_stripname '-R' '' "$deplib" 802954b44505Smrg func_resolve_sysroot "$func_stripname_result" 803054b44505Smrg dir=$func_resolve_sysroot_result 803154b44505Smrg # Make sure the xrpath contains only unique directories. 803254b44505Smrg case "$xrpath " in 803354b44505Smrg *" $dir "*) ;; 803454b44505Smrg *) func_append xrpath " $dir" ;; 803554b44505Smrg esac 803654b44505Smrg fi 803754b44505Smrg deplibs="$deplib $deplibs" 803854b44505Smrg continue 803954b44505Smrg ;; 804054b44505Smrg *.la) 804154b44505Smrg func_resolve_sysroot "$deplib" 804254b44505Smrg lib=$func_resolve_sysroot_result 804354b44505Smrg ;; 804454b44505Smrg *.$libext) 80450a392d7eSmrg if test conv = "$pass"; then 804654b44505Smrg deplibs="$deplib $deplibs" 804754b44505Smrg continue 804854b44505Smrg fi 804954b44505Smrg case $linkmode in 805054b44505Smrg lib) 805154b44505Smrg # Linking convenience modules into shared libraries is allowed, 805254b44505Smrg # but linking other static libraries is non-portable. 805354b44505Smrg case " $dlpreconveniencelibs " in 805454b44505Smrg *" $deplib "*) ;; 805554b44505Smrg *) 80560a392d7eSmrg valid_a_lib=false 805754b44505Smrg case $deplibs_check_method in 805854b44505Smrg match_pattern*) 805954b44505Smrg set dummy $deplibs_check_method; shift 806054b44505Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 806154b44505Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 806254b44505Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80630a392d7eSmrg valid_a_lib=: 806454b44505Smrg fi 806554b44505Smrg ;; 806654b44505Smrg pass_all) 80670a392d7eSmrg valid_a_lib=: 806854b44505Smrg ;; 806954b44505Smrg esac 80700a392d7eSmrg if $valid_a_lib; then 80710a392d7eSmrg echo 80720a392d7eSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80730a392d7eSmrg $ECHO "*** static library $deplib is not portable!" 80740a392d7eSmrg deplibs="$deplib $deplibs" 80750a392d7eSmrg else 807654b44505Smrg echo 807754b44505Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 807854b44505Smrg echo "*** I have the capability to make that library automatically link in when" 807954b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 808054b44505Smrg echo "*** shared version of the library, which you do not appear to have" 808154b44505Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 808254b44505Smrg echo "*** that it is just a static archive that I should not use here." 808354b44505Smrg fi 808454b44505Smrg ;; 808554b44505Smrg esac 808654b44505Smrg continue 808754b44505Smrg ;; 808854b44505Smrg prog) 80890a392d7eSmrg if test link != "$pass"; then 809054b44505Smrg deplibs="$deplib $deplibs" 809154b44505Smrg else 809254b44505Smrg compile_deplibs="$deplib $compile_deplibs" 809354b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 809454b44505Smrg fi 809554b44505Smrg continue 809654b44505Smrg ;; 809754b44505Smrg esac # linkmode 809854b44505Smrg ;; # *.$libext 809954b44505Smrg *.lo | *.$objext) 81000a392d7eSmrg if test conv = "$pass"; then 810154b44505Smrg deplibs="$deplib $deplibs" 81020a392d7eSmrg elif test prog = "$linkmode"; then 81030a392d7eSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 810454b44505Smrg # If there is no dlopen support or we're linking statically, 810554b44505Smrg # we need to preload. 810654b44505Smrg func_append newdlprefiles " $deplib" 810754b44505Smrg compile_deplibs="$deplib $compile_deplibs" 810854b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 810954b44505Smrg else 811054b44505Smrg func_append newdlfiles " $deplib" 811154b44505Smrg fi 811254b44505Smrg fi 811354b44505Smrg continue 811454b44505Smrg ;; 811554b44505Smrg %DEPLIBS%) 81160a392d7eSmrg alldeplibs=: 811754b44505Smrg continue 811854b44505Smrg ;; 811954b44505Smrg esac # case $deplib 812054b44505Smrg 81210a392d7eSmrg $found || test -f "$lib" \ 81220a392d7eSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 812354b44505Smrg 812454b44505Smrg # Check to see that this really is a libtool archive. 812554b44505Smrg func_lalib_unsafe_p "$lib" \ 81260a392d7eSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 812754b44505Smrg 812854b44505Smrg func_dirname "$lib" "" "." 81290a392d7eSmrg ladir=$func_dirname_result 813054b44505Smrg 813154b44505Smrg dlname= 813254b44505Smrg dlopen= 813354b44505Smrg dlpreopen= 813454b44505Smrg libdir= 813554b44505Smrg library_names= 813654b44505Smrg old_library= 813754b44505Smrg inherited_linker_flags= 813854b44505Smrg # If the library was installed with an old release of libtool, 813954b44505Smrg # it will not redefine variables installed, or shouldnotlink 814054b44505Smrg installed=yes 814154b44505Smrg shouldnotlink=no 814254b44505Smrg avoidtemprpath= 814354b44505Smrg 814454b44505Smrg 814554b44505Smrg # Read the .la file 814654b44505Smrg func_source "$lib" 814754b44505Smrg 814854b44505Smrg # Convert "-framework foo" to "foo.ltframework" 814954b44505Smrg if test -n "$inherited_linker_flags"; then 815054b44505Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 815154b44505Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 815254b44505Smrg case " $new_inherited_linker_flags " in 815354b44505Smrg *" $tmp_inherited_linker_flag "*) ;; 815454b44505Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 815554b44505Smrg esac 815654b44505Smrg done 815754b44505Smrg fi 815854b44505Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81590a392d7eSmrg if test lib,link = "$linkmode,$pass" || 81600a392d7eSmrg test prog,scan = "$linkmode,$pass" || 81610a392d7eSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 816254b44505Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 816354b44505Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 816454b44505Smrg fi 816554b44505Smrg 81660a392d7eSmrg if test conv = "$pass"; then 816754b44505Smrg # Only check for convenience libraries 816854b44505Smrg deplibs="$lib $deplibs" 816954b44505Smrg if test -z "$libdir"; then 817054b44505Smrg if test -z "$old_library"; then 81710a392d7eSmrg func_fatal_error "cannot find name of link library for '$lib'" 817254b44505Smrg fi 817354b44505Smrg # It is a libtool convenience library, so add in its objects. 817454b44505Smrg func_append convenience " $ladir/$objdir/$old_library" 817554b44505Smrg func_append old_convenience " $ladir/$objdir/$old_library" 81760a392d7eSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81770a392d7eSmrg func_fatal_error "'$lib' is not a convenience library" 817854b44505Smrg fi 817954b44505Smrg tmp_libs= 818054b44505Smrg for deplib in $dependency_libs; do 818154b44505Smrg deplibs="$deplib $deplibs" 81820a392d7eSmrg if $opt_preserve_dup_deps; then 818354b44505Smrg case "$tmp_libs " in 818454b44505Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 818554b44505Smrg esac 818654b44505Smrg fi 818754b44505Smrg func_append tmp_libs " $deplib" 818854b44505Smrg done 818954b44505Smrg continue 819054b44505Smrg fi # $pass = conv 819154b44505Smrg 819254b44505Smrg 819354b44505Smrg # Get the name of the library we link against. 819454b44505Smrg linklib= 819554b44505Smrg if test -n "$old_library" && 81960a392d7eSmrg { test yes = "$prefer_static_libs" || 81970a392d7eSmrg test built,no = "$prefer_static_libs,$installed"; }; then 819854b44505Smrg linklib=$old_library 819954b44505Smrg else 820054b44505Smrg for l in $old_library $library_names; do 82010a392d7eSmrg linklib=$l 820254b44505Smrg done 820354b44505Smrg fi 820454b44505Smrg if test -z "$linklib"; then 82050a392d7eSmrg func_fatal_error "cannot find name of link library for '$lib'" 820654b44505Smrg fi 820754b44505Smrg 820854b44505Smrg # This library was specified with -dlopen. 82090a392d7eSmrg if test dlopen = "$pass"; then 82100a392d7eSmrg test -z "$libdir" \ 82110a392d7eSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 821254b44505Smrg if test -z "$dlname" || 82130a392d7eSmrg test yes != "$dlopen_support" || 82140a392d7eSmrg test no = "$build_libtool_libs" 82150a392d7eSmrg then 821654b44505Smrg # If there is no dlname, no dlopen support or we're linking 821754b44505Smrg # statically, we need to preload. We also need to preload any 821854b44505Smrg # dependent libraries so libltdl's deplib preloader doesn't 821954b44505Smrg # bomb out in the load deplibs phase. 822054b44505Smrg func_append dlprefiles " $lib $dependency_libs" 822154b44505Smrg else 822254b44505Smrg func_append newdlfiles " $lib" 822354b44505Smrg fi 822454b44505Smrg continue 822554b44505Smrg fi # $pass = dlopen 822654b44505Smrg 822754b44505Smrg # We need an absolute path. 822854b44505Smrg case $ladir in 82290a392d7eSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 823054b44505Smrg *) 823154b44505Smrg abs_ladir=`cd "$ladir" && pwd` 823254b44505Smrg if test -z "$abs_ladir"; then 82330a392d7eSmrg func_warning "cannot determine absolute directory name of '$ladir'" 823454b44505Smrg func_warning "passing it literally to the linker, although it might fail" 82350a392d7eSmrg abs_ladir=$ladir 823654b44505Smrg fi 823754b44505Smrg ;; 823854b44505Smrg esac 823954b44505Smrg func_basename "$lib" 82400a392d7eSmrg laname=$func_basename_result 824154b44505Smrg 824254b44505Smrg # Find the relevant object directory and library name. 82430a392d7eSmrg if test yes = "$installed"; then 824454b44505Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82450a392d7eSmrg func_warning "library '$lib' was moved." 82460a392d7eSmrg dir=$ladir 82470a392d7eSmrg absdir=$abs_ladir 82480a392d7eSmrg libdir=$abs_ladir 824954b44505Smrg else 82500a392d7eSmrg dir=$lt_sysroot$libdir 82510a392d7eSmrg absdir=$lt_sysroot$libdir 825254b44505Smrg fi 82530a392d7eSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 825454b44505Smrg else 825554b44505Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82560a392d7eSmrg dir=$ladir 82570a392d7eSmrg absdir=$abs_ladir 825854b44505Smrg # Remove this search path later 825954b44505Smrg func_append notinst_path " $abs_ladir" 826054b44505Smrg else 82610a392d7eSmrg dir=$ladir/$objdir 82620a392d7eSmrg absdir=$abs_ladir/$objdir 826354b44505Smrg # Remove this search path later 826454b44505Smrg func_append notinst_path " $abs_ladir" 826554b44505Smrg fi 826654b44505Smrg fi # $installed = yes 826754b44505Smrg func_stripname 'lib' '.la' "$laname" 826854b44505Smrg name=$func_stripname_result 826954b44505Smrg 827054b44505Smrg # This library was specified with -dlpreopen. 82710a392d7eSmrg if test dlpreopen = "$pass"; then 82720a392d7eSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82730a392d7eSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 827454b44505Smrg fi 82750a392d7eSmrg case $host in 827654b44505Smrg # special handling for platforms with PE-DLLs. 827754b44505Smrg *cygwin* | *mingw* | *cegcc* ) 827854b44505Smrg # Linker will automatically link against shared library if both 827954b44505Smrg # static and shared are present. Therefore, ensure we extract 828054b44505Smrg # symbols from the import library if a shared library is present 828154b44505Smrg # (otherwise, the dlopen module name will be incorrect). We do 828254b44505Smrg # this by putting the import library name into $newdlprefiles. 828354b44505Smrg # We recover the dlopen module name by 'saving' the la file 828454b44505Smrg # name in a special purpose variable, and (later) extracting the 828554b44505Smrg # dlname from the la file. 828654b44505Smrg if test -n "$dlname"; then 828754b44505Smrg func_tr_sh "$dir/$linklib" 828854b44505Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 828954b44505Smrg func_append newdlprefiles " $dir/$linklib" 829054b44505Smrg else 829154b44505Smrg func_append newdlprefiles " $dir/$old_library" 829254b44505Smrg # Keep a list of preopened convenience libraries to check 829354b44505Smrg # that they are being used correctly in the link pass. 829454b44505Smrg test -z "$libdir" && \ 829554b44505Smrg func_append dlpreconveniencelibs " $dir/$old_library" 829654b44505Smrg fi 829754b44505Smrg ;; 829854b44505Smrg * ) 829954b44505Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 830054b44505Smrg # are required to link). 830154b44505Smrg if test -n "$old_library"; then 830254b44505Smrg func_append newdlprefiles " $dir/$old_library" 830354b44505Smrg # Keep a list of preopened convenience libraries to check 830454b44505Smrg # that they are being used correctly in the link pass. 830554b44505Smrg test -z "$libdir" && \ 830654b44505Smrg func_append dlpreconveniencelibs " $dir/$old_library" 830754b44505Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 830854b44505Smrg elif test -n "$dlname"; then 830954b44505Smrg func_append newdlprefiles " $dir/$dlname" 831054b44505Smrg else 831154b44505Smrg func_append newdlprefiles " $dir/$linklib" 831254b44505Smrg fi 831354b44505Smrg ;; 831454b44505Smrg esac 831554b44505Smrg fi # $pass = dlpreopen 831654b44505Smrg 831754b44505Smrg if test -z "$libdir"; then 831854b44505Smrg # Link the convenience library 83190a392d7eSmrg if test lib = "$linkmode"; then 832054b44505Smrg deplibs="$dir/$old_library $deplibs" 83210a392d7eSmrg elif test prog,link = "$linkmode,$pass"; then 832254b44505Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 832354b44505Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 832454b44505Smrg else 832554b44505Smrg deplibs="$lib $deplibs" # used for prog,scan pass 832654b44505Smrg fi 832754b44505Smrg continue 832854b44505Smrg fi 832954b44505Smrg 833054b44505Smrg 83310a392d7eSmrg if test prog = "$linkmode" && test link != "$pass"; then 833254b44505Smrg func_append newlib_search_path " $ladir" 833354b44505Smrg deplibs="$lib $deplibs" 833454b44505Smrg 83350a392d7eSmrg linkalldeplibs=false 83360a392d7eSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83370a392d7eSmrg test no = "$build_libtool_libs"; then 83380a392d7eSmrg linkalldeplibs=: 833954b44505Smrg fi 834054b44505Smrg 834154b44505Smrg tmp_libs= 834254b44505Smrg for deplib in $dependency_libs; do 834354b44505Smrg case $deplib in 834454b44505Smrg -L*) func_stripname '-L' '' "$deplib" 834554b44505Smrg func_resolve_sysroot "$func_stripname_result" 834654b44505Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 834754b44505Smrg ;; 834854b44505Smrg esac 834954b44505Smrg # Need to link against all dependency_libs? 83500a392d7eSmrg if $linkalldeplibs; then 835154b44505Smrg deplibs="$deplib $deplibs" 835254b44505Smrg else 835354b44505Smrg # Need to hardcode shared library paths 835454b44505Smrg # or/and link against static libraries 835554b44505Smrg newdependency_libs="$deplib $newdependency_libs" 835654b44505Smrg fi 83570a392d7eSmrg if $opt_preserve_dup_deps; then 835854b44505Smrg case "$tmp_libs " in 835954b44505Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 836054b44505Smrg esac 836154b44505Smrg fi 836254b44505Smrg func_append tmp_libs " $deplib" 836354b44505Smrg done # for deplib 836454b44505Smrg continue 836554b44505Smrg fi # $linkmode = prog... 836654b44505Smrg 83670a392d7eSmrg if test prog,link = "$linkmode,$pass"; then 836854b44505Smrg if test -n "$library_names" && 83690a392d7eSmrg { { test no = "$prefer_static_libs" || 83700a392d7eSmrg test built,yes = "$prefer_static_libs,$installed"; } || 837154b44505Smrg test -z "$old_library"; }; then 837254b44505Smrg # We need to hardcode the library path 83730a392d7eSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 837454b44505Smrg # Make sure the rpath contains only unique directories. 83750a392d7eSmrg case $temp_rpath: in 837654b44505Smrg *"$absdir:"*) ;; 837754b44505Smrg *) func_append temp_rpath "$absdir:" ;; 837854b44505Smrg esac 837954b44505Smrg fi 838054b44505Smrg 838154b44505Smrg # Hardcode the library path. 838254b44505Smrg # Skip directories that are in the system default run-time 838354b44505Smrg # search path. 838454b44505Smrg case " $sys_lib_dlsearch_path " in 838554b44505Smrg *" $absdir "*) ;; 838654b44505Smrg *) 838754b44505Smrg case "$compile_rpath " in 838854b44505Smrg *" $absdir "*) ;; 838954b44505Smrg *) func_append compile_rpath " $absdir" ;; 839054b44505Smrg esac 839154b44505Smrg ;; 839254b44505Smrg esac 839354b44505Smrg case " $sys_lib_dlsearch_path " in 839454b44505Smrg *" $libdir "*) ;; 839554b44505Smrg *) 839654b44505Smrg case "$finalize_rpath " in 839754b44505Smrg *" $libdir "*) ;; 839854b44505Smrg *) func_append finalize_rpath " $libdir" ;; 839954b44505Smrg esac 840054b44505Smrg ;; 840154b44505Smrg esac 840254b44505Smrg fi # $linkmode,$pass = prog,link... 840354b44505Smrg 84040a392d7eSmrg if $alldeplibs && 84050a392d7eSmrg { test pass_all = "$deplibs_check_method" || 84060a392d7eSmrg { test yes = "$build_libtool_libs" && 840754b44505Smrg test -n "$library_names"; }; }; then 840854b44505Smrg # We only need to search for static libraries 840954b44505Smrg continue 841054b44505Smrg fi 841154b44505Smrg fi 841254b44505Smrg 841354b44505Smrg link_static=no # Whether the deplib will be linked statically 841454b44505Smrg use_static_libs=$prefer_static_libs 84150a392d7eSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 841654b44505Smrg use_static_libs=no 841754b44505Smrg fi 841854b44505Smrg if test -n "$library_names" && 84190a392d7eSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 842054b44505Smrg case $host in 84210a392d7eSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 842254b44505Smrg # No point in relinking DLLs because paths are not encoded 842354b44505Smrg func_append notinst_deplibs " $lib" 842454b44505Smrg need_relink=no 842554b44505Smrg ;; 842654b44505Smrg *) 84270a392d7eSmrg if test no = "$installed"; then 842854b44505Smrg func_append notinst_deplibs " $lib" 842954b44505Smrg need_relink=yes 843054b44505Smrg fi 843154b44505Smrg ;; 843254b44505Smrg esac 843354b44505Smrg # This is a shared library 843454b44505Smrg 843554b44505Smrg # Warn about portability, can't link against -module's on some 843654b44505Smrg # systems (darwin). Don't bleat about dlopened modules though! 84370a392d7eSmrg dlopenmodule= 843854b44505Smrg for dlpremoduletest in $dlprefiles; do 843954b44505Smrg if test "X$dlpremoduletest" = "X$lib"; then 84400a392d7eSmrg dlopenmodule=$dlpremoduletest 844154b44505Smrg break 844254b44505Smrg fi 844354b44505Smrg done 84440a392d7eSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 844554b44505Smrg echo 84460a392d7eSmrg if test prog = "$linkmode"; then 844754b44505Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 844854b44505Smrg else 844954b44505Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 845054b44505Smrg fi 845154b44505Smrg $ECHO "*** $linklib is not portable!" 845254b44505Smrg fi 84530a392d7eSmrg if test lib = "$linkmode" && 84540a392d7eSmrg test yes = "$hardcode_into_libs"; then 845554b44505Smrg # Hardcode the library path. 845654b44505Smrg # Skip directories that are in the system default run-time 845754b44505Smrg # search path. 845854b44505Smrg case " $sys_lib_dlsearch_path " in 845954b44505Smrg *" $absdir "*) ;; 846054b44505Smrg *) 846154b44505Smrg case "$compile_rpath " in 846254b44505Smrg *" $absdir "*) ;; 846354b44505Smrg *) func_append compile_rpath " $absdir" ;; 846454b44505Smrg esac 846554b44505Smrg ;; 846654b44505Smrg esac 846754b44505Smrg case " $sys_lib_dlsearch_path " in 846854b44505Smrg *" $libdir "*) ;; 846954b44505Smrg *) 847054b44505Smrg case "$finalize_rpath " in 847154b44505Smrg *" $libdir "*) ;; 847254b44505Smrg *) func_append finalize_rpath " $libdir" ;; 847354b44505Smrg esac 847454b44505Smrg ;; 847554b44505Smrg esac 847654b44505Smrg fi 847754b44505Smrg 847854b44505Smrg if test -n "$old_archive_from_expsyms_cmds"; then 847954b44505Smrg # figure out the soname 848054b44505Smrg set dummy $library_names 848154b44505Smrg shift 84820a392d7eSmrg realname=$1 848354b44505Smrg shift 848454b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 848554b44505Smrg # use dlname if we got it. it's perfectly good, no? 848654b44505Smrg if test -n "$dlname"; then 84870a392d7eSmrg soname=$dlname 848854b44505Smrg elif test -n "$soname_spec"; then 848954b44505Smrg # bleh windows 849054b44505Smrg case $host in 84910a392d7eSmrg *cygwin* | mingw* | *cegcc* | *os2*) 849254b44505Smrg func_arith $current - $age 849354b44505Smrg major=$func_arith_result 84940a392d7eSmrg versuffix=-$major 849554b44505Smrg ;; 849654b44505Smrg esac 849754b44505Smrg eval soname=\"$soname_spec\" 849854b44505Smrg else 84990a392d7eSmrg soname=$realname 850054b44505Smrg fi 850154b44505Smrg 850254b44505Smrg # Make a new name for the extract_expsyms_cmds to use 85030a392d7eSmrg soroot=$soname 850454b44505Smrg func_basename "$soroot" 85050a392d7eSmrg soname=$func_basename_result 850654b44505Smrg func_stripname 'lib' '.dll' "$soname" 850754b44505Smrg newlib=libimp-$func_stripname_result.a 850854b44505Smrg 850954b44505Smrg # If the library has no export list, then create one now 851054b44505Smrg if test -f "$output_objdir/$soname-def"; then : 851154b44505Smrg else 85120a392d7eSmrg func_verbose "extracting exported symbol list from '$soname'" 851354b44505Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 851454b44505Smrg fi 851554b44505Smrg 851654b44505Smrg # Create $newlib 851754b44505Smrg if test -f "$output_objdir/$newlib"; then :; else 85180a392d7eSmrg func_verbose "generating import library for '$soname'" 851954b44505Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 852054b44505Smrg fi 852154b44505Smrg # make sure the library variables are pointing to the new library 852254b44505Smrg dir=$output_objdir 852354b44505Smrg linklib=$newlib 852454b44505Smrg fi # test -n "$old_archive_from_expsyms_cmds" 852554b44505Smrg 85260a392d7eSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 852754b44505Smrg add_shlibpath= 852854b44505Smrg add_dir= 852954b44505Smrg add= 853054b44505Smrg lib_linked=yes 853154b44505Smrg case $hardcode_action in 853254b44505Smrg immediate | unsupported) 85330a392d7eSmrg if test no = "$hardcode_direct"; then 85340a392d7eSmrg add=$dir/$linklib 853554b44505Smrg case $host in 85360a392d7eSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85370a392d7eSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 853854b44505Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85390a392d7eSmrg *-*-unixware7*) add_dir=-L$dir ;; 854054b44505Smrg *-*-darwin* ) 85410a392d7eSmrg # if the lib is a (non-dlopened) module then we cannot 854254b44505Smrg # link against it, someone is ignoring the earlier warnings 854354b44505Smrg if /usr/bin/file -L $add 2> /dev/null | 85440a392d7eSmrg $GREP ": [^:]* bundle" >/dev/null; then 854554b44505Smrg if test "X$dlopenmodule" != "X$lib"; then 854654b44505Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85470a392d7eSmrg if test -z "$old_library"; then 854854b44505Smrg echo 854954b44505Smrg echo "*** And there doesn't seem to be a static archive available" 855054b44505Smrg echo "*** The link will probably fail, sorry" 855154b44505Smrg else 85520a392d7eSmrg add=$dir/$old_library 855354b44505Smrg fi 855454b44505Smrg elif test -n "$old_library"; then 85550a392d7eSmrg add=$dir/$old_library 855654b44505Smrg fi 855754b44505Smrg fi 855854b44505Smrg esac 85590a392d7eSmrg elif test no = "$hardcode_minus_L"; then 856054b44505Smrg case $host in 85610a392d7eSmrg *-*-sunos*) add_shlibpath=$dir ;; 856254b44505Smrg esac 85630a392d7eSmrg add_dir=-L$dir 85640a392d7eSmrg add=-l$name 85650a392d7eSmrg elif test no = "$hardcode_shlibpath_var"; then 85660a392d7eSmrg add_shlibpath=$dir 85670a392d7eSmrg add=-l$name 856854b44505Smrg else 856954b44505Smrg lib_linked=no 857054b44505Smrg fi 857154b44505Smrg ;; 857254b44505Smrg relink) 85730a392d7eSmrg if test yes = "$hardcode_direct" && 85740a392d7eSmrg test no = "$hardcode_direct_absolute"; then 85750a392d7eSmrg add=$dir/$linklib 85760a392d7eSmrg elif test yes = "$hardcode_minus_L"; then 85770a392d7eSmrg add_dir=-L$absdir 857854b44505Smrg # Try looking first in the location we're being installed to. 857954b44505Smrg if test -n "$inst_prefix_dir"; then 858054b44505Smrg case $libdir in 858154b44505Smrg [\\/]*) 858254b44505Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 858354b44505Smrg ;; 858454b44505Smrg esac 858554b44505Smrg fi 85860a392d7eSmrg add=-l$name 85870a392d7eSmrg elif test yes = "$hardcode_shlibpath_var"; then 85880a392d7eSmrg add_shlibpath=$dir 85890a392d7eSmrg add=-l$name 859054b44505Smrg else 859154b44505Smrg lib_linked=no 859254b44505Smrg fi 859354b44505Smrg ;; 859454b44505Smrg *) lib_linked=no ;; 859554b44505Smrg esac 859654b44505Smrg 85970a392d7eSmrg if test yes != "$lib_linked"; then 859854b44505Smrg func_fatal_configuration "unsupported hardcode properties" 859954b44505Smrg fi 860054b44505Smrg 860154b44505Smrg if test -n "$add_shlibpath"; then 860254b44505Smrg case :$compile_shlibpath: in 860354b44505Smrg *":$add_shlibpath:"*) ;; 860454b44505Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 860554b44505Smrg esac 860654b44505Smrg fi 86070a392d7eSmrg if test prog = "$linkmode"; then 860854b44505Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 860954b44505Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 861054b44505Smrg else 861154b44505Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 861254b44505Smrg test -n "$add" && deplibs="$add $deplibs" 86130a392d7eSmrg if test yes != "$hardcode_direct" && 86140a392d7eSmrg test yes != "$hardcode_minus_L" && 86150a392d7eSmrg test yes = "$hardcode_shlibpath_var"; then 861654b44505Smrg case :$finalize_shlibpath: in 861754b44505Smrg *":$libdir:"*) ;; 861854b44505Smrg *) func_append finalize_shlibpath "$libdir:" ;; 861954b44505Smrg esac 862054b44505Smrg fi 862154b44505Smrg fi 862254b44505Smrg fi 862354b44505Smrg 86240a392d7eSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 862554b44505Smrg add_shlibpath= 862654b44505Smrg add_dir= 862754b44505Smrg add= 862854b44505Smrg # Finalize command for both is simple: just hardcode it. 86290a392d7eSmrg if test yes = "$hardcode_direct" && 86300a392d7eSmrg test no = "$hardcode_direct_absolute"; then 86310a392d7eSmrg add=$libdir/$linklib 86320a392d7eSmrg elif test yes = "$hardcode_minus_L"; then 86330a392d7eSmrg add_dir=-L$libdir 86340a392d7eSmrg add=-l$name 86350a392d7eSmrg elif test yes = "$hardcode_shlibpath_var"; then 863654b44505Smrg case :$finalize_shlibpath: in 863754b44505Smrg *":$libdir:"*) ;; 863854b44505Smrg *) func_append finalize_shlibpath "$libdir:" ;; 863954b44505Smrg esac 86400a392d7eSmrg add=-l$name 86410a392d7eSmrg elif test yes = "$hardcode_automatic"; then 864254b44505Smrg if test -n "$inst_prefix_dir" && 86430a392d7eSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86440a392d7eSmrg add=$inst_prefix_dir$libdir/$linklib 864554b44505Smrg else 86460a392d7eSmrg add=$libdir/$linklib 864754b44505Smrg fi 864854b44505Smrg else 864954b44505Smrg # We cannot seem to hardcode it, guess we'll fake it. 86500a392d7eSmrg add_dir=-L$libdir 865154b44505Smrg # Try looking first in the location we're being installed to. 865254b44505Smrg if test -n "$inst_prefix_dir"; then 865354b44505Smrg case $libdir in 865454b44505Smrg [\\/]*) 865554b44505Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 865654b44505Smrg ;; 865754b44505Smrg esac 865854b44505Smrg fi 86590a392d7eSmrg add=-l$name 866054b44505Smrg fi 866154b44505Smrg 86620a392d7eSmrg if test prog = "$linkmode"; then 866354b44505Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 866454b44505Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 866554b44505Smrg else 866654b44505Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 866754b44505Smrg test -n "$add" && deplibs="$add $deplibs" 866854b44505Smrg fi 866954b44505Smrg fi 86700a392d7eSmrg elif test prog = "$linkmode"; then 867154b44505Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 867254b44505Smrg # is not unsupported. This is valid on all known static and 867354b44505Smrg # shared platforms. 86740a392d7eSmrg if test unsupported != "$hardcode_direct"; then 86750a392d7eSmrg test -n "$old_library" && linklib=$old_library 867654b44505Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 867754b44505Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 867854b44505Smrg else 867954b44505Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 868054b44505Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 868154b44505Smrg fi 86820a392d7eSmrg elif test yes = "$build_libtool_libs"; then 868354b44505Smrg # Not a shared library 86840a392d7eSmrg if test pass_all != "$deplibs_check_method"; then 868554b44505Smrg # We're trying link a shared library against a static one 868654b44505Smrg # but the system doesn't support it. 868754b44505Smrg 868854b44505Smrg # Just print a warning and add the library to dependency_libs so 868954b44505Smrg # that the program can be linked against the static library. 869054b44505Smrg echo 86910a392d7eSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 869254b44505Smrg echo "*** I have the capability to make that library automatically link in when" 869354b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 869454b44505Smrg echo "*** shared version of the library, which you do not appear to have." 86950a392d7eSmrg if test yes = "$module"; then 869654b44505Smrg echo "*** But as you try to build a module library, libtool will still create " 869754b44505Smrg echo "*** a static module, that should work as long as the dlopening application" 869854b44505Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 869954b44505Smrg if test -z "$global_symbol_pipe"; then 870054b44505Smrg echo 870154b44505Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87020a392d7eSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 870354b44505Smrg echo "*** not find such a program. So, this module is probably useless." 87040a392d7eSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 870554b44505Smrg fi 87060a392d7eSmrg if test no = "$build_old_libs"; then 870754b44505Smrg build_libtool_libs=module 870854b44505Smrg build_old_libs=yes 870954b44505Smrg else 871054b44505Smrg build_libtool_libs=no 871154b44505Smrg fi 871254b44505Smrg fi 871354b44505Smrg else 871454b44505Smrg deplibs="$dir/$old_library $deplibs" 871554b44505Smrg link_static=yes 871654b44505Smrg fi 871754b44505Smrg fi # link shared/static library? 871854b44505Smrg 87190a392d7eSmrg if test lib = "$linkmode"; then 872054b44505Smrg if test -n "$dependency_libs" && 87210a392d7eSmrg { test yes != "$hardcode_into_libs" || 87220a392d7eSmrg test yes = "$build_old_libs" || 87230a392d7eSmrg test yes = "$link_static"; }; then 872454b44505Smrg # Extract -R from dependency_libs 872554b44505Smrg temp_deplibs= 872654b44505Smrg for libdir in $dependency_libs; do 872754b44505Smrg case $libdir in 872854b44505Smrg -R*) func_stripname '-R' '' "$libdir" 872954b44505Smrg temp_xrpath=$func_stripname_result 873054b44505Smrg case " $xrpath " in 873154b44505Smrg *" $temp_xrpath "*) ;; 873254b44505Smrg *) func_append xrpath " $temp_xrpath";; 873354b44505Smrg esac;; 873454b44505Smrg *) func_append temp_deplibs " $libdir";; 873554b44505Smrg esac 873654b44505Smrg done 87370a392d7eSmrg dependency_libs=$temp_deplibs 873854b44505Smrg fi 873954b44505Smrg 874054b44505Smrg func_append newlib_search_path " $absdir" 874154b44505Smrg # Link against this library 87420a392d7eSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 874354b44505Smrg # ... and its dependency_libs 874454b44505Smrg tmp_libs= 874554b44505Smrg for deplib in $dependency_libs; do 874654b44505Smrg newdependency_libs="$deplib $newdependency_libs" 874754b44505Smrg case $deplib in 874854b44505Smrg -L*) func_stripname '-L' '' "$deplib" 874954b44505Smrg func_resolve_sysroot "$func_stripname_result";; 875054b44505Smrg *) func_resolve_sysroot "$deplib" ;; 875154b44505Smrg esac 87520a392d7eSmrg if $opt_preserve_dup_deps; then 875354b44505Smrg case "$tmp_libs " in 875454b44505Smrg *" $func_resolve_sysroot_result "*) 875554b44505Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 875654b44505Smrg esac 875754b44505Smrg fi 875854b44505Smrg func_append tmp_libs " $func_resolve_sysroot_result" 875954b44505Smrg done 876054b44505Smrg 87610a392d7eSmrg if test no != "$link_all_deplibs"; then 876254b44505Smrg # Add the search paths of all dependency libraries 876354b44505Smrg for deplib in $dependency_libs; do 876454b44505Smrg path= 876554b44505Smrg case $deplib in 87660a392d7eSmrg -L*) path=$deplib ;; 876754b44505Smrg *.la) 876854b44505Smrg func_resolve_sysroot "$deplib" 876954b44505Smrg deplib=$func_resolve_sysroot_result 877054b44505Smrg func_dirname "$deplib" "" "." 877154b44505Smrg dir=$func_dirname_result 877254b44505Smrg # We need an absolute path. 877354b44505Smrg case $dir in 87740a392d7eSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 877554b44505Smrg *) 877654b44505Smrg absdir=`cd "$dir" && pwd` 877754b44505Smrg if test -z "$absdir"; then 87780a392d7eSmrg func_warning "cannot determine absolute directory name of '$dir'" 87790a392d7eSmrg absdir=$dir 878054b44505Smrg fi 878154b44505Smrg ;; 878254b44505Smrg esac 878354b44505Smrg if $GREP "^installed=no" $deplib > /dev/null; then 878454b44505Smrg case $host in 878554b44505Smrg *-*-darwin*) 878654b44505Smrg depdepl= 87870a392d7eSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87880a392d7eSmrg if test -n "$deplibrary_names"; then 87890a392d7eSmrg for tmp in $deplibrary_names; do 879054b44505Smrg depdepl=$tmp 879154b44505Smrg done 87920a392d7eSmrg if test -f "$absdir/$objdir/$depdepl"; then 87930a392d7eSmrg depdepl=$absdir/$objdir/$depdepl 87940a392d7eSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879554b44505Smrg if test -z "$darwin_install_name"; then 87960a392d7eSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879754b44505Smrg fi 87980a392d7eSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87990a392d7eSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 880054b44505Smrg path= 880154b44505Smrg fi 880254b44505Smrg fi 880354b44505Smrg ;; 880454b44505Smrg *) 88050a392d7eSmrg path=-L$absdir/$objdir 880654b44505Smrg ;; 880754b44505Smrg esac 880854b44505Smrg else 88090a392d7eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 881054b44505Smrg test -z "$libdir" && \ 88110a392d7eSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 881254b44505Smrg test "$absdir" != "$libdir" && \ 88130a392d7eSmrg func_warning "'$deplib' seems to be moved" 881454b44505Smrg 88150a392d7eSmrg path=-L$absdir 881654b44505Smrg fi 881754b44505Smrg ;; 881854b44505Smrg esac 881954b44505Smrg case " $deplibs " in 882054b44505Smrg *" $path "*) ;; 882154b44505Smrg *) deplibs="$path $deplibs" ;; 882254b44505Smrg esac 882354b44505Smrg done 882454b44505Smrg fi # link_all_deplibs != no 882554b44505Smrg fi # linkmode = lib 882654b44505Smrg done # for deplib in $libs 88270a392d7eSmrg if test link = "$pass"; then 88280a392d7eSmrg if test prog = "$linkmode"; then 882954b44505Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 883054b44505Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 883154b44505Smrg else 883254b44505Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 883354b44505Smrg fi 883454b44505Smrg fi 88350a392d7eSmrg dependency_libs=$newdependency_libs 88360a392d7eSmrg if test dlpreopen = "$pass"; then 883754b44505Smrg # Link the dlpreopened libraries before other libraries 883854b44505Smrg for deplib in $save_deplibs; do 883954b44505Smrg deplibs="$deplib $deplibs" 884054b44505Smrg done 884154b44505Smrg fi 88420a392d7eSmrg if test dlopen != "$pass"; then 88430a392d7eSmrg test conv = "$pass" || { 884454b44505Smrg # Make sure lib_search_path contains only unique directories. 884554b44505Smrg lib_search_path= 884654b44505Smrg for dir in $newlib_search_path; do 884754b44505Smrg case "$lib_search_path " in 884854b44505Smrg *" $dir "*) ;; 884954b44505Smrg *) func_append lib_search_path " $dir" ;; 885054b44505Smrg esac 885154b44505Smrg done 885254b44505Smrg newlib_search_path= 88530a392d7eSmrg } 885454b44505Smrg 88550a392d7eSmrg if test prog,link = "$linkmode,$pass"; then 885654b44505Smrg vars="compile_deplibs finalize_deplibs" 88570a392d7eSmrg else 88580a392d7eSmrg vars=deplibs 885954b44505Smrg fi 886054b44505Smrg for var in $vars dependency_libs; do 886154b44505Smrg # Add libraries to $var in reverse order 886254b44505Smrg eval tmp_libs=\"\$$var\" 886354b44505Smrg new_libs= 886454b44505Smrg for deplib in $tmp_libs; do 886554b44505Smrg # FIXME: Pedantically, this is the right thing to do, so 886654b44505Smrg # that some nasty dependency loop isn't accidentally 886754b44505Smrg # broken: 886854b44505Smrg #new_libs="$deplib $new_libs" 886954b44505Smrg # Pragmatically, this seems to cause very few problems in 887054b44505Smrg # practice: 887154b44505Smrg case $deplib in 887254b44505Smrg -L*) new_libs="$deplib $new_libs" ;; 887354b44505Smrg -R*) ;; 887454b44505Smrg *) 887554b44505Smrg # And here is the reason: when a library appears more 887654b44505Smrg # than once as an explicit dependence of a library, or 887754b44505Smrg # is implicitly linked in more than once by the 887854b44505Smrg # compiler, it is considered special, and multiple 887954b44505Smrg # occurrences thereof are not removed. Compare this 888054b44505Smrg # with having the same library being listed as a 888154b44505Smrg # dependency of multiple other libraries: in this case, 888254b44505Smrg # we know (pedantically, we assume) the library does not 888354b44505Smrg # need to be listed more than once, so we keep only the 888454b44505Smrg # last copy. This is not always right, but it is rare 888554b44505Smrg # enough that we require users that really mean to play 888654b44505Smrg # such unportable linking tricks to link the library 888754b44505Smrg # using -Wl,-lname, so that libtool does not consider it 888854b44505Smrg # for duplicate removal. 888954b44505Smrg case " $specialdeplibs " in 889054b44505Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 889154b44505Smrg *) 889254b44505Smrg case " $new_libs " in 889354b44505Smrg *" $deplib "*) ;; 889454b44505Smrg *) new_libs="$deplib $new_libs" ;; 889554b44505Smrg esac 889654b44505Smrg ;; 889754b44505Smrg esac 889854b44505Smrg ;; 889954b44505Smrg esac 890054b44505Smrg done 890154b44505Smrg tmp_libs= 890254b44505Smrg for deplib in $new_libs; do 890354b44505Smrg case $deplib in 890454b44505Smrg -L*) 890554b44505Smrg case " $tmp_libs " in 890654b44505Smrg *" $deplib "*) ;; 890754b44505Smrg *) func_append tmp_libs " $deplib" ;; 890854b44505Smrg esac 890954b44505Smrg ;; 891054b44505Smrg *) func_append tmp_libs " $deplib" ;; 891154b44505Smrg esac 891254b44505Smrg done 891354b44505Smrg eval $var=\"$tmp_libs\" 891454b44505Smrg done # for var 891554b44505Smrg fi 89160a392d7eSmrg 89170a392d7eSmrg # Add Sun CC postdeps if required: 89180a392d7eSmrg test CXX = "$tagname" && { 89190a392d7eSmrg case $host_os in 89200a392d7eSmrg linux*) 89218fc2d0c6Smrg case `$CC -V 2>&1 | $SED 5q` in 89220a392d7eSmrg *Sun\ C*) # Sun C++ 5.9 89230a392d7eSmrg func_suncc_cstd_abi 89240a392d7eSmrg 89250a392d7eSmrg if test no != "$suncc_use_cstd_abi"; then 89260a392d7eSmrg func_append postdeps ' -library=Cstd -library=Crun' 89270a392d7eSmrg fi 89280a392d7eSmrg ;; 89290a392d7eSmrg esac 89300a392d7eSmrg ;; 89310a392d7eSmrg 89320a392d7eSmrg solaris*) 89330a392d7eSmrg func_cc_basename "$CC" 89340a392d7eSmrg case $func_cc_basename_result in 89350a392d7eSmrg CC* | sunCC*) 89360a392d7eSmrg func_suncc_cstd_abi 89370a392d7eSmrg 89380a392d7eSmrg if test no != "$suncc_use_cstd_abi"; then 89390a392d7eSmrg func_append postdeps ' -library=Cstd -library=Crun' 89400a392d7eSmrg fi 89410a392d7eSmrg ;; 89420a392d7eSmrg esac 89430a392d7eSmrg ;; 89440a392d7eSmrg esac 89450a392d7eSmrg } 89460a392d7eSmrg 894754b44505Smrg # Last step: remove runtime libs from dependency_libs 894854b44505Smrg # (they stay in deplibs) 894954b44505Smrg tmp_libs= 89500a392d7eSmrg for i in $dependency_libs; do 895154b44505Smrg case " $predeps $postdeps $compiler_lib_search_path " in 895254b44505Smrg *" $i "*) 89530a392d7eSmrg i= 895454b44505Smrg ;; 895554b44505Smrg esac 89560a392d7eSmrg if test -n "$i"; then 895754b44505Smrg func_append tmp_libs " $i" 895854b44505Smrg fi 895954b44505Smrg done 896054b44505Smrg dependency_libs=$tmp_libs 896154b44505Smrg done # for pass 89620a392d7eSmrg if test prog = "$linkmode"; then 89630a392d7eSmrg dlfiles=$newdlfiles 896454b44505Smrg fi 89650a392d7eSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89660a392d7eSmrg dlprefiles=$newdlprefiles 896754b44505Smrg fi 896854b44505Smrg 896954b44505Smrg case $linkmode in 897054b44505Smrg oldlib) 89710a392d7eSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89720a392d7eSmrg func_warning "'-dlopen' is ignored for archives" 897354b44505Smrg fi 897454b44505Smrg 897554b44505Smrg case " $deplibs" in 897654b44505Smrg *\ -l* | *\ -L*) 89770a392d7eSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 897854b44505Smrg esac 897954b44505Smrg 898054b44505Smrg test -n "$rpath" && \ 89810a392d7eSmrg func_warning "'-rpath' is ignored for archives" 898254b44505Smrg 898354b44505Smrg test -n "$xrpath" && \ 89840a392d7eSmrg func_warning "'-R' is ignored for archives" 898554b44505Smrg 898654b44505Smrg test -n "$vinfo" && \ 89870a392d7eSmrg func_warning "'-version-info/-version-number' is ignored for archives" 898854b44505Smrg 898954b44505Smrg test -n "$release" && \ 89900a392d7eSmrg func_warning "'-release' is ignored for archives" 899154b44505Smrg 899254b44505Smrg test -n "$export_symbols$export_symbols_regex" && \ 89930a392d7eSmrg func_warning "'-export-symbols' is ignored for archives" 899454b44505Smrg 899554b44505Smrg # Now set the variables for building old libraries. 899654b44505Smrg build_libtool_libs=no 89970a392d7eSmrg oldlibs=$output 899854b44505Smrg func_append objs "$old_deplibs" 899954b44505Smrg ;; 900054b44505Smrg 900154b44505Smrg lib) 90020a392d7eSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 900354b44505Smrg case $outputname in 900454b44505Smrg lib*) 900554b44505Smrg func_stripname 'lib' '.la' "$outputname" 900654b44505Smrg name=$func_stripname_result 900754b44505Smrg eval shared_ext=\"$shrext_cmds\" 900854b44505Smrg eval libname=\"$libname_spec\" 900954b44505Smrg ;; 901054b44505Smrg *) 90110a392d7eSmrg test no = "$module" \ 90120a392d7eSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 901354b44505Smrg 90140a392d7eSmrg if test no != "$need_lib_prefix"; then 901554b44505Smrg # Add the "lib" prefix for modules if required 901654b44505Smrg func_stripname '' '.la' "$outputname" 901754b44505Smrg name=$func_stripname_result 901854b44505Smrg eval shared_ext=\"$shrext_cmds\" 901954b44505Smrg eval libname=\"$libname_spec\" 902054b44505Smrg else 902154b44505Smrg func_stripname '' '.la' "$outputname" 902254b44505Smrg libname=$func_stripname_result 902354b44505Smrg fi 902454b44505Smrg ;; 902554b44505Smrg esac 902654b44505Smrg 902754b44505Smrg if test -n "$objs"; then 90280a392d7eSmrg if test pass_all != "$deplibs_check_method"; then 90290a392d7eSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 903054b44505Smrg else 903154b44505Smrg echo 903254b44505Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 903354b44505Smrg $ECHO "*** objects $objs is not portable!" 903454b44505Smrg func_append libobjs " $objs" 903554b44505Smrg fi 903654b44505Smrg fi 903754b44505Smrg 90380a392d7eSmrg test no = "$dlself" \ 90390a392d7eSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 904054b44505Smrg 904154b44505Smrg set dummy $rpath 904254b44505Smrg shift 90430a392d7eSmrg test 1 -lt "$#" \ 90440a392d7eSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 904554b44505Smrg 90460a392d7eSmrg install_libdir=$1 904754b44505Smrg 904854b44505Smrg oldlibs= 904954b44505Smrg if test -z "$rpath"; then 90500a392d7eSmrg if test yes = "$build_libtool_libs"; then 905154b44505Smrg # Building a libtool convenience library. 90520a392d7eSmrg # Some compilers have problems with a '.al' extension so 905354b44505Smrg # convenience libraries should have the same extension an 905454b44505Smrg # archive normally would. 905554b44505Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 905654b44505Smrg build_libtool_libs=convenience 905754b44505Smrg build_old_libs=yes 905854b44505Smrg fi 905954b44505Smrg 906054b44505Smrg test -n "$vinfo" && \ 90610a392d7eSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 906254b44505Smrg 906354b44505Smrg test -n "$release" && \ 90640a392d7eSmrg func_warning "'-release' is ignored for convenience libraries" 906554b44505Smrg else 906654b44505Smrg 906754b44505Smrg # Parse the version information argument. 90680a392d7eSmrg save_ifs=$IFS; IFS=: 906954b44505Smrg set dummy $vinfo 0 0 0 907054b44505Smrg shift 90710a392d7eSmrg IFS=$save_ifs 907254b44505Smrg 907354b44505Smrg test -n "$7" && \ 90740a392d7eSmrg func_fatal_help "too many parameters to '-version-info'" 907554b44505Smrg 907654b44505Smrg # convert absolute version numbers to libtool ages 907754b44505Smrg # this retains compatibility with .la files and attempts 907854b44505Smrg # to make the code below a bit more comprehensible 907954b44505Smrg 908054b44505Smrg case $vinfo_number in 908154b44505Smrg yes) 90820a392d7eSmrg number_major=$1 90830a392d7eSmrg number_minor=$2 90840a392d7eSmrg number_revision=$3 908554b44505Smrg # 908654b44505Smrg # There are really only two kinds -- those that 908754b44505Smrg # use the current revision as the major version 908854b44505Smrg # and those that subtract age and use age as 908954b44505Smrg # a minor version. But, then there is irix 90900a392d7eSmrg # that has an extra 1 added just for fun 909154b44505Smrg # 909254b44505Smrg case $version_type in 90930a392d7eSmrg # correct linux to gnu/linux during the next big refactor 90948fc2d0c6Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 909554b44505Smrg func_arith $number_major + $number_minor 909654b44505Smrg current=$func_arith_result 90970a392d7eSmrg age=$number_minor 90980a392d7eSmrg revision=$number_revision 909954b44505Smrg ;; 91000a392d7eSmrg freebsd-aout|qnx|sunos) 91010a392d7eSmrg current=$number_major 91020a392d7eSmrg revision=$number_minor 91030a392d7eSmrg age=0 910454b44505Smrg ;; 910554b44505Smrg irix|nonstopux) 910654b44505Smrg func_arith $number_major + $number_minor 910754b44505Smrg current=$func_arith_result 91080a392d7eSmrg age=$number_minor 91090a392d7eSmrg revision=$number_minor 911054b44505Smrg lt_irix_increment=no 911154b44505Smrg ;; 911254b44505Smrg esac 911354b44505Smrg ;; 911454b44505Smrg no) 91150a392d7eSmrg current=$1 91160a392d7eSmrg revision=$2 91170a392d7eSmrg age=$3 911854b44505Smrg ;; 911954b44505Smrg esac 912054b44505Smrg 912154b44505Smrg # Check that each of the things are valid numbers. 912254b44505Smrg case $current in 912354b44505Smrg 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]) ;; 912454b44505Smrg *) 91250a392d7eSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91260a392d7eSmrg func_fatal_error "'$vinfo' is not valid version information" 912754b44505Smrg ;; 912854b44505Smrg esac 912954b44505Smrg 913054b44505Smrg case $revision in 913154b44505Smrg 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]) ;; 913254b44505Smrg *) 91330a392d7eSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91340a392d7eSmrg func_fatal_error "'$vinfo' is not valid version information" 913554b44505Smrg ;; 913654b44505Smrg esac 913754b44505Smrg 913854b44505Smrg case $age in 913954b44505Smrg 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]) ;; 914054b44505Smrg *) 91410a392d7eSmrg func_error "AGE '$age' must be a nonnegative integer" 91420a392d7eSmrg func_fatal_error "'$vinfo' is not valid version information" 914354b44505Smrg ;; 914454b44505Smrg esac 914554b44505Smrg 914654b44505Smrg if test "$age" -gt "$current"; then 91470a392d7eSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91480a392d7eSmrg func_fatal_error "'$vinfo' is not valid version information" 914954b44505Smrg fi 915054b44505Smrg 915154b44505Smrg # Calculate the version variables. 915254b44505Smrg major= 915354b44505Smrg versuffix= 915454b44505Smrg verstring= 915554b44505Smrg case $version_type in 915654b44505Smrg none) ;; 915754b44505Smrg 915854b44505Smrg darwin) 915954b44505Smrg # Like Linux, but with the current version available in 916054b44505Smrg # verstring for coding it into the library header 916154b44505Smrg func_arith $current - $age 916254b44505Smrg major=.$func_arith_result 91630a392d7eSmrg versuffix=$major.$age.$revision 916454b44505Smrg # Darwin ld doesn't like 0 for these options... 916554b44505Smrg func_arith $current + 1 916654b44505Smrg minor_current=$func_arith_result 91670a392d7eSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 916854b44505Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91690a392d7eSmrg # On Darwin other compilers 91700a392d7eSmrg case $CC in 91710a392d7eSmrg nagfor*) 91720a392d7eSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91730a392d7eSmrg ;; 91740a392d7eSmrg *) 91750a392d7eSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91760a392d7eSmrg ;; 91770a392d7eSmrg esac 917854b44505Smrg ;; 917954b44505Smrg 918054b44505Smrg freebsd-aout) 91810a392d7eSmrg major=.$current 91820a392d7eSmrg versuffix=.$current.$revision 918354b44505Smrg ;; 918454b44505Smrg 91858fc2d0c6Smrg freebsd-elf | midnightbsd-elf) 91860a392d7eSmrg func_arith $current - $age 91870a392d7eSmrg major=.$func_arith_result 91880a392d7eSmrg versuffix=$major.$age.$revision 918954b44505Smrg ;; 919054b44505Smrg 919154b44505Smrg irix | nonstopux) 91920a392d7eSmrg if test no = "$lt_irix_increment"; then 919354b44505Smrg func_arith $current - $age 919454b44505Smrg else 919554b44505Smrg func_arith $current - $age + 1 919654b44505Smrg fi 919754b44505Smrg major=$func_arith_result 919854b44505Smrg 919954b44505Smrg case $version_type in 920054b44505Smrg nonstopux) verstring_prefix=nonstopux ;; 920154b44505Smrg *) verstring_prefix=sgi ;; 920254b44505Smrg esac 92030a392d7eSmrg verstring=$verstring_prefix$major.$revision 920454b44505Smrg 920554b44505Smrg # Add in all the interfaces that we are compatible with. 920654b44505Smrg loop=$revision 92070a392d7eSmrg while test 0 -ne "$loop"; do 920854b44505Smrg func_arith $revision - $loop 920954b44505Smrg iface=$func_arith_result 921054b44505Smrg func_arith $loop - 1 921154b44505Smrg loop=$func_arith_result 92120a392d7eSmrg verstring=$verstring_prefix$major.$iface:$verstring 921354b44505Smrg done 921454b44505Smrg 92150a392d7eSmrg # Before this point, $major must not contain '.'. 921654b44505Smrg major=.$major 92170a392d7eSmrg versuffix=$major.$revision 921854b44505Smrg ;; 921954b44505Smrg 92200a392d7eSmrg linux) # correct to gnu/linux during the next big refactor 922154b44505Smrg func_arith $current - $age 922254b44505Smrg major=.$func_arith_result 92230a392d7eSmrg versuffix=$major.$age.$revision 922454b44505Smrg ;; 922554b44505Smrg 922654b44505Smrg osf) 922754b44505Smrg func_arith $current - $age 922854b44505Smrg major=.$func_arith_result 92290a392d7eSmrg versuffix=.$current.$age.$revision 92300a392d7eSmrg verstring=$current.$age.$revision 923154b44505Smrg 923254b44505Smrg # Add in all the interfaces that we are compatible with. 923354b44505Smrg loop=$age 92340a392d7eSmrg while test 0 -ne "$loop"; do 923554b44505Smrg func_arith $current - $loop 923654b44505Smrg iface=$func_arith_result 923754b44505Smrg func_arith $loop - 1 923854b44505Smrg loop=$func_arith_result 92390a392d7eSmrg verstring=$verstring:$iface.0 924054b44505Smrg done 924154b44505Smrg 924254b44505Smrg # Make executables depend on our current version. 92430a392d7eSmrg func_append verstring ":$current.0" 924454b44505Smrg ;; 924554b44505Smrg 924654b44505Smrg qnx) 92470a392d7eSmrg major=.$current 92480a392d7eSmrg versuffix=.$current 92490a392d7eSmrg ;; 92500a392d7eSmrg 92510a392d7eSmrg sco) 92520a392d7eSmrg major=.$current 92530a392d7eSmrg versuffix=.$current 925454b44505Smrg ;; 925554b44505Smrg 925654b44505Smrg sunos) 92570a392d7eSmrg major=.$current 92580a392d7eSmrg versuffix=.$current.$revision 925954b44505Smrg ;; 926054b44505Smrg 926154b44505Smrg windows) 926254b44505Smrg # Use '-' rather than '.', since we only want one 92630a392d7eSmrg # extension on DOS 8.3 file systems. 926454b44505Smrg func_arith $current - $age 926554b44505Smrg major=$func_arith_result 92660a392d7eSmrg versuffix=-$major 926754b44505Smrg ;; 926854b44505Smrg 926954b44505Smrg *) 92700a392d7eSmrg func_fatal_configuration "unknown library version type '$version_type'" 927154b44505Smrg ;; 927254b44505Smrg esac 927354b44505Smrg 927454b44505Smrg # Clear the version info if we defaulted, and they specified a release. 927554b44505Smrg if test -z "$vinfo" && test -n "$release"; then 927654b44505Smrg major= 927754b44505Smrg case $version_type in 927854b44505Smrg darwin) 927954b44505Smrg # we can't check for "0.0" in archive_cmds due to quoting 928054b44505Smrg # problems, so we reset it completely 928154b44505Smrg verstring= 928254b44505Smrg ;; 928354b44505Smrg *) 92840a392d7eSmrg verstring=0.0 928554b44505Smrg ;; 928654b44505Smrg esac 92870a392d7eSmrg if test no = "$need_version"; then 928854b44505Smrg versuffix= 928954b44505Smrg else 92900a392d7eSmrg versuffix=.0.0 929154b44505Smrg fi 929254b44505Smrg fi 929354b44505Smrg 929454b44505Smrg # Remove version info from name if versioning should be avoided 92950a392d7eSmrg if test yes,no = "$avoid_version,$need_version"; then 929654b44505Smrg major= 929754b44505Smrg versuffix= 92980a392d7eSmrg verstring= 929954b44505Smrg fi 930054b44505Smrg 930154b44505Smrg # Check to see if the archive will have undefined symbols. 93020a392d7eSmrg if test yes = "$allow_undefined"; then 93030a392d7eSmrg if test unsupported = "$allow_undefined_flag"; then 93040a392d7eSmrg if test yes = "$build_old_libs"; then 93050a392d7eSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93060a392d7eSmrg build_libtool_libs=no 93070a392d7eSmrg else 93080a392d7eSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93090a392d7eSmrg fi 931054b44505Smrg fi 931154b44505Smrg else 931254b44505Smrg # Don't allow undefined symbols. 93130a392d7eSmrg allow_undefined_flag=$no_undefined_flag 931454b44505Smrg fi 931554b44505Smrg 931654b44505Smrg fi 931754b44505Smrg 93180a392d7eSmrg func_generate_dlsyms "$libname" "$libname" : 931954b44505Smrg func_append libobjs " $symfileobj" 93200a392d7eSmrg test " " = "$libobjs" && libobjs= 932154b44505Smrg 93220a392d7eSmrg if test relink != "$opt_mode"; then 932354b44505Smrg # Remove our outputs, but don't remove object files since they 932454b44505Smrg # may have been created when compiling PIC objects. 932554b44505Smrg removelist= 932654b44505Smrg tempremovelist=`$ECHO "$output_objdir/*"` 932754b44505Smrg for p in $tempremovelist; do 932854b44505Smrg case $p in 932954b44505Smrg *.$objext | *.gcno) 933054b44505Smrg ;; 93310a392d7eSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93320a392d7eSmrg if test -n "$precious_files_regex"; then 933354b44505Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 933454b44505Smrg then 933554b44505Smrg continue 933654b44505Smrg fi 933754b44505Smrg fi 933854b44505Smrg func_append removelist " $p" 933954b44505Smrg ;; 934054b44505Smrg *) ;; 934154b44505Smrg esac 934254b44505Smrg done 934354b44505Smrg test -n "$removelist" && \ 934454b44505Smrg func_show_eval "${RM}r \$removelist" 934554b44505Smrg fi 934654b44505Smrg 934754b44505Smrg # Now set the variables for building old libraries. 93480a392d7eSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 934954b44505Smrg func_append oldlibs " $output_objdir/$libname.$libext" 935054b44505Smrg 935154b44505Smrg # Transform .lo files to .o files. 93520a392d7eSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 935354b44505Smrg fi 935454b44505Smrg 935554b44505Smrg # Eliminate all temporary directories. 935654b44505Smrg #for path in $notinst_path; do 935754b44505Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 935854b44505Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 935954b44505Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 936054b44505Smrg #done 936154b44505Smrg 936254b44505Smrg if test -n "$xrpath"; then 936354b44505Smrg # If the user specified any rpath flags, then add them. 936454b44505Smrg temp_xrpath= 936554b44505Smrg for libdir in $xrpath; do 936654b44505Smrg func_replace_sysroot "$libdir" 936754b44505Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 936854b44505Smrg case "$finalize_rpath " in 936954b44505Smrg *" $libdir "*) ;; 937054b44505Smrg *) func_append finalize_rpath " $libdir" ;; 937154b44505Smrg esac 937254b44505Smrg done 93730a392d7eSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 937454b44505Smrg dependency_libs="$temp_xrpath $dependency_libs" 937554b44505Smrg fi 937654b44505Smrg fi 937754b44505Smrg 937854b44505Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93790a392d7eSmrg old_dlfiles=$dlfiles 938054b44505Smrg dlfiles= 938154b44505Smrg for lib in $old_dlfiles; do 938254b44505Smrg case " $dlprefiles $dlfiles " in 938354b44505Smrg *" $lib "*) ;; 938454b44505Smrg *) func_append dlfiles " $lib" ;; 938554b44505Smrg esac 938654b44505Smrg done 938754b44505Smrg 938854b44505Smrg # Make sure dlprefiles contains only unique files 93890a392d7eSmrg old_dlprefiles=$dlprefiles 939054b44505Smrg dlprefiles= 939154b44505Smrg for lib in $old_dlprefiles; do 939254b44505Smrg case "$dlprefiles " in 939354b44505Smrg *" $lib "*) ;; 939454b44505Smrg *) func_append dlprefiles " $lib" ;; 939554b44505Smrg esac 939654b44505Smrg done 939754b44505Smrg 93980a392d7eSmrg if test yes = "$build_libtool_libs"; then 939954b44505Smrg if test -n "$rpath"; then 940054b44505Smrg case $host in 940154b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 940254b44505Smrg # these systems don't actually have a c library (as such)! 940354b44505Smrg ;; 940454b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 940554b44505Smrg # Rhapsody C library is in the System framework 940654b44505Smrg func_append deplibs " System.ltframework" 940754b44505Smrg ;; 940854b44505Smrg *-*-netbsd*) 940954b44505Smrg # Don't link with libc until the a.out ld.so is fixed. 941054b44505Smrg ;; 94118fc2d0c6Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 941254b44505Smrg # Do not include libc due to us having libc/libc_r. 941354b44505Smrg ;; 941454b44505Smrg *-*-sco3.2v5* | *-*-sco5v6*) 941554b44505Smrg # Causes problems with __ctype 941654b44505Smrg ;; 941754b44505Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 941854b44505Smrg # Compiler inserts libc in the correct place for threads to work 941954b44505Smrg ;; 942054b44505Smrg *) 942154b44505Smrg # Add libc to deplibs on all other systems if necessary. 94220a392d7eSmrg if test yes = "$build_libtool_need_lc"; then 942354b44505Smrg func_append deplibs " -lc" 942454b44505Smrg fi 942554b44505Smrg ;; 942654b44505Smrg esac 942754b44505Smrg fi 942854b44505Smrg 942954b44505Smrg # Transform deplibs into only deplibs that can be linked in shared. 943054b44505Smrg name_save=$name 943154b44505Smrg libname_save=$libname 943254b44505Smrg release_save=$release 943354b44505Smrg versuffix_save=$versuffix 943454b44505Smrg major_save=$major 943554b44505Smrg # I'm not sure if I'm treating the release correctly. I think 943654b44505Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 943754b44505Smrg # add it in twice. Is that correct? 94380a392d7eSmrg release= 94390a392d7eSmrg versuffix= 94400a392d7eSmrg major= 944154b44505Smrg newdeplibs= 944254b44505Smrg droppeddeps=no 944354b44505Smrg case $deplibs_check_method in 944454b44505Smrg pass_all) 944554b44505Smrg # Don't check for shared/static. Everything works. 944654b44505Smrg # This might be a little naive. We might want to check 944754b44505Smrg # whether the library exists or not. But this is on 944854b44505Smrg # osf3 & osf4 and I'm not really sure... Just 944954b44505Smrg # implementing what was already the behavior. 945054b44505Smrg newdeplibs=$deplibs 945154b44505Smrg ;; 945254b44505Smrg test_compile) 945354b44505Smrg # This code stresses the "libraries are programs" paradigm to its 945454b44505Smrg # limits. Maybe even breaks it. We compile a program, linking it 945554b44505Smrg # against the deplibs as a proxy for the library. Then we can check 945654b44505Smrg # whether they linked in statically or dynamically with ldd. 945754b44505Smrg $opt_dry_run || $RM conftest.c 945854b44505Smrg cat > conftest.c <<EOF 945954b44505Smrg int main() { return 0; } 946054b44505SmrgEOF 946154b44505Smrg $opt_dry_run || $RM conftest 946254b44505Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 946354b44505Smrg ldd_output=`ldd conftest` 946454b44505Smrg for i in $deplibs; do 946554b44505Smrg case $i in 946654b44505Smrg -l*) 946754b44505Smrg func_stripname -l '' "$i" 946854b44505Smrg name=$func_stripname_result 94690a392d7eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 947054b44505Smrg case " $predeps $postdeps " in 947154b44505Smrg *" $i "*) 947254b44505Smrg func_append newdeplibs " $i" 94730a392d7eSmrg i= 947454b44505Smrg ;; 947554b44505Smrg esac 947654b44505Smrg fi 94770a392d7eSmrg if test -n "$i"; then 947854b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 947954b44505Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 948054b44505Smrg set dummy $deplib_matches; shift 948154b44505Smrg deplib_match=$1 94820a392d7eSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 948354b44505Smrg func_append newdeplibs " $i" 948454b44505Smrg else 948554b44505Smrg droppeddeps=yes 948654b44505Smrg echo 948754b44505Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 948854b44505Smrg echo "*** I have the capability to make that library automatically link in when" 948954b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 949054b44505Smrg echo "*** shared version of the library, which I believe you do not have" 949154b44505Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 949254b44505Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 949354b44505Smrg fi 949454b44505Smrg fi 949554b44505Smrg ;; 949654b44505Smrg *) 949754b44505Smrg func_append newdeplibs " $i" 949854b44505Smrg ;; 949954b44505Smrg esac 950054b44505Smrg done 950154b44505Smrg else 950254b44505Smrg # Error occurred in the first compile. Let's try to salvage 950354b44505Smrg # the situation: Compile a separate program for each library. 950454b44505Smrg for i in $deplibs; do 950554b44505Smrg case $i in 950654b44505Smrg -l*) 950754b44505Smrg func_stripname -l '' "$i" 950854b44505Smrg name=$func_stripname_result 950954b44505Smrg $opt_dry_run || $RM conftest 951054b44505Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 951154b44505Smrg ldd_output=`ldd conftest` 95120a392d7eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 951354b44505Smrg case " $predeps $postdeps " in 951454b44505Smrg *" $i "*) 951554b44505Smrg func_append newdeplibs " $i" 95160a392d7eSmrg i= 951754b44505Smrg ;; 951854b44505Smrg esac 951954b44505Smrg fi 95200a392d7eSmrg if test -n "$i"; then 952154b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 952254b44505Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 952354b44505Smrg set dummy $deplib_matches; shift 952454b44505Smrg deplib_match=$1 95250a392d7eSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 952654b44505Smrg func_append newdeplibs " $i" 952754b44505Smrg else 952854b44505Smrg droppeddeps=yes 952954b44505Smrg echo 953054b44505Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 953154b44505Smrg echo "*** I have the capability to make that library automatically link in when" 953254b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 953354b44505Smrg echo "*** shared version of the library, which you do not appear to have" 953454b44505Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 953554b44505Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 953654b44505Smrg fi 953754b44505Smrg fi 953854b44505Smrg else 953954b44505Smrg droppeddeps=yes 954054b44505Smrg echo 954154b44505Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 954254b44505Smrg echo "*** make it link in! You will probably need to install it or some" 954354b44505Smrg echo "*** library that it depends on before this library will be fully" 954454b44505Smrg echo "*** functional. Installing it before continuing would be even better." 954554b44505Smrg fi 954654b44505Smrg ;; 954754b44505Smrg *) 954854b44505Smrg func_append newdeplibs " $i" 954954b44505Smrg ;; 955054b44505Smrg esac 955154b44505Smrg done 955254b44505Smrg fi 955354b44505Smrg ;; 955454b44505Smrg file_magic*) 955554b44505Smrg set dummy $deplibs_check_method; shift 955654b44505Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 955754b44505Smrg for a_deplib in $deplibs; do 955854b44505Smrg case $a_deplib in 955954b44505Smrg -l*) 956054b44505Smrg func_stripname -l '' "$a_deplib" 956154b44505Smrg name=$func_stripname_result 95620a392d7eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 956354b44505Smrg case " $predeps $postdeps " in 956454b44505Smrg *" $a_deplib "*) 956554b44505Smrg func_append newdeplibs " $a_deplib" 95660a392d7eSmrg a_deplib= 956754b44505Smrg ;; 956854b44505Smrg esac 956954b44505Smrg fi 95700a392d7eSmrg if test -n "$a_deplib"; then 957154b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 957254b44505Smrg if test -n "$file_magic_glob"; then 957354b44505Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 957454b44505Smrg else 957554b44505Smrg libnameglob=$libname 957654b44505Smrg fi 95770a392d7eSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 957854b44505Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95790a392d7eSmrg if test yes = "$want_nocaseglob"; then 958054b44505Smrg shopt -s nocaseglob 958154b44505Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 958254b44505Smrg $nocaseglob 958354b44505Smrg else 958454b44505Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 958554b44505Smrg fi 958654b44505Smrg for potent_lib in $potential_libs; do 958754b44505Smrg # Follow soft links. 958854b44505Smrg if ls -lLd "$potent_lib" 2>/dev/null | 958954b44505Smrg $GREP " -> " >/dev/null; then 959054b44505Smrg continue 959154b44505Smrg fi 959254b44505Smrg # The statement above tries to avoid entering an 959354b44505Smrg # endless loop below, in case of cyclic links. 959454b44505Smrg # We might still enter an endless loop, since a link 959554b44505Smrg # loop can be closed while we follow links, 959654b44505Smrg # but so what? 95970a392d7eSmrg potlib=$potent_lib 959854b44505Smrg while test -h "$potlib" 2>/dev/null; do 95990a392d7eSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 960054b44505Smrg case $potliblink in 96010a392d7eSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96020a392d7eSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 960354b44505Smrg esac 960454b44505Smrg done 960554b44505Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 960654b44505Smrg $SED -e 10q | 960754b44505Smrg $EGREP "$file_magic_regex" > /dev/null; then 960854b44505Smrg func_append newdeplibs " $a_deplib" 96090a392d7eSmrg a_deplib= 961054b44505Smrg break 2 961154b44505Smrg fi 961254b44505Smrg done 961354b44505Smrg done 961454b44505Smrg fi 96150a392d7eSmrg if test -n "$a_deplib"; then 961654b44505Smrg droppeddeps=yes 961754b44505Smrg echo 961854b44505Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 961954b44505Smrg echo "*** I have the capability to make that library automatically link in when" 962054b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 962154b44505Smrg echo "*** shared version of the library, which you do not appear to have" 962254b44505Smrg echo "*** because I did check the linker path looking for a file starting" 96230a392d7eSmrg if test -z "$potlib"; then 962454b44505Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 962554b44505Smrg else 962654b44505Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 962754b44505Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 962854b44505Smrg fi 962954b44505Smrg fi 963054b44505Smrg ;; 963154b44505Smrg *) 963254b44505Smrg # Add a -L argument. 963354b44505Smrg func_append newdeplibs " $a_deplib" 963454b44505Smrg ;; 963554b44505Smrg esac 963654b44505Smrg done # Gone through all deplibs. 963754b44505Smrg ;; 963854b44505Smrg match_pattern*) 963954b44505Smrg set dummy $deplibs_check_method; shift 964054b44505Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 964154b44505Smrg for a_deplib in $deplibs; do 964254b44505Smrg case $a_deplib in 964354b44505Smrg -l*) 964454b44505Smrg func_stripname -l '' "$a_deplib" 964554b44505Smrg name=$func_stripname_result 96460a392d7eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 964754b44505Smrg case " $predeps $postdeps " in 964854b44505Smrg *" $a_deplib "*) 964954b44505Smrg func_append newdeplibs " $a_deplib" 96500a392d7eSmrg a_deplib= 965154b44505Smrg ;; 965254b44505Smrg esac 965354b44505Smrg fi 96540a392d7eSmrg if test -n "$a_deplib"; then 965554b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 965654b44505Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 965754b44505Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 965854b44505Smrg for potent_lib in $potential_libs; do 96590a392d7eSmrg potlib=$potent_lib # see symlink-check above in file_magic test 966054b44505Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 966154b44505Smrg $EGREP "$match_pattern_regex" > /dev/null; then 966254b44505Smrg func_append newdeplibs " $a_deplib" 96630a392d7eSmrg a_deplib= 966454b44505Smrg break 2 966554b44505Smrg fi 966654b44505Smrg done 966754b44505Smrg done 966854b44505Smrg fi 96690a392d7eSmrg if test -n "$a_deplib"; then 967054b44505Smrg droppeddeps=yes 967154b44505Smrg echo 967254b44505Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 967354b44505Smrg echo "*** I have the capability to make that library automatically link in when" 967454b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 967554b44505Smrg echo "*** shared version of the library, which you do not appear to have" 967654b44505Smrg echo "*** because I did check the linker path looking for a file starting" 96770a392d7eSmrg if test -z "$potlib"; then 967854b44505Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 967954b44505Smrg else 968054b44505Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 968154b44505Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 968254b44505Smrg fi 968354b44505Smrg fi 968454b44505Smrg ;; 968554b44505Smrg *) 968654b44505Smrg # Add a -L argument. 968754b44505Smrg func_append newdeplibs " $a_deplib" 968854b44505Smrg ;; 968954b44505Smrg esac 969054b44505Smrg done # Gone through all deplibs. 969154b44505Smrg ;; 969254b44505Smrg none | unknown | *) 96930a392d7eSmrg newdeplibs= 969454b44505Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96950a392d7eSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96960a392d7eSmrg for i in $predeps $postdeps; do 969754b44505Smrg # can't use Xsed below, because $i might contain '/' 96980a392d7eSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 969954b44505Smrg done 970054b44505Smrg fi 970154b44505Smrg case $tmp_deplibs in 970254b44505Smrg *[!\ \ ]*) 970354b44505Smrg echo 97040a392d7eSmrg if test none = "$deplibs_check_method"; then 970554b44505Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 970654b44505Smrg else 970754b44505Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 970854b44505Smrg fi 970954b44505Smrg echo "*** All declared inter-library dependencies are being dropped." 971054b44505Smrg droppeddeps=yes 971154b44505Smrg ;; 971254b44505Smrg esac 971354b44505Smrg ;; 971454b44505Smrg esac 971554b44505Smrg versuffix=$versuffix_save 971654b44505Smrg major=$major_save 971754b44505Smrg release=$release_save 971854b44505Smrg libname=$libname_save 971954b44505Smrg name=$name_save 972054b44505Smrg 972154b44505Smrg case $host in 972254b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 972354b44505Smrg # On Rhapsody replace the C library with the System framework 972454b44505Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 972554b44505Smrg ;; 972654b44505Smrg esac 972754b44505Smrg 97280a392d7eSmrg if test yes = "$droppeddeps"; then 97290a392d7eSmrg if test yes = "$module"; then 973054b44505Smrg echo 973154b44505Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 973254b44505Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 973354b44505Smrg echo "*** a static module, that should work as long as the dlopening" 973454b44505Smrg echo "*** application is linked with the -dlopen flag." 973554b44505Smrg if test -z "$global_symbol_pipe"; then 973654b44505Smrg echo 973754b44505Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97380a392d7eSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 973954b44505Smrg echo "*** not find such a program. So, this module is probably useless." 97400a392d7eSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 974154b44505Smrg fi 97420a392d7eSmrg if test no = "$build_old_libs"; then 97430a392d7eSmrg oldlibs=$output_objdir/$libname.$libext 974454b44505Smrg build_libtool_libs=module 974554b44505Smrg build_old_libs=yes 974654b44505Smrg else 974754b44505Smrg build_libtool_libs=no 974854b44505Smrg fi 974954b44505Smrg else 975054b44505Smrg echo "*** The inter-library dependencies that have been dropped here will be" 975154b44505Smrg echo "*** automatically added whenever a program is linked with this library" 975254b44505Smrg echo "*** or is declared to -dlopen it." 97534a041c5bSmacallan 97540a392d7eSmrg if test no = "$allow_undefined"; then 975554b44505Smrg echo 975654b44505Smrg echo "*** Since this library must not contain undefined symbols," 975754b44505Smrg echo "*** because either the platform does not support them or" 975854b44505Smrg echo "*** it was explicitly requested with -no-undefined," 975954b44505Smrg echo "*** libtool will only create a static version of it." 97600a392d7eSmrg if test no = "$build_old_libs"; then 97610a392d7eSmrg oldlibs=$output_objdir/$libname.$libext 976254b44505Smrg build_libtool_libs=module 976354b44505Smrg build_old_libs=yes 976454b44505Smrg else 976554b44505Smrg build_libtool_libs=no 976654b44505Smrg fi 976754b44505Smrg fi 976854b44505Smrg fi 976954b44505Smrg fi 977054b44505Smrg # Done checking deplibs! 977154b44505Smrg deplibs=$newdeplibs 977254b44505Smrg fi 977354b44505Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 977454b44505Smrg case $host in 977554b44505Smrg *-*-darwin*) 977654b44505Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977754b44505Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977854b44505Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977954b44505Smrg ;; 978054b44505Smrg esac 97814a041c5bSmacallan 978254b44505Smrg # move library search paths that coincide with paths to not yet 978354b44505Smrg # installed libraries to the beginning of the library search list 978454b44505Smrg new_libs= 978554b44505Smrg for path in $notinst_path; do 978654b44505Smrg case " $new_libs " in 978754b44505Smrg *" -L$path/$objdir "*) ;; 978854b44505Smrg *) 978954b44505Smrg case " $deplibs " in 979054b44505Smrg *" -L$path/$objdir "*) 979154b44505Smrg func_append new_libs " -L$path/$objdir" ;; 979254b44505Smrg esac 979354b44505Smrg ;; 979454b44505Smrg esac 979554b44505Smrg done 979654b44505Smrg for deplib in $deplibs; do 979754b44505Smrg case $deplib in 979854b44505Smrg -L*) 979954b44505Smrg case " $new_libs " in 980054b44505Smrg *" $deplib "*) ;; 980154b44505Smrg *) func_append new_libs " $deplib" ;; 980254b44505Smrg esac 980354b44505Smrg ;; 980454b44505Smrg *) func_append new_libs " $deplib" ;; 980554b44505Smrg esac 980654b44505Smrg done 98070a392d7eSmrg deplibs=$new_libs 98084a041c5bSmacallan 980954b44505Smrg # All the library-specific variables (install_libdir is set above). 981054b44505Smrg library_names= 981154b44505Smrg old_library= 981254b44505Smrg dlname= 98134a041c5bSmacallan 981454b44505Smrg # Test again, we may have decided not to build it any more 98150a392d7eSmrg if test yes = "$build_libtool_libs"; then 98160a392d7eSmrg # Remove $wl instances when linking with ld. 98170a392d7eSmrg # FIXME: should test the right _cmds variable. 98180a392d7eSmrg case $archive_cmds in 98190a392d7eSmrg *\$LD\ *) wl= ;; 98200a392d7eSmrg esac 98210a392d7eSmrg if test yes = "$hardcode_into_libs"; then 982254b44505Smrg # Hardcode the library paths 982354b44505Smrg hardcode_libdirs= 982454b44505Smrg dep_rpath= 98250a392d7eSmrg rpath=$finalize_rpath 98260a392d7eSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 982754b44505Smrg for libdir in $rpath; do 982854b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 982954b44505Smrg if test -n "$hardcode_libdir_separator"; then 983054b44505Smrg func_replace_sysroot "$libdir" 983154b44505Smrg libdir=$func_replace_sysroot_result 983254b44505Smrg if test -z "$hardcode_libdirs"; then 98330a392d7eSmrg hardcode_libdirs=$libdir 983454b44505Smrg else 983554b44505Smrg # Just accumulate the unique libdirs. 983654b44505Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 983754b44505Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 983854b44505Smrg ;; 983954b44505Smrg *) 984054b44505Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 984154b44505Smrg ;; 984254b44505Smrg esac 984354b44505Smrg fi 984454b44505Smrg else 984554b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 984654b44505Smrg func_append dep_rpath " $flag" 984754b44505Smrg fi 984854b44505Smrg elif test -n "$runpath_var"; then 984954b44505Smrg case "$perm_rpath " in 985054b44505Smrg *" $libdir "*) ;; 98510a392d7eSmrg *) func_append perm_rpath " $libdir" ;; 985254b44505Smrg esac 985354b44505Smrg fi 985454b44505Smrg done 985554b44505Smrg # Substitute the hardcoded libdirs into the rpath. 985654b44505Smrg if test -n "$hardcode_libdir_separator" && 985754b44505Smrg test -n "$hardcode_libdirs"; then 98580a392d7eSmrg libdir=$hardcode_libdirs 98590a392d7eSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 986054b44505Smrg fi 986154b44505Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 986254b44505Smrg # We should set the runpath_var. 986354b44505Smrg rpath= 986454b44505Smrg for dir in $perm_rpath; do 986554b44505Smrg func_append rpath "$dir:" 986654b44505Smrg done 986754b44505Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 986854b44505Smrg fi 986954b44505Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 987054b44505Smrg fi 98714a041c5bSmacallan 98720a392d7eSmrg shlibpath=$finalize_shlibpath 98730a392d7eSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 987454b44505Smrg if test -n "$shlibpath"; then 987554b44505Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 987654b44505Smrg fi 98774a041c5bSmacallan 987854b44505Smrg # Get the real and link names of the library. 987954b44505Smrg eval shared_ext=\"$shrext_cmds\" 988054b44505Smrg eval library_names=\"$library_names_spec\" 988154b44505Smrg set dummy $library_names 988254b44505Smrg shift 98830a392d7eSmrg realname=$1 988454b44505Smrg shift 98854a041c5bSmacallan 988654b44505Smrg if test -n "$soname_spec"; then 988754b44505Smrg eval soname=\"$soname_spec\" 98884a041c5bSmacallan else 98890a392d7eSmrg soname=$realname 989054b44505Smrg fi 989154b44505Smrg if test -z "$dlname"; then 989254b44505Smrg dlname=$soname 98934a041c5bSmacallan fi 98944a041c5bSmacallan 98950a392d7eSmrg lib=$output_objdir/$realname 989654b44505Smrg linknames= 989754b44505Smrg for link 989854b44505Smrg do 989954b44505Smrg func_append linknames " $link" 990054b44505Smrg done 99014a041c5bSmacallan 990254b44505Smrg # Use standard objects if they are pic 990354b44505Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 990454b44505Smrg test "X$libobjs" = "X " && libobjs= 99054a041c5bSmacallan 990654b44505Smrg delfiles= 990754b44505Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 990854b44505Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99090a392d7eSmrg export_symbols=$output_objdir/$libname.uexp 991054b44505Smrg func_append delfiles " $export_symbols" 991154b44505Smrg fi 99124a041c5bSmacallan 991354b44505Smrg orig_export_symbols= 991454b44505Smrg case $host_os in 991554b44505Smrg cygwin* | mingw* | cegcc*) 991654b44505Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 991754b44505Smrg # exporting using user supplied symfile 99180a392d7eSmrg func_dll_def_p "$export_symbols" || { 991954b44505Smrg # and it's NOT already a .def file. Must figure out 992054b44505Smrg # which of the given symbols are data symbols and tag 992154b44505Smrg # them as such. So, trigger use of export_symbols_cmds. 992254b44505Smrg # export_symbols gets reassigned inside the "prepare 992354b44505Smrg # the list of exported symbols" if statement, so the 992454b44505Smrg # include_expsyms logic still works. 99250a392d7eSmrg orig_export_symbols=$export_symbols 992654b44505Smrg export_symbols= 992754b44505Smrg always_export_symbols=yes 99280a392d7eSmrg } 992954b44505Smrg fi 993054b44505Smrg ;; 993154b44505Smrg esac 99324a041c5bSmacallan 993354b44505Smrg # Prepare the list of exported symbols 993454b44505Smrg if test -z "$export_symbols"; then 99350a392d7eSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99360a392d7eSmrg func_verbose "generating symbol list for '$libname.la'" 99370a392d7eSmrg export_symbols=$output_objdir/$libname.exp 993854b44505Smrg $opt_dry_run || $RM $export_symbols 993954b44505Smrg cmds=$export_symbols_cmds 99400a392d7eSmrg save_ifs=$IFS; IFS='~' 994154b44505Smrg for cmd1 in $cmds; do 99420a392d7eSmrg IFS=$save_ifs 994354b44505Smrg # Take the normal branch if the nm_file_list_spec branch 994454b44505Smrg # doesn't work or if tool conversion is not needed. 994554b44505Smrg case $nm_file_list_spec~$to_tool_file_cmd in 994654b44505Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 994754b44505Smrg try_normal_branch=yes 994854b44505Smrg eval cmd=\"$cmd1\" 994954b44505Smrg func_len " $cmd" 995054b44505Smrg len=$func_len_result 995154b44505Smrg ;; 995254b44505Smrg *) 995354b44505Smrg try_normal_branch=no 995454b44505Smrg ;; 995554b44505Smrg esac 99560a392d7eSmrg if test yes = "$try_normal_branch" \ 995754b44505Smrg && { test "$len" -lt "$max_cmd_len" \ 995854b44505Smrg || test "$max_cmd_len" -le -1; } 995954b44505Smrg then 996054b44505Smrg func_show_eval "$cmd" 'exit $?' 996154b44505Smrg skipped_export=false 996254b44505Smrg elif test -n "$nm_file_list_spec"; then 996354b44505Smrg func_basename "$output" 996454b44505Smrg output_la=$func_basename_result 996554b44505Smrg save_libobjs=$libobjs 996654b44505Smrg save_output=$output 99670a392d7eSmrg output=$output_objdir/$output_la.nm 996854b44505Smrg func_to_tool_file "$output" 996954b44505Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 997054b44505Smrg func_append delfiles " $output" 997154b44505Smrg func_verbose "creating $NM input file list: $output" 997254b44505Smrg for obj in $save_libobjs; do 997354b44505Smrg func_to_tool_file "$obj" 997454b44505Smrg $ECHO "$func_to_tool_file_result" 997554b44505Smrg done > "$output" 997654b44505Smrg eval cmd=\"$cmd1\" 997754b44505Smrg func_show_eval "$cmd" 'exit $?' 997854b44505Smrg output=$save_output 997954b44505Smrg libobjs=$save_libobjs 998054b44505Smrg skipped_export=false 998154b44505Smrg else 998254b44505Smrg # The command line is too long to execute in one step. 998354b44505Smrg func_verbose "using reloadable object file for export list..." 998454b44505Smrg skipped_export=: 998554b44505Smrg # Break out early, otherwise skipped_export may be 998654b44505Smrg # set to false by a later but shorter cmd. 998754b44505Smrg break 998854b44505Smrg fi 998954b44505Smrg done 99900a392d7eSmrg IFS=$save_ifs 99910a392d7eSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 999254b44505Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 999354b44505Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 999454b44505Smrg fi 999554b44505Smrg fi 99964a041c5bSmacallan fi 99974a041c5bSmacallan 999854b44505Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99990a392d7eSmrg tmp_export_symbols=$export_symbols 100000a392d7eSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1000154b44505Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100024a041c5bSmacallan fi 100034a041c5bSmacallan 100040a392d7eSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 1000554b44505Smrg # The given exports_symbols file has to be filtered, so filter it. 100060a392d7eSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1000754b44505Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100080a392d7eSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 1000954b44505Smrg # though. Also, the filter scales superlinearly with the number of 1001054b44505Smrg # global variables. join(1) would be nice here, but unfortunately 1001154b44505Smrg # isn't a blessed tool. 1001254b44505Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1001354b44505Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1001454b44505Smrg export_symbols=$output_objdir/$libname.def 1001554b44505Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1001654b44505Smrg fi 100174a041c5bSmacallan 1001854b44505Smrg tmp_deplibs= 1001954b44505Smrg for test_deplib in $deplibs; do 1002054b44505Smrg case " $convenience " in 1002154b44505Smrg *" $test_deplib "*) ;; 1002254b44505Smrg *) 1002354b44505Smrg func_append tmp_deplibs " $test_deplib" 1002454b44505Smrg ;; 1002554b44505Smrg esac 1002654b44505Smrg done 100270a392d7eSmrg deplibs=$tmp_deplibs 100284a041c5bSmacallan 1002954b44505Smrg if test -n "$convenience"; then 1003054b44505Smrg if test -n "$whole_archive_flag_spec" && 100310a392d7eSmrg test yes = "$compiler_needs_object" && 1003254b44505Smrg test -z "$libobjs"; then 1003354b44505Smrg # extract the archives, so we have objects to list. 1003454b44505Smrg # TODO: could optimize this to just extract one archive. 1003554b44505Smrg whole_archive_flag_spec= 1003654b44505Smrg fi 1003754b44505Smrg if test -n "$whole_archive_flag_spec"; then 1003854b44505Smrg save_libobjs=$libobjs 1003954b44505Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1004054b44505Smrg test "X$libobjs" = "X " && libobjs= 1004154b44505Smrg else 100420a392d7eSmrg gentop=$output_objdir/${outputname}x 1004354b44505Smrg func_append generated " $gentop" 100444a041c5bSmacallan 1004554b44505Smrg func_extract_archives $gentop $convenience 1004654b44505Smrg func_append libobjs " $func_extract_archives_result" 1004754b44505Smrg test "X$libobjs" = "X " && libobjs= 1004854b44505Smrg fi 100494a041c5bSmacallan fi 100504a041c5bSmacallan 100510a392d7eSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 1005254b44505Smrg eval flag=\"$thread_safe_flag_spec\" 1005354b44505Smrg func_append linker_flags " $flag" 1005454b44505Smrg fi 100554a041c5bSmacallan 1005654b44505Smrg # Make a backup of the uninstalled library when relinking 100570a392d7eSmrg if test relink = "$opt_mode"; then 1005854b44505Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 1005954b44505Smrg fi 1006054b44505Smrg 1006154b44505Smrg # Do each of the archive commands. 100620a392d7eSmrg if test yes = "$module" && test -n "$module_cmds"; then 1006354b44505Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1006454b44505Smrg eval test_cmds=\"$module_expsym_cmds\" 1006554b44505Smrg cmds=$module_expsym_cmds 1006654b44505Smrg else 1006754b44505Smrg eval test_cmds=\"$module_cmds\" 1006854b44505Smrg cmds=$module_cmds 1006954b44505Smrg fi 1007054b44505Smrg else 1007154b44505Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1007254b44505Smrg eval test_cmds=\"$archive_expsym_cmds\" 1007354b44505Smrg cmds=$archive_expsym_cmds 1007454b44505Smrg else 1007554b44505Smrg eval test_cmds=\"$archive_cmds\" 1007654b44505Smrg cmds=$archive_cmds 1007754b44505Smrg fi 1007854b44505Smrg fi 100794a041c5bSmacallan 100800a392d7eSmrg if test : != "$skipped_export" && 1008154b44505Smrg func_len " $test_cmds" && 1008254b44505Smrg len=$func_len_result && 1008354b44505Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100844a041c5bSmacallan : 100854a041c5bSmacallan else 1008654b44505Smrg # The command line is too long to link in one step, link piecewise 1008754b44505Smrg # or, if using GNU ld and skipped_export is not :, use a linker 1008854b44505Smrg # script. 100894a041c5bSmacallan 1009054b44505Smrg # Save the value of $output and $libobjs because we want to 1009154b44505Smrg # use them later. If we have whole_archive_flag_spec, we 1009254b44505Smrg # want to use save_libobjs as it was before 1009354b44505Smrg # whole_archive_flag_spec was expanded, because we can't 1009454b44505Smrg # assume the linker understands whole_archive_flag_spec. 1009554b44505Smrg # This may have to be revisited, in case too many 1009654b44505Smrg # convenience libraries get linked in and end up exceeding 1009754b44505Smrg # the spec. 1009854b44505Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 1009954b44505Smrg save_libobjs=$libobjs 101004a041c5bSmacallan fi 1010154b44505Smrg save_output=$output 1010254b44505Smrg func_basename "$output" 1010354b44505Smrg output_la=$func_basename_result 101044a041c5bSmacallan 1010554b44505Smrg # Clear the reloadable object creation command queue and 1010654b44505Smrg # initialize k to one. 1010754b44505Smrg test_cmds= 101084a041c5bSmacallan concat_cmds= 1010954b44505Smrg objlist= 1011054b44505Smrg last_robj= 1011154b44505Smrg k=1 101124a041c5bSmacallan 101130a392d7eSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101140a392d7eSmrg output=$output_objdir/$output_la.lnkscript 1011554b44505Smrg func_verbose "creating GNU ld script: $output" 1011654b44505Smrg echo 'INPUT (' > $output 1011754b44505Smrg for obj in $save_libobjs 1011854b44505Smrg do 1011954b44505Smrg func_to_tool_file "$obj" 1012054b44505Smrg $ECHO "$func_to_tool_file_result" >> $output 1012154b44505Smrg done 1012254b44505Smrg echo ')' >> $output 1012354b44505Smrg func_append delfiles " $output" 1012454b44505Smrg func_to_tool_file "$output" 1012554b44505Smrg output=$func_to_tool_file_result 101260a392d7eSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101270a392d7eSmrg output=$output_objdir/$output_la.lnk 1012854b44505Smrg func_verbose "creating linker input file list: $output" 1012954b44505Smrg : > $output 1013054b44505Smrg set x $save_libobjs 1013154b44505Smrg shift 1013254b44505Smrg firstobj= 101330a392d7eSmrg if test yes = "$compiler_needs_object"; then 1013454b44505Smrg firstobj="$1 " 1013554b44505Smrg shift 1013654b44505Smrg fi 1013754b44505Smrg for obj 1013854b44505Smrg do 1013954b44505Smrg func_to_tool_file "$obj" 1014054b44505Smrg $ECHO "$func_to_tool_file_result" >> $output 1014154b44505Smrg done 1014254b44505Smrg func_append delfiles " $output" 1014354b44505Smrg func_to_tool_file "$output" 1014454b44505Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 1014554b44505Smrg else 1014654b44505Smrg if test -n "$save_libobjs"; then 1014754b44505Smrg func_verbose "creating reloadable object files..." 101480a392d7eSmrg output=$output_objdir/$output_la-$k.$objext 1014954b44505Smrg eval test_cmds=\"$reload_cmds\" 1015054b44505Smrg func_len " $test_cmds" 1015154b44505Smrg len0=$func_len_result 1015254b44505Smrg len=$len0 1015354b44505Smrg 1015454b44505Smrg # Loop over the list of objects to be linked. 1015554b44505Smrg for obj in $save_libobjs 1015654b44505Smrg do 1015754b44505Smrg func_len " $obj" 1015854b44505Smrg func_arith $len + $func_len_result 1015954b44505Smrg len=$func_arith_result 101600a392d7eSmrg if test -z "$objlist" || 1016154b44505Smrg test "$len" -lt "$max_cmd_len"; then 1016254b44505Smrg func_append objlist " $obj" 1016354b44505Smrg else 1016454b44505Smrg # The command $test_cmds is almost too long, add a 1016554b44505Smrg # command to the queue. 101660a392d7eSmrg if test 1 -eq "$k"; then 1016754b44505Smrg # The first file doesn't have a previous command to add. 1016854b44505Smrg reload_objs=$objlist 1016954b44505Smrg eval concat_cmds=\"$reload_cmds\" 1017054b44505Smrg else 1017154b44505Smrg # All subsequent reloadable object files will link in 1017254b44505Smrg # the last one created. 1017354b44505Smrg reload_objs="$objlist $last_robj" 1017454b44505Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 1017554b44505Smrg fi 101760a392d7eSmrg last_robj=$output_objdir/$output_la-$k.$objext 1017754b44505Smrg func_arith $k + 1 1017854b44505Smrg k=$func_arith_result 101790a392d7eSmrg output=$output_objdir/$output_la-$k.$objext 1018054b44505Smrg objlist=" $obj" 1018154b44505Smrg func_len " $last_robj" 1018254b44505Smrg func_arith $len0 + $func_len_result 1018354b44505Smrg len=$func_arith_result 1018454b44505Smrg fi 1018554b44505Smrg done 1018654b44505Smrg # Handle the remaining objects by creating one last 1018754b44505Smrg # reloadable object file. All subsequent reloadable object 1018854b44505Smrg # files will link in the last one created. 1018954b44505Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1019054b44505Smrg reload_objs="$objlist $last_robj" 101910a392d7eSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 1019254b44505Smrg if test -n "$last_robj"; then 101930a392d7eSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 101944a041c5bSmacallan fi 1019554b44505Smrg func_append delfiles " $output" 1019654b44505Smrg 1019754b44505Smrg else 1019854b44505Smrg output= 1019954b44505Smrg fi 1020054b44505Smrg 102010a392d7eSmrg ${skipped_export-false} && { 102020a392d7eSmrg func_verbose "generating symbol list for '$libname.la'" 102030a392d7eSmrg export_symbols=$output_objdir/$libname.exp 1020454b44505Smrg $opt_dry_run || $RM $export_symbols 1020554b44505Smrg libobjs=$output 1020654b44505Smrg # Append the command to create the export file. 102074a041c5bSmacallan test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1020854b44505Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 1020954b44505Smrg if test -n "$last_robj"; then 1021054b44505Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1021154b44505Smrg fi 102120a392d7eSmrg } 1021354b44505Smrg 1021454b44505Smrg test -n "$save_libobjs" && 1021554b44505Smrg func_verbose "creating a temporary reloadable object file: $output" 1021654b44505Smrg 1021754b44505Smrg # Loop through the commands generated above and execute them. 102180a392d7eSmrg save_ifs=$IFS; IFS='~' 1021954b44505Smrg for cmd in $concat_cmds; do 102200a392d7eSmrg IFS=$save_ifs 102210a392d7eSmrg $opt_quiet || { 102228fc2d0c6Smrg func_quote_arg expand,pretty "$cmd" 102238fc2d0c6Smrg eval "func_echo $func_quote_arg_result" 1022454b44505Smrg } 1022554b44505Smrg $opt_dry_run || eval "$cmd" || { 1022654b44505Smrg lt_exit=$? 1022754b44505Smrg 1022854b44505Smrg # Restore the uninstalled library and exit 102290a392d7eSmrg if test relink = "$opt_mode"; then 1023054b44505Smrg ( cd "$output_objdir" && \ 1023154b44505Smrg $RM "${realname}T" && \ 1023254b44505Smrg $MV "${realname}U" "$realname" ) 1023354b44505Smrg fi 1023454b44505Smrg 1023554b44505Smrg exit $lt_exit 1023654b44505Smrg } 1023754b44505Smrg done 102380a392d7eSmrg IFS=$save_ifs 1023954b44505Smrg 1024054b44505Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 1024154b44505Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 1024254b44505Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102434a041c5bSmacallan fi 102444a041c5bSmacallan fi 102454a041c5bSmacallan 102460a392d7eSmrg ${skipped_export-false} && { 1024754b44505Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102480a392d7eSmrg tmp_export_symbols=$export_symbols 102490a392d7eSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1025054b44505Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1025154b44505Smrg fi 102524a041c5bSmacallan 1025354b44505Smrg if test -n "$orig_export_symbols"; then 1025454b44505Smrg # The given exports_symbols file has to be filtered, so filter it. 102550a392d7eSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1025654b44505Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102570a392d7eSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 1025854b44505Smrg # though. Also, the filter scales superlinearly with the number of 1025954b44505Smrg # global variables. join(1) would be nice here, but unfortunately 1026054b44505Smrg # isn't a blessed tool. 1026154b44505Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1026254b44505Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1026354b44505Smrg export_symbols=$output_objdir/$libname.def 1026454b44505Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1026554b44505Smrg fi 102660a392d7eSmrg } 102674a041c5bSmacallan 1026854b44505Smrg libobjs=$output 1026954b44505Smrg # Restore the value of output. 1027054b44505Smrg output=$save_output 102714a041c5bSmacallan 1027254b44505Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 1027354b44505Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1027454b44505Smrg test "X$libobjs" = "X " && libobjs= 1027554b44505Smrg fi 1027654b44505Smrg # Expand the library linking commands again to reset the 1027754b44505Smrg # value of $libobjs for piecewise linking. 102784a041c5bSmacallan 1027954b44505Smrg # Do each of the archive commands. 102800a392d7eSmrg if test yes = "$module" && test -n "$module_cmds"; then 1028154b44505Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1028254b44505Smrg cmds=$module_expsym_cmds 1028354b44505Smrg else 1028454b44505Smrg cmds=$module_cmds 102854a041c5bSmacallan fi 102864a041c5bSmacallan else 1028754b44505Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1028854b44505Smrg cmds=$archive_expsym_cmds 1028954b44505Smrg else 1029054b44505Smrg cmds=$archive_cmds 1029154b44505Smrg fi 102924a041c5bSmacallan fi 1029354b44505Smrg fi 102944a041c5bSmacallan 1029554b44505Smrg if test -n "$delfiles"; then 1029654b44505Smrg # Append the command to remove temporary files to $cmds. 1029754b44505Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 1029854b44505Smrg fi 102994a041c5bSmacallan 1030054b44505Smrg # Add any objects from preloaded convenience libraries 1030154b44505Smrg if test -n "$dlprefiles"; then 103020a392d7eSmrg gentop=$output_objdir/${outputname}x 1030354b44505Smrg func_append generated " $gentop" 103044a041c5bSmacallan 1030554b44505Smrg func_extract_archives $gentop $dlprefiles 1030654b44505Smrg func_append libobjs " $func_extract_archives_result" 1030754b44505Smrg test "X$libobjs" = "X " && libobjs= 1030854b44505Smrg fi 103094a041c5bSmacallan 103100a392d7eSmrg save_ifs=$IFS; IFS='~' 1031154b44505Smrg for cmd in $cmds; do 103120a392d7eSmrg IFS=$sp$nl 1031354b44505Smrg eval cmd=\"$cmd\" 103140a392d7eSmrg IFS=$save_ifs 103150a392d7eSmrg $opt_quiet || { 103168fc2d0c6Smrg func_quote_arg expand,pretty "$cmd" 103178fc2d0c6Smrg eval "func_echo $func_quote_arg_result" 1031854b44505Smrg } 1031954b44505Smrg $opt_dry_run || eval "$cmd" || { 1032054b44505Smrg lt_exit=$? 103214a041c5bSmacallan 1032254b44505Smrg # Restore the uninstalled library and exit 103230a392d7eSmrg if test relink = "$opt_mode"; then 1032454b44505Smrg ( cd "$output_objdir" && \ 1032554b44505Smrg $RM "${realname}T" && \ 1032654b44505Smrg $MV "${realname}U" "$realname" ) 1032754b44505Smrg fi 103284a041c5bSmacallan 1032954b44505Smrg exit $lt_exit 1033054b44505Smrg } 1033154b44505Smrg done 103320a392d7eSmrg IFS=$save_ifs 103334a041c5bSmacallan 1033454b44505Smrg # Restore the uninstalled library and exit 103350a392d7eSmrg if test relink = "$opt_mode"; then 1033654b44505Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103374a041c5bSmacallan 1033854b44505Smrg if test -n "$convenience"; then 1033954b44505Smrg if test -z "$whole_archive_flag_spec"; then 1034054b44505Smrg func_show_eval '${RM}r "$gentop"' 1034154b44505Smrg fi 1034254b44505Smrg fi 103434a041c5bSmacallan 1034454b44505Smrg exit $EXIT_SUCCESS 1034554b44505Smrg fi 1034654b44505Smrg 1034754b44505Smrg # Create links to the real library. 1034854b44505Smrg for linkname in $linknames; do 1034954b44505Smrg if test "$realname" != "$linkname"; then 1035054b44505Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103514a041c5bSmacallan fi 103524a041c5bSmacallan done 103534a041c5bSmacallan 1035454b44505Smrg # If -module or -export-dynamic was specified, set the dlname. 103550a392d7eSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 1035654b44505Smrg # On all known operating systems, these are identical. 103570a392d7eSmrg dlname=$soname 1035854b44505Smrg fi 1035954b44505Smrg fi 103604a041c5bSmacallan ;; 103614a041c5bSmacallan 1036254b44505Smrg obj) 103630a392d7eSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103640a392d7eSmrg func_warning "'-dlopen' is ignored for objects" 1036554b44505Smrg fi 103664a041c5bSmacallan 1036754b44505Smrg case " $deplibs" in 1036854b44505Smrg *\ -l* | *\ -L*) 103690a392d7eSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 103704a041c5bSmacallan esac 103714a041c5bSmacallan 1037254b44505Smrg test -n "$rpath" && \ 103730a392d7eSmrg func_warning "'-rpath' is ignored for objects" 103744a041c5bSmacallan 1037554b44505Smrg test -n "$xrpath" && \ 103760a392d7eSmrg func_warning "'-R' is ignored for objects" 103774a041c5bSmacallan 1037854b44505Smrg test -n "$vinfo" && \ 103790a392d7eSmrg func_warning "'-version-info' is ignored for objects" 1038054b44505Smrg 1038154b44505Smrg test -n "$release" && \ 103820a392d7eSmrg func_warning "'-release' is ignored for objects" 1038354b44505Smrg 1038454b44505Smrg case $output in 1038554b44505Smrg *.lo) 1038654b44505Smrg test -n "$objs$old_deplibs" && \ 103870a392d7eSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1038854b44505Smrg 1038954b44505Smrg libobj=$output 1039054b44505Smrg func_lo2o "$libobj" 1039154b44505Smrg obj=$func_lo2o_result 103924a041c5bSmacallan ;; 103934a041c5bSmacallan *) 1039454b44505Smrg libobj= 103950a392d7eSmrg obj=$output 103964a041c5bSmacallan ;; 103974a041c5bSmacallan esac 103984a041c5bSmacallan 1039954b44505Smrg # Delete the old objects. 1040054b44505Smrg $opt_dry_run || $RM $obj $libobj 104014a041c5bSmacallan 1040254b44505Smrg # Objects from convenience libraries. This assumes 1040354b44505Smrg # single-version convenience libraries. Whenever we create 1040454b44505Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 1040554b44505Smrg # the extraction. 1040654b44505Smrg reload_conv_objs= 1040754b44505Smrg gentop= 104080a392d7eSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104090a392d7eSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104100a392d7eSmrg # into space. 104110a392d7eSmrg case $reload_cmds in 104120a392d7eSmrg *\$LD[\ \$]*) wl= ;; 104130a392d7eSmrg esac 1041454b44505Smrg if test -n "$convenience"; then 1041554b44505Smrg if test -n "$whole_archive_flag_spec"; then 1041654b44505Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104170a392d7eSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104180a392d7eSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1041954b44505Smrg else 104200a392d7eSmrg gentop=$output_objdir/${obj}x 1042154b44505Smrg func_append generated " $gentop" 104224a041c5bSmacallan 1042354b44505Smrg func_extract_archives $gentop $convenience 1042454b44505Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1042554b44505Smrg fi 104264a041c5bSmacallan fi 104274a041c5bSmacallan 1042854b44505Smrg # If we're not building shared, we need to use non_pic_objs 104290a392d7eSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104304a041c5bSmacallan 1043154b44505Smrg # Create the old-style object. 104320a392d7eSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104334a041c5bSmacallan 104340a392d7eSmrg output=$obj 1043554b44505Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1043654b44505Smrg 1043754b44505Smrg # Exit if we aren't doing a library object file. 1043854b44505Smrg if test -z "$libobj"; then 1043954b44505Smrg if test -n "$gentop"; then 1044054b44505Smrg func_show_eval '${RM}r "$gentop"' 1044154b44505Smrg fi 1044254b44505Smrg 1044354b44505Smrg exit $EXIT_SUCCESS 104444a041c5bSmacallan fi 1044554b44505Smrg 104460a392d7eSmrg test yes = "$build_libtool_libs" || { 1044754b44505Smrg if test -n "$gentop"; then 1044854b44505Smrg func_show_eval '${RM}r "$gentop"' 1044954b44505Smrg fi 1045054b44505Smrg 1045154b44505Smrg # Create an invalid libtool object if no PIC, so that we don't 1045254b44505Smrg # accidentally link it into a program. 1045354b44505Smrg # $show "echo timestamp > $libobj" 1045454b44505Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1045554b44505Smrg exit $EXIT_SUCCESS 104560a392d7eSmrg } 1045754b44505Smrg 104580a392d7eSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1045954b44505Smrg # Only do commands if we really have different PIC objects. 1046054b44505Smrg reload_objs="$libobjs $reload_conv_objs" 104610a392d7eSmrg output=$libobj 1046254b44505Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1046354b44505Smrg fi 1046454b44505Smrg 1046554b44505Smrg if test -n "$gentop"; then 1046654b44505Smrg func_show_eval '${RM}r "$gentop"' 1046754b44505Smrg fi 1046854b44505Smrg 1046954b44505Smrg exit $EXIT_SUCCESS 104704a041c5bSmacallan ;; 104714a041c5bSmacallan 1047254b44505Smrg prog) 1047354b44505Smrg case $host in 1047454b44505Smrg *cygwin*) func_stripname '' '.exe' "$output" 1047554b44505Smrg output=$func_stripname_result.exe;; 1047654b44505Smrg esac 1047754b44505Smrg test -n "$vinfo" && \ 104780a392d7eSmrg func_warning "'-version-info' is ignored for programs" 104794a041c5bSmacallan 1048054b44505Smrg test -n "$release" && \ 104810a392d7eSmrg func_warning "'-release' is ignored for programs" 104824a041c5bSmacallan 104830a392d7eSmrg $preload \ 104840a392d7eSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104850a392d7eSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1048654b44505Smrg 1048754b44505Smrg case $host in 1048854b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 1048954b44505Smrg # On Rhapsody replace the C library is the System framework 1049054b44505Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1049154b44505Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104924a041c5bSmacallan ;; 1049354b44505Smrg esac 104944a041c5bSmacallan 1049554b44505Smrg case $host in 1049654b44505Smrg *-*-darwin*) 1049754b44505Smrg # Don't allow lazy linking, it breaks C++ global constructors 1049854b44505Smrg # But is supposedly fixed on 10.4 or later (yay!). 104990a392d7eSmrg if test CXX = "$tagname"; then 1050054b44505Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1050154b44505Smrg 10.[0123]) 105020a392d7eSmrg func_append compile_command " $wl-bind_at_load" 105030a392d7eSmrg func_append finalize_command " $wl-bind_at_load" 1050454b44505Smrg ;; 1050554b44505Smrg esac 105064a041c5bSmacallan fi 1050754b44505Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1050854b44505Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1050954b44505Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1051054b44505Smrg ;; 1051154b44505Smrg esac 105124a041c5bSmacallan 105134a041c5bSmacallan 1051454b44505Smrg # move library search paths that coincide with paths to not yet 1051554b44505Smrg # installed libraries to the beginning of the library search list 1051654b44505Smrg new_libs= 1051754b44505Smrg for path in $notinst_path; do 1051854b44505Smrg case " $new_libs " in 1051954b44505Smrg *" -L$path/$objdir "*) ;; 1052054b44505Smrg *) 1052154b44505Smrg case " $compile_deplibs " in 1052254b44505Smrg *" -L$path/$objdir "*) 1052354b44505Smrg func_append new_libs " -L$path/$objdir" ;; 105244a041c5bSmacallan esac 1052554b44505Smrg ;; 1052654b44505Smrg esac 1052754b44505Smrg done 1052854b44505Smrg for deplib in $compile_deplibs; do 1052954b44505Smrg case $deplib in 1053054b44505Smrg -L*) 1053154b44505Smrg case " $new_libs " in 1053254b44505Smrg *" $deplib "*) ;; 1053354b44505Smrg *) func_append new_libs " $deplib" ;; 105344a041c5bSmacallan esac 1053554b44505Smrg ;; 1053654b44505Smrg *) func_append new_libs " $deplib" ;; 1053754b44505Smrg esac 1053854b44505Smrg done 105390a392d7eSmrg compile_deplibs=$new_libs 105404a041c5bSmacallan 105414a041c5bSmacallan 1054254b44505Smrg func_append compile_command " $compile_deplibs" 1054354b44505Smrg func_append finalize_command " $finalize_deplibs" 105444a041c5bSmacallan 1054554b44505Smrg if test -n "$rpath$xrpath"; then 1054654b44505Smrg # If the user specified any rpath flags, then add them. 1054754b44505Smrg for libdir in $rpath $xrpath; do 1054854b44505Smrg # This is the magic to use -rpath. 1054954b44505Smrg case "$finalize_rpath " in 1055054b44505Smrg *" $libdir "*) ;; 1055154b44505Smrg *) func_append finalize_rpath " $libdir" ;; 1055254b44505Smrg esac 1055354b44505Smrg done 1055454b44505Smrg fi 105554a041c5bSmacallan 1055654b44505Smrg # Now hardcode the library paths 1055754b44505Smrg rpath= 1055854b44505Smrg hardcode_libdirs= 1055954b44505Smrg for libdir in $compile_rpath $finalize_rpath; do 1056054b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 1056154b44505Smrg if test -n "$hardcode_libdir_separator"; then 1056254b44505Smrg if test -z "$hardcode_libdirs"; then 105630a392d7eSmrg hardcode_libdirs=$libdir 1056454b44505Smrg else 1056554b44505Smrg # Just accumulate the unique libdirs. 1056654b44505Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1056754b44505Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1056854b44505Smrg ;; 1056954b44505Smrg *) 1057054b44505Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1057154b44505Smrg ;; 1057254b44505Smrg esac 1057354b44505Smrg fi 105744a041c5bSmacallan else 1057554b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1057654b44505Smrg func_append rpath " $flag" 105774a041c5bSmacallan fi 1057854b44505Smrg elif test -n "$runpath_var"; then 1057954b44505Smrg case "$perm_rpath " in 1058054b44505Smrg *" $libdir "*) ;; 1058154b44505Smrg *) func_append perm_rpath " $libdir" ;; 1058254b44505Smrg esac 1058354b44505Smrg fi 1058454b44505Smrg case $host in 1058554b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105860a392d7eSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1058754b44505Smrg case :$dllsearchpath: in 1058854b44505Smrg *":$libdir:"*) ;; 1058954b44505Smrg ::) dllsearchpath=$libdir;; 1059054b44505Smrg *) func_append dllsearchpath ":$libdir";; 1059154b44505Smrg esac 1059254b44505Smrg case :$dllsearchpath: in 1059354b44505Smrg *":$testbindir:"*) ;; 1059454b44505Smrg ::) dllsearchpath=$testbindir;; 1059554b44505Smrg *) func_append dllsearchpath ":$testbindir";; 1059654b44505Smrg esac 1059754b44505Smrg ;; 1059854b44505Smrg esac 1059954b44505Smrg done 1060054b44505Smrg # Substitute the hardcoded libdirs into the rpath. 1060154b44505Smrg if test -n "$hardcode_libdir_separator" && 1060254b44505Smrg test -n "$hardcode_libdirs"; then 106030a392d7eSmrg libdir=$hardcode_libdirs 1060454b44505Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1060554b44505Smrg fi 106060a392d7eSmrg compile_rpath=$rpath 106074a041c5bSmacallan 1060854b44505Smrg rpath= 1060954b44505Smrg hardcode_libdirs= 1061054b44505Smrg for libdir in $finalize_rpath; do 1061154b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 1061254b44505Smrg if test -n "$hardcode_libdir_separator"; then 1061354b44505Smrg if test -z "$hardcode_libdirs"; then 106140a392d7eSmrg hardcode_libdirs=$libdir 1061554b44505Smrg else 1061654b44505Smrg # Just accumulate the unique libdirs. 1061754b44505Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1061854b44505Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1061954b44505Smrg ;; 1062054b44505Smrg *) 1062154b44505Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1062254b44505Smrg ;; 1062354b44505Smrg esac 1062454b44505Smrg fi 106254a041c5bSmacallan else 1062654b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1062754b44505Smrg func_append rpath " $flag" 106284a041c5bSmacallan fi 1062954b44505Smrg elif test -n "$runpath_var"; then 1063054b44505Smrg case "$finalize_perm_rpath " in 1063154b44505Smrg *" $libdir "*) ;; 1063254b44505Smrg *) func_append finalize_perm_rpath " $libdir" ;; 1063354b44505Smrg esac 106344a041c5bSmacallan fi 1063554b44505Smrg done 1063654b44505Smrg # Substitute the hardcoded libdirs into the rpath. 1063754b44505Smrg if test -n "$hardcode_libdir_separator" && 1063854b44505Smrg test -n "$hardcode_libdirs"; then 106390a392d7eSmrg libdir=$hardcode_libdirs 1064054b44505Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1064154b44505Smrg fi 106420a392d7eSmrg finalize_rpath=$rpath 106434a041c5bSmacallan 106440a392d7eSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1064554b44505Smrg # Transform all the library objects into standard objects. 1064654b44505Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064754b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064854b44505Smrg fi 106494a041c5bSmacallan 106500a392d7eSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106514a041c5bSmacallan 1065254b44505Smrg # template prelinking step 1065354b44505Smrg if test -n "$prelink_cmds"; then 1065454b44505Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 1065554b44505Smrg fi 106564a041c5bSmacallan 106570a392d7eSmrg wrappers_required=: 1065854b44505Smrg case $host in 1065954b44505Smrg *cegcc* | *mingw32ce*) 1066054b44505Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106610a392d7eSmrg wrappers_required=false 1066254b44505Smrg ;; 1066354b44505Smrg *cygwin* | *mingw* ) 106640a392d7eSmrg test yes = "$build_libtool_libs" || wrappers_required=false 1066554b44505Smrg ;; 1066654b44505Smrg *) 106670a392d7eSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106680a392d7eSmrg wrappers_required=false 1066954b44505Smrg fi 1067054b44505Smrg ;; 1067154b44505Smrg esac 106720a392d7eSmrg $wrappers_required || { 1067354b44505Smrg # Replace the output file specification. 1067454b44505Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106750a392d7eSmrg link_command=$compile_command$compile_rpath 106764a041c5bSmacallan 1067754b44505Smrg # We have no uninstalled library dependencies, so finalize right now. 1067854b44505Smrg exit_status=0 1067954b44505Smrg func_show_eval "$link_command" 'exit_status=$?' 106804a041c5bSmacallan 1068154b44505Smrg if test -n "$postlink_cmds"; then 1068254b44505Smrg func_to_tool_file "$output" 1068354b44505Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1068454b44505Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 106854a041c5bSmacallan fi 106864a041c5bSmacallan 1068754b44505Smrg # Delete the generated files. 106880a392d7eSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 106890a392d7eSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1069054b44505Smrg fi 106914a041c5bSmacallan 1069254b44505Smrg exit $exit_status 106930a392d7eSmrg } 106944a041c5bSmacallan 1069554b44505Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1069654b44505Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1069754b44505Smrg fi 1069854b44505Smrg if test -n "$finalize_shlibpath"; then 1069954b44505Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1070054b44505Smrg fi 107014a041c5bSmacallan 1070254b44505Smrg compile_var= 1070354b44505Smrg finalize_var= 1070454b44505Smrg if test -n "$runpath_var"; then 1070554b44505Smrg if test -n "$perm_rpath"; then 1070654b44505Smrg # We should set the runpath_var. 1070754b44505Smrg rpath= 1070854b44505Smrg for dir in $perm_rpath; do 1070954b44505Smrg func_append rpath "$dir:" 1071054b44505Smrg done 1071154b44505Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107124a041c5bSmacallan fi 1071354b44505Smrg if test -n "$finalize_perm_rpath"; then 1071454b44505Smrg # We should set the runpath_var. 1071554b44505Smrg rpath= 1071654b44505Smrg for dir in $finalize_perm_rpath; do 1071754b44505Smrg func_append rpath "$dir:" 1071854b44505Smrg done 1071954b44505Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107204a041c5bSmacallan fi 1072154b44505Smrg fi 107224a041c5bSmacallan 107230a392d7eSmrg if test yes = "$no_install"; then 1072454b44505Smrg # We don't need to create a wrapper script. 107250a392d7eSmrg link_command=$compile_var$compile_command$compile_rpath 1072654b44505Smrg # Replace the output file specification. 1072754b44505Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1072854b44505Smrg # Delete the old output file. 1072954b44505Smrg $opt_dry_run || $RM $output 1073054b44505Smrg # Link the executable and exit 1073154b44505Smrg func_show_eval "$link_command" 'exit $?' 107324a041c5bSmacallan 1073354b44505Smrg if test -n "$postlink_cmds"; then 1073454b44505Smrg func_to_tool_file "$output" 1073554b44505Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1073654b44505Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107374a041c5bSmacallan fi 1073854b44505Smrg 107394a041c5bSmacallan exit $EXIT_SUCCESS 1074054b44505Smrg fi 107414a041c5bSmacallan 107420a392d7eSmrg case $hardcode_action,$fast_install in 107430a392d7eSmrg relink,*) 107440a392d7eSmrg # Fast installation is not supported 107450a392d7eSmrg link_command=$compile_var$compile_command$compile_rpath 107460a392d7eSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1074754b44505Smrg 107480a392d7eSmrg func_warning "this platform does not like uninstalled shared libraries" 107490a392d7eSmrg func_warning "'$output' will be relinked during installation" 107500a392d7eSmrg ;; 107510a392d7eSmrg *,yes) 107520a392d7eSmrg link_command=$finalize_var$compile_command$finalize_rpath 107530a392d7eSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107540a392d7eSmrg ;; 107550a392d7eSmrg *,no) 107560a392d7eSmrg link_command=$compile_var$compile_command$compile_rpath 107570a392d7eSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107580a392d7eSmrg ;; 107590a392d7eSmrg *,needless) 107600a392d7eSmrg link_command=$finalize_var$compile_command$finalize_rpath 107610a392d7eSmrg relink_command= 107620a392d7eSmrg ;; 107630a392d7eSmrg esac 107644a041c5bSmacallan 1076554b44505Smrg # Replace the output file specification. 1076654b44505Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107674a041c5bSmacallan 1076854b44505Smrg # Delete the old output files. 1076954b44505Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107704a041c5bSmacallan 1077154b44505Smrg func_show_eval "$link_command" 'exit $?' 107724a041c5bSmacallan 1077354b44505Smrg if test -n "$postlink_cmds"; then 1077454b44505Smrg func_to_tool_file "$output_objdir/$outputname" 1077554b44505Smrg 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'` 1077654b44505Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1077754b44505Smrg fi 107784a041c5bSmacallan 1077954b44505Smrg # Now create the wrapper script. 1078054b44505Smrg func_verbose "creating $output" 107814a041c5bSmacallan 1078254b44505Smrg # Quote the relink command for shipping. 1078354b44505Smrg if test -n "$relink_command"; then 1078454b44505Smrg # Preserve any variables that may affect compiler behavior 1078554b44505Smrg for var in $variables_saved_for_relink; do 1078654b44505Smrg if eval test -z \"\${$var+set}\"; then 1078754b44505Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1078854b44505Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1078954b44505Smrg relink_command="$var=; export $var; $relink_command" 107904a041c5bSmacallan else 107918fc2d0c6Smrg func_quote_arg pretty "$var_value" 107928fc2d0c6Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107934a041c5bSmacallan fi 1079454b44505Smrg done 107958fc2d0c6Smrg func_quote eval cd "`pwd`" 107968fc2d0c6Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107978fc2d0c6Smrg relink_command=$func_quote_arg_unquoted_result 1079854b44505Smrg fi 1079954b44505Smrg 1080054b44505Smrg # Only actually do things if not in dry run mode. 1080154b44505Smrg $opt_dry_run || { 1080254b44505Smrg # win32 will think the script is a binary if it has 1080354b44505Smrg # a .exe suffix, so we strip it off here. 1080454b44505Smrg case $output in 1080554b44505Smrg *.exe) func_stripname '' '.exe' "$output" 1080654b44505Smrg output=$func_stripname_result ;; 108074a041c5bSmacallan esac 1080854b44505Smrg # test for cygwin because mv fails w/o .exe extensions 1080954b44505Smrg case $host in 1081054b44505Smrg *cygwin*) 1081154b44505Smrg exeext=.exe 1081254b44505Smrg func_stripname '' '.exe' "$outputname" 1081354b44505Smrg outputname=$func_stripname_result ;; 1081454b44505Smrg *) exeext= ;; 1081554b44505Smrg esac 1081654b44505Smrg case $host in 1081754b44505Smrg *cygwin* | *mingw* ) 1081854b44505Smrg func_dirname_and_basename "$output" "" "." 1081954b44505Smrg output_name=$func_basename_result 1082054b44505Smrg output_path=$func_dirname_result 108210a392d7eSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108220a392d7eSmrg cwrapper=$output_path/$output_name.exe 1082354b44505Smrg $RM $cwrappersource $cwrapper 1082454b44505Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1082554b44505Smrg 1082654b44505Smrg func_emit_cwrapperexe_src > $cwrappersource 1082754b44505Smrg 1082854b44505Smrg # The wrapper executable is built using the $host compiler, 1082954b44505Smrg # because it contains $host paths and files. If cross- 1083054b44505Smrg # compiling, it, like the target executable, must be 1083154b44505Smrg # executed on the $host or under an emulation environment. 1083254b44505Smrg $opt_dry_run || { 1083354b44505Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1083454b44505Smrg $STRIP $cwrapper 1083554b44505Smrg } 108364a041c5bSmacallan 1083754b44505Smrg # Now, create the wrapper script for func_source use: 1083854b44505Smrg func_ltwrapper_scriptname $cwrapper 1083954b44505Smrg $RM $func_ltwrapper_scriptname_result 1084054b44505Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1084154b44505Smrg $opt_dry_run || { 1084254b44505Smrg # note: this script will not be executed, so do not chmod. 108430a392d7eSmrg if test "x$build" = "x$host"; then 1084454b44505Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1084554b44505Smrg else 1084654b44505Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1084754b44505Smrg fi 1084854b44505Smrg } 1084954b44505Smrg ;; 1085054b44505Smrg * ) 1085154b44505Smrg $RM $output 1085254b44505Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108534a041c5bSmacallan 1085454b44505Smrg func_emit_wrapper no > $output 1085554b44505Smrg chmod +x $output 1085654b44505Smrg ;; 1085754b44505Smrg esac 1085854b44505Smrg } 1085954b44505Smrg exit $EXIT_SUCCESS 1086054b44505Smrg ;; 1086154b44505Smrg esac 108624a041c5bSmacallan 1086354b44505Smrg # See if we need to build an old-fashioned archive. 1086454b44505Smrg for oldlib in $oldlibs; do 108654a041c5bSmacallan 108660a392d7eSmrg case $build_libtool_libs in 108670a392d7eSmrg convenience) 108680a392d7eSmrg oldobjs="$libobjs_save $symfileobj" 108690a392d7eSmrg addlibs=$convenience 1087054b44505Smrg build_libtool_libs=no 108710a392d7eSmrg ;; 108720a392d7eSmrg module) 108730a392d7eSmrg oldobjs=$libobjs_save 108740a392d7eSmrg addlibs=$old_convenience 108750a392d7eSmrg build_libtool_libs=no 108760a392d7eSmrg ;; 108770a392d7eSmrg *) 1087854b44505Smrg oldobjs="$old_deplibs $non_pic_objects" 108790a392d7eSmrg $preload && test -f "$symfileobj" \ 108800a392d7eSmrg && func_append oldobjs " $symfileobj" 108810a392d7eSmrg addlibs=$old_convenience 108820a392d7eSmrg ;; 108830a392d7eSmrg esac 108844a041c5bSmacallan 1088554b44505Smrg if test -n "$addlibs"; then 108860a392d7eSmrg gentop=$output_objdir/${outputname}x 1088754b44505Smrg func_append generated " $gentop" 108884a041c5bSmacallan 1088954b44505Smrg func_extract_archives $gentop $addlibs 1089054b44505Smrg func_append oldobjs " $func_extract_archives_result" 1089154b44505Smrg fi 108924a041c5bSmacallan 1089354b44505Smrg # Do each command in the archive commands. 108940a392d7eSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1089554b44505Smrg cmds=$old_archive_from_new_cmds 1089654b44505Smrg else 108974a041c5bSmacallan 1089854b44505Smrg # Add any objects from preloaded convenience libraries 1089954b44505Smrg if test -n "$dlprefiles"; then 109000a392d7eSmrg gentop=$output_objdir/${outputname}x 1090154b44505Smrg func_append generated " $gentop" 109024a041c5bSmacallan 1090354b44505Smrg func_extract_archives $gentop $dlprefiles 1090454b44505Smrg func_append oldobjs " $func_extract_archives_result" 1090554b44505Smrg fi 109064a041c5bSmacallan 1090754b44505Smrg # POSIX demands no paths to be encoded in archives. We have 1090854b44505Smrg # to avoid creating archives with duplicate basenames if we 1090954b44505Smrg # might have to extract them afterwards, e.g., when creating a 1091054b44505Smrg # static archive out of a convenience library, or when linking 1091154b44505Smrg # the entirety of a libtool archive into another (currently 1091254b44505Smrg # not supported by libtool). 1091354b44505Smrg if (for obj in $oldobjs 1091454b44505Smrg do 1091554b44505Smrg func_basename "$obj" 1091654b44505Smrg $ECHO "$func_basename_result" 1091754b44505Smrg done | sort | sort -uc >/dev/null 2>&1); then 1091854b44505Smrg : 1091954b44505Smrg else 1092054b44505Smrg echo "copying selected object files to avoid basename conflicts..." 109210a392d7eSmrg gentop=$output_objdir/${outputname}x 1092254b44505Smrg func_append generated " $gentop" 1092354b44505Smrg func_mkdir_p "$gentop" 1092454b44505Smrg save_oldobjs=$oldobjs 1092554b44505Smrg oldobjs= 1092654b44505Smrg counter=1 1092754b44505Smrg for obj in $save_oldobjs 1092854b44505Smrg do 1092954b44505Smrg func_basename "$obj" 109300a392d7eSmrg objbase=$func_basename_result 1093154b44505Smrg case " $oldobjs " in 1093254b44505Smrg " ") oldobjs=$obj ;; 1093354b44505Smrg *[\ /]"$objbase "*) 1093454b44505Smrg while :; do 1093554b44505Smrg # Make sure we don't pick an alternate name that also 1093654b44505Smrg # overlaps. 1093754b44505Smrg newobj=lt$counter-$objbase 1093854b44505Smrg func_arith $counter + 1 1093954b44505Smrg counter=$func_arith_result 1094054b44505Smrg case " $oldobjs " in 1094154b44505Smrg *[\ /]"$newobj "*) ;; 1094254b44505Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1094354b44505Smrg esac 1094454b44505Smrg done 1094554b44505Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1094654b44505Smrg func_append oldobjs " $gentop/$newobj" 1094754b44505Smrg ;; 1094854b44505Smrg *) func_append oldobjs " $obj" ;; 1094954b44505Smrg esac 109504a041c5bSmacallan done 109514a041c5bSmacallan fi 109520a392d7eSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109530a392d7eSmrg tool_oldlib=$func_to_tool_file_result 1095454b44505Smrg eval cmds=\"$old_archive_cmds\" 109554a041c5bSmacallan 1095654b44505Smrg func_len " $cmds" 1095754b44505Smrg len=$func_len_result 1095854b44505Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1095954b44505Smrg cmds=$old_archive_cmds 1096054b44505Smrg elif test -n "$archiver_list_spec"; then 1096154b44505Smrg func_verbose "using command file archive linking..." 1096254b44505Smrg for obj in $oldobjs 1096354b44505Smrg do 1096454b44505Smrg func_to_tool_file "$obj" 1096554b44505Smrg $ECHO "$func_to_tool_file_result" 1096654b44505Smrg done > $output_objdir/$libname.libcmd 1096754b44505Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1096854b44505Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1096954b44505Smrg cmds=$old_archive_cmds 1097054b44505Smrg else 1097154b44505Smrg # the command line is too long to link in one step, link in parts 1097254b44505Smrg func_verbose "using piecewise archive linking..." 1097354b44505Smrg save_RANLIB=$RANLIB 1097454b44505Smrg RANLIB=: 1097554b44505Smrg objlist= 1097654b44505Smrg concat_cmds= 1097754b44505Smrg save_oldobjs=$oldobjs 1097854b44505Smrg oldobjs= 1097954b44505Smrg # Is there a better way of finding the last object in the list? 1098054b44505Smrg for obj in $save_oldobjs 1098154b44505Smrg do 1098254b44505Smrg last_oldobj=$obj 1098354b44505Smrg done 1098454b44505Smrg eval test_cmds=\"$old_archive_cmds\" 1098554b44505Smrg func_len " $test_cmds" 1098654b44505Smrg len0=$func_len_result 1098754b44505Smrg len=$len0 1098854b44505Smrg for obj in $save_oldobjs 1098954b44505Smrg do 1099054b44505Smrg func_len " $obj" 1099154b44505Smrg func_arith $len + $func_len_result 1099254b44505Smrg len=$func_arith_result 1099354b44505Smrg func_append objlist " $obj" 1099454b44505Smrg if test "$len" -lt "$max_cmd_len"; then 1099554b44505Smrg : 1099654b44505Smrg else 1099754b44505Smrg # the above command should be used before it gets too long 1099854b44505Smrg oldobjs=$objlist 109990a392d7eSmrg if test "$obj" = "$last_oldobj"; then 1100054b44505Smrg RANLIB=$save_RANLIB 1100154b44505Smrg fi 1100254b44505Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110030a392d7eSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1100454b44505Smrg objlist= 1100554b44505Smrg len=$len0 1100654b44505Smrg fi 1100754b44505Smrg done 1100854b44505Smrg RANLIB=$save_RANLIB 1100954b44505Smrg oldobjs=$objlist 110100a392d7eSmrg if test -z "$oldobjs"; then 1101154b44505Smrg eval cmds=\"\$concat_cmds\" 1101254b44505Smrg else 1101354b44505Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1101454b44505Smrg fi 1101554b44505Smrg fi 1101654b44505Smrg fi 1101754b44505Smrg func_execute_cmds "$cmds" 'exit $?' 110184a041c5bSmacallan done 110194a041c5bSmacallan 1102054b44505Smrg test -n "$generated" && \ 1102154b44505Smrg func_show_eval "${RM}r$generated" 110224a041c5bSmacallan 1102354b44505Smrg # Now create the libtool archive. 1102454b44505Smrg case $output in 1102554b44505Smrg *.la) 1102654b44505Smrg old_library= 110270a392d7eSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 1102854b44505Smrg func_verbose "creating $output" 110294a041c5bSmacallan 1103054b44505Smrg # Preserve any variables that may affect compiler behavior 1103154b44505Smrg for var in $variables_saved_for_relink; do 1103254b44505Smrg if eval test -z \"\${$var+set}\"; then 1103354b44505Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1103454b44505Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1103554b44505Smrg relink_command="$var=; export $var; $relink_command" 110364a041c5bSmacallan else 110378fc2d0c6Smrg func_quote_arg pretty,unquoted "$var_value" 110388fc2d0c6Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110394a041c5bSmacallan fi 1104054b44505Smrg done 1104154b44505Smrg # Quote the link command for shipping. 110428fc2d0c6Smrg func_quote eval cd "`pwd`" 110438fc2d0c6Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110448fc2d0c6Smrg func_quote_arg pretty,unquoted "$relink_command" 110458fc2d0c6Smrg relink_command=$func_quote_arg_unquoted_result 110460a392d7eSmrg if test yes = "$hardcode_automatic"; then 1104754b44505Smrg relink_command= 1104854b44505Smrg fi 110494a041c5bSmacallan 1105054b44505Smrg # Only create the output if not a dry run. 1105154b44505Smrg $opt_dry_run || { 1105254b44505Smrg for installed in no yes; do 110530a392d7eSmrg if test yes = "$installed"; then 1105454b44505Smrg if test -z "$install_libdir"; then 1105554b44505Smrg break 1105654b44505Smrg fi 110570a392d7eSmrg output=$output_objdir/${outputname}i 1105854b44505Smrg # Replace all uninstalled libtool libraries with the installed ones 1105954b44505Smrg newdependency_libs= 1106054b44505Smrg for deplib in $dependency_libs; do 1106154b44505Smrg case $deplib in 1106254b44505Smrg *.la) 1106354b44505Smrg func_basename "$deplib" 110640a392d7eSmrg name=$func_basename_result 110650a392d7eSmrg func_resolve_sysroot "$deplib" 110660a392d7eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1106754b44505Smrg test -z "$libdir" && \ 110680a392d7eSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 1106954b44505Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1107054b44505Smrg ;; 1107154b44505Smrg -L*) 1107254b44505Smrg func_stripname -L '' "$deplib" 1107354b44505Smrg func_replace_sysroot "$func_stripname_result" 1107454b44505Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1107554b44505Smrg ;; 1107654b44505Smrg -R*) 1107754b44505Smrg func_stripname -R '' "$deplib" 1107854b44505Smrg func_replace_sysroot "$func_stripname_result" 1107954b44505Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1108054b44505Smrg ;; 1108154b44505Smrg *) func_append newdependency_libs " $deplib" ;; 1108254b44505Smrg esac 1108354b44505Smrg done 110840a392d7eSmrg dependency_libs=$newdependency_libs 1108554b44505Smrg newdlfiles= 1108654b44505Smrg 1108754b44505Smrg for lib in $dlfiles; do 1108854b44505Smrg case $lib in 1108954b44505Smrg *.la) 1109054b44505Smrg func_basename "$lib" 110910a392d7eSmrg name=$func_basename_result 110920a392d7eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1109354b44505Smrg test -z "$libdir" && \ 110940a392d7eSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1109554b44505Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1109654b44505Smrg ;; 1109754b44505Smrg *) func_append newdlfiles " $lib" ;; 1109854b44505Smrg esac 1109954b44505Smrg done 111000a392d7eSmrg dlfiles=$newdlfiles 1110154b44505Smrg newdlprefiles= 1110254b44505Smrg for lib in $dlprefiles; do 1110354b44505Smrg case $lib in 1110454b44505Smrg *.la) 1110554b44505Smrg # Only pass preopened files to the pseudo-archive (for 1110654b44505Smrg # eventual linking with the app. that links it) if we 1110754b44505Smrg # didn't already link the preopened objects directly into 1110854b44505Smrg # the library: 1110954b44505Smrg func_basename "$lib" 111100a392d7eSmrg name=$func_basename_result 111110a392d7eSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1111254b44505Smrg test -z "$libdir" && \ 111130a392d7eSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1111454b44505Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1111554b44505Smrg ;; 1111654b44505Smrg esac 1111754b44505Smrg done 111180a392d7eSmrg dlprefiles=$newdlprefiles 1111954b44505Smrg else 1112054b44505Smrg newdlfiles= 1112154b44505Smrg for lib in $dlfiles; do 1112254b44505Smrg case $lib in 111230a392d7eSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1112454b44505Smrg *) abs=`pwd`"/$lib" ;; 1112554b44505Smrg esac 1112654b44505Smrg func_append newdlfiles " $abs" 1112754b44505Smrg done 111280a392d7eSmrg dlfiles=$newdlfiles 1112954b44505Smrg newdlprefiles= 1113054b44505Smrg for lib in $dlprefiles; do 1113154b44505Smrg case $lib in 111320a392d7eSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1113354b44505Smrg *) abs=`pwd`"/$lib" ;; 1113454b44505Smrg esac 1113554b44505Smrg func_append newdlprefiles " $abs" 1113654b44505Smrg done 111370a392d7eSmrg dlprefiles=$newdlprefiles 1113854b44505Smrg fi 1113954b44505Smrg $RM $output 1114054b44505Smrg # place dlname in correct position for cygwin 1114154b44505Smrg # In fact, it would be nice if we could use this code for all target 1114254b44505Smrg # systems that can't hard-code library paths into their executables 1114354b44505Smrg # and that have no shared library path variable independent of PATH, 1114454b44505Smrg # but it turns out we can't easily determine that from inspecting 1114554b44505Smrg # libtool variables, so we have to hard-code the OSs to which it 1114654b44505Smrg # applies here; at the moment, that means platforms that use the PE 1114754b44505Smrg # object format with DLL files. See the long comment at the top of 1114854b44505Smrg # tests/bindir.at for full details. 1114954b44505Smrg tdlname=$dlname 1115054b44505Smrg case $host,$output,$installed,$module,$dlname in 1115154b44505Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1115254b44505Smrg # If a -bindir argument was supplied, place the dll there. 111530a392d7eSmrg if test -n "$bindir"; then 1115454b44505Smrg func_relative_path "$install_libdir" "$bindir" 111550a392d7eSmrg tdlname=$func_relative_path_result/$dlname 1115654b44505Smrg else 1115754b44505Smrg # Otherwise fall back on heuristic. 1115854b44505Smrg tdlname=../bin/$dlname 1115954b44505Smrg fi 1116054b44505Smrg ;; 1116154b44505Smrg esac 1116254b44505Smrg $ECHO > $output "\ 1116354b44505Smrg# $outputname - a libtool library file 111640a392d7eSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1116554b44505Smrg# 1116654b44505Smrg# Please DO NOT delete this file! 1116754b44505Smrg# It is necessary for linking the library. 111684a041c5bSmacallan 1116954b44505Smrg# The name that we can dlopen(3). 1117054b44505Smrgdlname='$tdlname' 111714a041c5bSmacallan 1117254b44505Smrg# Names of this library. 1117354b44505Smrglibrary_names='$library_names' 111744a041c5bSmacallan 1117554b44505Smrg# The name of the static archive. 1117654b44505Smrgold_library='$old_library' 111774a041c5bSmacallan 111780a392d7eSmrg# Linker flags that cannot go in dependency_libs. 1117954b44505Smrginherited_linker_flags='$new_inherited_linker_flags' 111804a041c5bSmacallan 1118154b44505Smrg# Libraries that this one depends upon. 1118254b44505Smrgdependency_libs='$dependency_libs' 111834a041c5bSmacallan 1118454b44505Smrg# Names of additional weak libraries provided by this library 1118554b44505Smrgweak_library_names='$weak_libs' 111864a041c5bSmacallan 1118754b44505Smrg# Version information for $libname. 1118854b44505Smrgcurrent=$current 1118954b44505Smrgage=$age 1119054b44505Smrgrevision=$revision 111914a041c5bSmacallan 1119254b44505Smrg# Is this an already installed library? 1119354b44505Smrginstalled=$installed 111944a041c5bSmacallan 1119554b44505Smrg# Should we warn about portability when linking against -modules? 1119654b44505Smrgshouldnotlink=$module 111974a041c5bSmacallan 1119854b44505Smrg# Files to dlopen/dlpreopen 1119954b44505Smrgdlopen='$dlfiles' 1120054b44505Smrgdlpreopen='$dlprefiles' 112014a041c5bSmacallan 1120254b44505Smrg# Directory that this library needs to be installed in: 1120354b44505Smrglibdir='$install_libdir'" 112040a392d7eSmrg if test no,yes = "$installed,$need_relink"; then 1120554b44505Smrg $ECHO >> $output "\ 1120654b44505Smrgrelink_command=\"$relink_command\"" 1120754b44505Smrg fi 1120854b44505Smrg done 1120954b44505Smrg } 112104a041c5bSmacallan 1121154b44505Smrg # Do a symbolic link so that the libtool archive can be found in 1121254b44505Smrg # LD_LIBRARY_PATH before the program is installed. 1121354b44505Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1121454b44505Smrg ;; 1121554b44505Smrg esac 1121654b44505Smrg exit $EXIT_SUCCESS 1121754b44505Smrg} 112184a041c5bSmacallan 112190a392d7eSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112200a392d7eSmrg func_mode_link ${1+"$@"} 112210a392d7eSmrgfi 112224a041c5bSmacallan 112234a041c5bSmacallan 1122454b44505Smrg# func_mode_uninstall arg... 1122554b44505Smrgfunc_mode_uninstall () 1122654b44505Smrg{ 112270a392d7eSmrg $debug_cmd 112280a392d7eSmrg 112290a392d7eSmrg RM=$nonopt 112304a041c5bSmacallan files= 112310a392d7eSmrg rmforce=false 112324a041c5bSmacallan exit_status=0 112334a041c5bSmacallan 112344a041c5bSmacallan # This variable tells wrapper scripts just to set variables rather 112354a041c5bSmacallan # than running their programs. 112360a392d7eSmrg libtool_install_magic=$magic 112374a041c5bSmacallan 112384a041c5bSmacallan for arg 112394a041c5bSmacallan do 112404a041c5bSmacallan case $arg in 112410a392d7eSmrg -f) func_append RM " $arg"; rmforce=: ;; 1124254b44505Smrg -*) func_append RM " $arg" ;; 1124354b44505Smrg *) func_append files " $arg" ;; 112444a041c5bSmacallan esac 112454a041c5bSmacallan done 112464a041c5bSmacallan 1124754b44505Smrg test -z "$RM" && \ 1124854b44505Smrg func_fatal_help "you must specify an RM program" 112494a041c5bSmacallan 112504a041c5bSmacallan rmdirs= 112514a041c5bSmacallan 112524a041c5bSmacallan for file in $files; do 1125354b44505Smrg func_dirname "$file" "" "." 112540a392d7eSmrg dir=$func_dirname_result 112550a392d7eSmrg if test . = "$dir"; then 112560a392d7eSmrg odir=$objdir 112574a041c5bSmacallan else 112580a392d7eSmrg odir=$dir/$objdir 112594a041c5bSmacallan fi 1126054b44505Smrg func_basename "$file" 112610a392d7eSmrg name=$func_basename_result 112620a392d7eSmrg test uninstall = "$opt_mode" && odir=$dir 112634a041c5bSmacallan 1126454b44505Smrg # Remember odir for removal later, being careful to avoid duplicates 112650a392d7eSmrg if test clean = "$opt_mode"; then 112664a041c5bSmacallan case " $rmdirs " in 1126754b44505Smrg *" $odir "*) ;; 1126854b44505Smrg *) func_append rmdirs " $odir" ;; 112694a041c5bSmacallan esac 112704a041c5bSmacallan fi 112714a041c5bSmacallan 112724a041c5bSmacallan # Don't error if the file doesn't exist and rm -f was used. 1127354b44505Smrg if { test -L "$file"; } >/dev/null 2>&1 || 1127454b44505Smrg { test -h "$file"; } >/dev/null 2>&1 || 1127554b44505Smrg test -f "$file"; then 112764a041c5bSmacallan : 112774a041c5bSmacallan elif test -d "$file"; then 112784a041c5bSmacallan exit_status=1 112794a041c5bSmacallan continue 112800a392d7eSmrg elif $rmforce; then 112814a041c5bSmacallan continue 112824a041c5bSmacallan fi 112834a041c5bSmacallan 112840a392d7eSmrg rmfiles=$file 112854a041c5bSmacallan 112864a041c5bSmacallan case $name in 112874a041c5bSmacallan *.la) 112884a041c5bSmacallan # Possibly a libtool archive, so verify it. 1128954b44505Smrg if func_lalib_p "$file"; then 1129054b44505Smrg func_source $dir/$name 112914a041c5bSmacallan 112924a041c5bSmacallan # Delete the libtool libraries and symlinks. 112934a041c5bSmacallan for n in $library_names; do 1129454b44505Smrg func_append rmfiles " $odir/$n" 112954a041c5bSmacallan done 1129654b44505Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112974a041c5bSmacallan 112980a392d7eSmrg case $opt_mode in 112994a041c5bSmacallan clean) 1130054b44505Smrg case " $library_names " in 113014a041c5bSmacallan *" $dlname "*) ;; 1130254b44505Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113034a041c5bSmacallan esac 1130454b44505Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113054a041c5bSmacallan ;; 113064a041c5bSmacallan uninstall) 113074a041c5bSmacallan if test -n "$library_names"; then 113084a041c5bSmacallan # Do each command in the postuninstall commands. 113090a392d7eSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113104a041c5bSmacallan fi 113114a041c5bSmacallan 113124a041c5bSmacallan if test -n "$old_library"; then 113134a041c5bSmacallan # Do each command in the old_postuninstall commands. 113140a392d7eSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113154a041c5bSmacallan fi 113164a041c5bSmacallan # FIXME: should reinstall the best remaining shared library. 113174a041c5bSmacallan ;; 113184a041c5bSmacallan esac 113194a041c5bSmacallan fi 113204a041c5bSmacallan ;; 113214a041c5bSmacallan 113224a041c5bSmacallan *.lo) 113234a041c5bSmacallan # Possibly a libtool object, so verify it. 1132454b44505Smrg if func_lalib_p "$file"; then 113254a041c5bSmacallan 113264a041c5bSmacallan # Read the .lo file 1132754b44505Smrg func_source $dir/$name 113284a041c5bSmacallan 113294a041c5bSmacallan # Add PIC object to the list of files to remove. 113300a392d7eSmrg if test -n "$pic_object" && test none != "$pic_object"; then 1133154b44505Smrg func_append rmfiles " $dir/$pic_object" 113324a041c5bSmacallan fi 113334a041c5bSmacallan 113344a041c5bSmacallan # Add non-PIC object to the list of files to remove. 113350a392d7eSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1133654b44505Smrg func_append rmfiles " $dir/$non_pic_object" 113374a041c5bSmacallan fi 113384a041c5bSmacallan fi 113394a041c5bSmacallan ;; 113404a041c5bSmacallan 113414a041c5bSmacallan *) 113420a392d7eSmrg if test clean = "$opt_mode"; then 113434a041c5bSmacallan noexename=$name 113444a041c5bSmacallan case $file in 113454a041c5bSmacallan *.exe) 1134654b44505Smrg func_stripname '' '.exe' "$file" 1134754b44505Smrg file=$func_stripname_result 1134854b44505Smrg func_stripname '' '.exe' "$name" 1134954b44505Smrg noexename=$func_stripname_result 113504a041c5bSmacallan # $file with .exe has already been added to rmfiles, 113514a041c5bSmacallan # add $file without .exe 1135254b44505Smrg func_append rmfiles " $file" 113534a041c5bSmacallan ;; 113544a041c5bSmacallan esac 113554a041c5bSmacallan # Do a test to see if this is a libtool program. 1135654b44505Smrg if func_ltwrapper_p "$file"; then 1135754b44505Smrg if func_ltwrapper_executable_p "$file"; then 1135854b44505Smrg func_ltwrapper_scriptname "$file" 1135954b44505Smrg relink_command= 1136054b44505Smrg func_source $func_ltwrapper_scriptname_result 1136154b44505Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1136254b44505Smrg else 1136354b44505Smrg relink_command= 1136454b44505Smrg func_source $dir/$noexename 1136554b44505Smrg fi 113664a041c5bSmacallan 113674a041c5bSmacallan # note $name still contains .exe if it was in $file originally 113684a041c5bSmacallan # as does the version of $file that was added into $rmfiles 113690a392d7eSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113700a392d7eSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 1137154b44505Smrg func_append rmfiles " $odir/lt-$name" 113724a041c5bSmacallan fi 113730a392d7eSmrg if test "X$noexename" != "X$name"; then 113740a392d7eSmrg func_append rmfiles " $odir/lt-$noexename.c" 113754a041c5bSmacallan fi 113764a041c5bSmacallan fi 113774a041c5bSmacallan fi 113784a041c5bSmacallan ;; 113794a041c5bSmacallan esac 1138054b44505Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113814a041c5bSmacallan done 113824a041c5bSmacallan 113830a392d7eSmrg # Try to remove the $objdir's in the directories where we deleted files 113844a041c5bSmacallan for dir in $rmdirs; do 113854a041c5bSmacallan if test -d "$dir"; then 1138654b44505Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113874a041c5bSmacallan fi 113884a041c5bSmacallan done 113894a041c5bSmacallan 113904a041c5bSmacallan exit $exit_status 1139154b44505Smrg} 113924a041c5bSmacallan 113930a392d7eSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113940a392d7eSmrg func_mode_uninstall ${1+"$@"} 113950a392d7eSmrgfi 113964a041c5bSmacallan 1139754b44505Smrgtest -z "$opt_mode" && { 113980a392d7eSmrg help=$generic_help 1139954b44505Smrg func_fatal_help "you must specify a MODE" 1140054b44505Smrg} 1140154b44505Smrg 1140254b44505Smrgtest -z "$exec_cmd" && \ 114030a392d7eSmrg func_fatal_help "invalid operation mode '$opt_mode'" 114044a041c5bSmacallan 114054a041c5bSmacallanif test -n "$exec_cmd"; then 1140654b44505Smrg eval exec "$exec_cmd" 114074a041c5bSmacallan exit $EXIT_FAILURE 114084a041c5bSmacallanfi 114094a041c5bSmacallan 1141054b44505Smrgexit $exit_status 114114a041c5bSmacallan 114124a041c5bSmacallan 114134a041c5bSmacallan# The TAGs below are defined such that we never get into a situation 114140a392d7eSmrg# where we disable both kinds of libraries. Given conflicting 114154a041c5bSmacallan# choices, we go for a static library, that is the most portable, 114164a041c5bSmacallan# since we can't tell whether shared libraries were disabled because 114174a041c5bSmacallan# the user asked for that or because the platform doesn't support 114184a041c5bSmacallan# them. This is particularly important on AIX, because we don't 114194a041c5bSmacallan# support having both static and shared libraries enabled at the same 114204a041c5bSmacallan# time on that platform, so we default to a shared-only configuration. 114214a041c5bSmacallan# If a disable-shared tag is given, we'll fallback to a static-only 114224a041c5bSmacallan# configuration. But we'll never go from static-only to shared-only. 114234a041c5bSmacallan 114244a041c5bSmacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1142554b44505Smrgbuild_libtool_libs=no 1142654b44505Smrgbuild_old_libs=yes 114274a041c5bSmacallan# ### END LIBTOOL TAG CONFIG: disable-shared 114284a041c5bSmacallan 114294a041c5bSmacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1143054b44505Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114314a041c5bSmacallan# ### END LIBTOOL TAG CONFIG: disable-static 114324a041c5bSmacallan 114334a041c5bSmacallan# Local Variables: 114344a041c5bSmacallan# mode:shell-script 114354a041c5bSmacallan# sh-indentation:2 114364a041c5bSmacallan# End: 11437