15c30ecadSmrg#! /usr/bin/env sh 25c30ecadSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 35c30ecadSmrg## by inline-source v2019-02-19.15 4dc99b369Smrg 55c30ecadSmrg# libtool (GNU libtool) 2.4.7 65c30ecadSmrg# Provide generalized library-building support services. 7dc99b369Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8dc99b369Smrg 95c30ecadSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10dc99b369Smrg# This is free software; see the source for copying conditions. There is NO 11dc99b369Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12dc99b369Smrg 13dc99b369Smrg# GNU Libtool is free software; you can redistribute it and/or modify 145eefee25Smacallan# it under the terms of the GNU General Public License as published by 155eefee25Smacallan# the Free Software Foundation; either version 2 of the License, or 165eefee25Smacallan# (at your option) any later version. 175eefee25Smacallan# 18dc99b369Smrg# As a special exception to the GNU General Public License, 19dc99b369Smrg# if you distribute this file as part of a program or library that 20dc99b369Smrg# is built using GNU Libtool, you may include this file under the 21dc99b369Smrg# same distribution terms that you use for the rest of that program. 22dc99b369Smrg# 23dc99b369Smrg# GNU Libtool is distributed in the hope that it will be useful, but 245eefee25Smacallan# WITHOUT ANY WARRANTY; without even the implied warranty of 255eefee25Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 265eefee25Smacallan# General Public License for more details. 275eefee25Smacallan# 285eefee25Smacallan# You should have received a copy of the GNU General Public License 295c30ecadSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 305eefee25Smacallan 315c30ecadSmrg 325c30ecadSmrgPROGRAM=libtool 335c30ecadSmrgPACKAGE=libtool 345c30ecadSmrgVERSION=2.4.7 355c30ecadSmrgpackage_revision=2.4.7 365c30ecadSmrg 375c30ecadSmrg 385c30ecadSmrg## ------ ## 395c30ecadSmrg## Usage. ## 405c30ecadSmrg## ------ ## 415c30ecadSmrg 425c30ecadSmrg# Run './libtool --help' for help with using this script from the 435c30ecadSmrg# command line. 445c30ecadSmrg 455c30ecadSmrg 465c30ecadSmrg## ------------------------------- ## 475c30ecadSmrg## User overridable command paths. ## 485c30ecadSmrg## ------------------------------- ## 495c30ecadSmrg 505c30ecadSmrg# After configure completes, it has a better idea of some of the 515c30ecadSmrg# shell tools we need than the defaults used by the functions shared 525c30ecadSmrg# with bootstrap, so set those here where they can still be over- 535c30ecadSmrg# ridden by the user, but otherwise take precedence. 545c30ecadSmrg 555c30ecadSmrg: ${AUTOCONF="autoconf"} 565c30ecadSmrg: ${AUTOMAKE="automake"} 575c30ecadSmrg 585c30ecadSmrg 595c30ecadSmrg## -------------------------- ## 605c30ecadSmrg## Source external libraries. ## 615c30ecadSmrg## -------------------------- ## 625c30ecadSmrg 635c30ecadSmrg# Much of our low-level functionality needs to be sourced from external 645c30ecadSmrg# libraries, which are installed to $pkgauxdir. 655c30ecadSmrg 665c30ecadSmrg# Set a version string for this script. 675c30ecadSmrgscriptversion=2019-02-19.15; # UTC 685c30ecadSmrg 695c30ecadSmrg# General shell script boiler plate, and helper functions. 705c30ecadSmrg# Written by Gary V. Vaughan, 2004 715c30ecadSmrg 725c30ecadSmrg# This is free software. There is NO warranty; not even for 735c30ecadSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74dc99b369Smrg# 755c30ecadSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76dc99b369Smrg# 775c30ecadSmrg# This file is dual licensed under the terms of the MIT license 785c30ecadSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 795c30ecadSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 805c30ecadSmrg# these licenses when using or redistributing this software or any of 815c30ecadSmrg# the files within it. See the URLs above, or the file `LICENSE` 825c30ecadSmrg# included in the Bootstrap distribution for the full license texts. 835c30ecadSmrg 845c30ecadSmrg# Please report bugs or propose patches to: 855c30ecadSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 865c30ecadSmrg 875c30ecadSmrg 885c30ecadSmrg## ------ ## 895c30ecadSmrg## Usage. ## 905c30ecadSmrg## ------ ## 915c30ecadSmrg 925c30ecadSmrg# Evaluate this file near the top of your script to gain access to 935c30ecadSmrg# the functions and variables defined here: 94dc99b369Smrg# 955c30ecadSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96dc99b369Smrg# 975c30ecadSmrg# If you need to override any of the default environment variable 985c30ecadSmrg# settings, do that before evaluating this file. 995eefee25Smacallan 10062ab96baSmrg 1015c30ecadSmrg## -------------------- ## 1025c30ecadSmrg## Shell normalisation. ## 1035c30ecadSmrg## -------------------- ## 1045c30ecadSmrg 1055c30ecadSmrg# Some shells need a little help to be as Bourne compatible as possible. 1065c30ecadSmrg# Before doing anything else, make sure all that help has been provided! 1075c30ecadSmrg 1085c30ecadSmrgDUALCASE=1; export DUALCASE # for MKS sh 1095c30ecadSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11062ab96baSmrg emulate sh 11162ab96baSmrg NULLCMD=: 1125c30ecadSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 11362ab96baSmrg # is contrary to our usage. Disable this feature. 11462ab96baSmrg alias -g '${1+"$@"}'='"$@"' 1155eefee25Smacallan setopt NO_GLOB_SUBST 11662ab96baSmrgelse 1175c30ecadSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1185eefee25Smacallanfi 1195eefee25Smacallan 1205c30ecadSmrg# NLS nuisances: We save the old values in case they are required later. 1215c30ecadSmrg_G_user_locale= 1225c30ecadSmrg_G_safe_locale= 1235c30ecadSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 12462ab96baSmrgdo 1255c30ecadSmrg eval "if test set = \"\${$_G_var+set}\"; then 1265c30ecadSmrg save_$_G_var=\$$_G_var 1275c30ecadSmrg $_G_var=C 1285c30ecadSmrg export $_G_var 1295c30ecadSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1305c30ecadSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 13162ab96baSmrg fi" 13262ab96baSmrgdone 1335c30ecadSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1345c30ecadSmrg# in case the environment reset is needed later and the $save_* variant is not 1355c30ecadSmrg# defined (see the code above). 136dc99b369SmrgLC_ALL=C 137dc99b369SmrgLANGUAGE=C 138dc99b369Smrgexport LANGUAGE LC_ALL 139dc99b369Smrg 1405c30ecadSmrg# Make sure IFS has a sensible default 1415c30ecadSmrgsp=' ' 1425c30ecadSmrgnl=' 1435c30ecadSmrg' 1445c30ecadSmrgIFS="$sp $nl" 1455c30ecadSmrg 1465c30ecadSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1475c30ecadSmrgif test "${PATH_SEPARATOR+set}" != set; then 1485c30ecadSmrg PATH_SEPARATOR=: 1495c30ecadSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1505c30ecadSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1515c30ecadSmrg PATH_SEPARATOR=';' 1525c30ecadSmrg } 1535c30ecadSmrgfi 154dc99b369Smrg 155dc99b369Smrg 1565c30ecadSmrg# func_unset VAR 1575c30ecadSmrg# -------------- 1585c30ecadSmrg# Portably unset VAR. 1595c30ecadSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1605c30ecadSmrg# status if VAR is already unset, which might be problematic if the 1615c30ecadSmrg# statement is used at the end of a function (thus poisoning its return 1625c30ecadSmrg# value) or when 'set -e' is active (causing even a spurious abort of 1635c30ecadSmrg# the script in this case). 1645c30ecadSmrgfunc_unset () 1655c30ecadSmrg{ 1665c30ecadSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1675c30ecadSmrg} 168dc99b369Smrg 169dc99b369Smrg 1705c30ecadSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1715c30ecadSmrgfunc_unset CDPATH 172dc99b369Smrg 1735c30ecadSmrg# Make sure ${,E,F}GREP behave sanely. 1745c30ecadSmrgfunc_unset GREP_OPTIONS 175dc99b369Smrg 1765eefee25Smacallan 1775c30ecadSmrg## ------------------------- ## 1785c30ecadSmrg## Locate command utilities. ## 1795c30ecadSmrg## ------------------------- ## 1805eefee25Smacallan 1815eefee25Smacallan 1825c30ecadSmrg# func_executable_p FILE 1835c30ecadSmrg# ---------------------- 1845c30ecadSmrg# Check that FILE is an executable regular file. 1855c30ecadSmrgfunc_executable_p () 186dc99b369Smrg{ 1875c30ecadSmrg test -f "$1" && test -x "$1" 1885c30ecadSmrg} 189dc99b369Smrg 190dc99b369Smrg 1915c30ecadSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1925c30ecadSmrg# -------------------------------------------- 1935c30ecadSmrg# Search for either a program that responds to --version with output 1945c30ecadSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1955c30ecadSmrg# trying all the directories in PATH with each of the elements of 1965c30ecadSmrg# PROGS_LIST. 1975c30ecadSmrg# 1985c30ecadSmrg# CHECK_FUNC should accept the path to a candidate program, and 1995c30ecadSmrg# set $func_check_prog_result if it truncates its output less than 2005c30ecadSmrg# $_G_path_prog_max characters. 2015c30ecadSmrgfunc_path_progs () 202dc99b369Smrg{ 2035c30ecadSmrg _G_progs_list=$1 2045c30ecadSmrg _G_check_func=$2 2055c30ecadSmrg _G_PATH=${3-"$PATH"} 2065c30ecadSmrg 2075c30ecadSmrg _G_path_prog_max=0 2085c30ecadSmrg _G_path_prog_found=false 2095c30ecadSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2105c30ecadSmrg for _G_dir in $_G_PATH; do 2115c30ecadSmrg IFS=$_G_save_IFS 2125c30ecadSmrg test -z "$_G_dir" && _G_dir=. 2135c30ecadSmrg for _G_prog_name in $_G_progs_list; do 2145c30ecadSmrg for _exeext in '' .EXE; do 2155c30ecadSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2165c30ecadSmrg func_executable_p "$_G_path_prog" || continue 2175c30ecadSmrg case `"$_G_path_prog" --version 2>&1` in 2185c30ecadSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2195c30ecadSmrg *) $_G_check_func $_G_path_prog 2205c30ecadSmrg func_path_progs_result=$func_check_prog_result 2215c30ecadSmrg ;; 2225c30ecadSmrg esac 2235c30ecadSmrg $_G_path_prog_found && break 3 2245c30ecadSmrg done 2255c30ecadSmrg done 2265c30ecadSmrg done 2275c30ecadSmrg IFS=$_G_save_IFS 2285c30ecadSmrg test -z "$func_path_progs_result" && { 2295c30ecadSmrg echo "no acceptable sed could be found in \$PATH" >&2 2305c30ecadSmrg exit 1 2315c30ecadSmrg } 2325c30ecadSmrg} 233dc99b369Smrg 234dc99b369Smrg 2355c30ecadSmrg# We want to be able to use the functions in this file before configure 2365c30ecadSmrg# has figured out where the best binaries are kept, which means we have 2375c30ecadSmrg# to search for them ourselves - except when the results are already set 2385c30ecadSmrg# where we skip the searches. 239dc99b369Smrg 2405c30ecadSmrg# Unless the user overrides by setting SED, search the path for either GNU 2415c30ecadSmrg# sed, or the sed that truncates its output the least. 2425c30ecadSmrgtest -z "$SED" && { 2435c30ecadSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2445c30ecadSmrg for _G_i in 1 2 3 4 5 6 7; do 2455c30ecadSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2465c30ecadSmrg done 2475c30ecadSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2485c30ecadSmrg _G_sed_script= 249dc99b369Smrg 2505c30ecadSmrg func_check_prog_sed () 2515c30ecadSmrg { 2525c30ecadSmrg _G_path_prog=$1 253dc99b369Smrg 2545c30ecadSmrg _G_count=0 2555c30ecadSmrg printf 0123456789 >conftest.in 2565c30ecadSmrg while : 2575c30ecadSmrg do 2585c30ecadSmrg cat conftest.in conftest.in >conftest.tmp 2595c30ecadSmrg mv conftest.tmp conftest.in 2605c30ecadSmrg cp conftest.in conftest.nl 2615c30ecadSmrg echo '' >> conftest.nl 2625c30ecadSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2635c30ecadSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2645c30ecadSmrg _G_count=`expr $_G_count + 1` 2655c30ecadSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2665c30ecadSmrg # Best one so far, save it but keep looking for a better one 2675c30ecadSmrg func_check_prog_result=$_G_path_prog 2685c30ecadSmrg _G_path_prog_max=$_G_count 2695c30ecadSmrg fi 2705c30ecadSmrg # 10*(2^10) chars as input seems more than enough 2715c30ecadSmrg test 10 -lt "$_G_count" && break 2725c30ecadSmrg done 2735c30ecadSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2745c30ecadSmrg } 275dc99b369Smrg 2765c30ecadSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2775c30ecadSmrg rm -f conftest.sed 2785c30ecadSmrg SED=$func_path_progs_result 2795c30ecadSmrg} 280dc99b369Smrg 2815c30ecadSmrg 2825c30ecadSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2835c30ecadSmrg# grep, or the grep that truncates its output the least. 2845c30ecadSmrgtest -z "$GREP" && { 2855c30ecadSmrg func_check_prog_grep () 2865c30ecadSmrg { 2875c30ecadSmrg _G_path_prog=$1 2885c30ecadSmrg 2895c30ecadSmrg _G_count=0 2905c30ecadSmrg _G_path_prog_max=0 2915c30ecadSmrg printf 0123456789 >conftest.in 2925c30ecadSmrg while : 2935c30ecadSmrg do 2945c30ecadSmrg cat conftest.in conftest.in >conftest.tmp 2955c30ecadSmrg mv conftest.tmp conftest.in 2965c30ecadSmrg cp conftest.in conftest.nl 2975c30ecadSmrg echo 'GREP' >> conftest.nl 2985c30ecadSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2995c30ecadSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3005c30ecadSmrg _G_count=`expr $_G_count + 1` 3015c30ecadSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3025c30ecadSmrg # Best one so far, save it but keep looking for a better one 3035c30ecadSmrg func_check_prog_result=$_G_path_prog 3045c30ecadSmrg _G_path_prog_max=$_G_count 3055c30ecadSmrg fi 3065c30ecadSmrg # 10*(2^10) chars as input seems more than enough 3075c30ecadSmrg test 10 -lt "$_G_count" && break 3085c30ecadSmrg done 3095c30ecadSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3105c30ecadSmrg } 3115c30ecadSmrg 3125c30ecadSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3135c30ecadSmrg GREP=$func_path_progs_result 3145c30ecadSmrg} 3155c30ecadSmrg 3165c30ecadSmrg 3175c30ecadSmrg## ------------------------------- ## 3185c30ecadSmrg## User overridable command paths. ## 3195c30ecadSmrg## ------------------------------- ## 3205c30ecadSmrg 3215c30ecadSmrg# All uppercase variable names are used for environment variables. These 3225c30ecadSmrg# variables can be overridden by the user before calling a script that 3235c30ecadSmrg# uses them if a suitable command of that name is not already available 3245c30ecadSmrg# in the command search PATH. 3255c30ecadSmrg 3265c30ecadSmrg: ${CP="cp -f"} 3275c30ecadSmrg: ${ECHO="printf %s\n"} 3285c30ecadSmrg: ${EGREP="$GREP -E"} 3295c30ecadSmrg: ${FGREP="$GREP -F"} 3305c30ecadSmrg: ${LN_S="ln -s"} 3315c30ecadSmrg: ${MAKE="make"} 3325c30ecadSmrg: ${MKDIR="mkdir"} 3335c30ecadSmrg: ${MV="mv -f"} 3345c30ecadSmrg: ${RM="rm -f"} 3355c30ecadSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3365c30ecadSmrg 3375c30ecadSmrg 3385c30ecadSmrg## -------------------- ## 3395c30ecadSmrg## Useful sed snippets. ## 3405c30ecadSmrg## -------------------- ## 3415c30ecadSmrg 3425c30ecadSmrgsed_dirname='s|/[^/]*$||' 3435c30ecadSmrgsed_basename='s|^.*/||' 3445c30ecadSmrg 3455c30ecadSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3465c30ecadSmrg# metacharacters that are still active within double-quoted strings. 3475c30ecadSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3485c30ecadSmrg 3495c30ecadSmrg# Same as above, but do not quote variable references. 3505c30ecadSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3515c30ecadSmrg 3525c30ecadSmrg# Sed substitution that turns a string into a regex matching for the 3535c30ecadSmrg# string literally. 3545c30ecadSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3555c30ecadSmrg 3565c30ecadSmrg# Sed substitution that converts a w32 file name or path 3575c30ecadSmrg# that contains forward slashes, into one that contains 3585c30ecadSmrg# (escaped) backslashes. A very naive implementation. 3595c30ecadSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3605c30ecadSmrg 3615c30ecadSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3625c30ecadSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3635c30ecadSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3645c30ecadSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3655c30ecadSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3665c30ecadSmrg_G_bs='\\' 3675c30ecadSmrg_G_bs2='\\\\' 3685c30ecadSmrg_G_bs4='\\\\\\\\' 3695c30ecadSmrg_G_dollar='\$' 3705c30ecadSmrgsed_double_backslash="\ 3715c30ecadSmrg s/$_G_bs4/&\\ 3725c30ecadSmrg/g 3735c30ecadSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3745c30ecadSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3755c30ecadSmrg s/\n//g" 3765c30ecadSmrg 3775c30ecadSmrg# require_check_ifs_backslash 3785c30ecadSmrg# --------------------------- 3795c30ecadSmrg# Check if we can use backslash as IFS='\' separator, and set 3805c30ecadSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 3815c30ecadSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3825c30ecadSmrgfunc_require_check_ifs_backslash () 383dc99b369Smrg{ 3845c30ecadSmrg _G_save_IFS=$IFS 3855c30ecadSmrg IFS='\' 3865c30ecadSmrg _G_check_ifs_backshlash='a\\b' 3875c30ecadSmrg for _G_i in $_G_check_ifs_backshlash 3885c30ecadSmrg do 3895c30ecadSmrg case $_G_i in 3905c30ecadSmrg a) 3915c30ecadSmrg check_ifs_backshlash_broken=false 392dc99b369Smrg ;; 3935c30ecadSmrg '') 3945c30ecadSmrg break 395dc99b369Smrg ;; 3965c30ecadSmrg *) 3975c30ecadSmrg check_ifs_backshlash_broken=: 3985c30ecadSmrg break 399dc99b369Smrg ;; 400dc99b369Smrg esac 401dc99b369Smrg done 4025c30ecadSmrg IFS=$_G_save_IFS 4035c30ecadSmrg require_check_ifs_backslash=: 404dc99b369Smrg} 405dc99b369Smrg 406dc99b369Smrg 4075c30ecadSmrg## ----------------- ## 4085c30ecadSmrg## Global variables. ## 4095c30ecadSmrg## ----------------- ## 410dc99b369Smrg 4115c30ecadSmrg# Except for the global variables explicitly listed below, the following 4125c30ecadSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4135c30ecadSmrg# variables initialised in the 'Resource management' section, sourcing 4145c30ecadSmrg# this file will not pollute your global namespace with anything 4155c30ecadSmrg# else. There's no portable way to scope variables in Bourne shell 4165c30ecadSmrg# though, so actually running these functions will sometimes place 4175c30ecadSmrg# results into a variable named after the function, and often use 4185c30ecadSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4195c30ecadSmrg# avoid using those namespaces casually in your sourcing script, things 4205c30ecadSmrg# should continue to work as you expect. And, of course, you can freely 4215c30ecadSmrg# overwrite any of the functions or variables defined here before 4225c30ecadSmrg# calling anything to customize them. 4235c30ecadSmrg 4245c30ecadSmrgEXIT_SUCCESS=0 4255c30ecadSmrgEXIT_FAILURE=1 4265c30ecadSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4275c30ecadSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 4285c30ecadSmrg 4295c30ecadSmrg# Allow overriding, eg assuming that you follow the convention of 4305c30ecadSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4315c30ecadSmrg# bash to show function call trace with: 4325c30ecadSmrg# 4335c30ecadSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4345c30ecadSmrgdebug_cmd=${debug_cmd-":"} 4355c30ecadSmrgexit_cmd=: 4365c30ecadSmrg 4375c30ecadSmrg# By convention, finish your script with: 4385c30ecadSmrg# 4395c30ecadSmrg# exit $exit_status 4405c30ecadSmrg# 4415c30ecadSmrg# so that you can set exit_status to non-zero if you want to indicate 4425c30ecadSmrg# something went wrong during execution without actually bailing out at 4435c30ecadSmrg# the point of failure. 4445c30ecadSmrgexit_status=$EXIT_SUCCESS 4455c30ecadSmrg 4465c30ecadSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4475c30ecadSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4485c30ecadSmrg# the _XPG environment variable is not equal to 1 (one), the special 4495c30ecadSmrg# positional parameter $0, within a function call, is the name of the 4505c30ecadSmrg# function. 4515c30ecadSmrgprogpath=$0 452dc99b369Smrg 4535c30ecadSmrg# The name of this program. 4545c30ecadSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455dc99b369Smrg 4565c30ecadSmrg# Make sure we have an absolute progpath for reexecution: 457dc99b369Smrgcase $progpath in 458dc99b369Smrg [\\/]*|[A-Za-z]:\\*) ;; 459dc99b369Smrg *[\\/]*) 4605c30ecadSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461dc99b369Smrg progdir=`cd "$progdir" && pwd` 4625c30ecadSmrg progpath=$progdir/$progname 463dc99b369Smrg ;; 464dc99b369Smrg *) 4655c30ecadSmrg _G_IFS=$IFS 4665c30ecadSmrg IFS=${PATH_SEPARATOR-:} 467dc99b369Smrg for progdir in $PATH; do 4685c30ecadSmrg IFS=$_G_IFS 469dc99b369Smrg test -x "$progdir/$progname" && break 470dc99b369Smrg done 4715c30ecadSmrg IFS=$_G_IFS 472dc99b369Smrg test -n "$progdir" || progdir=`pwd` 4735c30ecadSmrg progpath=$progdir/$progname 474dc99b369Smrg ;; 475dc99b369Smrgesac 476dc99b369Smrg 477dc99b369Smrg 4785c30ecadSmrg## ----------------- ## 4795c30ecadSmrg## Standard options. ## 4805c30ecadSmrg## ----------------- ## 481dc99b369Smrg 4825c30ecadSmrg# The following options affect the operation of the functions defined 4835c30ecadSmrg# below, and should be set appropriately depending on run-time para- 4845c30ecadSmrg# meters passed on the command line. 485dc99b369Smrg 486dc99b369Smrgopt_dry_run=false 487dc99b369Smrgopt_quiet=false 488dc99b369Smrgopt_verbose=false 489dc99b369Smrg 4905c30ecadSmrg# Categories 'all' and 'none' are always available. Append any others 4915c30ecadSmrg# you will pass as the first argument to func_warning from your own 4925c30ecadSmrg# code. 4935c30ecadSmrgwarning_categories= 494dc99b369Smrg 4955c30ecadSmrg# By default, display warnings according to 'opt_warning_types'. Set 4965c30ecadSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4975c30ecadSmrg# treat the next displayed warning as a fatal error. 4985c30ecadSmrgwarning_func=func_warn_and_continue 499dc99b369Smrg 5005c30ecadSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5015c30ecadSmrg# warnings, or a space delimited list of some subset of 5025c30ecadSmrg# 'warning_categories' to display only the listed warnings. 5035c30ecadSmrgopt_warning_types=all 504dc99b369Smrg 505dc99b369Smrg 5065c30ecadSmrg## -------------------- ## 5075c30ecadSmrg## Resource management. ## 5085c30ecadSmrg## -------------------- ## 509dc99b369Smrg 5105c30ecadSmrg# This section contains definitions for functions that each ensure a 5115c30ecadSmrg# particular resource (a file, or a non-empty configuration variable for 5125c30ecadSmrg# example) is available, and if appropriate to extract default values 5135c30ecadSmrg# from pertinent package files. Call them using their associated 5145c30ecadSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5155c30ecadSmrg# 5165c30ecadSmrg# It's entirely deliberate that calling these functions can set 5175c30ecadSmrg# variables that don't obey the namespace limitations obeyed by the rest 5185c30ecadSmrg# of this file, in order that that they be as useful as possible to 5195c30ecadSmrg# callers. 520dc99b369Smrg 521dc99b369Smrg 5225c30ecadSmrg# require_term_colors 5235c30ecadSmrg# ------------------- 5245c30ecadSmrg# Allow display of bold text on terminals that support it. 5255c30ecadSmrgrequire_term_colors=func_require_term_colors 5265c30ecadSmrgfunc_require_term_colors () 527dc99b369Smrg{ 5285c30ecadSmrg $debug_cmd 5295c30ecadSmrg 5305c30ecadSmrg test -t 1 && { 5315c30ecadSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5325c30ecadSmrg # precedence, because most terminfo databases neglect to describe 5335c30ecadSmrg # whether color sequences are supported. 5345c30ecadSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5355c30ecadSmrg 5365c30ecadSmrg if test 1 = "$USE_ANSI_COLORS"; then 5375c30ecadSmrg # Standard ANSI escape sequences 5385c30ecadSmrg tc_reset='[0m' 5395c30ecadSmrg tc_bold='[1m'; tc_standout='[7m' 5405c30ecadSmrg tc_red='[31m'; tc_green='[32m' 5415c30ecadSmrg tc_blue='[34m'; tc_cyan='[36m' 5425c30ecadSmrg else 5435c30ecadSmrg # Otherwise trust the terminfo database after all. 5445c30ecadSmrg test -n "`tput sgr0 2>/dev/null`" && { 5455c30ecadSmrg tc_reset=`tput sgr0` 5465c30ecadSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5475c30ecadSmrg tc_standout=$tc_bold 5485c30ecadSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5495c30ecadSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5505c30ecadSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5515c30ecadSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5525c30ecadSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5535c30ecadSmrg } 5545c30ecadSmrg fi 5555c30ecadSmrg } 556dc99b369Smrg 5575c30ecadSmrg require_term_colors=: 558dc99b369Smrg} 559dc99b369Smrg 560dc99b369Smrg 5615c30ecadSmrg## ----------------- ## 5625c30ecadSmrg## Function library. ## 5635c30ecadSmrg## ----------------- ## 564dc99b369Smrg 5655c30ecadSmrg# This section contains a variety of useful functions to call in your 5665c30ecadSmrg# scripts. Take note of the portable wrappers for features provided by 5675c30ecadSmrg# some modern shells, which will fall back to slower equivalents on 5685c30ecadSmrg# less featureful shells. 569dc99b369Smrg 5705c30ecadSmrg 5715c30ecadSmrg# func_append VAR VALUE 5725c30ecadSmrg# --------------------- 5735c30ecadSmrg# Append VALUE onto the existing contents of VAR. 5745c30ecadSmrg 5755c30ecadSmrg # We should try to minimise forks, especially on Windows where they are 5765c30ecadSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5775c30ecadSmrg # being used: 5785c30ecadSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5795c30ecadSmrg : ${_G_HAVE_ARITH_OP="yes"} 5805c30ecadSmrg : ${_G_HAVE_XSI_OPS="yes"} 5815c30ecadSmrg # The += operator was introduced in bash 3.1 5825c30ecadSmrg case $BASH_VERSION in 5835c30ecadSmrg [12].* | 3.0 | 3.0*) ;; 5845c30ecadSmrg *) 5855c30ecadSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5865c30ecadSmrg ;; 5875c30ecadSmrg esac 5885c30ecadSmrg fi 5895c30ecadSmrg 5905c30ecadSmrg # _G_HAVE_PLUSEQ_OP 5915c30ecadSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5925c30ecadSmrg # useable or anything else if it does not work. 5935c30ecadSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5945c30ecadSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5955c30ecadSmrg && _G_HAVE_PLUSEQ_OP=yes 5965c30ecadSmrg 5975c30ecadSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5985c30ecadSmrgthen 5995c30ecadSmrg # This is an XSI compatible shell, allowing a faster implementation... 6005c30ecadSmrg eval 'func_append () 6015c30ecadSmrg { 6025c30ecadSmrg $debug_cmd 6035c30ecadSmrg 6045c30ecadSmrg eval "$1+=\$2" 6055c30ecadSmrg }' 6065c30ecadSmrgelse 6075c30ecadSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6085c30ecadSmrg func_append () 6095c30ecadSmrg { 6105c30ecadSmrg $debug_cmd 6115c30ecadSmrg 6125c30ecadSmrg eval "$1=\$$1\$2" 6135c30ecadSmrg } 6145c30ecadSmrgfi 6155c30ecadSmrg 6165c30ecadSmrg 6175c30ecadSmrg# func_append_quoted VAR VALUE 6185c30ecadSmrg# ---------------------------- 6195c30ecadSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6205c30ecadSmrg# by a space. 6215c30ecadSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6225c30ecadSmrg eval 'func_append_quoted () 6235c30ecadSmrg { 6245c30ecadSmrg $debug_cmd 6255c30ecadSmrg 6265c30ecadSmrg func_quote_arg pretty "$2" 6275c30ecadSmrg eval "$1+=\\ \$func_quote_arg_result" 6285c30ecadSmrg }' 6295c30ecadSmrgelse 6305c30ecadSmrg func_append_quoted () 6315c30ecadSmrg { 6325c30ecadSmrg $debug_cmd 6335c30ecadSmrg 6345c30ecadSmrg func_quote_arg pretty "$2" 6355c30ecadSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 6365c30ecadSmrg } 6375c30ecadSmrgfi 6385c30ecadSmrg 6395c30ecadSmrg 6405c30ecadSmrg# func_append_uniq VAR VALUE 6415c30ecadSmrg# -------------------------- 6425c30ecadSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6435c30ecadSmrg# entries are delimited by the first character of VALUE. For example: 6445c30ecadSmrg# 6455c30ecadSmrg# func_append_uniq options " --another-option option-argument" 6465c30ecadSmrg# 6475c30ecadSmrg# will only append to $options if " --another-option option-argument " 6485c30ecadSmrg# is not already present somewhere in $options already (note spaces at 6495c30ecadSmrg# each end implied by leading space in second argument). 6505c30ecadSmrgfunc_append_uniq () 6515c30ecadSmrg{ 6525c30ecadSmrg $debug_cmd 6535c30ecadSmrg 6545c30ecadSmrg eval _G_current_value='`$ECHO $'$1'`' 6555c30ecadSmrg _G_delim=`expr "$2" : '\(.\)'` 6565c30ecadSmrg 6575c30ecadSmrg case $_G_delim$_G_current_value$_G_delim in 6585c30ecadSmrg *"$2$_G_delim"*) ;; 6595c30ecadSmrg *) func_append "$@" ;; 6605c30ecadSmrg esac 6615c30ecadSmrg} 6625c30ecadSmrg 6635c30ecadSmrg 6645c30ecadSmrg# func_arith TERM... 6655c30ecadSmrg# ------------------ 6665c30ecadSmrg# Set func_arith_result to the result of evaluating TERMs. 6675c30ecadSmrg test -z "$_G_HAVE_ARITH_OP" \ 6685c30ecadSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6695c30ecadSmrg && _G_HAVE_ARITH_OP=yes 6705c30ecadSmrg 6715c30ecadSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6725c30ecadSmrg eval 'func_arith () 6735c30ecadSmrg { 6745c30ecadSmrg $debug_cmd 6755c30ecadSmrg 6765c30ecadSmrg func_arith_result=$(( $* )) 6775c30ecadSmrg }' 6785c30ecadSmrgelse 6795c30ecadSmrg func_arith () 6805c30ecadSmrg { 6815c30ecadSmrg $debug_cmd 6825c30ecadSmrg 6835c30ecadSmrg func_arith_result=`expr "$@"` 6845c30ecadSmrg } 6855c30ecadSmrgfi 6865c30ecadSmrg 6875c30ecadSmrg 6885c30ecadSmrg# func_basename FILE 6895c30ecadSmrg# ------------------ 6905c30ecadSmrg# Set func_basename_result to FILE with everything up to and including 6915c30ecadSmrg# the last / stripped. 6925c30ecadSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6935c30ecadSmrg # If this shell supports suffix pattern removal, then use it to avoid 6945c30ecadSmrg # forking. Hide the definitions single quotes in case the shell chokes 6955c30ecadSmrg # on unsupported syntax... 6965c30ecadSmrg _b='func_basename_result=${1##*/}' 6975c30ecadSmrg _d='case $1 in 6985c30ecadSmrg */*) func_dirname_result=${1%/*}$2 ;; 6995c30ecadSmrg * ) func_dirname_result=$3 ;; 7005c30ecadSmrg esac' 7015c30ecadSmrg 7025c30ecadSmrgelse 7035c30ecadSmrg # ...otherwise fall back to using sed. 7045c30ecadSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7055c30ecadSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7065c30ecadSmrg if test "X$func_dirname_result" = "X$1"; then 7075c30ecadSmrg func_dirname_result=$3 7085c30ecadSmrg else 7095c30ecadSmrg func_append func_dirname_result "$2" 7105c30ecadSmrg fi' 7115c30ecadSmrgfi 7125c30ecadSmrg 7135c30ecadSmrgeval 'func_basename () 7145c30ecadSmrg{ 7155c30ecadSmrg $debug_cmd 7165c30ecadSmrg 7175c30ecadSmrg '"$_b"' 7185c30ecadSmrg}' 7195c30ecadSmrg 7205c30ecadSmrg 7215c30ecadSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7225c30ecadSmrg# ------------------------------------------- 7235c30ecadSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7245c30ecadSmrg# otherwise set result to NONDIR_REPLACEMENT. 7255c30ecadSmrgeval 'func_dirname () 7265c30ecadSmrg{ 7275c30ecadSmrg $debug_cmd 7285c30ecadSmrg 7295c30ecadSmrg '"$_d"' 7305c30ecadSmrg}' 7315c30ecadSmrg 7325c30ecadSmrg 7335c30ecadSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7345c30ecadSmrg# -------------------------------------------------------- 7355c30ecadSmrg# Perform func_basename and func_dirname in a single function 7365c30ecadSmrg# call: 7375c30ecadSmrg# dirname: Compute the dirname of FILE. If nonempty, 7385c30ecadSmrg# add APPEND to the result, otherwise set result 7395c30ecadSmrg# to NONDIR_REPLACEMENT. 7405c30ecadSmrg# value returned in "$func_dirname_result" 7415c30ecadSmrg# basename: Compute filename of FILE. 7425c30ecadSmrg# value retuned in "$func_basename_result" 7435c30ecadSmrg# For efficiency, we do not delegate to the functions above but instead 7445c30ecadSmrg# duplicate the functionality here. 7455c30ecadSmrgeval 'func_dirname_and_basename () 7465c30ecadSmrg{ 7475c30ecadSmrg $debug_cmd 7485c30ecadSmrg 7495c30ecadSmrg '"$_b"' 7505c30ecadSmrg '"$_d"' 7515c30ecadSmrg}' 7525c30ecadSmrg 7535c30ecadSmrg 7545c30ecadSmrg# func_echo ARG... 7555c30ecadSmrg# ---------------- 7565c30ecadSmrg# Echo program name prefixed message. 7575c30ecadSmrgfunc_echo () 7585c30ecadSmrg{ 7595c30ecadSmrg $debug_cmd 7605c30ecadSmrg 7615c30ecadSmrg _G_message=$* 7625c30ecadSmrg 7635c30ecadSmrg func_echo_IFS=$IFS 7645c30ecadSmrg IFS=$nl 7655c30ecadSmrg for _G_line in $_G_message; do 7665c30ecadSmrg IFS=$func_echo_IFS 7675c30ecadSmrg $ECHO "$progname: $_G_line" 7685c30ecadSmrg done 7695c30ecadSmrg IFS=$func_echo_IFS 7705c30ecadSmrg} 7715c30ecadSmrg 7725c30ecadSmrg 7735c30ecadSmrg# func_echo_all ARG... 7745c30ecadSmrg# -------------------- 7755c30ecadSmrg# Invoke $ECHO with all args, space-separated. 7765c30ecadSmrgfunc_echo_all () 7775c30ecadSmrg{ 7785c30ecadSmrg $ECHO "$*" 7795c30ecadSmrg} 7805c30ecadSmrg 7815c30ecadSmrg 7825c30ecadSmrg# func_echo_infix_1 INFIX ARG... 7835c30ecadSmrg# ------------------------------ 7845c30ecadSmrg# Echo program name, followed by INFIX on the first line, with any 7855c30ecadSmrg# additional lines not showing INFIX. 7865c30ecadSmrgfunc_echo_infix_1 () 7875c30ecadSmrg{ 7885c30ecadSmrg $debug_cmd 7895c30ecadSmrg 7905c30ecadSmrg $require_term_colors 7915c30ecadSmrg 7925c30ecadSmrg _G_infix=$1; shift 7935c30ecadSmrg _G_indent=$_G_infix 7945c30ecadSmrg _G_prefix="$progname: $_G_infix: " 7955c30ecadSmrg _G_message=$* 7965c30ecadSmrg 7975c30ecadSmrg # Strip color escape sequences before counting printable length 7985c30ecadSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7995c30ecadSmrg do 8005c30ecadSmrg test -n "$_G_tc" && { 8015c30ecadSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8025c30ecadSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8035c30ecadSmrg } 8045c30ecadSmrg done 8055c30ecadSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8065c30ecadSmrg 8075c30ecadSmrg func_echo_infix_1_IFS=$IFS 8085c30ecadSmrg IFS=$nl 8095c30ecadSmrg for _G_line in $_G_message; do 8105c30ecadSmrg IFS=$func_echo_infix_1_IFS 8115c30ecadSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8125c30ecadSmrg _G_prefix=$_G_indent 8135c30ecadSmrg done 8145c30ecadSmrg IFS=$func_echo_infix_1_IFS 8155c30ecadSmrg} 8165c30ecadSmrg 8175c30ecadSmrg 8185c30ecadSmrg# func_error ARG... 8195c30ecadSmrg# ----------------- 8205c30ecadSmrg# Echo program name prefixed message to standard error. 8215c30ecadSmrgfunc_error () 8225c30ecadSmrg{ 8235c30ecadSmrg $debug_cmd 8245c30ecadSmrg 8255c30ecadSmrg $require_term_colors 8265c30ecadSmrg 8275c30ecadSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8285c30ecadSmrg} 8295c30ecadSmrg 8305c30ecadSmrg 8315c30ecadSmrg# func_fatal_error ARG... 8325c30ecadSmrg# ----------------------- 8335c30ecadSmrg# Echo program name prefixed message to standard error, and exit. 8345c30ecadSmrgfunc_fatal_error () 8355c30ecadSmrg{ 8365c30ecadSmrg $debug_cmd 8375c30ecadSmrg 8385c30ecadSmrg func_error "$*" 8395c30ecadSmrg exit $EXIT_FAILURE 8405c30ecadSmrg} 8415c30ecadSmrg 8425c30ecadSmrg 8435c30ecadSmrg# func_grep EXPRESSION FILENAME 8445c30ecadSmrg# ----------------------------- 8455c30ecadSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8465c30ecadSmrgfunc_grep () 8475c30ecadSmrg{ 8485c30ecadSmrg $debug_cmd 8495c30ecadSmrg 8505c30ecadSmrg $GREP "$1" "$2" >/dev/null 2>&1 8515c30ecadSmrg} 8525c30ecadSmrg 8535c30ecadSmrg 8545c30ecadSmrg# func_len STRING 8555c30ecadSmrg# --------------- 8565c30ecadSmrg# Set func_len_result to the length of STRING. STRING may not 8575c30ecadSmrg# start with a hyphen. 8585c30ecadSmrg test -z "$_G_HAVE_XSI_OPS" \ 8595c30ecadSmrg && (eval 'x=a/b/c; 8605c30ecadSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8615c30ecadSmrg && _G_HAVE_XSI_OPS=yes 8625c30ecadSmrg 8635c30ecadSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8645c30ecadSmrg eval 'func_len () 8655c30ecadSmrg { 8665c30ecadSmrg $debug_cmd 8675c30ecadSmrg 8685c30ecadSmrg func_len_result=${#1} 8695c30ecadSmrg }' 8705c30ecadSmrgelse 8715c30ecadSmrg func_len () 8725c30ecadSmrg { 8735c30ecadSmrg $debug_cmd 8745c30ecadSmrg 8755c30ecadSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8765c30ecadSmrg } 8775c30ecadSmrgfi 8785c30ecadSmrg 8795c30ecadSmrg 8805c30ecadSmrg# func_mkdir_p DIRECTORY-PATH 8815c30ecadSmrg# --------------------------- 882dc99b369Smrg# Make sure the entire path to DIRECTORY-PATH is available. 883dc99b369Smrgfunc_mkdir_p () 884dc99b369Smrg{ 8855c30ecadSmrg $debug_cmd 886dc99b369Smrg 8875c30ecadSmrg _G_directory_path=$1 8885c30ecadSmrg _G_dir_list= 889dc99b369Smrg 8905c30ecadSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8915c30ecadSmrg 8925c30ecadSmrg # Protect directory names starting with '-' 8935c30ecadSmrg case $_G_directory_path in 8945c30ecadSmrg -*) _G_directory_path=./$_G_directory_path ;; 895dc99b369Smrg esac 896dc99b369Smrg 897dc99b369Smrg # While some portion of DIR does not yet exist... 8985c30ecadSmrg while test ! -d "$_G_directory_path"; do 899dc99b369Smrg # ...make a list in topmost first order. Use a colon delimited 900dc99b369Smrg # list incase some portion of path contains whitespace. 9015c30ecadSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 902dc99b369Smrg 903dc99b369Smrg # If the last portion added has no slash in it, the list is done 9045c30ecadSmrg case $_G_directory_path in */*) ;; *) break ;; esac 905dc99b369Smrg 906dc99b369Smrg # ...otherwise throw away the child directory and loop 9075c30ecadSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908dc99b369Smrg done 9095c30ecadSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910dc99b369Smrg 9115c30ecadSmrg func_mkdir_p_IFS=$IFS; IFS=: 9125c30ecadSmrg for _G_dir in $_G_dir_list; do 9135c30ecadSmrg IFS=$func_mkdir_p_IFS 9145c30ecadSmrg # mkdir can fail with a 'File exist' error if two processes 915dc99b369Smrg # try to create one of the directories concurrently. Don't 916dc99b369Smrg # stop in that case! 9175c30ecadSmrg $MKDIR "$_G_dir" 2>/dev/null || : 918dc99b369Smrg done 9195c30ecadSmrg IFS=$func_mkdir_p_IFS 920dc99b369Smrg 921dc99b369Smrg # Bail out if we (or some other process) failed to create a directory. 9225c30ecadSmrg test -d "$_G_directory_path" || \ 9235c30ecadSmrg func_fatal_error "Failed to create '$1'" 924dc99b369Smrg fi 925dc99b369Smrg} 9265eefee25Smacallan 9275eefee25Smacallan 9285c30ecadSmrg# func_mktempdir [BASENAME] 9295c30ecadSmrg# ------------------------- 9305eefee25Smacallan# Make a temporary directory that won't clash with other running 9315eefee25Smacallan# libtool processes, and avoids race conditions if possible. If 9325c30ecadSmrg# given, BASENAME is the basename for that directory. 9335eefee25Smacallanfunc_mktempdir () 9345eefee25Smacallan{ 9355c30ecadSmrg $debug_cmd 9365c30ecadSmrg 9375c30ecadSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9385eefee25Smacallan 9395c30ecadSmrg if test : = "$opt_dry_run"; then 9405eefee25Smacallan # Return a directory name, but don't create it in dry-run mode 9415c30ecadSmrg _G_tmpdir=$_G_template-$$ 9425eefee25Smacallan else 9435eefee25Smacallan 9445eefee25Smacallan # If mktemp works, use that first and foremost 9455c30ecadSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9465eefee25Smacallan 9475c30ecadSmrg if test ! -d "$_G_tmpdir"; then 948dc99b369Smrg # Failing that, at least try and use $RANDOM to avoid a race 9495c30ecadSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9505eefee25Smacallan 9515c30ecadSmrg func_mktempdir_umask=`umask` 952dc99b369Smrg umask 0077 9535c30ecadSmrg $MKDIR "$_G_tmpdir" 9545c30ecadSmrg umask $func_mktempdir_umask 9555eefee25Smacallan fi 9565eefee25Smacallan 9575eefee25Smacallan # If we're not in dry-run mode, bomb out on failure 9585c30ecadSmrg test -d "$_G_tmpdir" || \ 9595c30ecadSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9605eefee25Smacallan fi 9615eefee25Smacallan 9625c30ecadSmrg $ECHO "$_G_tmpdir" 9635eefee25Smacallan} 9645eefee25Smacallan 9655eefee25Smacallan 9665c30ecadSmrg# func_normal_abspath PATH 9675c30ecadSmrg# ------------------------ 9685c30ecadSmrg# Remove doubled-up and trailing slashes, "." path components, 9695c30ecadSmrg# and cancel out any ".." path components in PATH after making 9705c30ecadSmrg# it an absolute path. 9715c30ecadSmrgfunc_normal_abspath () 9725eefee25Smacallan{ 9735c30ecadSmrg $debug_cmd 9745c30ecadSmrg 9755c30ecadSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9765c30ecadSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9775c30ecadSmrg _G_pathcdr='s|^/[^/]*||' 9785c30ecadSmrg _G_removedotparts=':dotsl 9795c30ecadSmrg s|/\./|/|g 9805c30ecadSmrg t dotsl 9815c30ecadSmrg s|/\.$|/|' 9825c30ecadSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9835c30ecadSmrg _G_finalslash='s|/*$|/|' 9845c30ecadSmrg 9855c30ecadSmrg # Start from root dir and reassemble the path. 9865c30ecadSmrg func_normal_abspath_result= 9875c30ecadSmrg func_normal_abspath_tpath=$1 9885c30ecadSmrg func_normal_abspath_altnamespace= 9895c30ecadSmrg case $func_normal_abspath_tpath in 9905c30ecadSmrg "") 9915c30ecadSmrg # Empty path, that just means $cwd. 9925c30ecadSmrg func_stripname '' '/' "`pwd`" 9935c30ecadSmrg func_normal_abspath_result=$func_stripname_result 9945c30ecadSmrg return 9955c30ecadSmrg ;; 9965c30ecadSmrg # The next three entries are used to spot a run of precisely 9975c30ecadSmrg # two leading slashes without using negated character classes; 9985c30ecadSmrg # we take advantage of case's first-match behaviour. 9995c30ecadSmrg ///*) 10005c30ecadSmrg # Unusual form of absolute path, do nothing. 10015c30ecadSmrg ;; 10025c30ecadSmrg //*) 10035c30ecadSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10045c30ecadSmrg # and for example Cygwin uses it to access remote file shares 10055c30ecadSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10065c30ecadSmrg func_normal_abspath_altnamespace=/ 10075c30ecadSmrg ;; 10085c30ecadSmrg /*) 10095c30ecadSmrg # Absolute path, do nothing. 10105c30ecadSmrg ;; 1011dc99b369Smrg *) 10125c30ecadSmrg # Relative path, prepend $cwd. 10135c30ecadSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10145c30ecadSmrg ;; 1015dc99b369Smrg esac 1016dc99b369Smrg 10175c30ecadSmrg # Cancel out all the simple stuff to save iterations. We also want 10185c30ecadSmrg # the path to end with a slash for ease of parsing, so make sure 10195c30ecadSmrg # there is one (and only one) here. 10205c30ecadSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10215c30ecadSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10225c30ecadSmrg while :; do 10235c30ecadSmrg # Processed it all yet? 10245c30ecadSmrg if test / = "$func_normal_abspath_tpath"; then 10255c30ecadSmrg # If we ascended to the root using ".." the result may be empty now. 10265c30ecadSmrg if test -z "$func_normal_abspath_result"; then 10275c30ecadSmrg func_normal_abspath_result=/ 10285c30ecadSmrg fi 10295c30ecadSmrg break 10305c30ecadSmrg fi 10315c30ecadSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10325c30ecadSmrg -e "$_G_pathcar"` 10335c30ecadSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10345c30ecadSmrg -e "$_G_pathcdr"` 10355c30ecadSmrg # Figure out what to do with it 10365c30ecadSmrg case $func_normal_abspath_tcomponent in 10375c30ecadSmrg "") 10385c30ecadSmrg # Trailing empty path component, ignore it. 10395c30ecadSmrg ;; 10405c30ecadSmrg ..) 10415c30ecadSmrg # Parent dir; strip last assembled component from result. 10425c30ecadSmrg func_dirname "$func_normal_abspath_result" 10435c30ecadSmrg func_normal_abspath_result=$func_dirname_result 10445c30ecadSmrg ;; 10455c30ecadSmrg *) 10465c30ecadSmrg # Actual path component, append it. 10475c30ecadSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10485c30ecadSmrg ;; 10495c30ecadSmrg esac 10505c30ecadSmrg done 10515c30ecadSmrg # Restore leading double-slash if one was found on entry. 10525c30ecadSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10535c30ecadSmrg} 10545c30ecadSmrg 10555c30ecadSmrg 10565c30ecadSmrg# func_notquiet ARG... 10575c30ecadSmrg# -------------------- 10585c30ecadSmrg# Echo program name prefixed message only when not in quiet mode. 10595c30ecadSmrgfunc_notquiet () 10605c30ecadSmrg{ 10615c30ecadSmrg $debug_cmd 10625c30ecadSmrg 10635c30ecadSmrg $opt_quiet || func_echo ${1+"$@"} 10645c30ecadSmrg 10655c30ecadSmrg # A bug in bash halts the script if the last line of a function 10665c30ecadSmrg # fails when set -e is in force, so we need another command to 10675c30ecadSmrg # work around that: 10685c30ecadSmrg : 10695c30ecadSmrg} 10705c30ecadSmrg 10715c30ecadSmrg 10725c30ecadSmrg# func_relative_path SRCDIR DSTDIR 10735c30ecadSmrg# -------------------------------- 10745c30ecadSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10755c30ecadSmrgfunc_relative_path () 10765c30ecadSmrg{ 10775c30ecadSmrg $debug_cmd 10785c30ecadSmrg 10795c30ecadSmrg func_relative_path_result= 10805c30ecadSmrg func_normal_abspath "$1" 10815c30ecadSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10825c30ecadSmrg func_normal_abspath "$2" 10835c30ecadSmrg func_relative_path_tbindir=$func_normal_abspath_result 10845c30ecadSmrg 10855c30ecadSmrg # Ascend the tree starting from libdir 10865c30ecadSmrg while :; do 10875c30ecadSmrg # check if we have found a prefix of bindir 10885c30ecadSmrg case $func_relative_path_tbindir in 10895c30ecadSmrg $func_relative_path_tlibdir) 10905c30ecadSmrg # found an exact match 10915c30ecadSmrg func_relative_path_tcancelled= 10925c30ecadSmrg break 10935c30ecadSmrg ;; 10945c30ecadSmrg $func_relative_path_tlibdir*) 10955c30ecadSmrg # found a matching prefix 10965c30ecadSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10975c30ecadSmrg func_relative_path_tcancelled=$func_stripname_result 10985c30ecadSmrg if test -z "$func_relative_path_result"; then 10995c30ecadSmrg func_relative_path_result=. 11005c30ecadSmrg fi 11015c30ecadSmrg break 11025c30ecadSmrg ;; 11035c30ecadSmrg *) 11045c30ecadSmrg func_dirname $func_relative_path_tlibdir 11055c30ecadSmrg func_relative_path_tlibdir=$func_dirname_result 11065c30ecadSmrg if test -z "$func_relative_path_tlibdir"; then 11075c30ecadSmrg # Have to descend all the way to the root! 11085c30ecadSmrg func_relative_path_result=../$func_relative_path_result 11095c30ecadSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11105c30ecadSmrg break 11115c30ecadSmrg fi 11125c30ecadSmrg func_relative_path_result=../$func_relative_path_result 11135c30ecadSmrg ;; 11145c30ecadSmrg esac 11155c30ecadSmrg done 11165c30ecadSmrg 11175c30ecadSmrg # Now calculate path; take care to avoid doubling-up slashes. 11185c30ecadSmrg func_stripname '' '/' "$func_relative_path_result" 11195c30ecadSmrg func_relative_path_result=$func_stripname_result 11205c30ecadSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11215c30ecadSmrg if test -n "$func_stripname_result"; then 11225c30ecadSmrg func_append func_relative_path_result "/$func_stripname_result" 11235c30ecadSmrg fi 11245c30ecadSmrg 11255c30ecadSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11265c30ecadSmrg if test -n "$func_relative_path_result"; then 11275c30ecadSmrg func_stripname './' '' "$func_relative_path_result" 11285c30ecadSmrg func_relative_path_result=$func_stripname_result 11295c30ecadSmrg fi 11305c30ecadSmrg 11315c30ecadSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11325c30ecadSmrg 11335c30ecadSmrg : 11345c30ecadSmrg} 11355c30ecadSmrg 11365c30ecadSmrg 11375c30ecadSmrg# func_quote_portable EVAL ARG 11385c30ecadSmrg# ---------------------------- 11395c30ecadSmrg# Internal function to portably implement func_quote_arg. Note that we still 11405c30ecadSmrg# keep attention to performance here so we as much as possible try to avoid 11415c30ecadSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11425c30ecadSmrgfunc_quote_portable () 11435c30ecadSmrg{ 11445c30ecadSmrg $debug_cmd 11455c30ecadSmrg 11465c30ecadSmrg $require_check_ifs_backslash 11475c30ecadSmrg 11485c30ecadSmrg func_quote_portable_result=$2 11495c30ecadSmrg 11505c30ecadSmrg # one-time-loop (easy break) 11515c30ecadSmrg while true 11525c30ecadSmrg do 11535c30ecadSmrg if $1; then 11545c30ecadSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11555c30ecadSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11565c30ecadSmrg break 11575c30ecadSmrg fi 11585c30ecadSmrg 11595c30ecadSmrg # Quote for eval. 11605c30ecadSmrg case $func_quote_portable_result in 11615c30ecadSmrg *[\\\`\"\$]*) 11625c30ecadSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11635c30ecadSmrg # contains the shell wildcard characters. 11645c30ecadSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11655c30ecadSmrg :*|*[\[\*\?]*) 11665c30ecadSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11675c30ecadSmrg | $SED "$sed_quote_subst"` 11685c30ecadSmrg break 11695c30ecadSmrg ;; 11705c30ecadSmrg esac 11715c30ecadSmrg 11725c30ecadSmrg func_quote_portable_old_IFS=$IFS 11735c30ecadSmrg for _G_char in '\' '`' '"' '$' 11745c30ecadSmrg do 11755c30ecadSmrg # STATE($1) PREV($2) SEPARATOR($3) 11765c30ecadSmrg set start "" "" 11775c30ecadSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11785c30ecadSmrg IFS=$_G_char 11795c30ecadSmrg for _G_part in $func_quote_portable_result 11805c30ecadSmrg do 11815c30ecadSmrg case $1 in 11825c30ecadSmrg quote) 11835c30ecadSmrg func_append func_quote_portable_result "$3$2" 11845c30ecadSmrg set quote "$_G_part" "\\$_G_char" 11855c30ecadSmrg ;; 11865c30ecadSmrg start) 11875c30ecadSmrg set first "" "" 11885c30ecadSmrg func_quote_portable_result= 11895c30ecadSmrg ;; 11905c30ecadSmrg first) 11915c30ecadSmrg set quote "$_G_part" "" 11925c30ecadSmrg ;; 11935c30ecadSmrg esac 11945c30ecadSmrg done 11955c30ecadSmrg done 11965c30ecadSmrg IFS=$func_quote_portable_old_IFS 11975c30ecadSmrg ;; 11985c30ecadSmrg *) ;; 11995c30ecadSmrg esac 12005c30ecadSmrg break 12015c30ecadSmrg done 12025c30ecadSmrg 12035c30ecadSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 12045c30ecadSmrg case $func_quote_portable_result in 12055c30ecadSmrg # double-quote args containing shell metacharacters to delay 12065c30ecadSmrg # word splitting, command substitution and variable expansion 12075c30ecadSmrg # for a subsequent eval. 12085c30ecadSmrg # many bourne shells cannot handle close brackets correctly 1209dc99b369Smrg # in scan sets, so we specify it separately. 1210dc99b369Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12115c30ecadSmrg func_quote_portable_result=\"$func_quote_portable_result\" 12125c30ecadSmrg ;; 12135c30ecadSmrg esac 12145c30ecadSmrg} 12155c30ecadSmrg 12165c30ecadSmrg 12175c30ecadSmrg# func_quotefast_eval ARG 12185c30ecadSmrg# ----------------------- 12195c30ecadSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12205c30ecadSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12215c30ecadSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12225c30ecadSmrg printf -v _GL_test_printf_tilde %q '~' 12235c30ecadSmrg if test '\~' = "$_GL_test_printf_tilde"; then 12245c30ecadSmrg func_quotefast_eval () 12255c30ecadSmrg { 12265c30ecadSmrg printf -v func_quotefast_eval_result %q "$1" 12275c30ecadSmrg } 12285c30ecadSmrg else 12295c30ecadSmrg # Broken older Bash implementations. Make those faster too if possible. 12305c30ecadSmrg func_quotefast_eval () 12315c30ecadSmrg { 12325c30ecadSmrg case $1 in 12335c30ecadSmrg '~'*) 12345c30ecadSmrg func_quote_portable false "$1" 12355c30ecadSmrg func_quotefast_eval_result=$func_quote_portable_result 12365c30ecadSmrg ;; 12375c30ecadSmrg *) 12385c30ecadSmrg printf -v func_quotefast_eval_result %q "$1" 12395c30ecadSmrg ;; 12405c30ecadSmrg esac 12415c30ecadSmrg } 12425c30ecadSmrg fi 12435c30ecadSmrgelse 12445c30ecadSmrg func_quotefast_eval () 12455c30ecadSmrg { 12465c30ecadSmrg func_quote_portable false "$1" 12475c30ecadSmrg func_quotefast_eval_result=$func_quote_portable_result 12485c30ecadSmrg } 12495c30ecadSmrgfi 12505c30ecadSmrg 12515c30ecadSmrg 12525c30ecadSmrg# func_quote_arg MODEs ARG 12535c30ecadSmrg# ------------------------ 12545c30ecadSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12555c30ecadSmrg# specifiers listed below separated by ',' character. This function returns two 12565c30ecadSmrg# values: 12575c30ecadSmrg# i) func_quote_arg_result 12585c30ecadSmrg# double-quoted (when needed), suitable for a subsequent eval 12595c30ecadSmrg# ii) func_quote_arg_unquoted_result 12605c30ecadSmrg# has all characters that are still active within double 12615c30ecadSmrg# quotes backslashified. Available only if 'unquoted' is specified. 12625c30ecadSmrg# 12635c30ecadSmrg# Available modes: 12645c30ecadSmrg# ---------------- 12655c30ecadSmrg# 'eval' (default) 12665c30ecadSmrg# - escape shell special characters 12675c30ecadSmrg# 'expand' 12685c30ecadSmrg# - the same as 'eval'; but do not quote variable references 12695c30ecadSmrg# 'pretty' 12705c30ecadSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12715c30ecadSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 12725c30ecadSmrg# of 'echo a\ b'. This is slower than default on some shells. 12735c30ecadSmrg# 'unquoted' 12745c30ecadSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 12755c30ecadSmrg# wrapping double-quotes. 12765c30ecadSmrg# 12775c30ecadSmrg# Examples for 'func_quote_arg pretty,unquoted string': 12785c30ecadSmrg# 12795c30ecadSmrg# string | *_result | *_unquoted_result 12805c30ecadSmrg# ------------+-----------------------+------------------- 12815c30ecadSmrg# " | \" | \" 12825c30ecadSmrg# a b | "a b" | a b 12835c30ecadSmrg# "a b" | "\"a b\"" | \"a b\" 12845c30ecadSmrg# * | "*" | * 12855c30ecadSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12865c30ecadSmrg# 12875c30ecadSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12885c30ecadSmrg# 12895c30ecadSmrg# string | *_result | *_unquoted_result 12905c30ecadSmrg# --------------+---------------------+-------------------- 12915c30ecadSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12925c30ecadSmrgfunc_quote_arg () 12935c30ecadSmrg{ 12945c30ecadSmrg _G_quote_expand=false 12955c30ecadSmrg case ,$1, in 12965c30ecadSmrg *,expand,*) 12975c30ecadSmrg _G_quote_expand=: 12985c30ecadSmrg ;; 12995c30ecadSmrg esac 13005c30ecadSmrg 13015c30ecadSmrg case ,$1, in 13025c30ecadSmrg *,pretty,*|*,expand,*|*,unquoted,*) 13035c30ecadSmrg func_quote_portable $_G_quote_expand "$2" 13045c30ecadSmrg func_quote_arg_result=$func_quote_portable_result 13055c30ecadSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306dc99b369Smrg ;; 1307dc99b369Smrg *) 13085c30ecadSmrg # Faster quote-for-eval for some shells. 13095c30ecadSmrg func_quotefast_eval "$2" 13105c30ecadSmrg func_quote_arg_result=$func_quotefast_eval_result 13115c30ecadSmrg ;; 1312dc99b369Smrg esac 1313dc99b369Smrg} 1314dc99b369Smrg 1315dc99b369Smrg 13165c30ecadSmrg# func_quote MODEs ARGs... 13175c30ecadSmrg# ------------------------ 13185c30ecadSmrg# Quote all ARGs to be evaled later and join them into single command. See 13195c30ecadSmrg# func_quote_arg's description for more info. 13205c30ecadSmrgfunc_quote () 1321dc99b369Smrg{ 13225c30ecadSmrg $debug_cmd 13235c30ecadSmrg _G_func_quote_mode=$1 ; shift 13245c30ecadSmrg func_quote_result= 13255c30ecadSmrg while test 0 -lt $#; do 13265c30ecadSmrg func_quote_arg "$_G_func_quote_mode" "$1" 13275c30ecadSmrg if test -n "$func_quote_result"; then 13285c30ecadSmrg func_append func_quote_result " $func_quote_arg_result" 13295c30ecadSmrg else 13305c30ecadSmrg func_append func_quote_result "$func_quote_arg_result" 13315c30ecadSmrg fi 13325c30ecadSmrg shift 13335c30ecadSmrg done 13345c30ecadSmrg} 13355c30ecadSmrg 13365c30ecadSmrg 13375c30ecadSmrg# func_stripname PREFIX SUFFIX NAME 13385c30ecadSmrg# --------------------------------- 13395c30ecadSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13405c30ecadSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13415c30ecadSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13425c30ecadSmrg# dot (in which case that matches only a dot). 13435c30ecadSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13445c30ecadSmrg eval 'func_stripname () 13455c30ecadSmrg { 13465c30ecadSmrg $debug_cmd 13475c30ecadSmrg 13485c30ecadSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13495c30ecadSmrg # positional parameters, so assign one to ordinary variable first. 13505c30ecadSmrg func_stripname_result=$3 13515c30ecadSmrg func_stripname_result=${func_stripname_result#"$1"} 13525c30ecadSmrg func_stripname_result=${func_stripname_result%"$2"} 13535c30ecadSmrg }' 13545c30ecadSmrgelse 13555c30ecadSmrg func_stripname () 13565c30ecadSmrg { 13575c30ecadSmrg $debug_cmd 13585c30ecadSmrg 13595c30ecadSmrg case $2 in 13605c30ecadSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13615c30ecadSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13625c30ecadSmrg esac 13635c30ecadSmrg } 13645c30ecadSmrgfi 13655c30ecadSmrg 13665c30ecadSmrg 13675c30ecadSmrg# func_show_eval CMD [FAIL_EXP] 13685c30ecadSmrg# ----------------------------- 13695c30ecadSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13705c30ecadSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13715c30ecadSmrg# is given, then evaluate it. 13725c30ecadSmrgfunc_show_eval () 13735c30ecadSmrg{ 13745c30ecadSmrg $debug_cmd 13755c30ecadSmrg 13765c30ecadSmrg _G_cmd=$1 13775c30ecadSmrg _G_fail_exp=${2-':'} 13785c30ecadSmrg 13795c30ecadSmrg func_quote_arg pretty,expand "$_G_cmd" 13805c30ecadSmrg eval "func_notquiet $func_quote_arg_result" 13815c30ecadSmrg 13825c30ecadSmrg $opt_dry_run || { 13835c30ecadSmrg eval "$_G_cmd" 13845c30ecadSmrg _G_status=$? 13855c30ecadSmrg if test 0 -ne "$_G_status"; then 13865c30ecadSmrg eval "(exit $_G_status); $_G_fail_exp" 13875c30ecadSmrg fi 13885c30ecadSmrg } 13895c30ecadSmrg} 13905c30ecadSmrg 13915c30ecadSmrg 13925c30ecadSmrg# func_show_eval_locale CMD [FAIL_EXP] 13935c30ecadSmrg# ------------------------------------ 13945c30ecadSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13955c30ecadSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13965c30ecadSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13975c30ecadSmrgfunc_show_eval_locale () 13985c30ecadSmrg{ 13995c30ecadSmrg $debug_cmd 14005c30ecadSmrg 14015c30ecadSmrg _G_cmd=$1 14025c30ecadSmrg _G_fail_exp=${2-':'} 14035c30ecadSmrg 14045c30ecadSmrg $opt_quiet || { 14055c30ecadSmrg func_quote_arg expand,pretty "$_G_cmd" 14065c30ecadSmrg eval "func_echo $func_quote_arg_result" 14075c30ecadSmrg } 14085c30ecadSmrg 14095c30ecadSmrg $opt_dry_run || { 14105c30ecadSmrg eval "$_G_user_locale 14115c30ecadSmrg $_G_cmd" 14125c30ecadSmrg _G_status=$? 14135c30ecadSmrg eval "$_G_safe_locale" 14145c30ecadSmrg if test 0 -ne "$_G_status"; then 14155c30ecadSmrg eval "(exit $_G_status); $_G_fail_exp" 14165c30ecadSmrg fi 14175c30ecadSmrg } 14185c30ecadSmrg} 14195c30ecadSmrg 14205c30ecadSmrg 14215c30ecadSmrg# func_tr_sh 14225c30ecadSmrg# ---------- 14235c30ecadSmrg# Turn $1 into a string suitable for a shell variable name. 14245c30ecadSmrg# Result is stored in $func_tr_sh_result. All characters 14255c30ecadSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14265c30ecadSmrg# if $1 begins with a digit, a '_' is prepended as well. 14275c30ecadSmrgfunc_tr_sh () 14285c30ecadSmrg{ 14295c30ecadSmrg $debug_cmd 14305c30ecadSmrg 1431dc99b369Smrg case $1 in 14325c30ecadSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14335c30ecadSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14345c30ecadSmrg ;; 14355c30ecadSmrg * ) 14365c30ecadSmrg func_tr_sh_result=$1 14375c30ecadSmrg ;; 1438dc99b369Smrg esac 14395c30ecadSmrg} 1440dc99b369Smrg 14415c30ecadSmrg 14425c30ecadSmrg# func_verbose ARG... 14435c30ecadSmrg# ------------------- 14445c30ecadSmrg# Echo program name prefixed message in verbose mode only. 14455c30ecadSmrgfunc_verbose () 14465c30ecadSmrg{ 14475c30ecadSmrg $debug_cmd 14485c30ecadSmrg 14495c30ecadSmrg $opt_verbose && func_echo "$*" 14505c30ecadSmrg 14515c30ecadSmrg : 14525c30ecadSmrg} 14535c30ecadSmrg 14545c30ecadSmrg 14555c30ecadSmrg# func_warn_and_continue ARG... 14565c30ecadSmrg# ----------------------------- 14575c30ecadSmrg# Echo program name prefixed warning message to standard error. 14585c30ecadSmrgfunc_warn_and_continue () 14595c30ecadSmrg{ 14605c30ecadSmrg $debug_cmd 14615c30ecadSmrg 14625c30ecadSmrg $require_term_colors 14635c30ecadSmrg 14645c30ecadSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14655c30ecadSmrg} 14665c30ecadSmrg 14675c30ecadSmrg 14685c30ecadSmrg# func_warning CATEGORY ARG... 14695c30ecadSmrg# ---------------------------- 14705c30ecadSmrg# Echo program name prefixed warning message to standard error. Warning 14715c30ecadSmrg# messages can be filtered according to CATEGORY, where this function 14725c30ecadSmrg# elides messages where CATEGORY is not listed in the global variable 14735c30ecadSmrg# 'opt_warning_types'. 14745c30ecadSmrgfunc_warning () 14755c30ecadSmrg{ 14765c30ecadSmrg $debug_cmd 14775c30ecadSmrg 14785c30ecadSmrg # CATEGORY must be in the warning_categories list! 14795c30ecadSmrg case " $warning_categories " in 14805c30ecadSmrg *" $1 "*) ;; 14815c30ecadSmrg *) func_internal_error "invalid warning category '$1'" ;; 1482dc99b369Smrg esac 1483dc99b369Smrg 14845c30ecadSmrg _G_category=$1 14855c30ecadSmrg shift 14865c30ecadSmrg 14875c30ecadSmrg case " $opt_warning_types " in 14885c30ecadSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14895c30ecadSmrg esac 14905c30ecadSmrg} 14915c30ecadSmrg 14925c30ecadSmrg 14935c30ecadSmrg# func_sort_ver VER1 VER2 14945c30ecadSmrg# ----------------------- 14955c30ecadSmrg# 'sort -V' is not generally available. 14965c30ecadSmrg# Note this deviates from the version comparison in automake 14975c30ecadSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14985c30ecadSmrg# but this should suffice as we won't be specifying old 14995c30ecadSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15005c30ecadSmrg# If we did want full compatibility then we should probably 15015c30ecadSmrg# use m4_version_compare from autoconf. 15025c30ecadSmrgfunc_sort_ver () 15035c30ecadSmrg{ 15045c30ecadSmrg $debug_cmd 15055c30ecadSmrg 15065c30ecadSmrg printf '%s\n%s\n' "$1" "$2" \ 15075c30ecadSmrg | 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 15085c30ecadSmrg} 15095c30ecadSmrg 15105c30ecadSmrg# func_lt_ver PREV CURR 15115c30ecadSmrg# --------------------- 15125c30ecadSmrg# Return true if PREV and CURR are in the correct order according to 15135c30ecadSmrg# func_sort_ver, otherwise false. Use it like this: 15145c30ecadSmrg# 15155c30ecadSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15165c30ecadSmrgfunc_lt_ver () 15175c30ecadSmrg{ 15185c30ecadSmrg $debug_cmd 15195c30ecadSmrg 15205c30ecadSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15215c30ecadSmrg} 15225c30ecadSmrg 15235c30ecadSmrg 15245c30ecadSmrg# Local variables: 15255c30ecadSmrg# mode: shell-script 15265c30ecadSmrg# sh-indentation: 2 15275c30ecadSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15285c30ecadSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15295c30ecadSmrg# time-stamp-time-zone: "UTC" 15305c30ecadSmrg# End: 15315c30ecadSmrg#! /bin/sh 15325c30ecadSmrg 15335c30ecadSmrg# A portable, pluggable option parser for Bourne shell. 15345c30ecadSmrg# Written by Gary V. Vaughan, 2010 15355c30ecadSmrg 15365c30ecadSmrg# This is free software. There is NO warranty; not even for 15375c30ecadSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15385c30ecadSmrg# 15395c30ecadSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15405c30ecadSmrg# 15415c30ecadSmrg# This file is dual licensed under the terms of the MIT license 15425c30ecadSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15435c30ecadSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15445c30ecadSmrg# these licenses when using or redistributing this software or any of 15455c30ecadSmrg# the files within it. See the URLs above, or the file `LICENSE` 15465c30ecadSmrg# included in the Bootstrap distribution for the full license texts. 15475c30ecadSmrg 15485c30ecadSmrg# Please report bugs or propose patches to: 15495c30ecadSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 15505c30ecadSmrg 15515c30ecadSmrg# Set a version string for this script. 15525c30ecadSmrgscriptversion=2019-02-19.15; # UTC 15535c30ecadSmrg 15545c30ecadSmrg 15555c30ecadSmrg## ------ ## 15565c30ecadSmrg## Usage. ## 15575c30ecadSmrg## ------ ## 15585c30ecadSmrg 15595c30ecadSmrg# This file is a library for parsing options in your shell scripts along 15605c30ecadSmrg# with assorted other useful supporting features that you can make use 15615c30ecadSmrg# of too. 15625c30ecadSmrg# 15635c30ecadSmrg# For the simplest scripts you might need only: 15645c30ecadSmrg# 15655c30ecadSmrg# #!/bin/sh 15665c30ecadSmrg# . relative/path/to/funclib.sh 15675c30ecadSmrg# . relative/path/to/options-parser 15685c30ecadSmrg# scriptversion=1.0 15695c30ecadSmrg# func_options ${1+"$@"} 15705c30ecadSmrg# eval set dummy "$func_options_result"; shift 15715c30ecadSmrg# ...rest of your script... 15725c30ecadSmrg# 15735c30ecadSmrg# In order for the '--version' option to work, you will need to have a 15745c30ecadSmrg# suitably formatted comment like the one at the top of this file 15755c30ecadSmrg# starting with '# Written by ' and ending with '# Copyright'. 15765c30ecadSmrg# 15775c30ecadSmrg# For '-h' and '--help' to work, you will also need a one line 15785c30ecadSmrg# description of your script's purpose in a comment directly above the 15795c30ecadSmrg# '# Written by ' line, like the one at the top of this file. 15805c30ecadSmrg# 15815c30ecadSmrg# The default options also support '--debug', which will turn on shell 15825c30ecadSmrg# execution tracing (see the comment above debug_cmd below for another 15835c30ecadSmrg# use), and '--verbose' and the func_verbose function to allow your script 15845c30ecadSmrg# to display verbose messages only when your user has specified 15855c30ecadSmrg# '--verbose'. 15865c30ecadSmrg# 15875c30ecadSmrg# After sourcing this file, you can plug in processing for additional 15885c30ecadSmrg# options by amending the variables from the 'Configuration' section 15895c30ecadSmrg# below, and following the instructions in the 'Option parsing' 15905c30ecadSmrg# section further down. 15915c30ecadSmrg 15925c30ecadSmrg## -------------- ## 15935c30ecadSmrg## Configuration. ## 15945c30ecadSmrg## -------------- ## 15955c30ecadSmrg 15965c30ecadSmrg# You should override these variables in your script after sourcing this 15975c30ecadSmrg# file so that they reflect the customisations you have added to the 15985c30ecadSmrg# option parser. 15995c30ecadSmrg 16005c30ecadSmrg# The usage line for option parsing errors and the start of '-h' and 16015c30ecadSmrg# '--help' output messages. You can embed shell variables for delayed 16025c30ecadSmrg# expansion at the time the message is displayed, but you will need to 16035c30ecadSmrg# quote other shell meta-characters carefully to prevent them being 16045c30ecadSmrg# expanded when the contents are evaled. 16055c30ecadSmrgusage='$progpath [OPTION]...' 16065c30ecadSmrg 16075c30ecadSmrg# Short help message in response to '-h' and '--help'. Add to this or 16085c30ecadSmrg# override it after sourcing this library to reflect the full set of 16095c30ecadSmrg# options your script accepts. 16105c30ecadSmrgusage_message="\ 16115c30ecadSmrg --debug enable verbose shell tracing 16125c30ecadSmrg -W, --warnings=CATEGORY 16135c30ecadSmrg report the warnings falling in CATEGORY [all] 16145c30ecadSmrg -v, --verbose verbosely report processing 16155c30ecadSmrg --version print version information and exit 16165c30ecadSmrg -h, --help print short or long help message and exit 16175c30ecadSmrg" 16185c30ecadSmrg 16195c30ecadSmrg# Additional text appended to 'usage_message' in response to '--help'. 16205c30ecadSmrglong_help_message=" 16215c30ecadSmrgWarning categories include: 16225c30ecadSmrg 'all' show all warnings 16235c30ecadSmrg 'none' turn off all the warnings 16245c30ecadSmrg 'error' warnings are treated as fatal errors" 16255c30ecadSmrg 16265c30ecadSmrg# Help message printed before fatal option parsing errors. 16275c30ecadSmrgfatal_help="Try '\$progname --help' for more information." 16285c30ecadSmrg 16295c30ecadSmrg 16305c30ecadSmrg 16315c30ecadSmrg## ------------------------- ## 16325c30ecadSmrg## Hook function management. ## 16335c30ecadSmrg## ------------------------- ## 16345c30ecadSmrg 16355c30ecadSmrg# This section contains functions for adding, removing, and running hooks 16365c30ecadSmrg# in the main code. A hook is just a list of function names that can be 16375c30ecadSmrg# run in order later on. 16385c30ecadSmrg 16395c30ecadSmrg# func_hookable FUNC_NAME 16405c30ecadSmrg# ----------------------- 16415c30ecadSmrg# Declare that FUNC_NAME will run hooks added with 16425c30ecadSmrg# 'func_add_hook FUNC_NAME ...'. 16435c30ecadSmrgfunc_hookable () 16445c30ecadSmrg{ 16455c30ecadSmrg $debug_cmd 16465c30ecadSmrg 16475c30ecadSmrg func_append hookable_fns " $1" 16485c30ecadSmrg} 16495c30ecadSmrg 16505c30ecadSmrg 16515c30ecadSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16525c30ecadSmrg# --------------------------------- 16535c30ecadSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16545c30ecadSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16555c30ecadSmrgfunc_add_hook () 16565c30ecadSmrg{ 16575c30ecadSmrg $debug_cmd 16585c30ecadSmrg 16595c30ecadSmrg case " $hookable_fns " in 16605c30ecadSmrg *" $1 "*) ;; 16615c30ecadSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16625c30ecadSmrg esac 16635c30ecadSmrg 16645c30ecadSmrg eval func_append ${1}_hooks '" $2"' 16655c30ecadSmrg} 16665c30ecadSmrg 16675c30ecadSmrg 16685c30ecadSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16695c30ecadSmrg# ------------------------------------ 16705c30ecadSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 16715c30ecadSmrg# FUNC_NAME. 16725c30ecadSmrgfunc_remove_hook () 16735c30ecadSmrg{ 16745c30ecadSmrg $debug_cmd 16755c30ecadSmrg 16765c30ecadSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16775c30ecadSmrg} 16785c30ecadSmrg 16795c30ecadSmrg 16805c30ecadSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16815c30ecadSmrg# --------------------------------------------- 16825c30ecadSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16835c30ecadSmrg# *_result variable of FUNC_NAME_B. 16845c30ecadSmrgfunc_propagate_result () 16855c30ecadSmrg{ 16865c30ecadSmrg $debug_cmd 16875c30ecadSmrg 16885c30ecadSmrg func_propagate_result_result=: 16895c30ecadSmrg if eval "test \"\${${1}_result+set}\" = set" 16905c30ecadSmrg then 16915c30ecadSmrg eval "${2}_result=\$${1}_result" 16925c30ecadSmrg else 16935c30ecadSmrg func_propagate_result_result=false 16945c30ecadSmrg fi 16955c30ecadSmrg} 16965c30ecadSmrg 16975c30ecadSmrg 16985c30ecadSmrg# func_run_hooks FUNC_NAME [ARG]... 16995c30ecadSmrg# --------------------------------- 17005c30ecadSmrg# Run all hook functions registered to FUNC_NAME. 17015c30ecadSmrg# It's assumed that the list of hook functions contains nothing more 17025c30ecadSmrg# than a whitespace-delimited list of legal shell function names, and 17035c30ecadSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17045c30ecadSmrg# whitespace. 17055c30ecadSmrgfunc_run_hooks () 17065c30ecadSmrg{ 17075c30ecadSmrg $debug_cmd 17085c30ecadSmrg 17095c30ecadSmrg case " $hookable_fns " in 17105c30ecadSmrg *" $1 "*) ;; 17115c30ecadSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 17125c30ecadSmrg esac 17135c30ecadSmrg 17145c30ecadSmrg eval _G_hook_fns=\$$1_hooks; shift 17155c30ecadSmrg 17165c30ecadSmrg for _G_hook in $_G_hook_fns; do 17175c30ecadSmrg func_unset "${_G_hook}_result" 17185c30ecadSmrg eval $_G_hook '${1+"$@"}' 17195c30ecadSmrg func_propagate_result $_G_hook func_run_hooks 17205c30ecadSmrg if $func_propagate_result_result; then 17215c30ecadSmrg eval set dummy "$func_run_hooks_result"; shift 17225c30ecadSmrg fi 17235c30ecadSmrg done 17245c30ecadSmrg} 17255c30ecadSmrg 17265c30ecadSmrg 17275c30ecadSmrg 17285c30ecadSmrg## --------------- ## 17295c30ecadSmrg## Option parsing. ## 17305c30ecadSmrg## --------------- ## 17315c30ecadSmrg 17325c30ecadSmrg# In order to add your own option parsing hooks, you must accept the 17335c30ecadSmrg# full positional parameter list from your hook function. You may remove 17345c30ecadSmrg# or edit any options that you action, and then pass back the remaining 17355c30ecadSmrg# unprocessed options in '<hooked_function_name>_result', escaped 17365c30ecadSmrg# suitably for 'eval'. 17375c30ecadSmrg# 17385c30ecadSmrg# The '<hooked_function_name>_result' variable is automatically unset 17395c30ecadSmrg# before your hook gets called; for best performance, only set the 17405c30ecadSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17415c30ecadSmrg# function unnecessarily because it can be an expensive operation on some 17425c30ecadSmrg# machines). 17435c30ecadSmrg# 17445c30ecadSmrg# Like this: 17455c30ecadSmrg# 17465c30ecadSmrg# my_options_prep () 17475c30ecadSmrg# { 17485c30ecadSmrg# $debug_cmd 17495c30ecadSmrg# 17505c30ecadSmrg# # Extend the existing usage message. 17515c30ecadSmrg# usage_message=$usage_message' 17525c30ecadSmrg# -s, --silent don'\''t print informational messages 17535c30ecadSmrg# ' 17545c30ecadSmrg# # No change in '$@' (ignored completely by this hook). Leave 17555c30ecadSmrg# # my_options_prep_result variable intact. 17565c30ecadSmrg# } 17575c30ecadSmrg# func_add_hook func_options_prep my_options_prep 17585c30ecadSmrg# 17595c30ecadSmrg# 17605c30ecadSmrg# my_silent_option () 17615c30ecadSmrg# { 17625c30ecadSmrg# $debug_cmd 17635c30ecadSmrg# 17645c30ecadSmrg# args_changed=false 17655c30ecadSmrg# 17665c30ecadSmrg# # Note that, for efficiency, we parse as many options as we can 17675c30ecadSmrg# # recognise in a loop before passing the remainder back to the 17685c30ecadSmrg# # caller on the first unrecognised argument we encounter. 17695c30ecadSmrg# while test $# -gt 0; do 17705c30ecadSmrg# opt=$1; shift 17715c30ecadSmrg# case $opt in 17725c30ecadSmrg# --silent|-s) opt_silent=: 17735c30ecadSmrg# args_changed=: 17745c30ecadSmrg# ;; 17755c30ecadSmrg# # Separate non-argument short options: 17765c30ecadSmrg# -s*) func_split_short_opt "$_G_opt" 17775c30ecadSmrg# set dummy "$func_split_short_opt_name" \ 17785c30ecadSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17795c30ecadSmrg# shift 17805c30ecadSmrg# args_changed=: 17815c30ecadSmrg# ;; 17825c30ecadSmrg# *) # Make sure the first unrecognised option "$_G_opt" 17835c30ecadSmrg# # is added back to "$@" in case we need it later, 17845c30ecadSmrg# # if $args_changed was set to 'true'. 17855c30ecadSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17865c30ecadSmrg# esac 17875c30ecadSmrg# done 17885c30ecadSmrg# 17895c30ecadSmrg# # Only call 'func_quote' here if we processed at least one argument. 17905c30ecadSmrg# if $args_changed; then 17915c30ecadSmrg# func_quote eval ${1+"$@"} 17925c30ecadSmrg# my_silent_option_result=$func_quote_result 17935c30ecadSmrg# fi 17945c30ecadSmrg# } 17955c30ecadSmrg# func_add_hook func_parse_options my_silent_option 17965c30ecadSmrg# 17975c30ecadSmrg# 17985c30ecadSmrg# my_option_validation () 17995c30ecadSmrg# { 18005c30ecadSmrg# $debug_cmd 18015c30ecadSmrg# 18025c30ecadSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18035c30ecadSmrg# '--silent' and '--verbose' options are mutually exclusive." 18045c30ecadSmrg# } 18055c30ecadSmrg# func_add_hook func_validate_options my_option_validation 18065c30ecadSmrg# 18075c30ecadSmrg# You'll also need to manually amend $usage_message to reflect the extra 18085c30ecadSmrg# options you parse. It's preferable to append if you can, so that 18095c30ecadSmrg# multiple option parsing hooks can be added safely. 18105c30ecadSmrg 18115c30ecadSmrg 18125c30ecadSmrg# func_options_finish [ARG]... 18135c30ecadSmrg# ---------------------------- 18145c30ecadSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18155c30ecadSmrgfunc_options_finish () 18165c30ecadSmrg{ 18175c30ecadSmrg $debug_cmd 18185c30ecadSmrg 18195c30ecadSmrg func_run_hooks func_options ${1+"$@"} 18205c30ecadSmrg func_propagate_result func_run_hooks func_options_finish 18215c30ecadSmrg} 18225c30ecadSmrg 18235c30ecadSmrg 18245c30ecadSmrg# func_options [ARG]... 18255c30ecadSmrg# --------------------- 18265c30ecadSmrg# All the functions called inside func_options are hookable. See the 18275c30ecadSmrg# individual implementations for details. 18285c30ecadSmrgfunc_hookable func_options 18295c30ecadSmrgfunc_options () 18305c30ecadSmrg{ 18315c30ecadSmrg $debug_cmd 18325c30ecadSmrg 18335c30ecadSmrg _G_options_quoted=false 18345c30ecadSmrg 18355c30ecadSmrg for my_func in options_prep parse_options validate_options options_finish 18365c30ecadSmrg do 18375c30ecadSmrg func_unset func_${my_func}_result 18385c30ecadSmrg func_unset func_run_hooks_result 18395c30ecadSmrg eval func_$my_func '${1+"$@"}' 18405c30ecadSmrg func_propagate_result func_$my_func func_options 18415c30ecadSmrg if $func_propagate_result_result; then 18425c30ecadSmrg eval set dummy "$func_options_result"; shift 18435c30ecadSmrg _G_options_quoted=: 18445c30ecadSmrg fi 18455c30ecadSmrg done 18465c30ecadSmrg 18475c30ecadSmrg $_G_options_quoted || { 18485c30ecadSmrg # As we (func_options) are top-level options-parser function and 18495c30ecadSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18505c30ecadSmrg # caller. 18515c30ecadSmrg func_quote eval ${1+"$@"} 18525c30ecadSmrg func_options_result=$func_quote_result 18535c30ecadSmrg } 18545c30ecadSmrg} 18555c30ecadSmrg 18565c30ecadSmrg 18575c30ecadSmrg# func_options_prep [ARG]... 18585c30ecadSmrg# -------------------------- 18595c30ecadSmrg# All initialisations required before starting the option parse loop. 18605c30ecadSmrg# Note that when calling hook functions, we pass through the list of 18615c30ecadSmrg# positional parameters. If a hook function modifies that list, and 18625c30ecadSmrg# needs to propagate that back to rest of this script, then the complete 18635c30ecadSmrg# modified list must be put in 'func_run_hooks_result' before returning. 18645c30ecadSmrgfunc_hookable func_options_prep 18655c30ecadSmrgfunc_options_prep () 18665c30ecadSmrg{ 18675c30ecadSmrg $debug_cmd 18685c30ecadSmrg 18695c30ecadSmrg # Option defaults: 18705c30ecadSmrg opt_verbose=false 18715c30ecadSmrg opt_warning_types= 18725c30ecadSmrg 18735c30ecadSmrg func_run_hooks func_options_prep ${1+"$@"} 18745c30ecadSmrg func_propagate_result func_run_hooks func_options_prep 1875dc99b369Smrg} 1876dc99b369Smrg 1877dc99b369Smrg 18785c30ecadSmrg# func_parse_options [ARG]... 18795c30ecadSmrg# --------------------------- 18805c30ecadSmrg# The main option parsing loop. 18815c30ecadSmrgfunc_hookable func_parse_options 18825c30ecadSmrgfunc_parse_options () 1883dc99b369Smrg{ 18845c30ecadSmrg $debug_cmd 18855c30ecadSmrg 18865c30ecadSmrg _G_parse_options_requote=false 18875c30ecadSmrg # this just eases exit handling 18885c30ecadSmrg while test $# -gt 0; do 18895c30ecadSmrg # Defer to hook functions for initial option parsing, so they 18905c30ecadSmrg # get priority in the event of reusing an option name. 18915c30ecadSmrg func_run_hooks func_parse_options ${1+"$@"} 18925c30ecadSmrg func_propagate_result func_run_hooks func_parse_options 18935c30ecadSmrg if $func_propagate_result_result; then 18945c30ecadSmrg eval set dummy "$func_parse_options_result"; shift 18955c30ecadSmrg # Even though we may have changed "$@", we passed the "$@" array 18965c30ecadSmrg # down into the hook and it quoted it for us (because we are in 18975c30ecadSmrg # this if-branch). No need to quote it again. 18985c30ecadSmrg _G_parse_options_requote=false 18995c30ecadSmrg fi 1900dc99b369Smrg 19015c30ecadSmrg # Break out of the loop if we already parsed every option. 19025c30ecadSmrg test $# -gt 0 || break 19035c30ecadSmrg 19045c30ecadSmrg # We expect that one of the options parsed in this function matches 19055c30ecadSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 19065c30ecadSmrg _G_match_parse_options=: 19075c30ecadSmrg _G_opt=$1 19085c30ecadSmrg shift 19095c30ecadSmrg case $_G_opt in 19105c30ecadSmrg --debug|-x) debug_cmd='set -x' 19115c30ecadSmrg func_echo "enabling shell trace mode" >&2 19125c30ecadSmrg $debug_cmd 19135c30ecadSmrg ;; 19145c30ecadSmrg 19155c30ecadSmrg --no-warnings|--no-warning|--no-warn) 19165c30ecadSmrg set dummy --warnings none ${1+"$@"} 19175c30ecadSmrg shift 19185c30ecadSmrg ;; 1919dc99b369Smrg 19205c30ecadSmrg --warnings|--warning|-W) 19215c30ecadSmrg if test $# = 0 && func_missing_arg $_G_opt; then 19225c30ecadSmrg _G_parse_options_requote=: 19235c30ecadSmrg break 19245c30ecadSmrg fi 19255c30ecadSmrg case " $warning_categories $1" in 19265c30ecadSmrg *" $1 "*) 19275c30ecadSmrg # trailing space prevents matching last $1 above 19285c30ecadSmrg func_append_uniq opt_warning_types " $1" 19295c30ecadSmrg ;; 19305c30ecadSmrg *all) 19315c30ecadSmrg opt_warning_types=$warning_categories 19325c30ecadSmrg ;; 19335c30ecadSmrg *none) 19345c30ecadSmrg opt_warning_types=none 19355c30ecadSmrg warning_func=: 19365c30ecadSmrg ;; 19375c30ecadSmrg *error) 19385c30ecadSmrg opt_warning_types=$warning_categories 19395c30ecadSmrg warning_func=func_fatal_error 19405c30ecadSmrg ;; 19415c30ecadSmrg *) 19425c30ecadSmrg func_fatal_error \ 19435c30ecadSmrg "unsupported warning category: '$1'" 19445c30ecadSmrg ;; 19455c30ecadSmrg esac 19465c30ecadSmrg shift 19475c30ecadSmrg ;; 19485c30ecadSmrg 19495c30ecadSmrg --verbose|-v) opt_verbose=: ;; 19505c30ecadSmrg --version) func_version ;; 19515c30ecadSmrg -\?|-h) func_usage ;; 19525c30ecadSmrg --help) func_help ;; 19535c30ecadSmrg 19545c30ecadSmrg # Separate optargs to long options (plugins may need this): 19555c30ecadSmrg --*=*) func_split_equals "$_G_opt" 19565c30ecadSmrg set dummy "$func_split_equals_lhs" \ 19575c30ecadSmrg "$func_split_equals_rhs" ${1+"$@"} 19585c30ecadSmrg shift 19595c30ecadSmrg ;; 19605c30ecadSmrg 19615c30ecadSmrg # Separate optargs to short options: 19625c30ecadSmrg -W*) 19635c30ecadSmrg func_split_short_opt "$_G_opt" 19645c30ecadSmrg set dummy "$func_split_short_opt_name" \ 19655c30ecadSmrg "$func_split_short_opt_arg" ${1+"$@"} 19665c30ecadSmrg shift 19675c30ecadSmrg ;; 19685c30ecadSmrg 19695c30ecadSmrg # Separate non-argument short options: 19705c30ecadSmrg -\?*|-h*|-v*|-x*) 19715c30ecadSmrg func_split_short_opt "$_G_opt" 19725c30ecadSmrg set dummy "$func_split_short_opt_name" \ 19735c30ecadSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19745c30ecadSmrg shift 19755c30ecadSmrg ;; 19765c30ecadSmrg 19775c30ecadSmrg --) _G_parse_options_requote=: ; break ;; 19785c30ecadSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19795c30ecadSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19805c30ecadSmrg _G_match_parse_options=false 19815c30ecadSmrg break 19825c30ecadSmrg ;; 19835c30ecadSmrg esac 19845c30ecadSmrg 19855c30ecadSmrg if $_G_match_parse_options; then 19865c30ecadSmrg _G_parse_options_requote=: 1987dc99b369Smrg fi 19885c30ecadSmrg done 19895c30ecadSmrg 19905c30ecadSmrg if $_G_parse_options_requote; then 19915c30ecadSmrg # save modified positional parameters for caller 19925c30ecadSmrg func_quote eval ${1+"$@"} 19935c30ecadSmrg func_parse_options_result=$func_quote_result 19945eefee25Smacallan fi 1995dc99b369Smrg} 1996dc99b369Smrg 1997dc99b369Smrg 19985c30ecadSmrg# func_validate_options [ARG]... 19995c30ecadSmrg# ------------------------------ 20005c30ecadSmrg# Perform any sanity checks on option settings and/or unconsumed 20015c30ecadSmrg# arguments. 20025c30ecadSmrgfunc_hookable func_validate_options 20035c30ecadSmrgfunc_validate_options () 2004dc99b369Smrg{ 20055c30ecadSmrg $debug_cmd 2006dc99b369Smrg 20075c30ecadSmrg # Display all warnings if -W was not given. 20085c30ecadSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009dc99b369Smrg 20105c30ecadSmrg func_run_hooks func_validate_options ${1+"$@"} 20115c30ecadSmrg func_propagate_result func_run_hooks func_validate_options 2012dc99b369Smrg 20135c30ecadSmrg # Bail if the options were screwed! 20145c30ecadSmrg $exit_cmd $EXIT_FAILURE 20155eefee25Smacallan} 20165eefee25Smacallan 20175eefee25Smacallan 2018dc99b369Smrg 20195c30ecadSmrg## ----------------- ## 20205c30ecadSmrg## Helper functions. ## 20215c30ecadSmrg## ----------------- ## 20225eefee25Smacallan 20235c30ecadSmrg# This section contains the helper functions used by the rest of the 20245c30ecadSmrg# hookable option parser framework in ascii-betical order. 20255c30ecadSmrg 20265c30ecadSmrg 20275c30ecadSmrg# func_fatal_help ARG... 20285c30ecadSmrg# ---------------------- 20295c30ecadSmrg# Echo program name prefixed message to standard error, followed by 20305c30ecadSmrg# a help hint, and exit. 20315c30ecadSmrgfunc_fatal_help () 20325eefee25Smacallan{ 20335c30ecadSmrg $debug_cmd 2034dc99b369Smrg 20355c30ecadSmrg eval \$ECHO \""Usage: $usage"\" 20365c30ecadSmrg eval \$ECHO \""$fatal_help"\" 20375c30ecadSmrg func_error ${1+"$@"} 20385c30ecadSmrg exit $EXIT_FAILURE 20395eefee25Smacallan} 20405eefee25Smacallan 20415c30ecadSmrg 20425c30ecadSmrg# func_help 20435c30ecadSmrg# --------- 20445c30ecadSmrg# Echo long help message to standard output and exit. 2045dc99b369Smrgfunc_help () 20465eefee25Smacallan{ 20475c30ecadSmrg $debug_cmd 20485c30ecadSmrg 20495c30ecadSmrg func_usage_message 20505c30ecadSmrg $ECHO "$long_help_message" 20515c30ecadSmrg exit 0 2052dc99b369Smrg} 20535eefee25Smacallan 20545c30ecadSmrg 20555c30ecadSmrg# func_missing_arg ARGNAME 20565c30ecadSmrg# ------------------------ 2057dc99b369Smrg# Echo program name prefixed message to standard error and set global 2058dc99b369Smrg# exit_cmd. 2059dc99b369Smrgfunc_missing_arg () 2060dc99b369Smrg{ 20615c30ecadSmrg $debug_cmd 20625eefee25Smacallan 20635c30ecadSmrg func_error "Missing argument for '$1'." 2064dc99b369Smrg exit_cmd=exit 20655eefee25Smacallan} 20665eefee25Smacallan 20675eefee25Smacallan 20685c30ecadSmrg# func_split_equals STRING 20695c30ecadSmrg# ------------------------ 20705c30ecadSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20715c30ecadSmrg# after splitting STRING at the '=' sign. 20725c30ecadSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20735c30ecadSmrg && (eval 'x=a/b/c; 20745c30ecadSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20755c30ecadSmrg && _G_HAVE_XSI_OPS=yes 20765c30ecadSmrg 20775c30ecadSmrgif test yes = "$_G_HAVE_XSI_OPS" 20785c30ecadSmrgthen 20795c30ecadSmrg # This is an XSI compatible shell, allowing a faster implementation... 20805c30ecadSmrg eval 'func_split_equals () 20815c30ecadSmrg { 20825c30ecadSmrg $debug_cmd 20835c30ecadSmrg 20845c30ecadSmrg func_split_equals_lhs=${1%%=*} 20855c30ecadSmrg func_split_equals_rhs=${1#*=} 20865c30ecadSmrg if test "x$func_split_equals_lhs" = "x$1"; then 20875c30ecadSmrg func_split_equals_rhs= 20885c30ecadSmrg fi 20895c30ecadSmrg }' 20905c30ecadSmrgelse 20915c30ecadSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20925c30ecadSmrg func_split_equals () 20935c30ecadSmrg { 20945c30ecadSmrg $debug_cmd 20955c30ecadSmrg 20965c30ecadSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20975c30ecadSmrg func_split_equals_rhs= 20985c30ecadSmrg test "x$func_split_equals_lhs=" = "x$1" \ 20995c30ecadSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21005c30ecadSmrg } 21015c30ecadSmrgfi #func_split_equals 21025c30ecadSmrg 21035c30ecadSmrg 21045c30ecadSmrg# func_split_short_opt SHORTOPT 21055c30ecadSmrg# ----------------------------- 2106dc99b369Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107dc99b369Smrg# variables after splitting SHORTOPT after the 2nd character. 21085c30ecadSmrgif test yes = "$_G_HAVE_XSI_OPS" 21095c30ecadSmrgthen 21105c30ecadSmrg # This is an XSI compatible shell, allowing a faster implementation... 21115c30ecadSmrg eval 'func_split_short_opt () 21125c30ecadSmrg { 21135c30ecadSmrg $debug_cmd 21145c30ecadSmrg 21155c30ecadSmrg func_split_short_opt_arg=${1#??} 21165c30ecadSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21175c30ecadSmrg }' 21185c30ecadSmrgelse 21195c30ecadSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21205c30ecadSmrg func_split_short_opt () 21215c30ecadSmrg { 21225c30ecadSmrg $debug_cmd 21235c30ecadSmrg 21245c30ecadSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21255c30ecadSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21265c30ecadSmrg } 21275c30ecadSmrgfi #func_split_short_opt 21285c30ecadSmrg 21295c30ecadSmrg 21305c30ecadSmrg# func_usage 21315c30ecadSmrg# ---------- 21325c30ecadSmrg# Echo short help message to standard output and exit. 21335c30ecadSmrgfunc_usage () 2134dc99b369Smrg{ 21355c30ecadSmrg $debug_cmd 2136dc99b369Smrg 21375c30ecadSmrg func_usage_message 21385c30ecadSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21395c30ecadSmrg exit 0 21405c30ecadSmrg} 21415eefee25Smacallan 21425eefee25Smacallan 21435c30ecadSmrg# func_usage_message 21445c30ecadSmrg# ------------------ 21455c30ecadSmrg# Echo short help message to standard output. 21465c30ecadSmrgfunc_usage_message () 2147dc99b369Smrg{ 21485c30ecadSmrg $debug_cmd 21495eefee25Smacallan 21505c30ecadSmrg eval \$ECHO \""Usage: $usage"\" 21515c30ecadSmrg echo 21525c30ecadSmrg $SED -n 's|^# || 21535c30ecadSmrg /^Written by/{ 21545c30ecadSmrg x;p;x 21555c30ecadSmrg } 21565c30ecadSmrg h 21575c30ecadSmrg /^Written by/q' < "$progpath" 21585c30ecadSmrg echo 21595c30ecadSmrg eval \$ECHO \""$usage_message"\" 21605c30ecadSmrg} 21615eefee25Smacallan 21625eefee25Smacallan 21635c30ecadSmrg# func_version 21645c30ecadSmrg# ------------ 21655c30ecadSmrg# Echo version message to standard output and exit. 21665c30ecadSmrg# The version message is extracted from the calling file's header 21675c30ecadSmrg# comments, with leading '# ' stripped: 21685c30ecadSmrg# 1. First display the progname and version 21695c30ecadSmrg# 2. Followed by the header comment line matching /^# Written by / 21705c30ecadSmrg# 3. Then a blank line followed by the first following line matching 21715c30ecadSmrg# /^# Copyright / 21725c30ecadSmrg# 4. Immediately followed by any lines between the previous matches, 21735c30ecadSmrg# except lines preceding the intervening completely blank line. 21745c30ecadSmrg# For example, see the header comments of this file. 21755c30ecadSmrgfunc_version () 21765c30ecadSmrg{ 21775c30ecadSmrg $debug_cmd 21785eefee25Smacallan 21795c30ecadSmrg printf '%s\n' "$progname $scriptversion" 21805c30ecadSmrg $SED -n ' 21815c30ecadSmrg /^# Written by /!b 21825c30ecadSmrg s|^# ||; p; n 21835eefee25Smacallan 21845c30ecadSmrg :fwd2blnk 21855c30ecadSmrg /./ { 21865c30ecadSmrg n 21875c30ecadSmrg b fwd2blnk 21885c30ecadSmrg } 21895c30ecadSmrg p; n 21905c30ecadSmrg 21915c30ecadSmrg :holdwrnt 21925c30ecadSmrg s|^# || 21935c30ecadSmrg s|^# *$|| 21945c30ecadSmrg /^Copyright /!{ 21955c30ecadSmrg /./H 21965c30ecadSmrg n 21975c30ecadSmrg b holdwrnt 21985c30ecadSmrg } 219962ab96baSmrg 22005c30ecadSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22015c30ecadSmrg G 22025c30ecadSmrg s|\(\n\)\n*|\1|g 22035c30ecadSmrg p; q' < "$progpath" 22045eefee25Smacallan 22055c30ecadSmrg exit $? 22065c30ecadSmrg} 2207dc99b369Smrg 2208dc99b369Smrg 22095c30ecadSmrg# Local variables: 22105c30ecadSmrg# mode: shell-script 22115c30ecadSmrg# sh-indentation: 2 22125c30ecadSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 22135c30ecadSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22145c30ecadSmrg# time-stamp-time-zone: "UTC" 22155c30ecadSmrg# End: 2216dc99b369Smrg 22175c30ecadSmrg# Set a version string. 22185c30ecadSmrgscriptversion='(GNU libtool) 2.4.7' 2219dc99b369Smrg 22205c30ecadSmrg 22215c30ecadSmrg# func_echo ARG... 22225c30ecadSmrg# ---------------- 22235c30ecadSmrg# Libtool also displays the current mode in messages, so override 22245c30ecadSmrg# funclib.sh func_echo with this custom definition. 22255c30ecadSmrgfunc_echo () 2226dc99b369Smrg{ 22275c30ecadSmrg $debug_cmd 2228dc99b369Smrg 22295c30ecadSmrg _G_message=$* 2230dc99b369Smrg 22315c30ecadSmrg func_echo_IFS=$IFS 22325c30ecadSmrg IFS=$nl 22335c30ecadSmrg for _G_line in $_G_message; do 22345c30ecadSmrg IFS=$func_echo_IFS 22355c30ecadSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22365c30ecadSmrg done 22375c30ecadSmrg IFS=$func_echo_IFS 22385c30ecadSmrg} 2239dc99b369Smrg 2240dc99b369Smrg 22415c30ecadSmrg# func_warning ARG... 22425c30ecadSmrg# ------------------- 22435c30ecadSmrg# Libtool warnings are not categorized, so override funclib.sh 22445c30ecadSmrg# func_warning with this simpler definition. 22455c30ecadSmrgfunc_warning () 2246dc99b369Smrg{ 22475c30ecadSmrg $debug_cmd 2248dc99b369Smrg 22495c30ecadSmrg $warning_func ${1+"$@"} 22505c30ecadSmrg} 2251dc99b369Smrg 2252dc99b369Smrg 22535c30ecadSmrg## ---------------- ## 22545c30ecadSmrg## Options parsing. ## 22555c30ecadSmrg## ---------------- ## 22565c30ecadSmrg 22575c30ecadSmrg# Hook in the functions to make sure our own options are parsed during 22585c30ecadSmrg# the option parsing loop. 22595c30ecadSmrg 22605c30ecadSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22615c30ecadSmrg 22625c30ecadSmrg# Short help message in response to '-h'. 22635c30ecadSmrgusage_message="Options: 22645c30ecadSmrg --config show all configuration variables 22655c30ecadSmrg --debug enable verbose shell tracing 22665c30ecadSmrg -n, --dry-run display commands without modifying any files 22675c30ecadSmrg --features display basic configuration information and exit 22685c30ecadSmrg --mode=MODE use operation mode MODE 22695c30ecadSmrg --no-warnings equivalent to '-Wnone' 22705c30ecadSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22715c30ecadSmrg --quiet, --silent don't print informational messages 22725c30ecadSmrg --tag=TAG use configuration variables from tag TAG 22735c30ecadSmrg -v, --verbose print more informational messages than default 22745c30ecadSmrg --version print version information 22755c30ecadSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22765c30ecadSmrg -h, --help, --help-all print short, long, or detailed help message 22775c30ecadSmrg" 2278dc99b369Smrg 22795c30ecadSmrg# Additional text appended to 'usage_message' in response to '--help'. 22805c30ecadSmrgfunc_help () 2281dc99b369Smrg{ 22825c30ecadSmrg $debug_cmd 22835c30ecadSmrg 22845c30ecadSmrg func_usage_message 22855c30ecadSmrg $ECHO "$long_help_message 22865c30ecadSmrg 22875c30ecadSmrgMODE must be one of the following: 22885c30ecadSmrg 22895c30ecadSmrg clean remove files from the build directory 22905c30ecadSmrg compile compile a source file into a libtool object 22915c30ecadSmrg execute automatically set library path, then run a program 22925c30ecadSmrg finish complete the installation of libtool libraries 22935c30ecadSmrg install install libraries or executables 22945c30ecadSmrg link create a library or an executable 22955c30ecadSmrg uninstall remove libraries from an installed directory 22965c30ecadSmrg 22975c30ecadSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22985c30ecadSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22995c30ecadSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23005c30ecadSmrg 23015c30ecadSmrgWhen reporting a bug, please describe a test case to reproduce it and 23025c30ecadSmrginclude the following information: 23035c30ecadSmrg 23045c30ecadSmrg host-triplet: $host 23055c30ecadSmrg shell: $SHELL 23065c30ecadSmrg compiler: $LTCC 23075c30ecadSmrg compiler flags: $LTCFLAGS 23085c30ecadSmrg linker: $LD (gnu? $with_gnu_ld) 23095c30ecadSmrg version: $progname (GNU libtool) 2.4.7 23105c30ecadSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23115c30ecadSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23125c30ecadSmrg 23135c30ecadSmrgReport bugs to <bug-libtool@gnu.org>. 23145c30ecadSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23155c30ecadSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23165c30ecadSmrg exit 0 23175c30ecadSmrg} 23185c30ecadSmrg 2319dc99b369Smrg 23205c30ecadSmrg# func_lo2o OBJECT-NAME 23215c30ecadSmrg# --------------------- 23225c30ecadSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23235c30ecadSmrg# object suffix. 2324dc99b369Smrg 23255c30ecadSmrglo2o=s/\\.lo\$/.$objext/ 23265c30ecadSmrgo2lo=s/\\.$objext\$/.lo/ 23275c30ecadSmrg 23285c30ecadSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23295c30ecadSmrg eval 'func_lo2o () 23305c30ecadSmrg { 23315c30ecadSmrg case $1 in 23325c30ecadSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23335c30ecadSmrg * ) func_lo2o_result=$1 ;; 23345c30ecadSmrg esac 23355c30ecadSmrg }' 23365c30ecadSmrg 23375c30ecadSmrg # func_xform LIBOBJ-OR-SOURCE 23385c30ecadSmrg # --------------------------- 23395c30ecadSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23405c30ecadSmrg # suffix to a '.lo' libtool-object suffix. 23415c30ecadSmrg eval 'func_xform () 23425c30ecadSmrg { 23435c30ecadSmrg func_xform_result=${1%.*}.lo 23445c30ecadSmrg }' 23455c30ecadSmrgelse 23465c30ecadSmrg # ...otherwise fall back to using sed. 23475c30ecadSmrg func_lo2o () 23485c30ecadSmrg { 23495c30ecadSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23505c30ecadSmrg } 23515c30ecadSmrg 23525c30ecadSmrg func_xform () 23535c30ecadSmrg { 23545c30ecadSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23555c30ecadSmrg } 23565c30ecadSmrgfi 23575c30ecadSmrg 23585c30ecadSmrg 23595c30ecadSmrg# func_fatal_configuration ARG... 23605c30ecadSmrg# ------------------------------- 2361dc99b369Smrg# Echo program name prefixed message to standard error, followed by 2362dc99b369Smrg# a configuration failure hint, and exit. 2363dc99b369Smrgfunc_fatal_configuration () 2364dc99b369Smrg{ 23655c30ecadSmrg func_fatal_error ${1+"$@"} \ 23665c30ecadSmrg "See the $PACKAGE documentation for more information." \ 23675c30ecadSmrg "Fatal configuration error." 2368dc99b369Smrg} 2369dc99b369Smrg 2370dc99b369Smrg 2371dc99b369Smrg# func_config 23725c30ecadSmrg# ----------- 2373dc99b369Smrg# Display the configuration for all the tags in this script. 2374dc99b369Smrgfunc_config () 2375dc99b369Smrg{ 2376dc99b369Smrg re_begincf='^# ### BEGIN LIBTOOL' 2377dc99b369Smrg re_endcf='^# ### END LIBTOOL' 2378dc99b369Smrg 2379dc99b369Smrg # Default configuration. 2380dc99b369Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381dc99b369Smrg 23825eefee25Smacallan # Now print the configurations for the tags. 23835eefee25Smacallan for tagname in $taglist; do 2384dc99b369Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23855eefee25Smacallan done 23865eefee25Smacallan 2387dc99b369Smrg exit $? 2388dc99b369Smrg} 23895eefee25Smacallan 23905c30ecadSmrg 2391dc99b369Smrg# func_features 23925c30ecadSmrg# ------------- 2393dc99b369Smrg# Display the features supported by this script. 2394dc99b369Smrgfunc_features () 2395dc99b369Smrg{ 2396dc99b369Smrg echo "host: $host" 23975c30ecadSmrg if test yes = "$build_libtool_libs"; then 2398dc99b369Smrg echo "enable shared libraries" 23995eefee25Smacallan else 2400dc99b369Smrg echo "disable shared libraries" 24015eefee25Smacallan fi 24025c30ecadSmrg if test yes = "$build_old_libs"; then 2403dc99b369Smrg echo "enable static libraries" 24045eefee25Smacallan else 2405dc99b369Smrg echo "disable static libraries" 24065eefee25Smacallan fi 24075eefee25Smacallan 2408dc99b369Smrg exit $? 2409dc99b369Smrg} 24105eefee25Smacallan 24115c30ecadSmrg 24125c30ecadSmrg# func_enable_tag TAGNAME 24135c30ecadSmrg# ----------------------- 2414dc99b369Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415dc99b369Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416dc99b369Smrg# variable here. 2417dc99b369Smrgfunc_enable_tag () 2418dc99b369Smrg{ 24195c30ecadSmrg # Global variable: 24205c30ecadSmrg tagname=$1 24215eefee25Smacallan 24225c30ecadSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24235c30ecadSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24245c30ecadSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24255eefee25Smacallan 24265c30ecadSmrg # Validate tagname. 24275c30ecadSmrg case $tagname in 24285c30ecadSmrg *[!-_A-Za-z0-9,/]*) 24295c30ecadSmrg func_fatal_error "invalid tag name: $tagname" 24305c30ecadSmrg ;; 24315c30ecadSmrg esac 24325eefee25Smacallan 24335c30ecadSmrg # Don't test for the "default" C tag, as we know it's 24345c30ecadSmrg # there but not specially marked. 24355c30ecadSmrg case $tagname in 24365c30ecadSmrg CC) ;; 2437dc99b369Smrg *) 24385c30ecadSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24395c30ecadSmrg taglist="$taglist $tagname" 24405c30ecadSmrg 24415c30ecadSmrg # Evaluate the configuration. Be careful to quote the path 24425c30ecadSmrg # and the sed script, to avoid splitting on whitespace, but 24435c30ecadSmrg # also don't use non-portable quotes within backquotes within 24445c30ecadSmrg # quotes we have to do it in 2 steps: 24455c30ecadSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24465c30ecadSmrg eval "$extractedcf" 24475c30ecadSmrg else 24485c30ecadSmrg func_error "ignoring unknown tag $tagname" 24495c30ecadSmrg fi 24505c30ecadSmrg ;; 24515c30ecadSmrg esac 2452dc99b369Smrg} 24535eefee25Smacallan 24545c30ecadSmrg 2455dc99b369Smrg# func_check_version_match 24565c30ecadSmrg# ------------------------ 2457dc99b369Smrg# Ensure that we are using m4 macros, and libtool script from the same 2458dc99b369Smrg# release of libtool. 2459dc99b369Smrgfunc_check_version_match () 2460dc99b369Smrg{ 24615c30ecadSmrg if test "$package_revision" != "$macro_revision"; then 24625c30ecadSmrg if test "$VERSION" != "$macro_version"; then 24635c30ecadSmrg if test -z "$macro_version"; then 24645c30ecadSmrg cat >&2 <<_LT_EOF 2465dc99b369Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466dc99b369Smrg$progname: definition of this LT_INIT comes from an older release. 2467dc99b369Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468dc99b369Smrg$progname: and run autoconf again. 2469dc99b369Smrg_LT_EOF 24705c30ecadSmrg else 24715c30ecadSmrg cat >&2 <<_LT_EOF 2472dc99b369Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473dc99b369Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474dc99b369Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475dc99b369Smrg$progname: and run autoconf again. 2476dc99b369Smrg_LT_EOF 24775c30ecadSmrg fi 24785c30ecadSmrg else 24795c30ecadSmrg cat >&2 <<_LT_EOF 2480dc99b369Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481dc99b369Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482dc99b369Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483dc99b369Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484dc99b369Smrg_LT_EOF 24855c30ecadSmrg fi 24865eefee25Smacallan 24875c30ecadSmrg exit $EXIT_MISMATCH 24885c30ecadSmrg fi 2489dc99b369Smrg} 24905eefee25Smacallan 24915eefee25Smacallan 24925c30ecadSmrg# libtool_options_prep [ARG]... 24935c30ecadSmrg# ----------------------------- 24945c30ecadSmrg# Preparation for options parsed by libtool. 24955c30ecadSmrglibtool_options_prep () 24965c30ecadSmrg{ 24975c30ecadSmrg $debug_mode 24985eefee25Smacallan 24995c30ecadSmrg # Option defaults: 25005c30ecadSmrg opt_config=false 25015c30ecadSmrg opt_dlopen= 25025c30ecadSmrg opt_dry_run=false 25035c30ecadSmrg opt_help=false 25045c30ecadSmrg opt_mode= 25055c30ecadSmrg opt_preserve_dup_deps=false 25065c30ecadSmrg opt_quiet=false 25075eefee25Smacallan 25085c30ecadSmrg nonopt= 25095c30ecadSmrg preserve_args= 25105eefee25Smacallan 25115c30ecadSmrg _G_rc_lt_options_prep=: 2512dc99b369Smrg 25135c30ecadSmrg # Shorthand for --mode=foo, only valid as the first argument 25145c30ecadSmrg case $1 in 25155c30ecadSmrg clean|clea|cle|cl) 25165c30ecadSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25175c30ecadSmrg ;; 25185c30ecadSmrg compile|compil|compi|comp|com|co|c) 25195c30ecadSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25205c30ecadSmrg ;; 25215c30ecadSmrg execute|execut|execu|exec|exe|ex|e) 25225c30ecadSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25235c30ecadSmrg ;; 25245c30ecadSmrg finish|finis|fini|fin|fi|f) 25255c30ecadSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25265c30ecadSmrg ;; 25275c30ecadSmrg install|instal|insta|inst|ins|in|i) 25285c30ecadSmrg shift; set dummy --mode install ${1+"$@"}; shift 25295c30ecadSmrg ;; 25305c30ecadSmrg link|lin|li|l) 25315c30ecadSmrg shift; set dummy --mode link ${1+"$@"}; shift 25325c30ecadSmrg ;; 25335c30ecadSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25345c30ecadSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25355c30ecadSmrg ;; 25365c30ecadSmrg *) 25375c30ecadSmrg _G_rc_lt_options_prep=false 25385c30ecadSmrg ;; 25395eefee25Smacallan esac 25405eefee25Smacallan 25415c30ecadSmrg if $_G_rc_lt_options_prep; then 25425c30ecadSmrg # Pass back the list of options. 25435c30ecadSmrg func_quote eval ${1+"$@"} 25445c30ecadSmrg libtool_options_prep_result=$func_quote_result 25455c30ecadSmrg fi 25465c30ecadSmrg} 25475c30ecadSmrgfunc_add_hook func_options_prep libtool_options_prep 2548dc99b369Smrg 25495eefee25Smacallan 25505c30ecadSmrg# libtool_parse_options [ARG]... 25515c30ecadSmrg# --------------------------------- 25525c30ecadSmrg# Provide handling for libtool specific options. 25535c30ecadSmrglibtool_parse_options () 25545c30ecadSmrg{ 25555c30ecadSmrg $debug_cmd 25565eefee25Smacallan 25575c30ecadSmrg _G_rc_lt_parse_options=false 25585eefee25Smacallan 25595c30ecadSmrg # Perform our own loop to consume as many options as possible in 25605c30ecadSmrg # each iteration. 25615c30ecadSmrg while test $# -gt 0; do 25625c30ecadSmrg _G_match_lt_parse_options=: 25635c30ecadSmrg _G_opt=$1 25645c30ecadSmrg shift 25655c30ecadSmrg case $_G_opt in 25665c30ecadSmrg --dry-run|--dryrun|-n) 25675c30ecadSmrg opt_dry_run=: 25685c30ecadSmrg ;; 25695c30ecadSmrg 25705c30ecadSmrg --config) func_config ;; 25715c30ecadSmrg 25725c30ecadSmrg --dlopen|-dlopen) 25735c30ecadSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25745c30ecadSmrg}$1" 25755c30ecadSmrg shift 25765c30ecadSmrg ;; 25775c30ecadSmrg 25785c30ecadSmrg --preserve-dup-deps) 25795c30ecadSmrg opt_preserve_dup_deps=: ;; 25805c30ecadSmrg 25815c30ecadSmrg --features) func_features ;; 25825c30ecadSmrg 25835c30ecadSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25845c30ecadSmrg 25855c30ecadSmrg --help) opt_help=: ;; 25865c30ecadSmrg 25875c30ecadSmrg --help-all) opt_help=': help-all' ;; 25885c30ecadSmrg 25895c30ecadSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25905c30ecadSmrg opt_mode=$1 25915c30ecadSmrg case $1 in 25925c30ecadSmrg # Valid mode arguments: 25935c30ecadSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25945c30ecadSmrg 25955c30ecadSmrg # Catch anything else as an error 25965c30ecadSmrg *) func_error "invalid argument for $_G_opt" 25975c30ecadSmrg exit_cmd=exit 25985c30ecadSmrg break 25995c30ecadSmrg ;; 26005c30ecadSmrg esac 26015c30ecadSmrg shift 26025c30ecadSmrg ;; 26035c30ecadSmrg 26045c30ecadSmrg --no-silent|--no-quiet) 26055c30ecadSmrg opt_quiet=false 26065c30ecadSmrg func_append preserve_args " $_G_opt" 26075c30ecadSmrg ;; 26085c30ecadSmrg 26095c30ecadSmrg --no-warnings|--no-warning|--no-warn) 26105c30ecadSmrg opt_warning=false 26115c30ecadSmrg func_append preserve_args " $_G_opt" 26125c30ecadSmrg ;; 26135c30ecadSmrg 26145c30ecadSmrg --no-verbose) 26155c30ecadSmrg opt_verbose=false 26165c30ecadSmrg func_append preserve_args " $_G_opt" 26175c30ecadSmrg ;; 26185c30ecadSmrg 26195c30ecadSmrg --silent|--quiet) 26205c30ecadSmrg opt_quiet=: 26215c30ecadSmrg opt_verbose=false 26225c30ecadSmrg func_append preserve_args " $_G_opt" 26235c30ecadSmrg ;; 26245c30ecadSmrg 26255c30ecadSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26265c30ecadSmrg opt_tag=$1 26275c30ecadSmrg func_append preserve_args " $_G_opt $1" 26285c30ecadSmrg func_enable_tag "$1" 26295c30ecadSmrg shift 26305c30ecadSmrg ;; 26315c30ecadSmrg 26325c30ecadSmrg --verbose|-v) opt_quiet=false 26335c30ecadSmrg opt_verbose=: 26345c30ecadSmrg func_append preserve_args " $_G_opt" 26355c30ecadSmrg ;; 26365c30ecadSmrg 26375c30ecadSmrg # An option not handled by this hook function: 26385c30ecadSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26395c30ecadSmrg _G_match_lt_parse_options=false 26405c30ecadSmrg break 26415c30ecadSmrg ;; 26425c30ecadSmrg esac 26435c30ecadSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26445c30ecadSmrg done 26455eefee25Smacallan 26465c30ecadSmrg if $_G_rc_lt_parse_options; then 26475c30ecadSmrg # save modified positional parameters for caller 26485c30ecadSmrg func_quote eval ${1+"$@"} 26495c30ecadSmrg libtool_parse_options_result=$func_quote_result 2650dc99b369Smrg fi 26515c30ecadSmrg} 26525c30ecadSmrgfunc_add_hook func_parse_options libtool_parse_options 26535eefee25Smacallan 26545eefee25Smacallan 26555c30ecadSmrg 26565c30ecadSmrg# libtool_validate_options [ARG]... 26575c30ecadSmrg# --------------------------------- 26585c30ecadSmrg# Perform any sanity checks on option settings and/or unconsumed 26595c30ecadSmrg# arguments. 26605c30ecadSmrglibtool_validate_options () 26615c30ecadSmrg{ 26625c30ecadSmrg # save first non-option argument 26635c30ecadSmrg if test 0 -lt $#; then 26645c30ecadSmrg nonopt=$1 26655c30ecadSmrg shift 2666dc99b369Smrg fi 26675eefee25Smacallan 26685c30ecadSmrg # preserve --debug 26695c30ecadSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26705c30ecadSmrg 26715c30ecadSmrg case $host in 26725c30ecadSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26735c30ecadSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26745c30ecadSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26755c30ecadSmrg # don't eliminate duplications in $postdeps and $predeps 26765c30ecadSmrg opt_duplicate_compiler_generated_deps=: 26775c30ecadSmrg ;; 26785c30ecadSmrg *) 26795c30ecadSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26805c30ecadSmrg ;; 26815c30ecadSmrg esac 26825eefee25Smacallan 26835c30ecadSmrg $opt_help || { 26845c30ecadSmrg # Sanity checks first: 26855c30ecadSmrg func_check_version_match 26865eefee25Smacallan 26875c30ecadSmrg test yes != "$build_libtool_libs" \ 26885c30ecadSmrg && test yes != "$build_old_libs" \ 26895c30ecadSmrg && func_fatal_configuration "not configured to build any kind of library" 26905c30ecadSmrg 26915c30ecadSmrg # Darwin sucks 26925c30ecadSmrg eval std_shrext=\"$shrext_cmds\" 26935c30ecadSmrg 26945c30ecadSmrg # Only execute mode is allowed to have -dlopen flags. 26955c30ecadSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26965c30ecadSmrg func_error "unrecognized option '-dlopen'" 26975c30ecadSmrg $ECHO "$help" 1>&2 26985c30ecadSmrg exit $EXIT_FAILURE 26995c30ecadSmrg fi 27005c30ecadSmrg 27015c30ecadSmrg # Change the help message to a mode-specific one. 27025c30ecadSmrg generic_help=$help 27035c30ecadSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27045c30ecadSmrg } 27055c30ecadSmrg 27065c30ecadSmrg # Pass back the unparsed argument list 27075c30ecadSmrg func_quote eval ${1+"$@"} 27085c30ecadSmrg libtool_validate_options_result=$func_quote_result 2709dc99b369Smrg} 27105c30ecadSmrgfunc_add_hook func_validate_options libtool_validate_options 27115eefee25Smacallan 27125eefee25Smacallan 27135c30ecadSmrg# Process options as early as possible so that --help and --version 27145c30ecadSmrg# can return quickly. 27155c30ecadSmrgfunc_options ${1+"$@"} 27165c30ecadSmrgeval set dummy "$func_options_result"; shift 27175c30ecadSmrg 27185eefee25Smacallan 27195eefee25Smacallan 2720dc99b369Smrg## ----------- ## 2721dc99b369Smrg## Main. ## 2722dc99b369Smrg## ----------- ## 27235eefee25Smacallan 27245c30ecadSmrgmagic='%%%MAGIC variable%%%' 27255c30ecadSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27265c30ecadSmrg 27275c30ecadSmrg# Global variables. 27285c30ecadSmrgextracted_archives= 27295c30ecadSmrgextracted_serial=0 27305c30ecadSmrg 27315c30ecadSmrg# If this variable is set in any of the actions, the command in it 27325c30ecadSmrg# will be execed at the end. This prevents here-documents from being 27335c30ecadSmrg# left over by shells. 27345c30ecadSmrgexec_cmd= 27355c30ecadSmrg 27365c30ecadSmrg 27375c30ecadSmrg# A function that is used when there is no print builtin or printf. 27385c30ecadSmrgfunc_fallback_echo () 27395c30ecadSmrg{ 27405c30ecadSmrg eval 'cat <<_LTECHO_EOF 27415c30ecadSmrg$1 27425c30ecadSmrg_LTECHO_EOF' 27435c30ecadSmrg} 27445c30ecadSmrg 27455c30ecadSmrg# func_generated_by_libtool 27465c30ecadSmrg# True iff stdin has been generated by Libtool. This function is only 27475c30ecadSmrg# a basic sanity check; it will hardly flush out determined imposters. 27485c30ecadSmrgfunc_generated_by_libtool_p () 27495c30ecadSmrg{ 27505c30ecadSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27515c30ecadSmrg} 27525c30ecadSmrg 2753dc99b369Smrg# func_lalib_p file 27545c30ecadSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755dc99b369Smrg# This function is only a basic sanity check; it will hardly flush out 2756dc99b369Smrg# determined imposters. 2757dc99b369Smrgfunc_lalib_p () 2758dc99b369Smrg{ 2759dc99b369Smrg test -f "$1" && 27605c30ecadSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761dc99b369Smrg} 27625eefee25Smacallan 2763dc99b369Smrg# func_lalib_unsafe_p file 27645c30ecadSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765dc99b369Smrg# This function implements the same check as func_lalib_p without 2766dc99b369Smrg# resorting to external programs. To this end, it redirects stdin and 2767dc99b369Smrg# closes it afterwards, without saving the original file descriptor. 2768dc99b369Smrg# As a safety measure, use it only where a negative result would be 27695c30ecadSmrg# fatal anyway. Works if 'file' does not exist. 2770dc99b369Smrgfunc_lalib_unsafe_p () 2771dc99b369Smrg{ 2772dc99b369Smrg lalib_p=no 2773dc99b369Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774dc99b369Smrg for lalib_p_l in 1 2 3 4 2775dc99b369Smrg do 2776dc99b369Smrg read lalib_p_line 27775c30ecadSmrg case $lalib_p_line in 2778dc99b369Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779dc99b369Smrg esac 2780dc99b369Smrg done 2781dc99b369Smrg exec 0<&5 5<&- 2782dc99b369Smrg fi 27835c30ecadSmrg test yes = "$lalib_p" 2784dc99b369Smrg} 27855eefee25Smacallan 2786dc99b369Smrg# func_ltwrapper_script_p file 2787dc99b369Smrg# True iff FILE is a libtool wrapper script 2788dc99b369Smrg# This function is only a basic sanity check; it will hardly flush out 2789dc99b369Smrg# determined imposters. 2790dc99b369Smrgfunc_ltwrapper_script_p () 2791dc99b369Smrg{ 27925c30ecadSmrg test -f "$1" && 27935c30ecadSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794dc99b369Smrg} 27955eefee25Smacallan 2796dc99b369Smrg# func_ltwrapper_executable_p file 2797dc99b369Smrg# True iff FILE is a libtool wrapper executable 2798dc99b369Smrg# This function is only a basic sanity check; it will hardly flush out 2799dc99b369Smrg# determined imposters. 2800dc99b369Smrgfunc_ltwrapper_executable_p () 2801dc99b369Smrg{ 2802dc99b369Smrg func_ltwrapper_exec_suffix= 2803dc99b369Smrg case $1 in 2804dc99b369Smrg *.exe) ;; 2805dc99b369Smrg *) func_ltwrapper_exec_suffix=.exe ;; 28065eefee25Smacallan esac 2807dc99b369Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808dc99b369Smrg} 28095eefee25Smacallan 2810dc99b369Smrg# func_ltwrapper_scriptname file 2811dc99b369Smrg# Assumes file is an ltwrapper_executable 2812dc99b369Smrg# uses $file to determine the appropriate filename for a 2813dc99b369Smrg# temporary ltwrapper_script. 2814dc99b369Smrgfunc_ltwrapper_scriptname () 2815dc99b369Smrg{ 2816dc99b369Smrg func_dirname_and_basename "$1" "" "." 2817dc99b369Smrg func_stripname '' '.exe' "$func_basename_result" 28185c30ecadSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819dc99b369Smrg} 28205eefee25Smacallan 2821dc99b369Smrg# func_ltwrapper_p file 2822dc99b369Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2823dc99b369Smrg# This function is only a basic sanity check; it will hardly flush out 2824dc99b369Smrg# determined imposters. 2825dc99b369Smrgfunc_ltwrapper_p () 2826dc99b369Smrg{ 2827dc99b369Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828dc99b369Smrg} 28295eefee25Smacallan 28305eefee25Smacallan 2831dc99b369Smrg# func_execute_cmds commands fail_cmd 2832dc99b369Smrg# Execute tilde-delimited COMMANDS. 2833dc99b369Smrg# If FAIL_CMD is given, eval that upon failure. 2834dc99b369Smrg# FAIL_CMD may read-access the current command in variable CMD! 2835dc99b369Smrgfunc_execute_cmds () 2836dc99b369Smrg{ 28375c30ecadSmrg $debug_cmd 28385c30ecadSmrg 2839dc99b369Smrg save_ifs=$IFS; IFS='~' 2840dc99b369Smrg for cmd in $1; do 28415c30ecadSmrg IFS=$sp$nl 2842dc99b369Smrg eval cmd=\"$cmd\" 28435c30ecadSmrg IFS=$save_ifs 2844dc99b369Smrg func_show_eval "$cmd" "${2-:}" 28455eefee25Smacallan done 2846dc99b369Smrg IFS=$save_ifs 2847dc99b369Smrg} 28485eefee25Smacallan 28495eefee25Smacallan 2850dc99b369Smrg# func_source file 2851dc99b369Smrg# Source FILE, adding directory component if necessary. 2852dc99b369Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853dc99b369Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854dc99b369Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28555c30ecadSmrg# 'FILE.' does not work on cygwin managed mounts. 2856dc99b369Smrgfunc_source () 2857dc99b369Smrg{ 28585c30ecadSmrg $debug_cmd 28595c30ecadSmrg 2860dc99b369Smrg case $1 in 2861dc99b369Smrg */* | *\\*) . "$1" ;; 2862dc99b369Smrg *) . "./$1" ;; 2863dc99b369Smrg esac 2864dc99b369Smrg} 28655eefee25Smacallan 28665eefee25Smacallan 2867dc99b369Smrg# func_resolve_sysroot PATH 2868dc99b369Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2869dc99b369Smrg# func_resolve_sysroot_result 2870dc99b369Smrgfunc_resolve_sysroot () 2871dc99b369Smrg{ 2872dc99b369Smrg func_resolve_sysroot_result=$1 2873dc99b369Smrg case $func_resolve_sysroot_result in 2874dc99b369Smrg =*) 2875dc99b369Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876dc99b369Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877dc99b369Smrg ;; 2878dc99b369Smrg esac 2879dc99b369Smrg} 28805eefee25Smacallan 2881dc99b369Smrg# func_replace_sysroot PATH 2882dc99b369Smrg# If PATH begins with the sysroot, replace it with = and 2883dc99b369Smrg# store the result into func_replace_sysroot_result. 2884dc99b369Smrgfunc_replace_sysroot () 2885dc99b369Smrg{ 28865c30ecadSmrg case $lt_sysroot:$1 in 2887dc99b369Smrg ?*:"$lt_sysroot"*) 2888dc99b369Smrg func_stripname "$lt_sysroot" '' "$1" 28895c30ecadSmrg func_replace_sysroot_result='='$func_stripname_result 2890dc99b369Smrg ;; 2891dc99b369Smrg *) 2892dc99b369Smrg # Including no sysroot. 2893dc99b369Smrg func_replace_sysroot_result=$1 2894dc99b369Smrg ;; 2895dc99b369Smrg esac 2896dc99b369Smrg} 28975eefee25Smacallan 2898dc99b369Smrg# func_infer_tag arg 2899dc99b369Smrg# Infer tagged configuration to use if any are available and 2900dc99b369Smrg# if one wasn't chosen via the "--tag" command line option. 2901dc99b369Smrg# Only attempt this if the compiler in the base compile 2902dc99b369Smrg# command doesn't match the default compiler. 2903dc99b369Smrg# arg is usually of the form 'gcc ...' 2904dc99b369Smrgfunc_infer_tag () 2905dc99b369Smrg{ 29065c30ecadSmrg $debug_cmd 29075c30ecadSmrg 2908dc99b369Smrg if test -n "$available_tags" && test -z "$tagname"; then 2909dc99b369Smrg CC_quoted= 2910dc99b369Smrg for arg in $CC; do 2911dc99b369Smrg func_append_quoted CC_quoted "$arg" 2912dc99b369Smrg done 2913dc99b369Smrg CC_expanded=`func_echo_all $CC` 2914dc99b369Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915dc99b369Smrg case $@ in 2916dc99b369Smrg # Blanks in the command may have been stripped by the calling shell, 2917dc99b369Smrg # but not from the CC environment variable when configure was run. 2918dc99b369Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919dc99b369Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920dc99b369Smrg # Blanks at the start of $base_compile will cause this to fail 2921dc99b369Smrg # if we don't check for them as well. 2922dc99b369Smrg *) 2923dc99b369Smrg for z in $available_tags; do 2924dc99b369Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925dc99b369Smrg # Evaluate the configuration. 29265c30ecadSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927dc99b369Smrg CC_quoted= 2928dc99b369Smrg for arg in $CC; do 2929dc99b369Smrg # Double-quote args containing other shell metacharacters. 2930dc99b369Smrg func_append_quoted CC_quoted "$arg" 2931dc99b369Smrg done 2932dc99b369Smrg CC_expanded=`func_echo_all $CC` 2933dc99b369Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934dc99b369Smrg case "$@ " in 2935dc99b369Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936dc99b369Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937dc99b369Smrg # The compiler in the base compile command matches 2938dc99b369Smrg # the one in the tagged configuration. 2939dc99b369Smrg # Assume this is the tagged configuration we want. 2940dc99b369Smrg tagname=$z 2941dc99b369Smrg break 2942dc99b369Smrg ;; 2943dc99b369Smrg esac 2944dc99b369Smrg fi 2945dc99b369Smrg done 2946dc99b369Smrg # If $tagname still isn't set, then no tagged configuration 2947dc99b369Smrg # was found and let the user know that the "--tag" command 2948dc99b369Smrg # line option must be used. 2949dc99b369Smrg if test -z "$tagname"; then 2950dc99b369Smrg func_echo "unable to infer tagged configuration" 29515c30ecadSmrg func_fatal_error "specify a tag with '--tag'" 2952dc99b369Smrg# else 2953dc99b369Smrg# func_verbose "using $tagname tagged configuration" 2954dc99b369Smrg fi 2955dc99b369Smrg ;; 2956dc99b369Smrg esac 29575eefee25Smacallan fi 2958dc99b369Smrg} 29595eefee25Smacallan 29605eefee25Smacallan 29615eefee25Smacallan 2962dc99b369Smrg# func_write_libtool_object output_name pic_name nonpic_name 2963dc99b369Smrg# Create a libtool object file (analogous to a ".la" file), 2964dc99b369Smrg# but don't create it if we're doing a dry run. 2965dc99b369Smrgfunc_write_libtool_object () 2966dc99b369Smrg{ 29675c30ecadSmrg write_libobj=$1 29685c30ecadSmrg if test yes = "$build_libtool_libs"; then 29695c30ecadSmrg write_lobj=\'$2\' 2970dc99b369Smrg else 2971dc99b369Smrg write_lobj=none 29725eefee25Smacallan fi 29735eefee25Smacallan 29745c30ecadSmrg if test yes = "$build_old_libs"; then 29755c30ecadSmrg write_oldobj=\'$3\' 2976dc99b369Smrg else 2977dc99b369Smrg write_oldobj=none 29785eefee25Smacallan fi 29795eefee25Smacallan 2980dc99b369Smrg $opt_dry_run || { 2981dc99b369Smrg cat >${write_libobj}T <<EOF 2982dc99b369Smrg# $write_libobj - a libtool object file 29835c30ecadSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29845eefee25Smacallan# 29855eefee25Smacallan# Please DO NOT delete this file! 29865eefee25Smacallan# It is necessary for linking the library. 29875eefee25Smacallan 29885eefee25Smacallan# Name of the PIC object. 2989dc99b369Smrgpic_object=$write_lobj 29905eefee25Smacallan 2991dc99b369Smrg# Name of the non-PIC object 2992dc99b369Smrgnon_pic_object=$write_oldobj 29935eefee25Smacallan 2994dc99b369SmrgEOF 29955c30ecadSmrg $MV "${write_libobj}T" "$write_libobj" 2996dc99b369Smrg } 2997dc99b369Smrg} 29985eefee25Smacallan 29995eefee25Smacallan 3000dc99b369Smrg################################################## 3001dc99b369Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002dc99b369Smrg################################################## 30035eefee25Smacallan 3004dc99b369Smrg# func_convert_core_file_wine_to_w32 ARG 3005dc99b369Smrg# Helper function used by file name conversion functions when $build is *nix, 3006dc99b369Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007dc99b369Smrg# correctly configured wine environment available, with the winepath program 3008dc99b369Smrg# in $build's $PATH. 3009dc99b369Smrg# 3010dc99b369Smrg# ARG is the $build file name to be converted to w32 format. 3011dc99b369Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012dc99b369Smrg# be empty on error (or when ARG is empty) 3013dc99b369Smrgfunc_convert_core_file_wine_to_w32 () 3014dc99b369Smrg{ 30155c30ecadSmrg $debug_cmd 30165c30ecadSmrg 30175c30ecadSmrg func_convert_core_file_wine_to_w32_result=$1 3018dc99b369Smrg if test -n "$1"; then 3019dc99b369Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020dc99b369Smrg # are forced to check the contents of stdout. On the other hand, if the 3021dc99b369Smrg # command is not found, the shell will set an exit code of 127 and print 3022dc99b369Smrg # *an error message* to stdout. So we must check for both error code of 3023dc99b369Smrg # zero AND non-empty stdout, which explains the odd construction: 3024dc99b369Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30255c30ecadSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026dc99b369Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30275c30ecadSmrg $SED -e "$sed_naive_backslashify"` 3028dc99b369Smrg else 3029dc99b369Smrg func_convert_core_file_wine_to_w32_result= 3030dc99b369Smrg fi 3031dc99b369Smrg fi 3032dc99b369Smrg} 3033dc99b369Smrg# end: func_convert_core_file_wine_to_w32 30345eefee25Smacallan 3035dc99b369Smrg 3036dc99b369Smrg# func_convert_core_path_wine_to_w32 ARG 3037dc99b369Smrg# Helper function used by path conversion functions when $build is *nix, and 3038dc99b369Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039dc99b369Smrg# configured wine environment available, with the winepath program in $build's 3040dc99b369Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041dc99b369Smrg# 3042dc99b369Smrg# ARG is path to be converted from $build format to win32. 3043dc99b369Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044dc99b369Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045dc99b369Smrg# are convertible, then the result may be empty. 3046dc99b369Smrgfunc_convert_core_path_wine_to_w32 () 3047dc99b369Smrg{ 30485c30ecadSmrg $debug_cmd 30495c30ecadSmrg 3050dc99b369Smrg # unfortunately, winepath doesn't convert paths, only file names 30515c30ecadSmrg func_convert_core_path_wine_to_w32_result= 3052dc99b369Smrg if test -n "$1"; then 3053dc99b369Smrg oldIFS=$IFS 3054dc99b369Smrg IFS=: 3055dc99b369Smrg for func_convert_core_path_wine_to_w32_f in $1; do 3056dc99b369Smrg IFS=$oldIFS 3057dc99b369Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30585c30ecadSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059dc99b369Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30605c30ecadSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061dc99b369Smrg else 3062dc99b369Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063dc99b369Smrg fi 30645eefee25Smacallan fi 3065dc99b369Smrg done 3066dc99b369Smrg IFS=$oldIFS 3067dc99b369Smrg fi 3068dc99b369Smrg} 3069dc99b369Smrg# end: func_convert_core_path_wine_to_w32 3070dc99b369Smrg 3071dc99b369Smrg 3072dc99b369Smrg# func_cygpath ARGS... 3073dc99b369Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074dc99b369Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075dc99b369Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076dc99b369Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077dc99b369Smrg# file name or path is assumed to be in w32 format, as previously converted 3078dc99b369Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079dc99b369Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080dc99b369Smrg# Cygwin format). Returns an empty string on error. 3081dc99b369Smrg# 3082dc99b369Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083dc99b369Smrg# be converted. 3084dc99b369Smrg# 3085dc99b369Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086dc99b369Smrg# environment variable; do not put it in $PATH. 3087dc99b369Smrgfunc_cygpath () 3088dc99b369Smrg{ 30895c30ecadSmrg $debug_cmd 30905c30ecadSmrg 3091dc99b369Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092dc99b369Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093dc99b369Smrg if test "$?" -ne 0; then 3094dc99b369Smrg # on failure, ensure result is empty 3095dc99b369Smrg func_cygpath_result= 3096dc99b369Smrg fi 3097dc99b369Smrg else 3098dc99b369Smrg func_cygpath_result= 30995c30ecadSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100dc99b369Smrg fi 3101dc99b369Smrg} 3102dc99b369Smrg#end: func_cygpath 31035eefee25Smacallan 31045eefee25Smacallan 3105dc99b369Smrg# func_convert_core_msys_to_w32 ARG 3106dc99b369Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107dc99b369Smrg# result in func_convert_core_msys_to_w32_result. 3108dc99b369Smrgfunc_convert_core_msys_to_w32 () 3109dc99b369Smrg{ 31105c30ecadSmrg $debug_cmd 31115c30ecadSmrg 3112dc99b369Smrg # awkward: cmd appends spaces to result 3113dc99b369Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31145c30ecadSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115dc99b369Smrg} 3116dc99b369Smrg#end: func_convert_core_msys_to_w32 31175eefee25Smacallan 31185eefee25Smacallan 3119dc99b369Smrg# func_convert_file_check ARG1 ARG2 3120dc99b369Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121dc99b369Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122dc99b369Smrg# func_to_host_file_result to ARG1). 3123dc99b369Smrgfunc_convert_file_check () 3124dc99b369Smrg{ 31255c30ecadSmrg $debug_cmd 31265c30ecadSmrg 31275c30ecadSmrg if test -z "$2" && test -n "$1"; then 3128dc99b369Smrg func_error "Could not determine host file name corresponding to" 31295c30ecadSmrg func_error " '$1'" 3130dc99b369Smrg func_error "Continuing, but uninstalled executables may not work." 3131dc99b369Smrg # Fallback: 31325c30ecadSmrg func_to_host_file_result=$1 3133dc99b369Smrg fi 3134dc99b369Smrg} 3135dc99b369Smrg# end func_convert_file_check 31365eefee25Smacallan 31375eefee25Smacallan 3138dc99b369Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139dc99b369Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140dc99b369Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141dc99b369Smrg# func_to_host_file_result to a simplistic fallback value (see below). 3142dc99b369Smrgfunc_convert_path_check () 3143dc99b369Smrg{ 31445c30ecadSmrg $debug_cmd 31455c30ecadSmrg 3146dc99b369Smrg if test -z "$4" && test -n "$3"; then 3147dc99b369Smrg func_error "Could not determine the host path corresponding to" 31485c30ecadSmrg func_error " '$3'" 3149dc99b369Smrg func_error "Continuing, but uninstalled executables may not work." 3150dc99b369Smrg # Fallback. This is a deliberately simplistic "conversion" and 3151dc99b369Smrg # should not be "improved". See libtool.info. 3152dc99b369Smrg if test "x$1" != "x$2"; then 3153dc99b369Smrg lt_replace_pathsep_chars="s|$1|$2|g" 3154dc99b369Smrg func_to_host_path_result=`echo "$3" | 3155dc99b369Smrg $SED -e "$lt_replace_pathsep_chars"` 3156dc99b369Smrg else 31575c30ecadSmrg func_to_host_path_result=$3 3158dc99b369Smrg fi 3159dc99b369Smrg fi 3160dc99b369Smrg} 3161dc99b369Smrg# end func_convert_path_check 31625eefee25Smacallan 31635eefee25Smacallan 3164dc99b369Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165dc99b369Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166dc99b369Smrg# and appending REPL if ORIG matches BACKPAT. 3167dc99b369Smrgfunc_convert_path_front_back_pathsep () 3168dc99b369Smrg{ 31695c30ecadSmrg $debug_cmd 31705c30ecadSmrg 3171dc99b369Smrg case $4 in 31725c30ecadSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173dc99b369Smrg ;; 3174dc99b369Smrg esac 3175dc99b369Smrg case $4 in 3176dc99b369Smrg $2 ) func_append func_to_host_path_result "$3" 3177dc99b369Smrg ;; 3178dc99b369Smrg esac 3179dc99b369Smrg} 3180dc99b369Smrg# end func_convert_path_front_back_pathsep 31815eefee25Smacallan 31825eefee25Smacallan 3183dc99b369Smrg################################################## 3184dc99b369Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185dc99b369Smrg################################################## 31865c30ecadSmrg# invoked via '$to_host_file_cmd ARG' 3187dc99b369Smrg# 3188dc99b369Smrg# In each case, ARG is the path to be converted from $build to $host format. 3189dc99b369Smrg# Result will be available in $func_to_host_file_result. 31905eefee25Smacallan 31915eefee25Smacallan 3192dc99b369Smrg# func_to_host_file ARG 3193dc99b369Smrg# Converts the file name ARG from $build format to $host format. Return result 3194dc99b369Smrg# in func_to_host_file_result. 3195dc99b369Smrgfunc_to_host_file () 3196dc99b369Smrg{ 31975c30ecadSmrg $debug_cmd 31985c30ecadSmrg 3199dc99b369Smrg $to_host_file_cmd "$1" 3200dc99b369Smrg} 3201dc99b369Smrg# end func_to_host_file 32025eefee25Smacallan 32035eefee25Smacallan 3204dc99b369Smrg# func_to_tool_file ARG LAZY 3205dc99b369Smrg# converts the file name ARG from $build format to toolchain format. Return 3206dc99b369Smrg# result in func_to_tool_file_result. If the conversion in use is listed 3207dc99b369Smrg# in (the comma separated) LAZY, no conversion takes place. 3208dc99b369Smrgfunc_to_tool_file () 3209dc99b369Smrg{ 32105c30ecadSmrg $debug_cmd 32115c30ecadSmrg 3212dc99b369Smrg case ,$2, in 3213dc99b369Smrg *,"$to_tool_file_cmd",*) 3214dc99b369Smrg func_to_tool_file_result=$1 3215dc99b369Smrg ;; 3216dc99b369Smrg *) 3217dc99b369Smrg $to_tool_file_cmd "$1" 3218dc99b369Smrg func_to_tool_file_result=$func_to_host_file_result 3219dc99b369Smrg ;; 3220dc99b369Smrg esac 3221dc99b369Smrg} 3222dc99b369Smrg# end func_to_tool_file 32235eefee25Smacallan 32245eefee25Smacallan 3225dc99b369Smrg# func_convert_file_noop ARG 3226dc99b369Smrg# Copy ARG to func_to_host_file_result. 3227dc99b369Smrgfunc_convert_file_noop () 3228dc99b369Smrg{ 32295c30ecadSmrg func_to_host_file_result=$1 3230dc99b369Smrg} 3231dc99b369Smrg# end func_convert_file_noop 32325eefee25Smacallan 32335eefee25Smacallan 3234dc99b369Smrg# func_convert_file_msys_to_w32 ARG 3235dc99b369Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236dc99b369Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237dc99b369Smrg# func_to_host_file_result. 3238dc99b369Smrgfunc_convert_file_msys_to_w32 () 3239dc99b369Smrg{ 32405c30ecadSmrg $debug_cmd 32415c30ecadSmrg 32425c30ecadSmrg func_to_host_file_result=$1 3243dc99b369Smrg if test -n "$1"; then 3244dc99b369Smrg func_convert_core_msys_to_w32 "$1" 32455c30ecadSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246dc99b369Smrg fi 3247dc99b369Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3248dc99b369Smrg} 3249dc99b369Smrg# end func_convert_file_msys_to_w32 32505eefee25Smacallan 32515eefee25Smacallan 3252dc99b369Smrg# func_convert_file_cygwin_to_w32 ARG 3253dc99b369Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254dc99b369Smrg# func_to_host_file_result. 3255dc99b369Smrgfunc_convert_file_cygwin_to_w32 () 3256dc99b369Smrg{ 32575c30ecadSmrg $debug_cmd 32585c30ecadSmrg 32595c30ecadSmrg func_to_host_file_result=$1 3260dc99b369Smrg if test -n "$1"; then 3261dc99b369Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262dc99b369Smrg # LT_CYGPATH in this case. 3263dc99b369Smrg func_to_host_file_result=`cygpath -m "$1"` 3264dc99b369Smrg fi 3265dc99b369Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3266dc99b369Smrg} 3267dc99b369Smrg# end func_convert_file_cygwin_to_w32 32685eefee25Smacallan 32695eefee25Smacallan 3270dc99b369Smrg# func_convert_file_nix_to_w32 ARG 3271dc99b369Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272dc99b369Smrg# and a working winepath. Returns result in func_to_host_file_result. 3273dc99b369Smrgfunc_convert_file_nix_to_w32 () 3274dc99b369Smrg{ 32755c30ecadSmrg $debug_cmd 32765c30ecadSmrg 32775c30ecadSmrg func_to_host_file_result=$1 3278dc99b369Smrg if test -n "$1"; then 3279dc99b369Smrg func_convert_core_file_wine_to_w32 "$1" 32805c30ecadSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281dc99b369Smrg fi 3282dc99b369Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3283dc99b369Smrg} 3284dc99b369Smrg# end func_convert_file_nix_to_w32 32855eefee25Smacallan 32865eefee25Smacallan 3287dc99b369Smrg# func_convert_file_msys_to_cygwin ARG 3288dc99b369Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289dc99b369Smrg# Returns result in func_to_host_file_result. 3290dc99b369Smrgfunc_convert_file_msys_to_cygwin () 3291dc99b369Smrg{ 32925c30ecadSmrg $debug_cmd 32935c30ecadSmrg 32945c30ecadSmrg func_to_host_file_result=$1 3295dc99b369Smrg if test -n "$1"; then 3296dc99b369Smrg func_convert_core_msys_to_w32 "$1" 3297dc99b369Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32985c30ecadSmrg func_to_host_file_result=$func_cygpath_result 3299dc99b369Smrg fi 3300dc99b369Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3301dc99b369Smrg} 3302dc99b369Smrg# end func_convert_file_msys_to_cygwin 33035eefee25Smacallan 33045eefee25Smacallan 3305dc99b369Smrg# func_convert_file_nix_to_cygwin ARG 3306dc99b369Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307dc99b369Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308dc99b369Smrg# in func_to_host_file_result. 3309dc99b369Smrgfunc_convert_file_nix_to_cygwin () 3310dc99b369Smrg{ 33115c30ecadSmrg $debug_cmd 33125c30ecadSmrg 33135c30ecadSmrg func_to_host_file_result=$1 3314dc99b369Smrg if test -n "$1"; then 3315dc99b369Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316dc99b369Smrg func_convert_core_file_wine_to_w32 "$1" 3317dc99b369Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33185c30ecadSmrg func_to_host_file_result=$func_cygpath_result 3319dc99b369Smrg fi 3320dc99b369Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3321dc99b369Smrg} 3322dc99b369Smrg# end func_convert_file_nix_to_cygwin 33235eefee25Smacallan 33245eefee25Smacallan 3325dc99b369Smrg############################################# 3326dc99b369Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3327dc99b369Smrg############################################# 33285c30ecadSmrg# invoked via '$to_host_path_cmd ARG' 3329dc99b369Smrg# 3330dc99b369Smrg# In each case, ARG is the path to be converted from $build to $host format. 3331dc99b369Smrg# The result will be available in $func_to_host_path_result. 3332dc99b369Smrg# 3333dc99b369Smrg# Path separators are also converted from $build format to $host format. If 3334dc99b369Smrg# ARG begins or ends with a path separator character, it is preserved (but 3335dc99b369Smrg# converted to $host format) on output. 3336dc99b369Smrg# 3337dc99b369Smrg# All path conversion functions are named using the following convention: 3338dc99b369Smrg# file name conversion function : func_convert_file_X_to_Y () 3339dc99b369Smrg# path conversion function : func_convert_path_X_to_Y () 3340dc99b369Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341dc99b369Smrg# same. If conversion functions are added for new $build/$host combinations, 3342dc99b369Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343dc99b369Smrg# will break. 3344dc99b369Smrg 3345dc99b369Smrg 3346dc99b369Smrg# func_init_to_host_path_cmd 3347dc99b369Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348dc99b369Smrg# appropriate value, based on the value of $to_host_file_cmd. 3349dc99b369Smrgto_host_path_cmd= 3350dc99b369Smrgfunc_init_to_host_path_cmd () 3351dc99b369Smrg{ 33525c30ecadSmrg $debug_cmd 33535c30ecadSmrg 3354dc99b369Smrg if test -z "$to_host_path_cmd"; then 3355dc99b369Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33565c30ecadSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357dc99b369Smrg fi 3358dc99b369Smrg} 33595eefee25Smacallan 33605eefee25Smacallan 3361dc99b369Smrg# func_to_host_path ARG 3362dc99b369Smrg# Converts the path ARG from $build format to $host format. Return result 3363dc99b369Smrg# in func_to_host_path_result. 3364dc99b369Smrgfunc_to_host_path () 3365dc99b369Smrg{ 33665c30ecadSmrg $debug_cmd 33675c30ecadSmrg 3368dc99b369Smrg func_init_to_host_path_cmd 3369dc99b369Smrg $to_host_path_cmd "$1" 3370dc99b369Smrg} 3371dc99b369Smrg# end func_to_host_path 33725eefee25Smacallan 33735eefee25Smacallan 3374dc99b369Smrg# func_convert_path_noop ARG 3375dc99b369Smrg# Copy ARG to func_to_host_path_result. 3376dc99b369Smrgfunc_convert_path_noop () 3377dc99b369Smrg{ 33785c30ecadSmrg func_to_host_path_result=$1 3379dc99b369Smrg} 3380dc99b369Smrg# end func_convert_path_noop 33815eefee25Smacallan 33825eefee25Smacallan 3383dc99b369Smrg# func_convert_path_msys_to_w32 ARG 3384dc99b369Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385dc99b369Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386dc99b369Smrg# func_to_host_path_result. 3387dc99b369Smrgfunc_convert_path_msys_to_w32 () 3388dc99b369Smrg{ 33895c30ecadSmrg $debug_cmd 33905c30ecadSmrg 33915c30ecadSmrg func_to_host_path_result=$1 3392dc99b369Smrg if test -n "$1"; then 3393dc99b369Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3394dc99b369Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395dc99b369Smrg # and winepath ignores them completely. 3396dc99b369Smrg func_stripname : : "$1" 3397dc99b369Smrg func_to_host_path_tmp1=$func_stripname_result 3398dc99b369Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33995c30ecadSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400dc99b369Smrg func_convert_path_check : ";" \ 3401dc99b369Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402dc99b369Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403dc99b369Smrg fi 3404dc99b369Smrg} 3405dc99b369Smrg# end func_convert_path_msys_to_w32 34065eefee25Smacallan 34075eefee25Smacallan 3408dc99b369Smrg# func_convert_path_cygwin_to_w32 ARG 3409dc99b369Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410dc99b369Smrg# func_to_host_file_result. 3411dc99b369Smrgfunc_convert_path_cygwin_to_w32 () 3412dc99b369Smrg{ 34135c30ecadSmrg $debug_cmd 34145c30ecadSmrg 34155c30ecadSmrg func_to_host_path_result=$1 3416dc99b369Smrg if test -n "$1"; then 3417dc99b369Smrg # See func_convert_path_msys_to_w32: 3418dc99b369Smrg func_stripname : : "$1" 3419dc99b369Smrg func_to_host_path_tmp1=$func_stripname_result 3420dc99b369Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421dc99b369Smrg func_convert_path_check : ";" \ 3422dc99b369Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423dc99b369Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424dc99b369Smrg fi 3425dc99b369Smrg} 3426dc99b369Smrg# end func_convert_path_cygwin_to_w32 34275eefee25Smacallan 34285eefee25Smacallan 3429dc99b369Smrg# func_convert_path_nix_to_w32 ARG 3430dc99b369Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431dc99b369Smrg# a working winepath. Returns result in func_to_host_file_result. 3432dc99b369Smrgfunc_convert_path_nix_to_w32 () 3433dc99b369Smrg{ 34345c30ecadSmrg $debug_cmd 34355c30ecadSmrg 34365c30ecadSmrg func_to_host_path_result=$1 3437dc99b369Smrg if test -n "$1"; then 3438dc99b369Smrg # See func_convert_path_msys_to_w32: 3439dc99b369Smrg func_stripname : : "$1" 3440dc99b369Smrg func_to_host_path_tmp1=$func_stripname_result 3441dc99b369Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34425c30ecadSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443dc99b369Smrg func_convert_path_check : ";" \ 3444dc99b369Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445dc99b369Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446dc99b369Smrg fi 3447dc99b369Smrg} 3448dc99b369Smrg# end func_convert_path_nix_to_w32 34495eefee25Smacallan 34505eefee25Smacallan 3451dc99b369Smrg# func_convert_path_msys_to_cygwin ARG 3452dc99b369Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453dc99b369Smrg# Returns result in func_to_host_file_result. 3454dc99b369Smrgfunc_convert_path_msys_to_cygwin () 3455dc99b369Smrg{ 34565c30ecadSmrg $debug_cmd 34575c30ecadSmrg 34585c30ecadSmrg func_to_host_path_result=$1 3459dc99b369Smrg if test -n "$1"; then 3460dc99b369Smrg # See func_convert_path_msys_to_w32: 3461dc99b369Smrg func_stripname : : "$1" 3462dc99b369Smrg func_to_host_path_tmp1=$func_stripname_result 3463dc99b369Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464dc99b369Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34655c30ecadSmrg func_to_host_path_result=$func_cygpath_result 3466dc99b369Smrg func_convert_path_check : : \ 3467dc99b369Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468dc99b369Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469dc99b369Smrg fi 3470dc99b369Smrg} 3471dc99b369Smrg# end func_convert_path_msys_to_cygwin 34725eefee25Smacallan 34735eefee25Smacallan 3474dc99b369Smrg# func_convert_path_nix_to_cygwin ARG 3475dc99b369Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476dc99b369Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477dc99b369Smrg# func_to_host_file_result. 3478dc99b369Smrgfunc_convert_path_nix_to_cygwin () 3479dc99b369Smrg{ 34805c30ecadSmrg $debug_cmd 34815c30ecadSmrg 34825c30ecadSmrg func_to_host_path_result=$1 3483dc99b369Smrg if test -n "$1"; then 3484dc99b369Smrg # Remove leading and trailing path separator characters from 3485dc99b369Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486dc99b369Smrg # into '.;' and ';.', and winepath ignores them completely. 3487dc99b369Smrg func_stripname : : "$1" 3488dc99b369Smrg func_to_host_path_tmp1=$func_stripname_result 3489dc99b369Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490dc99b369Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34915c30ecadSmrg func_to_host_path_result=$func_cygpath_result 3492dc99b369Smrg func_convert_path_check : : \ 3493dc99b369Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494dc99b369Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495dc99b369Smrg fi 3496dc99b369Smrg} 3497dc99b369Smrg# end func_convert_path_nix_to_cygwin 34985eefee25Smacallan 34995eefee25Smacallan 35005c30ecadSmrg# func_dll_def_p FILE 35015c30ecadSmrg# True iff FILE is a Windows DLL '.def' file. 35025c30ecadSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35035c30ecadSmrgfunc_dll_def_p () 35045c30ecadSmrg{ 35055c30ecadSmrg $debug_cmd 35065c30ecadSmrg 35075c30ecadSmrg func_dll_def_p_tmp=`$SED -n \ 35085c30ecadSmrg -e 's/^[ ]*//' \ 35095c30ecadSmrg -e '/^\(;.*\)*$/d' \ 35105c30ecadSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35115c30ecadSmrg -e q \ 35125c30ecadSmrg "$1"` 35135c30ecadSmrg test DEF = "$func_dll_def_p_tmp" 35145c30ecadSmrg} 35155c30ecadSmrg 35165c30ecadSmrg 3517dc99b369Smrg# func_mode_compile arg... 3518dc99b369Smrgfunc_mode_compile () 3519dc99b369Smrg{ 35205c30ecadSmrg $debug_cmd 35215c30ecadSmrg 3522dc99b369Smrg # Get the compilation command and the source file. 3523dc99b369Smrg base_compile= 35245c30ecadSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525dc99b369Smrg suppress_opt=yes 3526dc99b369Smrg suppress_output= 3527dc99b369Smrg arg_mode=normal 3528dc99b369Smrg libobj= 3529dc99b369Smrg later= 3530dc99b369Smrg pie_flag= 3531dc99b369Smrg 3532dc99b369Smrg for arg 3533dc99b369Smrg do 3534dc99b369Smrg case $arg_mode in 3535dc99b369Smrg arg ) 3536dc99b369Smrg # do not "continue". Instead, add this to base_compile 35375c30ecadSmrg lastarg=$arg 3538dc99b369Smrg arg_mode=normal 3539dc99b369Smrg ;; 3540dc99b369Smrg 3541dc99b369Smrg target ) 35425c30ecadSmrg libobj=$arg 3543dc99b369Smrg arg_mode=normal 3544dc99b369Smrg continue 3545dc99b369Smrg ;; 3546dc99b369Smrg 3547dc99b369Smrg normal ) 3548dc99b369Smrg # Accept any command-line options. 3549dc99b369Smrg case $arg in 3550dc99b369Smrg -o) 3551dc99b369Smrg test -n "$libobj" && \ 35525c30ecadSmrg func_fatal_error "you cannot specify '-o' more than once" 3553dc99b369Smrg arg_mode=target 35545eefee25Smacallan continue 35555eefee25Smacallan ;; 3556dc99b369Smrg 3557dc99b369Smrg -pie | -fpie | -fPIE) 3558dc99b369Smrg func_append pie_flag " $arg" 35595eefee25Smacallan continue 35605eefee25Smacallan ;; 3561dc99b369Smrg 3562dc99b369Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563dc99b369Smrg func_append later " $arg" 35645eefee25Smacallan continue 35655eefee25Smacallan ;; 3566dc99b369Smrg 3567dc99b369Smrg -no-suppress) 3568dc99b369Smrg suppress_opt=no 35695eefee25Smacallan continue 35705eefee25Smacallan ;; 35715eefee25Smacallan 3572dc99b369Smrg -Xcompiler) 3573dc99b369Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574dc99b369Smrg continue # The current "srcfile" will either be retained or 3575dc99b369Smrg ;; # replaced later. I would guess that would be a bug. 35765eefee25Smacallan 3577dc99b369Smrg -Wc,*) 3578dc99b369Smrg func_stripname '-Wc,' '' "$arg" 3579dc99b369Smrg args=$func_stripname_result 3580dc99b369Smrg lastarg= 35815c30ecadSmrg save_ifs=$IFS; IFS=, 3582dc99b369Smrg for arg in $args; do 35835c30ecadSmrg IFS=$save_ifs 3584dc99b369Smrg func_append_quoted lastarg "$arg" 3585dc99b369Smrg done 35865c30ecadSmrg IFS=$save_ifs 3587dc99b369Smrg func_stripname ' ' '' "$lastarg" 3588dc99b369Smrg lastarg=$func_stripname_result 35895eefee25Smacallan 3590dc99b369Smrg # Add the arguments to base_compile. 3591dc99b369Smrg func_append base_compile " $lastarg" 3592dc99b369Smrg continue 3593dc99b369Smrg ;; 35945eefee25Smacallan 3595dc99b369Smrg *) 3596dc99b369Smrg # Accept the current argument as the source file. 3597dc99b369Smrg # The previous "srcfile" becomes the current argument. 3598dc99b369Smrg # 35995c30ecadSmrg lastarg=$srcfile 36005c30ecadSmrg srcfile=$arg 3601dc99b369Smrg ;; 3602dc99b369Smrg esac # case $arg 36035eefee25Smacallan ;; 3604dc99b369Smrg esac # case $arg_mode 36055eefee25Smacallan 3606dc99b369Smrg # Aesthetically quote the previous argument. 3607dc99b369Smrg func_append_quoted base_compile "$lastarg" 3608dc99b369Smrg done # for arg 36095eefee25Smacallan 3610dc99b369Smrg case $arg_mode in 3611dc99b369Smrg arg) 3612dc99b369Smrg func_fatal_error "you must specify an argument for -Xcompile" 3613dc99b369Smrg ;; 3614dc99b369Smrg target) 36155c30ecadSmrg func_fatal_error "you must specify a target with '-o'" 3616dc99b369Smrg ;; 3617dc99b369Smrg *) 3618dc99b369Smrg # Get the name of the library object. 3619dc99b369Smrg test -z "$libobj" && { 3620dc99b369Smrg func_basename "$srcfile" 36215c30ecadSmrg libobj=$func_basename_result 3622dc99b369Smrg } 3623dc99b369Smrg ;; 3624dc99b369Smrg esac 36255eefee25Smacallan 3626dc99b369Smrg # Recognize several different file suffixes. 3627dc99b369Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628dc99b369Smrg case $libobj in 3629dc99b369Smrg *.[cCFSifmso] | \ 3630dc99b369Smrg *.ada | *.adb | *.ads | *.asm | \ 3631dc99b369Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36325c30ecadSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633dc99b369Smrg func_xform "$libobj" 3634dc99b369Smrg libobj=$func_xform_result 3635dc99b369Smrg ;; 3636dc99b369Smrg esac 36375eefee25Smacallan 3638dc99b369Smrg case $libobj in 3639dc99b369Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640dc99b369Smrg *) 36415c30ecadSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642dc99b369Smrg ;; 3643dc99b369Smrg esac 36445eefee25Smacallan 3645dc99b369Smrg func_infer_tag $base_compile 36465eefee25Smacallan 3647dc99b369Smrg for arg in $later; do 3648dc99b369Smrg case $arg in 3649dc99b369Smrg -shared) 36505c30ecadSmrg test yes = "$build_libtool_libs" \ 36515c30ecadSmrg || func_fatal_configuration "cannot build a shared library" 3652dc99b369Smrg build_old_libs=no 36535eefee25Smacallan continue 36545eefee25Smacallan ;; 36555eefee25Smacallan 3656dc99b369Smrg -static) 3657dc99b369Smrg build_libtool_libs=no 3658dc99b369Smrg build_old_libs=yes 36595eefee25Smacallan continue 36605eefee25Smacallan ;; 36615eefee25Smacallan 3662dc99b369Smrg -prefer-pic) 3663dc99b369Smrg pic_mode=yes 36645eefee25Smacallan continue 36655eefee25Smacallan ;; 36665eefee25Smacallan 3667dc99b369Smrg -prefer-non-pic) 3668dc99b369Smrg pic_mode=no 36695eefee25Smacallan continue 36705eefee25Smacallan ;; 3671dc99b369Smrg esac 3672dc99b369Smrg done 36735eefee25Smacallan 36745c30ecadSmrg func_quote_arg pretty "$libobj" 36755c30ecadSmrg test "X$libobj" != "X$func_quote_arg_result" \ 3676dc99b369Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36775c30ecadSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678dc99b369Smrg func_dirname_and_basename "$obj" "/" "" 36795c30ecadSmrg objname=$func_basename_result 36805c30ecadSmrg xdir=$func_dirname_result 36815c30ecadSmrg lobj=$xdir$objdir/$objname 36825eefee25Smacallan 3683dc99b369Smrg test -z "$base_compile" && \ 3684dc99b369Smrg func_fatal_help "you must specify a compilation command" 36855eefee25Smacallan 3686dc99b369Smrg # Delete any leftover library objects. 36875c30ecadSmrg if test yes = "$build_old_libs"; then 3688dc99b369Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689dc99b369Smrg else 3690dc99b369Smrg removelist="$lobj $libobj ${libobj}T" 3691dc99b369Smrg fi 369262ab96baSmrg 3693dc99b369Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694dc99b369Smrg case $host_os in 3695dc99b369Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696dc99b369Smrg pic_mode=default 3697dc99b369Smrg ;; 3698dc99b369Smrg esac 36995c30ecadSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700dc99b369Smrg # non-PIC code in shared libraries is not supported 3701dc99b369Smrg pic_mode=default 3702dc99b369Smrg fi 37035eefee25Smacallan 3704dc99b369Smrg # Calculate the filename of the output object if compiler does 3705dc99b369Smrg # not support -o with -c 37065c30ecadSmrg if test no = "$compiler_c_o"; then 37075c30ecadSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37085c30ecadSmrg lockfile=$output_obj.lock 3709dc99b369Smrg else 3710dc99b369Smrg output_obj= 3711dc99b369Smrg need_locks=no 3712dc99b369Smrg lockfile= 3713dc99b369Smrg fi 37145eefee25Smacallan 3715dc99b369Smrg # Lock this critical section if it is needed 3716dc99b369Smrg # We use this script file to make the link, it avoids creating a new file 37175c30ecadSmrg if test yes = "$need_locks"; then 3718dc99b369Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719dc99b369Smrg func_echo "Waiting for $lockfile to be removed" 3720dc99b369Smrg sleep 2 3721dc99b369Smrg done 37225c30ecadSmrg elif test warn = "$need_locks"; then 3723dc99b369Smrg if test -f "$lockfile"; then 3724dc99b369Smrg $ECHO "\ 3725dc99b369Smrg*** ERROR, $lockfile exists and contains: 3726dc99b369Smrg`cat $lockfile 2>/dev/null` 37275eefee25Smacallan 3728dc99b369SmrgThis indicates that another process is trying to use the same 3729dc99b369Smrgtemporary object file, and libtool could not work around it because 37305c30ecadSmrgyour compiler does not support '-c' and '-o' together. If you 3731dc99b369Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732dc99b369Smrgavoid parallel builds (make -j) in this platform, or get a better 3733dc99b369Smrgcompiler." 37345eefee25Smacallan 3735dc99b369Smrg $opt_dry_run || $RM $removelist 3736dc99b369Smrg exit $EXIT_FAILURE 3737dc99b369Smrg fi 3738dc99b369Smrg func_append removelist " $output_obj" 3739dc99b369Smrg $ECHO "$srcfile" > "$lockfile" 3740dc99b369Smrg fi 37415eefee25Smacallan 3742dc99b369Smrg $opt_dry_run || $RM $removelist 3743dc99b369Smrg func_append removelist " $lockfile" 3744dc99b369Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37455eefee25Smacallan 3746dc99b369Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747dc99b369Smrg srcfile=$func_to_tool_file_result 37485c30ecadSmrg func_quote_arg pretty "$srcfile" 37495c30ecadSmrg qsrcfile=$func_quote_arg_result 37505eefee25Smacallan 3751dc99b369Smrg # Only build a PIC object if we are building libtool libraries. 37525c30ecadSmrg if test yes = "$build_libtool_libs"; then 3753dc99b369Smrg # Without this assignment, base_compile gets emptied. 3754dc99b369Smrg fbsd_hideous_sh_bug=$base_compile 37555eefee25Smacallan 37565c30ecadSmrg if test no != "$pic_mode"; then 3757dc99b369Smrg command="$base_compile $qsrcfile $pic_flag" 3758dc99b369Smrg else 3759dc99b369Smrg # Don't build PIC code 3760dc99b369Smrg command="$base_compile $qsrcfile" 3761dc99b369Smrg fi 37625eefee25Smacallan 3763dc99b369Smrg func_mkdir_p "$xdir$objdir" 37645eefee25Smacallan 3765dc99b369Smrg if test -z "$output_obj"; then 3766dc99b369Smrg # Place PIC objects in $objdir 3767dc99b369Smrg func_append command " -o $lobj" 3768dc99b369Smrg fi 37695eefee25Smacallan 3770dc99b369Smrg func_show_eval_locale "$command" \ 3771dc99b369Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37725eefee25Smacallan 37735c30ecadSmrg if test warn = "$need_locks" && 3774dc99b369Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775dc99b369Smrg $ECHO "\ 3776dc99b369Smrg*** ERROR, $lockfile contains: 3777dc99b369Smrg`cat $lockfile 2>/dev/null` 37785eefee25Smacallan 3779dc99b369Smrgbut it should contain: 3780dc99b369Smrg$srcfile 37815eefee25Smacallan 3782dc99b369SmrgThis indicates that another process is trying to use the same 3783dc99b369Smrgtemporary object file, and libtool could not work around it because 37845c30ecadSmrgyour compiler does not support '-c' and '-o' together. If you 3785dc99b369Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786dc99b369Smrgavoid parallel builds (make -j) in this platform, or get a better 3787dc99b369Smrgcompiler." 37885eefee25Smacallan 3789dc99b369Smrg $opt_dry_run || $RM $removelist 3790dc99b369Smrg exit $EXIT_FAILURE 3791dc99b369Smrg fi 37925eefee25Smacallan 3793dc99b369Smrg # Just move the object if needed, then go on to compile the next one 3794dc99b369Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795dc99b369Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796dc99b369Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797dc99b369Smrg fi 37985eefee25Smacallan 3799dc99b369Smrg # Allow error messages only from the first compilation. 38005c30ecadSmrg if test yes = "$suppress_opt"; then 3801dc99b369Smrg suppress_output=' >/dev/null 2>&1' 3802dc99b369Smrg fi 3803dc99b369Smrg fi 38045eefee25Smacallan 3805dc99b369Smrg # Only build a position-dependent object if we build old libraries. 38065c30ecadSmrg if test yes = "$build_old_libs"; then 38075c30ecadSmrg if test yes != "$pic_mode"; then 3808dc99b369Smrg # Don't build PIC code 3809dc99b369Smrg command="$base_compile $qsrcfile$pie_flag" 3810dc99b369Smrg else 3811dc99b369Smrg command="$base_compile $qsrcfile $pic_flag" 3812dc99b369Smrg fi 38135c30ecadSmrg if test yes = "$compiler_c_o"; then 3814dc99b369Smrg func_append command " -o $obj" 3815dc99b369Smrg fi 38165eefee25Smacallan 3817dc99b369Smrg # Suppress compiler output if we already did a PIC compilation. 3818dc99b369Smrg func_append command "$suppress_output" 3819dc99b369Smrg func_show_eval_locale "$command" \ 3820dc99b369Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38215eefee25Smacallan 38225c30ecadSmrg if test warn = "$need_locks" && 3823dc99b369Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824dc99b369Smrg $ECHO "\ 3825dc99b369Smrg*** ERROR, $lockfile contains: 3826dc99b369Smrg`cat $lockfile 2>/dev/null` 38275eefee25Smacallan 3828dc99b369Smrgbut it should contain: 3829dc99b369Smrg$srcfile 38305eefee25Smacallan 3831dc99b369SmrgThis indicates that another process is trying to use the same 3832dc99b369Smrgtemporary object file, and libtool could not work around it because 38335c30ecadSmrgyour compiler does not support '-c' and '-o' together. If you 3834dc99b369Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835dc99b369Smrgavoid parallel builds (make -j) in this platform, or get a better 3836dc99b369Smrgcompiler." 38375eefee25Smacallan 3838dc99b369Smrg $opt_dry_run || $RM $removelist 3839dc99b369Smrg exit $EXIT_FAILURE 3840dc99b369Smrg fi 38415eefee25Smacallan 3842dc99b369Smrg # Just move the object if needed 3843dc99b369Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844dc99b369Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845dc99b369Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846dc99b369Smrg fi 3847dc99b369Smrg fi 38485eefee25Smacallan 3849dc99b369Smrg $opt_dry_run || { 3850dc99b369Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38515eefee25Smacallan 3852dc99b369Smrg # Unlock the critical section if it was locked 38535c30ecadSmrg if test no != "$need_locks"; then 3854dc99b369Smrg removelist=$lockfile 3855dc99b369Smrg $RM "$lockfile" 3856dc99b369Smrg fi 3857dc99b369Smrg } 38585eefee25Smacallan 3859dc99b369Smrg exit $EXIT_SUCCESS 3860dc99b369Smrg} 38615eefee25Smacallan 3862dc99b369Smrg$opt_help || { 38635c30ecadSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864dc99b369Smrg} 38655eefee25Smacallan 3866dc99b369Smrgfunc_mode_help () 3867dc99b369Smrg{ 3868dc99b369Smrg # We need to display help for each of the modes. 3869dc99b369Smrg case $opt_mode in 3870dc99b369Smrg "") 3871dc99b369Smrg # Generic help is extracted from the usage comments 3872dc99b369Smrg # at the start of this file. 3873dc99b369Smrg func_help 3874dc99b369Smrg ;; 38755eefee25Smacallan 3876dc99b369Smrg clean) 3877dc99b369Smrg $ECHO \ 3878dc99b369Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38795eefee25Smacallan 3880dc99b369SmrgRemove files from the build directory. 38815eefee25Smacallan 3882dc99b369SmrgRM is the name of the program to use to delete files associated with each FILE 38835c30ecadSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884dc99b369Smrgto RM. 38855eefee25Smacallan 3886dc99b369SmrgIf FILE is a libtool library, object or program, all the files associated 3887dc99b369Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888dc99b369Smrg ;; 38895eefee25Smacallan 3890dc99b369Smrg compile) 3891dc99b369Smrg $ECHO \ 3892dc99b369Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38935eefee25Smacallan 3894dc99b369SmrgCompile a source file into a libtool library object. 38955eefee25Smacallan 3896dc99b369SmrgThis mode accepts the following additional options: 38975eefee25Smacallan 3898dc99b369Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899dc99b369Smrg -no-suppress do not suppress compiler output for multiple passes 3900dc99b369Smrg -prefer-pic try to build PIC objects only 3901dc99b369Smrg -prefer-non-pic try to build non-PIC objects only 39025c30ecadSmrg -shared do not build a '.o' file suitable for static linking 39035c30ecadSmrg -static only build a '.o' file suitable for static linking 39045c30ecadSmrg -Wc,FLAG 39055c30ecadSmrg -Xcompiler FLAG pass FLAG directly to the compiler 39065eefee25Smacallan 39075c30ecadSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908dc99b369Smrgfrom the given SOURCEFILE. 39095eefee25Smacallan 3910dc99b369SmrgThe output file name is determined by removing the directory component from 39115c30ecadSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39125c30ecadSmrglibrary object suffix, '.lo'." 3913dc99b369Smrg ;; 39145eefee25Smacallan 3915dc99b369Smrg execute) 3916dc99b369Smrg $ECHO \ 3917dc99b369Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39185eefee25Smacallan 3919dc99b369SmrgAutomatically set library path, then run a program. 39205eefee25Smacallan 3921dc99b369SmrgThis mode accepts the following additional options: 39225eefee25Smacallan 3923dc99b369Smrg -dlopen FILE add the directory containing FILE to the library path 39245eefee25Smacallan 39255c30ecadSmrgThis mode sets the library path environment variable according to '-dlopen' 3926dc99b369Smrgflags. 39275eefee25Smacallan 3928dc99b369SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929dc99b369Smrginto their corresponding uninstalled binary, and any of their required library 3930dc99b369Smrgdirectories are added to the library path. 39315eefee25Smacallan 3932dc99b369SmrgThen, COMMAND is executed, with ARGS as arguments." 3933dc99b369Smrg ;; 39345eefee25Smacallan 3935dc99b369Smrg finish) 3936dc99b369Smrg $ECHO \ 3937dc99b369Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39385eefee25Smacallan 3939dc99b369SmrgComplete the installation of libtool libraries. 3940dc99b369Smrg 3941dc99b369SmrgEach LIBDIR is a directory that contains libtool libraries. 3942dc99b369Smrg 3943dc99b369SmrgThe commands that this mode executes may require superuser privileges. Use 39445c30ecadSmrgthe '--dry-run' option if you just want to see what would be executed." 3945dc99b369Smrg ;; 3946dc99b369Smrg 3947dc99b369Smrg install) 3948dc99b369Smrg $ECHO \ 3949dc99b369Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950dc99b369Smrg 3951dc99b369SmrgInstall executables or libraries. 3952dc99b369Smrg 3953dc99b369SmrgINSTALL-COMMAND is the installation command. The first component should be 39545c30ecadSmrgeither the 'install' or 'cp' program. 3955dc99b369Smrg 3956dc99b369SmrgThe following components of INSTALL-COMMAND are treated specially: 3957dc99b369Smrg 3958dc99b369Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959dc99b369Smrg 3960dc99b369SmrgThe rest of the components are interpreted as arguments to that command (only 3961dc99b369SmrgBSD-compatible install options are recognized)." 3962dc99b369Smrg ;; 3963dc99b369Smrg 3964dc99b369Smrg link) 3965dc99b369Smrg $ECHO \ 3966dc99b369Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967dc99b369Smrg 3968dc99b369SmrgLink object files or libraries together to form another library, or to 3969dc99b369Smrgcreate an executable program. 3970dc99b369Smrg 3971dc99b369SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972dc99b369Smrga program from several object files. 3973dc99b369Smrg 3974dc99b369SmrgThe following components of LINK-COMMAND are treated specially: 3975dc99b369Smrg 3976dc99b369Smrg -all-static do not do any dynamic linking at all 3977dc99b369Smrg -avoid-version do not add a version suffix if possible 3978dc99b369Smrg -bindir BINDIR specify path to binaries directory (for systems where 3979dc99b369Smrg libraries must be found in the PATH setting at runtime) 39805c30ecadSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981dc99b369Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982dc99b369Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983dc99b369Smrg -export-symbols SYMFILE 3984dc99b369Smrg try to export only the symbols listed in SYMFILE 3985dc99b369Smrg -export-symbols-regex REGEX 3986dc99b369Smrg try to export only the symbols matching REGEX 3987dc99b369Smrg -LLIBDIR search LIBDIR for required installed libraries 3988dc99b369Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989dc99b369Smrg -module build a library that can dlopened 3990dc99b369Smrg -no-fast-install disable the fast-install mode 3991dc99b369Smrg -no-install link a not-installable executable 3992dc99b369Smrg -no-undefined declare that a library does not refer to external symbols 3993dc99b369Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39945c30ecadSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39955c30ecadSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996dc99b369Smrg -precious-files-regex REGEX 3997dc99b369Smrg don't remove output files matching REGEX 3998dc99b369Smrg -release RELEASE specify package release information 3999dc99b369Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000dc99b369Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001dc99b369Smrg -shared only do dynamic linking of libtool libraries 4002dc99b369Smrg -shrext SUFFIX override the standard shared library file extension 4003dc99b369Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4004dc99b369Smrg -static-libtool-libs 4005dc99b369Smrg do not do any dynamic linking of libtool libraries 4006dc99b369Smrg -version-info CURRENT[:REVISION[:AGE]] 4007dc99b369Smrg specify library version info [each variable defaults to 0] 4008dc99b369Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009dc99b369Smrg -Wc,FLAG 4010dc99b369Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40115c30ecadSmrg -Wa,FLAG 40125c30ecadSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013dc99b369Smrg -Wl,FLAG 4014dc99b369Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015dc99b369Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016dc99b369Smrg 40175c30ecadSmrgAll other options (arguments beginning with '-') are ignored. 4018dc99b369Smrg 40195c30ecadSmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020dc99b369Smrgtreated as uninstalled libtool libraries, other files are standard or library 4021dc99b369Smrgobject files. 4022dc99b369Smrg 40235c30ecadSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40245c30ecadSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025dc99b369Smrgrequired, except when creating a convenience library. 4026dc99b369Smrg 40275c30ecadSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40285c30ecadSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029dc99b369Smrg 40305c30ecadSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031dc99b369Smrgis created, otherwise an executable program is created." 4032dc99b369Smrg ;; 4033dc99b369Smrg 4034dc99b369Smrg uninstall) 4035dc99b369Smrg $ECHO \ 4036dc99b369Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037dc99b369Smrg 4038dc99b369SmrgRemove libraries from an installation directory. 4039dc99b369Smrg 4040dc99b369SmrgRM is the name of the program to use to delete files associated with each FILE 40415c30ecadSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042dc99b369Smrgto RM. 4043dc99b369Smrg 4044dc99b369SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045dc99b369SmrgOtherwise, only FILE itself is deleted using RM." 4046dc99b369Smrg ;; 4047dc99b369Smrg 4048dc99b369Smrg *) 40495c30ecadSmrg func_fatal_help "invalid operation mode '$opt_mode'" 4050dc99b369Smrg ;; 40515eefee25Smacallan esac 40525eefee25Smacallan 4053dc99b369Smrg echo 40545c30ecadSmrg $ECHO "Try '$progname --help' for more information about other modes." 4055dc99b369Smrg} 40565eefee25Smacallan 4057dc99b369Smrg# Now that we've collected a possible --mode arg, show help if necessary 4058dc99b369Smrgif $opt_help; then 40595c30ecadSmrg if test : = "$opt_help"; then 4060dc99b369Smrg func_mode_help 4061dc99b369Smrg else 4062dc99b369Smrg { 4063dc99b369Smrg func_help noexit 4064dc99b369Smrg for opt_mode in compile link execute install finish uninstall clean; do 4065dc99b369Smrg func_mode_help 4066dc99b369Smrg done 40675c30ecadSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068dc99b369Smrg { 4069dc99b369Smrg func_help noexit 4070dc99b369Smrg for opt_mode in compile link execute install finish uninstall clean; do 4071dc99b369Smrg echo 4072dc99b369Smrg func_mode_help 4073dc99b369Smrg done 4074dc99b369Smrg } | 40755c30ecadSmrg $SED '1d 4076dc99b369Smrg /^When reporting/,/^Report/{ 4077dc99b369Smrg H 4078dc99b369Smrg d 4079dc99b369Smrg } 4080dc99b369Smrg $x 4081dc99b369Smrg /information about other modes/d 4082dc99b369Smrg /more detailed .*MODE/d 4083dc99b369Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084dc99b369Smrg fi 4085dc99b369Smrg exit $? 4086dc99b369Smrgfi 40875eefee25Smacallan 40885eefee25Smacallan 4089dc99b369Smrg# func_mode_execute arg... 4090dc99b369Smrgfunc_mode_execute () 4091dc99b369Smrg{ 40925c30ecadSmrg $debug_cmd 40935c30ecadSmrg 4094dc99b369Smrg # The first argument is the command name. 40955c30ecadSmrg cmd=$nonopt 4096dc99b369Smrg test -z "$cmd" && \ 4097dc99b369Smrg func_fatal_help "you must specify a COMMAND" 4098dc99b369Smrg 4099dc99b369Smrg # Handle -dlopen flags immediately. 4100dc99b369Smrg for file in $opt_dlopen; do 4101dc99b369Smrg test -f "$file" \ 41025c30ecadSmrg || func_fatal_help "'$file' is not a file" 4103dc99b369Smrg 4104dc99b369Smrg dir= 4105dc99b369Smrg case $file in 4106dc99b369Smrg *.la) 4107dc99b369Smrg func_resolve_sysroot "$file" 4108dc99b369Smrg file=$func_resolve_sysroot_result 4109dc99b369Smrg 4110dc99b369Smrg # Check to see that this really is a libtool archive. 4111dc99b369Smrg func_lalib_unsafe_p "$file" \ 41125c30ecadSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113dc99b369Smrg 4114dc99b369Smrg # Read the libtool library. 4115dc99b369Smrg dlname= 4116dc99b369Smrg library_names= 4117dc99b369Smrg func_source "$file" 4118dc99b369Smrg 4119dc99b369Smrg # Skip this library if it cannot be dlopened. 4120dc99b369Smrg if test -z "$dlname"; then 4121dc99b369Smrg # Warn if it was a shared library. 4122dc99b369Smrg test -n "$library_names" && \ 41235c30ecadSmrg func_warning "'$file' was not linked with '-export-dynamic'" 4124dc99b369Smrg continue 4125dc99b369Smrg fi 4126dc99b369Smrg 4127dc99b369Smrg func_dirname "$file" "" "." 41285c30ecadSmrg dir=$func_dirname_result 4129dc99b369Smrg 4130dc99b369Smrg if test -f "$dir/$objdir/$dlname"; then 4131dc99b369Smrg func_append dir "/$objdir" 4132dc99b369Smrg else 4133dc99b369Smrg if test ! -f "$dir/$dlname"; then 41345c30ecadSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135dc99b369Smrg fi 4136dc99b369Smrg fi 41375eefee25Smacallan ;; 4138dc99b369Smrg 4139dc99b369Smrg *.lo) 4140dc99b369Smrg # Just add the directory containing the .lo file. 4141dc99b369Smrg func_dirname "$file" "" "." 41425c30ecadSmrg dir=$func_dirname_result 41435eefee25Smacallan ;; 4144dc99b369Smrg 4145dc99b369Smrg *) 41465c30ecadSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147dc99b369Smrg continue 41485eefee25Smacallan ;; 4149dc99b369Smrg esac 4150dc99b369Smrg 4151dc99b369Smrg # Get the absolute pathname. 4152dc99b369Smrg absdir=`cd "$dir" && pwd` 41535c30ecadSmrg test -n "$absdir" && dir=$absdir 4154dc99b369Smrg 4155dc99b369Smrg # Now add the directory to shlibpath_var. 4156dc99b369Smrg if eval "test -z \"\$$shlibpath_var\""; then 4157dc99b369Smrg eval "$shlibpath_var=\"\$dir\"" 4158dc99b369Smrg else 4159dc99b369Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41605eefee25Smacallan fi 4161dc99b369Smrg done 4162dc99b369Smrg 4163dc99b369Smrg # This variable tells wrapper scripts just to set shlibpath_var 4164dc99b369Smrg # rather than running their programs. 41655c30ecadSmrg libtool_execute_magic=$magic 4166dc99b369Smrg 4167dc99b369Smrg # Check if any of the arguments is a wrapper script. 4168dc99b369Smrg args= 4169dc99b369Smrg for file 4170dc99b369Smrg do 4171dc99b369Smrg case $file in 4172dc99b369Smrg -* | *.la | *.lo ) ;; 4173dc99b369Smrg *) 4174dc99b369Smrg # Do a test to see if this is really a libtool program. 4175dc99b369Smrg if func_ltwrapper_script_p "$file"; then 4176dc99b369Smrg func_source "$file" 4177dc99b369Smrg # Transform arg to wrapped name. 41785c30ecadSmrg file=$progdir/$program 4179dc99b369Smrg elif func_ltwrapper_executable_p "$file"; then 4180dc99b369Smrg func_ltwrapper_scriptname "$file" 4181dc99b369Smrg func_source "$func_ltwrapper_scriptname_result" 4182dc99b369Smrg # Transform arg to wrapped name. 41835c30ecadSmrg file=$progdir/$program 4184dc99b369Smrg fi 4185dc99b369Smrg ;; 4186dc99b369Smrg esac 4187dc99b369Smrg # Quote arguments (to preserve shell metacharacters). 4188dc99b369Smrg func_append_quoted args "$file" 4189dc99b369Smrg done 4190dc99b369Smrg 41915c30ecadSmrg if $opt_dry_run; then 41925c30ecadSmrg # Display what would be done. 41935c30ecadSmrg if test -n "$shlibpath_var"; then 41945c30ecadSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41955c30ecadSmrg echo "export $shlibpath_var" 41965c30ecadSmrg fi 41975c30ecadSmrg $ECHO "$cmd$args" 41985c30ecadSmrg exit $EXIT_SUCCESS 41995c30ecadSmrg else 4200dc99b369Smrg if test -n "$shlibpath_var"; then 4201dc99b369Smrg # Export the shlibpath_var. 4202dc99b369Smrg eval "export $shlibpath_var" 42035eefee25Smacallan fi 4204dc99b369Smrg 4205dc99b369Smrg # Restore saved environment variables 4206dc99b369Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207dc99b369Smrg do 4208dc99b369Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209dc99b369Smrg $lt_var=\$save_$lt_var; export $lt_var 4210dc99b369Smrg else 4211dc99b369Smrg $lt_unset $lt_var 4212dc99b369Smrg fi" 4213dc99b369Smrg done 4214dc99b369Smrg 4215dc99b369Smrg # Now prepare to actually exec the command. 42165c30ecadSmrg exec_cmd=\$cmd$args 4217dc99b369Smrg fi 4218dc99b369Smrg} 42195eefee25Smacallan 42205c30ecadSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42215eefee25Smacallan 42225eefee25Smacallan 4223dc99b369Smrg# func_mode_finish arg... 4224dc99b369Smrgfunc_mode_finish () 4225dc99b369Smrg{ 42265c30ecadSmrg $debug_cmd 42275c30ecadSmrg 4228dc99b369Smrg libs= 4229dc99b369Smrg libdirs= 4230dc99b369Smrg admincmds= 42315eefee25Smacallan 4232dc99b369Smrg for opt in "$nonopt" ${1+"$@"} 4233dc99b369Smrg do 4234dc99b369Smrg if test -d "$opt"; then 4235dc99b369Smrg func_append libdirs " $opt" 42365eefee25Smacallan 4237dc99b369Smrg elif test -f "$opt"; then 4238dc99b369Smrg if func_lalib_unsafe_p "$opt"; then 4239dc99b369Smrg func_append libs " $opt" 4240dc99b369Smrg else 42415c30ecadSmrg func_warning "'$opt' is not a valid libtool archive" 42425eefee25Smacallan fi 42435eefee25Smacallan 4244dc99b369Smrg else 42455c30ecadSmrg func_fatal_error "invalid argument '$opt'" 4246dc99b369Smrg fi 4247dc99b369Smrg done 42485eefee25Smacallan 4249dc99b369Smrg if test -n "$libs"; then 4250dc99b369Smrg if test -n "$lt_sysroot"; then 4251dc99b369Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252dc99b369Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253dc99b369Smrg else 4254dc99b369Smrg sysroot_cmd= 4255dc99b369Smrg fi 42565eefee25Smacallan 4257dc99b369Smrg # Remove sysroot references 4258dc99b369Smrg if $opt_dry_run; then 4259dc99b369Smrg for lib in $libs; do 42605c30ecadSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261dc99b369Smrg done 4262dc99b369Smrg else 4263dc99b369Smrg tmpdir=`func_mktempdir` 4264dc99b369Smrg for lib in $libs; do 42655c30ecadSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266dc99b369Smrg > $tmpdir/tmp-la 4267dc99b369Smrg mv -f $tmpdir/tmp-la $lib 42685eefee25Smacallan done 4269dc99b369Smrg ${RM}r "$tmpdir" 4270dc99b369Smrg fi 4271dc99b369Smrg fi 4272dc99b369Smrg 4273dc99b369Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274dc99b369Smrg for libdir in $libdirs; do 4275dc99b369Smrg if test -n "$finish_cmds"; then 4276dc99b369Smrg # Do each command in the finish commands. 4277dc99b369Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278dc99b369Smrg'"$cmd"'"' 42795eefee25Smacallan fi 4280dc99b369Smrg if test -n "$finish_eval"; then 4281dc99b369Smrg # Do the single finish_eval. 4282dc99b369Smrg eval cmds=\"$finish_eval\" 4283dc99b369Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284dc99b369Smrg $cmds" 4285dc99b369Smrg fi 4286dc99b369Smrg done 4287dc99b369Smrg fi 42885eefee25Smacallan 4289dc99b369Smrg # Exit here if they wanted silent mode. 42905c30ecadSmrg $opt_quiet && exit $EXIT_SUCCESS 42915eefee25Smacallan 4292dc99b369Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293dc99b369Smrg echo "----------------------------------------------------------------------" 4294dc99b369Smrg echo "Libraries have been installed in:" 4295dc99b369Smrg for libdir in $libdirs; do 4296dc99b369Smrg $ECHO " $libdir" 4297dc99b369Smrg done 4298dc99b369Smrg echo 4299dc99b369Smrg echo "If you ever happen to want to link against installed libraries" 4300dc99b369Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43015c30ecadSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302dc99b369Smrg echo "flag during linking and do at least one of the following:" 4303dc99b369Smrg if test -n "$shlibpath_var"; then 43045c30ecadSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305dc99b369Smrg echo " during execution" 4306dc99b369Smrg fi 4307dc99b369Smrg if test -n "$runpath_var"; then 43085c30ecadSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309dc99b369Smrg echo " during linking" 4310dc99b369Smrg fi 4311dc99b369Smrg if test -n "$hardcode_libdir_flag_spec"; then 4312dc99b369Smrg libdir=LIBDIR 4313dc99b369Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4314dc99b369Smrg 43155c30ecadSmrg $ECHO " - use the '$flag' linker flag" 4316dc99b369Smrg fi 4317dc99b369Smrg if test -n "$admincmds"; then 4318dc99b369Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4319dc99b369Smrg fi 4320dc99b369Smrg if test -f /etc/ld.so.conf; then 43215c30ecadSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322dc99b369Smrg fi 4323dc99b369Smrg echo 4324dc99b369Smrg 4325dc99b369Smrg echo "See any operating system documentation about shared libraries for" 4326dc99b369Smrg case $host in 4327dc99b369Smrg solaris2.[6789]|solaris2.1[0-9]) 4328dc99b369Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329dc99b369Smrg echo "pages." 4330dc99b369Smrg ;; 43315eefee25Smacallan *) 4332dc99b369Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43335eefee25Smacallan ;; 4334dc99b369Smrg esac 4335dc99b369Smrg echo "----------------------------------------------------------------------" 4336dc99b369Smrg fi 4337dc99b369Smrg exit $EXIT_SUCCESS 4338dc99b369Smrg} 43395eefee25Smacallan 43405c30ecadSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43415eefee25Smacallan 4342dc99b369Smrg 4343dc99b369Smrg# func_mode_install arg... 4344dc99b369Smrgfunc_mode_install () 4345dc99b369Smrg{ 43465c30ecadSmrg $debug_cmd 43475c30ecadSmrg 4348dc99b369Smrg # There may be an optional sh(1) argument at the beginning of 4349dc99b369Smrg # install_prog (especially on Windows NT). 43505c30ecadSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351dc99b369Smrg # Allow the use of GNU shtool's install command. 43525c30ecadSmrg case $nonopt in *shtool*) :;; *) false;; esac 43535c30ecadSmrg then 4354dc99b369Smrg # Aesthetically quote it. 43555c30ecadSmrg func_quote_arg pretty "$nonopt" 43565c30ecadSmrg install_prog="$func_quote_arg_result " 4357dc99b369Smrg arg=$1 4358dc99b369Smrg shift 4359dc99b369Smrg else 4360dc99b369Smrg install_prog= 4361dc99b369Smrg arg=$nonopt 4362dc99b369Smrg fi 4363dc99b369Smrg 4364dc99b369Smrg # The real first argument should be the name of the installation program. 4365dc99b369Smrg # Aesthetically quote it. 43665c30ecadSmrg func_quote_arg pretty "$arg" 43675c30ecadSmrg func_append install_prog "$func_quote_arg_result" 4368dc99b369Smrg install_shared_prog=$install_prog 4369dc99b369Smrg case " $install_prog " in 4370dc99b369Smrg *[\\\ /]cp\ *) install_cp=: ;; 4371dc99b369Smrg *) install_cp=false ;; 4372dc99b369Smrg esac 4373dc99b369Smrg 4374dc99b369Smrg # We need to accept at least all the BSD install flags. 4375dc99b369Smrg dest= 4376dc99b369Smrg files= 4377dc99b369Smrg opts= 4378dc99b369Smrg prev= 4379dc99b369Smrg install_type= 43805c30ecadSmrg isdir=false 4381dc99b369Smrg stripme= 4382dc99b369Smrg no_mode=: 4383dc99b369Smrg for arg 4384dc99b369Smrg do 4385dc99b369Smrg arg2= 4386dc99b369Smrg if test -n "$dest"; then 4387dc99b369Smrg func_append files " $dest" 4388dc99b369Smrg dest=$arg 4389dc99b369Smrg continue 4390dc99b369Smrg fi 4391dc99b369Smrg 4392dc99b369Smrg case $arg in 43935c30ecadSmrg -d) isdir=: ;; 4394dc99b369Smrg -f) 4395dc99b369Smrg if $install_cp; then :; else 4396dc99b369Smrg prev=$arg 4397dc99b369Smrg fi 4398dc99b369Smrg ;; 4399dc99b369Smrg -g | -m | -o) 4400dc99b369Smrg prev=$arg 4401dc99b369Smrg ;; 4402dc99b369Smrg -s) 4403dc99b369Smrg stripme=" -s" 4404dc99b369Smrg continue 4405dc99b369Smrg ;; 4406dc99b369Smrg -*) 4407dc99b369Smrg ;; 4408dc99b369Smrg *) 4409dc99b369Smrg # If the previous option needed an argument, then skip it. 4410dc99b369Smrg if test -n "$prev"; then 44115c30ecadSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412dc99b369Smrg arg2=$install_override_mode 4413dc99b369Smrg no_mode=false 44145eefee25Smacallan fi 4415dc99b369Smrg prev= 4416dc99b369Smrg else 4417dc99b369Smrg dest=$arg 44185eefee25Smacallan continue 44195eefee25Smacallan fi 4420dc99b369Smrg ;; 4421dc99b369Smrg esac 44225eefee25Smacallan 4423dc99b369Smrg # Aesthetically quote the argument. 44245c30ecadSmrg func_quote_arg pretty "$arg" 44255c30ecadSmrg func_append install_prog " $func_quote_arg_result" 4426dc99b369Smrg if test -n "$arg2"; then 44275c30ecadSmrg func_quote_arg pretty "$arg2" 4428dc99b369Smrg fi 44295c30ecadSmrg func_append install_shared_prog " $func_quote_arg_result" 4430dc99b369Smrg done 44315eefee25Smacallan 4432dc99b369Smrg test -z "$install_prog" && \ 4433dc99b369Smrg func_fatal_help "you must specify an install program" 44345eefee25Smacallan 4435dc99b369Smrg test -n "$prev" && \ 44365c30ecadSmrg func_fatal_help "the '$prev' option requires an argument" 44375eefee25Smacallan 4438dc99b369Smrg if test -n "$install_override_mode" && $no_mode; then 4439dc99b369Smrg if $install_cp; then :; else 44405c30ecadSmrg func_quote_arg pretty "$install_override_mode" 44415c30ecadSmrg func_append install_shared_prog " -m $func_quote_arg_result" 4442dc99b369Smrg fi 4443dc99b369Smrg fi 44445eefee25Smacallan 4445dc99b369Smrg if test -z "$files"; then 4446dc99b369Smrg if test -z "$dest"; then 4447dc99b369Smrg func_fatal_help "no file or destination specified" 4448dc99b369Smrg else 4449dc99b369Smrg func_fatal_help "you must specify a destination" 4450dc99b369Smrg fi 4451dc99b369Smrg fi 44525eefee25Smacallan 4453dc99b369Smrg # Strip any trailing slash from the destination. 4454dc99b369Smrg func_stripname '' '/' "$dest" 4455dc99b369Smrg dest=$func_stripname_result 44565eefee25Smacallan 4457dc99b369Smrg # Check to see that the destination is a directory. 44585c30ecadSmrg test -d "$dest" && isdir=: 44595c30ecadSmrg if $isdir; then 44605c30ecadSmrg destdir=$dest 4461dc99b369Smrg destname= 4462dc99b369Smrg else 4463dc99b369Smrg func_dirname_and_basename "$dest" "" "." 44645c30ecadSmrg destdir=$func_dirname_result 44655c30ecadSmrg destname=$func_basename_result 44665eefee25Smacallan 4467dc99b369Smrg # Not a directory, so check to see that there is only one file specified. 4468dc99b369Smrg set dummy $files; shift 4469dc99b369Smrg test "$#" -gt 1 && \ 44705c30ecadSmrg func_fatal_help "'$dest' is not a directory" 4471dc99b369Smrg fi 4472dc99b369Smrg case $destdir in 4473dc99b369Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474dc99b369Smrg *) 4475dc99b369Smrg for file in $files; do 4476dc99b369Smrg case $file in 4477dc99b369Smrg *.lo) ;; 4478dc99b369Smrg *) 44795c30ecadSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4480dc99b369Smrg ;; 4481dc99b369Smrg esac 4482dc99b369Smrg done 4483dc99b369Smrg ;; 4484dc99b369Smrg esac 44855eefee25Smacallan 4486dc99b369Smrg # This variable tells wrapper scripts just to set variables rather 4487dc99b369Smrg # than running their programs. 44885c30ecadSmrg libtool_install_magic=$magic 44895eefee25Smacallan 4490dc99b369Smrg staticlibs= 4491dc99b369Smrg future_libdirs= 4492dc99b369Smrg current_libdirs= 4493dc99b369Smrg for file in $files; do 44945eefee25Smacallan 4495dc99b369Smrg # Do each installation. 4496dc99b369Smrg case $file in 4497dc99b369Smrg *.$libext) 4498dc99b369Smrg # Do the static libraries later. 4499dc99b369Smrg func_append staticlibs " $file" 4500dc99b369Smrg ;; 45015eefee25Smacallan 4502dc99b369Smrg *.la) 4503dc99b369Smrg func_resolve_sysroot "$file" 4504dc99b369Smrg file=$func_resolve_sysroot_result 45055eefee25Smacallan 4506dc99b369Smrg # Check to see that this really is a libtool archive. 4507dc99b369Smrg func_lalib_unsafe_p "$file" \ 45085c30ecadSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45095eefee25Smacallan 4510dc99b369Smrg library_names= 4511dc99b369Smrg old_library= 4512dc99b369Smrg relink_command= 4513dc99b369Smrg func_source "$file" 45145eefee25Smacallan 4515dc99b369Smrg # Add the libdir to current_libdirs if it is the destination. 4516dc99b369Smrg if test "X$destdir" = "X$libdir"; then 4517dc99b369Smrg case "$current_libdirs " in 4518dc99b369Smrg *" $libdir "*) ;; 4519dc99b369Smrg *) func_append current_libdirs " $libdir" ;; 4520dc99b369Smrg esac 4521dc99b369Smrg else 4522dc99b369Smrg # Note the libdir as a future libdir. 4523dc99b369Smrg case "$future_libdirs " in 4524dc99b369Smrg *" $libdir "*) ;; 4525dc99b369Smrg *) func_append future_libdirs " $libdir" ;; 4526dc99b369Smrg esac 4527dc99b369Smrg fi 45285eefee25Smacallan 4529dc99b369Smrg func_dirname "$file" "/" "" 45305c30ecadSmrg dir=$func_dirname_result 4531dc99b369Smrg func_append dir "$objdir" 45325eefee25Smacallan 4533dc99b369Smrg if test -n "$relink_command"; then 4534dc99b369Smrg # Determine the prefix the user has applied to our future dir. 4535dc99b369Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45365eefee25Smacallan 4537dc99b369Smrg # Don't allow the user to place us outside of our expected 4538dc99b369Smrg # location b/c this prevents finding dependent libraries that 4539dc99b369Smrg # are installed to the same prefix. 4540dc99b369Smrg # At present, this check doesn't affect windows .dll's that 4541dc99b369Smrg # are installed into $libdir/../bin (currently, that works fine) 4542dc99b369Smrg # but it's something to keep an eye on. 4543dc99b369Smrg test "$inst_prefix_dir" = "$destdir" && \ 45445c30ecadSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545dc99b369Smrg 4546dc99b369Smrg if test -n "$inst_prefix_dir"; then 4547dc99b369Smrg # Stick the inst_prefix_dir data into the link command. 4548dc99b369Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45495eefee25Smacallan else 4550dc99b369Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45515eefee25Smacallan fi 45525eefee25Smacallan 45535c30ecadSmrg func_warning "relinking '$file'" 4554dc99b369Smrg func_show_eval "$relink_command" \ 45555c30ecadSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556dc99b369Smrg fi 4557dc99b369Smrg 4558dc99b369Smrg # See the names of the shared library. 4559dc99b369Smrg set dummy $library_names; shift 4560dc99b369Smrg if test -n "$1"; then 45615c30ecadSmrg realname=$1 4562dc99b369Smrg shift 4563dc99b369Smrg 45645c30ecadSmrg srcname=$realname 45655c30ecadSmrg test -n "$relink_command" && srcname=${realname}T 4566dc99b369Smrg 4567dc99b369Smrg # Install the shared library and build the symlinks. 4568dc99b369Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569dc99b369Smrg 'exit $?' 45705c30ecadSmrg tstripme=$stripme 4571dc99b369Smrg case $host_os in 4572dc99b369Smrg cygwin* | mingw* | pw32* | cegcc*) 4573dc99b369Smrg case $realname in 4574dc99b369Smrg *.dll.a) 45755c30ecadSmrg tstripme= 45765c30ecadSmrg ;; 45775c30ecadSmrg esac 45785c30ecadSmrg ;; 45795c30ecadSmrg os2*) 45805c30ecadSmrg case $realname in 45815c30ecadSmrg *_dll.a) 45825c30ecadSmrg tstripme= 4583dc99b369Smrg ;; 4584dc99b369Smrg esac 4585dc99b369Smrg ;; 4586dc99b369Smrg esac 4587dc99b369Smrg if test -n "$tstripme" && test -n "$striplib"; then 4588dc99b369Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45895eefee25Smacallan fi 45905eefee25Smacallan 4591dc99b369Smrg if test "$#" -gt 0; then 4592dc99b369Smrg # Delete the old symlinks, and create new ones. 45935c30ecadSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594dc99b369Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595dc99b369Smrg # so we also need to try rm && ln -s. 4596dc99b369Smrg for linkname 4597dc99b369Smrg do 4598dc99b369Smrg test "$linkname" != "$realname" \ 4599dc99b369Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46005eefee25Smacallan done 46015eefee25Smacallan fi 46025eefee25Smacallan 4603dc99b369Smrg # Do each command in the postinstall commands. 46045c30ecadSmrg lib=$destdir/$realname 4605dc99b369Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606dc99b369Smrg fi 46075eefee25Smacallan 4608dc99b369Smrg # Install the pseudo-library for information purposes. 4609dc99b369Smrg func_basename "$file" 46105c30ecadSmrg name=$func_basename_result 46115c30ecadSmrg instname=$dir/${name}i 4612dc99b369Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46135eefee25Smacallan 4614dc99b369Smrg # Maybe install the static library, too. 4615dc99b369Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616dc99b369Smrg ;; 4617dc99b369Smrg 4618dc99b369Smrg *.lo) 4619dc99b369Smrg # Install (i.e. copy) a libtool object. 4620dc99b369Smrg 4621dc99b369Smrg # Figure out destination file name, if it wasn't already specified. 4622dc99b369Smrg if test -n "$destname"; then 46235c30ecadSmrg destfile=$destdir/$destname 46245eefee25Smacallan else 4625dc99b369Smrg func_basename "$file" 46265c30ecadSmrg destfile=$func_basename_result 46275c30ecadSmrg destfile=$destdir/$destfile 46285eefee25Smacallan fi 4629dc99b369Smrg 4630dc99b369Smrg # Deduce the name of the destination old-style object file. 4631dc99b369Smrg case $destfile in 4632dc99b369Smrg *.lo) 4633dc99b369Smrg func_lo2o "$destfile" 4634dc99b369Smrg staticdest=$func_lo2o_result 4635dc99b369Smrg ;; 4636dc99b369Smrg *.$objext) 46375c30ecadSmrg staticdest=$destfile 4638dc99b369Smrg destfile= 4639dc99b369Smrg ;; 4640dc99b369Smrg *) 46415c30ecadSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46425eefee25Smacallan ;; 46435eefee25Smacallan esac 46445eefee25Smacallan 4645dc99b369Smrg # Install the libtool object if requested. 4646dc99b369Smrg test -n "$destfile" && \ 4647dc99b369Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46485eefee25Smacallan 4649dc99b369Smrg # Install the old object if enabled. 46505c30ecadSmrg if test yes = "$build_old_libs"; then 4651dc99b369Smrg # Deduce the name of the old-style object file. 4652dc99b369Smrg func_lo2o "$file" 4653dc99b369Smrg staticobj=$func_lo2o_result 4654dc99b369Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655dc99b369Smrg fi 4656dc99b369Smrg exit $EXIT_SUCCESS 4657dc99b369Smrg ;; 46585eefee25Smacallan 4659dc99b369Smrg *) 4660dc99b369Smrg # Figure out destination file name, if it wasn't already specified. 4661dc99b369Smrg if test -n "$destname"; then 46625c30ecadSmrg destfile=$destdir/$destname 4663dc99b369Smrg else 4664dc99b369Smrg func_basename "$file" 46655c30ecadSmrg destfile=$func_basename_result 46665c30ecadSmrg destfile=$destdir/$destfile 4667dc99b369Smrg fi 46685eefee25Smacallan 4669dc99b369Smrg # If the file is missing, and there is a .exe on the end, strip it 4670dc99b369Smrg # because it is most likely a libtool script we actually want to 4671dc99b369Smrg # install 46725c30ecadSmrg stripped_ext= 4673dc99b369Smrg case $file in 4674dc99b369Smrg *.exe) 4675dc99b369Smrg if test ! -f "$file"; then 4676dc99b369Smrg func_stripname '' '.exe' "$file" 4677dc99b369Smrg file=$func_stripname_result 46785c30ecadSmrg stripped_ext=.exe 4679dc99b369Smrg fi 4680dc99b369Smrg ;; 4681dc99b369Smrg esac 46825eefee25Smacallan 4683dc99b369Smrg # Do a test to see if this is really a libtool program. 4684dc99b369Smrg case $host in 4685dc99b369Smrg *cygwin* | *mingw*) 4686dc99b369Smrg if func_ltwrapper_executable_p "$file"; then 4687dc99b369Smrg func_ltwrapper_scriptname "$file" 4688dc99b369Smrg wrapper=$func_ltwrapper_scriptname_result 4689dc99b369Smrg else 4690dc99b369Smrg func_stripname '' '.exe' "$file" 4691dc99b369Smrg wrapper=$func_stripname_result 4692dc99b369Smrg fi 4693dc99b369Smrg ;; 4694dc99b369Smrg *) 4695dc99b369Smrg wrapper=$file 4696dc99b369Smrg ;; 4697dc99b369Smrg esac 4698dc99b369Smrg if func_ltwrapper_script_p "$wrapper"; then 4699dc99b369Smrg notinst_deplibs= 4700dc99b369Smrg relink_command= 47015eefee25Smacallan 4702dc99b369Smrg func_source "$wrapper" 47035eefee25Smacallan 4704dc99b369Smrg # Check the variables that should have been set. 4705dc99b369Smrg test -z "$generated_by_libtool_version" && \ 47065c30ecadSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47075eefee25Smacallan 47085c30ecadSmrg finalize=: 4709dc99b369Smrg for lib in $notinst_deplibs; do 4710dc99b369Smrg # Check to see that each library is installed. 4711dc99b369Smrg libdir= 4712dc99b369Smrg if test -f "$lib"; then 4713dc99b369Smrg func_source "$lib" 4714dc99b369Smrg fi 47155c30ecadSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716dc99b369Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47175c30ecadSmrg func_warning "'$lib' has not been installed in '$libdir'" 47185c30ecadSmrg finalize=false 4719dc99b369Smrg fi 4720dc99b369Smrg done 47215eefee25Smacallan 4722dc99b369Smrg relink_command= 4723dc99b369Smrg func_source "$wrapper" 4724dc99b369Smrg 4725dc99b369Smrg outputname= 47265c30ecadSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4727dc99b369Smrg $opt_dry_run || { 47285c30ecadSmrg if $finalize; then 4729dc99b369Smrg tmpdir=`func_mktempdir` 4730dc99b369Smrg func_basename "$file$stripped_ext" 47315c30ecadSmrg file=$func_basename_result 47325c30ecadSmrg outputname=$tmpdir/$file 4733dc99b369Smrg # Replace the output file specification. 4734dc99b369Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735dc99b369Smrg 47365c30ecadSmrg $opt_quiet || { 47375c30ecadSmrg func_quote_arg expand,pretty "$relink_command" 47385c30ecadSmrg eval "func_echo $func_quote_arg_result" 4739dc99b369Smrg } 4740dc99b369Smrg if eval "$relink_command"; then : 4741dc99b369Smrg else 47425c30ecadSmrg func_error "error: relink '$file' with the above command before installing it" 4743dc99b369Smrg $opt_dry_run || ${RM}r "$tmpdir" 4744dc99b369Smrg continue 4745dc99b369Smrg fi 47465c30ecadSmrg file=$outputname 4747dc99b369Smrg else 47485c30ecadSmrg func_warning "cannot relink '$file'" 4749dc99b369Smrg fi 4750dc99b369Smrg } 4751dc99b369Smrg else 4752dc99b369Smrg # Install the binary that we compiled earlier. 4753dc99b369Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754dc99b369Smrg fi 47555eefee25Smacallan fi 4756dc99b369Smrg 4757dc99b369Smrg # remove .exe since cygwin /usr/bin/install will append another 4758dc99b369Smrg # one anyway 4759dc99b369Smrg case $install_prog,$host in 4760dc99b369Smrg */usr/bin/install*,*cygwin*) 4761dc99b369Smrg case $file:$destfile in 4762dc99b369Smrg *.exe:*.exe) 4763dc99b369Smrg # this is ok 4764dc99b369Smrg ;; 4765dc99b369Smrg *.exe:*) 4766dc99b369Smrg destfile=$destfile.exe 4767dc99b369Smrg ;; 4768dc99b369Smrg *:*.exe) 4769dc99b369Smrg func_stripname '' '.exe' "$destfile" 4770dc99b369Smrg destfile=$func_stripname_result 4771dc99b369Smrg ;; 4772dc99b369Smrg esac 4773dc99b369Smrg ;; 4774dc99b369Smrg esac 4775dc99b369Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776dc99b369Smrg $opt_dry_run || if test -n "$outputname"; then 4777dc99b369Smrg ${RM}r "$tmpdir" 47785eefee25Smacallan fi 47795eefee25Smacallan ;; 47805eefee25Smacallan esac 4781dc99b369Smrg done 47825eefee25Smacallan 4783dc99b369Smrg for file in $staticlibs; do 4784dc99b369Smrg func_basename "$file" 47855c30ecadSmrg name=$func_basename_result 47865eefee25Smacallan 4787dc99b369Smrg # Set up the ranlib parameters. 47885c30ecadSmrg oldlib=$destdir/$name 47895c30ecadSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47905c30ecadSmrg tool_oldlib=$func_to_tool_file_result 47915eefee25Smacallan 4792dc99b369Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793dc99b369Smrg 4794dc99b369Smrg if test -n "$stripme" && test -n "$old_striplib"; then 47955c30ecadSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47965eefee25Smacallan fi 47975eefee25Smacallan 4798dc99b369Smrg # Do each command in the postinstall commands. 4799dc99b369Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800dc99b369Smrg done 48015eefee25Smacallan 4802dc99b369Smrg test -n "$future_libdirs" && \ 48035c30ecadSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 48045eefee25Smacallan 4805dc99b369Smrg if test -n "$current_libdirs"; then 4806dc99b369Smrg # Maybe just do a dry run. 4807dc99b369Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48085c30ecadSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809dc99b369Smrg else 4810dc99b369Smrg exit $EXIT_SUCCESS 4811dc99b369Smrg fi 4812dc99b369Smrg} 48135eefee25Smacallan 48145c30ecadSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48155eefee25Smacallan 48165eefee25Smacallan 4817dc99b369Smrg# func_generate_dlsyms outputname originator pic_p 4818dc99b369Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819dc99b369Smrg# a dlpreopen symbol table. 4820dc99b369Smrgfunc_generate_dlsyms () 4821dc99b369Smrg{ 48225c30ecadSmrg $debug_cmd 48235c30ecadSmrg 48245c30ecadSmrg my_outputname=$1 48255c30ecadSmrg my_originator=$2 48265c30ecadSmrg my_pic_p=${3-false} 48275c30ecadSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828dc99b369Smrg my_dlsyms= 4829dc99b369Smrg 48305c30ecadSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831dc99b369Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48325c30ecadSmrg my_dlsyms=${my_outputname}S.c 4833dc99b369Smrg else 4834dc99b369Smrg func_error "not configured to extract global symbols from dlpreopened files" 4835dc99b369Smrg fi 4836dc99b369Smrg fi 48375eefee25Smacallan 4838dc99b369Smrg if test -n "$my_dlsyms"; then 4839dc99b369Smrg case $my_dlsyms in 4840dc99b369Smrg "") ;; 4841dc99b369Smrg *.c) 4842dc99b369Smrg # Discover the nlist of each of the dlfiles. 48435c30ecadSmrg nlist=$output_objdir/$my_outputname.nm 48445eefee25Smacallan 4845dc99b369Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48465eefee25Smacallan 4847dc99b369Smrg # Parse the name list into a source file. 4848dc99b369Smrg func_verbose "creating $output_objdir/$my_dlsyms" 48495eefee25Smacallan 4850dc99b369Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48515c30ecadSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48525c30ecadSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48535eefee25Smacallan 4854dc99b369Smrg#ifdef __cplusplus 4855dc99b369Smrgextern \"C\" { 4856dc99b369Smrg#endif 48575eefee25Smacallan 48585c30ecadSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859dc99b369Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860dc99b369Smrg#endif 48615eefee25Smacallan 4862dc99b369Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48635c30ecadSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48645c30ecadSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865dc99b369Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866dc99b369Smrg# define LT_DLSYM_CONST 48675c30ecadSmrg#elif defined __osf__ 4868dc99b369Smrg/* This system does not cope well with relocations in const data. */ 4869dc99b369Smrg# define LT_DLSYM_CONST 4870dc99b369Smrg#else 4871dc99b369Smrg# define LT_DLSYM_CONST const 4872dc99b369Smrg#endif 48735eefee25Smacallan 48745c30ecadSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48755c30ecadSmrg 4876dc99b369Smrg/* External symbol declarations for the compiler. */\ 4877dc99b369Smrg" 48785eefee25Smacallan 48795c30ecadSmrg if test yes = "$dlself"; then 48805c30ecadSmrg func_verbose "generating symbol list for '$output'" 48815eefee25Smacallan 4882dc99b369Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48835eefee25Smacallan 4884dc99b369Smrg # Add our own program objects to the symbol list. 4885dc99b369Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886dc99b369Smrg for progfile in $progfiles; do 4887dc99b369Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48885c30ecadSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889dc99b369Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48905eefee25Smacallan done 48915eefee25Smacallan 4892dc99b369Smrg if test -n "$exclude_expsyms"; then 4893dc99b369Smrg $opt_dry_run || { 4894dc99b369Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895dc99b369Smrg eval '$MV "$nlist"T "$nlist"' 4896dc99b369Smrg } 4897dc99b369Smrg fi 48985eefee25Smacallan 4899dc99b369Smrg if test -n "$export_symbols_regex"; then 4900dc99b369Smrg $opt_dry_run || { 4901dc99b369Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902dc99b369Smrg eval '$MV "$nlist"T "$nlist"' 4903dc99b369Smrg } 4904dc99b369Smrg fi 49055eefee25Smacallan 4906dc99b369Smrg # Prepare the list of exported symbols 4907dc99b369Smrg if test -z "$export_symbols"; then 49085c30ecadSmrg export_symbols=$output_objdir/$outputname.exp 4909dc99b369Smrg $opt_dry_run || { 4910dc99b369Smrg $RM $export_symbols 49115c30ecadSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912dc99b369Smrg case $host in 4913dc99b369Smrg *cygwin* | *mingw* | *cegcc* ) 4914dc99b369Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915dc99b369Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916dc99b369Smrg ;; 4917dc99b369Smrg esac 4918dc99b369Smrg } 4919dc99b369Smrg else 4920dc99b369Smrg $opt_dry_run || { 49215c30ecadSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922dc99b369Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923dc99b369Smrg eval '$MV "$nlist"T "$nlist"' 4924dc99b369Smrg case $host in 4925dc99b369Smrg *cygwin* | *mingw* | *cegcc* ) 4926dc99b369Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927dc99b369Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928dc99b369Smrg ;; 4929dc99b369Smrg esac 4930dc99b369Smrg } 4931dc99b369Smrg fi 4932dc99b369Smrg fi 49335eefee25Smacallan 4934dc99b369Smrg for dlprefile in $dlprefiles; do 49355c30ecadSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4936dc99b369Smrg func_basename "$dlprefile" 49375c30ecadSmrg name=$func_basename_result 4938dc99b369Smrg case $host in 4939dc99b369Smrg *cygwin* | *mingw* | *cegcc* ) 4940dc99b369Smrg # if an import library, we need to obtain dlname 4941dc99b369Smrg if func_win32_import_lib_p "$dlprefile"; then 4942dc99b369Smrg func_tr_sh "$dlprefile" 4943dc99b369Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49445c30ecadSmrg dlprefile_dlbasename= 4945dc99b369Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946dc99b369Smrg # Use subshell, to avoid clobbering current variable values 4947dc99b369Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49485c30ecadSmrg if test -n "$dlprefile_dlname"; then 4949dc99b369Smrg func_basename "$dlprefile_dlname" 49505c30ecadSmrg dlprefile_dlbasename=$func_basename_result 4951dc99b369Smrg else 4952dc99b369Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953dc99b369Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4954dc99b369Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955dc99b369Smrg fi 4956dc99b369Smrg fi 4957dc99b369Smrg $opt_dry_run || { 49585c30ecadSmrg if test -n "$dlprefile_dlbasename"; then 4959dc99b369Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960dc99b369Smrg else 4961dc99b369Smrg func_warning "Could not compute DLL name from $name" 4962dc99b369Smrg eval '$ECHO ": $name " >> "$nlist"' 4963dc99b369Smrg fi 4964dc99b369Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965dc99b369Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966dc99b369Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967dc99b369Smrg } 4968dc99b369Smrg else # not an import lib 4969dc99b369Smrg $opt_dry_run || { 4970dc99b369Smrg eval '$ECHO ": $name " >> "$nlist"' 4971dc99b369Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972dc99b369Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973dc99b369Smrg } 4974dc99b369Smrg fi 4975dc99b369Smrg ;; 4976dc99b369Smrg *) 4977dc99b369Smrg $opt_dry_run || { 4978dc99b369Smrg eval '$ECHO ": $name " >> "$nlist"' 4979dc99b369Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980dc99b369Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981dc99b369Smrg } 4982dc99b369Smrg ;; 4983dc99b369Smrg esac 4984dc99b369Smrg done 49855eefee25Smacallan 4986dc99b369Smrg $opt_dry_run || { 4987dc99b369Smrg # Make sure we have at least an empty file. 4988dc99b369Smrg test -f "$nlist" || : > "$nlist" 49895eefee25Smacallan 4990dc99b369Smrg if test -n "$exclude_expsyms"; then 4991dc99b369Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992dc99b369Smrg $MV "$nlist"T "$nlist" 4993dc99b369Smrg fi 49945eefee25Smacallan 4995dc99b369Smrg # Try sorting and uniquifying the output. 4996dc99b369Smrg if $GREP -v "^: " < "$nlist" | 4997dc99b369Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998dc99b369Smrg sort -k 3 4999dc99b369Smrg else 5000dc99b369Smrg sort +2 5001dc99b369Smrg fi | 5002dc99b369Smrg uniq > "$nlist"S; then 5003dc99b369Smrg : 5004dc99b369Smrg else 5005dc99b369Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006dc99b369Smrg fi 50075eefee25Smacallan 5008dc99b369Smrg if test -f "$nlist"S; then 5009dc99b369Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010dc99b369Smrg else 5011dc99b369Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012dc99b369Smrg fi 50135eefee25Smacallan 50145c30ecadSmrg func_show_eval '$RM "${nlist}I"' 50155c30ecadSmrg if test -n "$global_symbol_to_import"; then 50165c30ecadSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50175c30ecadSmrg fi 50185c30ecadSmrg 5019dc99b369Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020dc99b369Smrg 5021dc99b369Smrg/* The mapping between symbol names and symbols. */ 5022dc99b369Smrgtypedef struct { 5023dc99b369Smrg const char *name; 5024dc99b369Smrg void *address; 5025dc99b369Smrg} lt_dlsymlist; 5026dc99b369Smrgextern LT_DLSYM_CONST lt_dlsymlist 50275c30ecadSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50285c30ecadSmrg" 50295c30ecadSmrg 50305c30ecadSmrg if test -s "$nlist"I; then 50315c30ecadSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50325c30ecadSmrgstatic void lt_syminit(void) 50335c30ecadSmrg{ 50345c30ecadSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50355c30ecadSmrg for (; symbol->name; ++symbol) 50365c30ecadSmrg {" 50375c30ecadSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50385c30ecadSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50395c30ecadSmrg } 50405c30ecadSmrg}" 50415c30ecadSmrg fi 50425c30ecadSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043dc99b369SmrgLT_DLSYM_CONST lt_dlsymlist 5044dc99b369Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50455c30ecadSmrg{ {\"$my_originator\", (void *) 0}," 50465c30ecadSmrg 50475c30ecadSmrg if test -s "$nlist"I; then 50485c30ecadSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50495c30ecadSmrg {\"@INIT@\", (void *) <_syminit}," 50505c30ecadSmrg fi 5051dc99b369Smrg 5052dc99b369Smrg case $need_lib_prefix in 5053dc99b369Smrg no) 5054dc99b369Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50555eefee25Smacallan ;; 50565eefee25Smacallan *) 5057dc99b369Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50585eefee25Smacallan ;; 50595eefee25Smacallan esac 5060dc99b369Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061dc99b369Smrg {0, (void *) 0} 5062dc99b369Smrg}; 50635eefee25Smacallan 5064dc99b369Smrg/* This works around a problem in FreeBSD linker */ 5065dc99b369Smrg#ifdef FREEBSD_WORKAROUND 5066dc99b369Smrgstatic const void *lt_preloaded_setup() { 5067dc99b369Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068dc99b369Smrg} 5069dc99b369Smrg#endif 50705eefee25Smacallan 5071dc99b369Smrg#ifdef __cplusplus 5072dc99b369Smrg} 5073dc99b369Smrg#endif\ 5074dc99b369Smrg" 5075dc99b369Smrg } # !$opt_dry_run 50765eefee25Smacallan 5077dc99b369Smrg pic_flag_for_symtable= 5078dc99b369Smrg case "$compile_command " in 5079dc99b369Smrg *" -static "*) ;; 5080dc99b369Smrg *) 5081dc99b369Smrg case $host in 5082dc99b369Smrg # compiling the symbol table file with pic_flag works around 5083dc99b369Smrg # a FreeBSD bug that causes programs to crash when -lm is 5084dc99b369Smrg # linked before any other PIC object. But we must not use 5085dc99b369Smrg # pic_flag when linking with -static. The problem exists in 5086dc99b369Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50875c30ecadSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088dc99b369Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089dc99b369Smrg *-*-hpux*) 5090dc99b369Smrg pic_flag_for_symtable=" $pic_flag" ;; 5091dc99b369Smrg *) 50925c30ecadSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093dc99b369Smrg ;; 5094dc99b369Smrg esac 5095dc99b369Smrg ;; 5096dc99b369Smrg esac 5097dc99b369Smrg symtab_cflags= 5098dc99b369Smrg for arg in $LTCFLAGS; do 5099dc99b369Smrg case $arg in 5100dc99b369Smrg -pie | -fpie | -fPIE) ;; 5101dc99b369Smrg *) func_append symtab_cflags " $arg" ;; 51025eefee25Smacallan esac 51035eefee25Smacallan done 51045eefee25Smacallan 5105dc99b369Smrg # Now compile the dynamic symbol file. 5106dc99b369Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51075eefee25Smacallan 5108dc99b369Smrg # Clean up the generated files. 51095c30ecadSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51105eefee25Smacallan 5111dc99b369Smrg # Transform the symbol file into the correct name. 51125c30ecadSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113dc99b369Smrg case $host in 5114dc99b369Smrg *cygwin* | *mingw* | *cegcc* ) 5115dc99b369Smrg if test -f "$output_objdir/$my_outputname.def"; then 5116dc99b369Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117dc99b369Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118dc99b369Smrg else 5119dc99b369Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120dc99b369Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121dc99b369Smrg fi 5122dc99b369Smrg ;; 5123dc99b369Smrg *) 5124dc99b369Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125dc99b369Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126dc99b369Smrg ;; 5127dc99b369Smrg esac 5128dc99b369Smrg ;; 5129dc99b369Smrg *) 51305c30ecadSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131dc99b369Smrg ;; 5132dc99b369Smrg esac 5133dc99b369Smrg else 5134dc99b369Smrg # We keep going just in case the user didn't refer to 5135dc99b369Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136dc99b369Smrg # really was required. 51375eefee25Smacallan 5138dc99b369Smrg # Nullify the symbol file. 5139dc99b369Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140dc99b369Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141dc99b369Smrg fi 5142dc99b369Smrg} 51435eefee25Smacallan 51445c30ecadSmrg# func_cygming_gnu_implib_p ARG 51455c30ecadSmrg# This predicate returns with zero status (TRUE) if 51465c30ecadSmrg# ARG is a GNU/binutils-style import library. Returns 51475c30ecadSmrg# with nonzero status (FALSE) otherwise. 51485c30ecadSmrgfunc_cygming_gnu_implib_p () 51495c30ecadSmrg{ 51505c30ecadSmrg $debug_cmd 51515c30ecadSmrg 51525c30ecadSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51535c30ecadSmrg 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)$'` 51545c30ecadSmrg test -n "$func_cygming_gnu_implib_tmp" 51555c30ecadSmrg} 51565c30ecadSmrg 51575c30ecadSmrg# func_cygming_ms_implib_p ARG 51585c30ecadSmrg# This predicate returns with zero status (TRUE) if 51595c30ecadSmrg# ARG is an MS-style import library. Returns 51605c30ecadSmrg# with nonzero status (FALSE) otherwise. 51615c30ecadSmrgfunc_cygming_ms_implib_p () 51625c30ecadSmrg{ 51635c30ecadSmrg $debug_cmd 51645c30ecadSmrg 51655c30ecadSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51665c30ecadSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51675c30ecadSmrg test -n "$func_cygming_ms_implib_tmp" 51685c30ecadSmrg} 51695c30ecadSmrg 5170dc99b369Smrg# func_win32_libid arg 5171dc99b369Smrg# return the library type of file 'arg' 5172dc99b369Smrg# 5173dc99b369Smrg# Need a lot of goo to handle *both* DLLs and import libs 5174dc99b369Smrg# Has to be a shell function in order to 'eat' the argument 5175dc99b369Smrg# that is supplied when $file_magic_command is called. 5176dc99b369Smrg# Despite the name, also deal with 64 bit binaries. 5177dc99b369Smrgfunc_win32_libid () 5178dc99b369Smrg{ 51795c30ecadSmrg $debug_cmd 51805c30ecadSmrg 51815c30ecadSmrg win32_libid_type=unknown 5182dc99b369Smrg win32_fileres=`file -L $1 2>/dev/null` 5183dc99b369Smrg case $win32_fileres in 5184dc99b369Smrg *ar\ archive\ import\ library*) # definitely import 5185dc99b369Smrg win32_libid_type="x86 archive import" 5186dc99b369Smrg ;; 5187dc99b369Smrg *ar\ archive*) # could be an import, or static 5188dc99b369Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189dc99b369Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190dc99b369Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51915c30ecadSmrg case $nm_interface in 51925c30ecadSmrg "MS dumpbin") 51935c30ecadSmrg if func_cygming_ms_implib_p "$1" || 51945c30ecadSmrg func_cygming_gnu_implib_p "$1" 51955c30ecadSmrg then 51965c30ecadSmrg win32_nmres=import 51975c30ecadSmrg else 51985c30ecadSmrg win32_nmres= 51995c30ecadSmrg fi 52005c30ecadSmrg ;; 52015c30ecadSmrg *) 52025c30ecadSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52035c30ecadSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52045c30ecadSmrg $SED -n -e ' 5205dc99b369Smrg 1,100{ 5206dc99b369Smrg / I /{ 52075c30ecadSmrg s|.*|import| 5208dc99b369Smrg p 5209dc99b369Smrg q 5210dc99b369Smrg } 5211dc99b369Smrg }'` 52125c30ecadSmrg ;; 52135c30ecadSmrg esac 5214dc99b369Smrg case $win32_nmres in 5215dc99b369Smrg import*) win32_libid_type="x86 archive import";; 5216dc99b369Smrg *) win32_libid_type="x86 archive static";; 5217dc99b369Smrg esac 5218dc99b369Smrg fi 5219dc99b369Smrg ;; 5220dc99b369Smrg *DLL*) 5221dc99b369Smrg win32_libid_type="x86 DLL" 5222dc99b369Smrg ;; 5223dc99b369Smrg *executable*) # but shell scripts are "executable" too... 5224dc99b369Smrg case $win32_fileres in 5225dc99b369Smrg *MS\ Windows\ PE\ Intel*) 5226dc99b369Smrg win32_libid_type="x86 DLL" 5227dc99b369Smrg ;; 5228dc99b369Smrg esac 5229dc99b369Smrg ;; 5230dc99b369Smrg esac 5231dc99b369Smrg $ECHO "$win32_libid_type" 5232dc99b369Smrg} 5233dc99b369Smrg 5234dc99b369Smrg# func_cygming_dll_for_implib ARG 5235dc99b369Smrg# 5236dc99b369Smrg# Platform-specific function to extract the 5237dc99b369Smrg# name of the DLL associated with the specified 5238dc99b369Smrg# import library ARG. 5239dc99b369Smrg# Invoked by eval'ing the libtool variable 5240dc99b369Smrg# $sharedlib_from_linklib_cmd 5241dc99b369Smrg# Result is available in the variable 5242dc99b369Smrg# $sharedlib_from_linklib_result 5243dc99b369Smrgfunc_cygming_dll_for_implib () 5244dc99b369Smrg{ 52455c30ecadSmrg $debug_cmd 52465c30ecadSmrg 5247dc99b369Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248dc99b369Smrg} 5249dc99b369Smrg 5250dc99b369Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251dc99b369Smrg# 5252dc99b369Smrg# The is the core of a fallback implementation of a 5253dc99b369Smrg# platform-specific function to extract the name of the 5254dc99b369Smrg# DLL associated with the specified import library LIBNAME. 5255dc99b369Smrg# 5256dc99b369Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257dc99b369Smrg# on the platform and compiler that created the implib. 5258dc99b369Smrg# 5259dc99b369Smrg# Echos the name of the DLL associated with the 5260dc99b369Smrg# specified import library. 5261dc99b369Smrgfunc_cygming_dll_for_implib_fallback_core () 5262dc99b369Smrg{ 52635c30ecadSmrg $debug_cmd 52645c30ecadSmrg 5265dc99b369Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266dc99b369Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267dc99b369Smrg $SED '/^Contents of section '"$match_literal"':/{ 5268dc99b369Smrg # Place marker at beginning of archive member dllname section 5269dc99b369Smrg s/.*/====MARK====/ 5270dc99b369Smrg p 5271dc99b369Smrg d 5272dc99b369Smrg } 5273dc99b369Smrg # These lines can sometimes be longer than 43 characters, but 5274dc99b369Smrg # are always uninteresting 5275dc99b369Smrg /:[ ]*file format pe[i]\{,1\}-/d 5276dc99b369Smrg /^In archive [^:]*:/d 5277dc99b369Smrg # Ensure marker is printed 5278dc99b369Smrg /^====MARK====/p 5279dc99b369Smrg # Remove all lines with less than 43 characters 5280dc99b369Smrg /^.\{43\}/!d 5281dc99b369Smrg # From remaining lines, remove first 43 characters 5282dc99b369Smrg s/^.\{43\}//' | 5283dc99b369Smrg $SED -n ' 5284dc99b369Smrg # Join marker and all lines until next marker into a single line 5285dc99b369Smrg /^====MARK====/ b para 5286dc99b369Smrg H 5287dc99b369Smrg $ b para 5288dc99b369Smrg b 5289dc99b369Smrg :para 5290dc99b369Smrg x 5291dc99b369Smrg s/\n//g 5292dc99b369Smrg # Remove the marker 5293dc99b369Smrg s/^====MARK====// 5294dc99b369Smrg # Remove trailing dots and whitespace 5295dc99b369Smrg s/[\. \t]*$// 5296dc99b369Smrg # Print 5297dc99b369Smrg /./p' | 5298dc99b369Smrg # we now have a list, one entry per line, of the stringified 5299dc99b369Smrg # contents of the appropriate section of all members of the 53005c30ecadSmrg # archive that possess that section. Heuristic: eliminate 53015c30ecadSmrg # all those that have a first or second character that is 5302dc99b369Smrg # a '.' (that is, objdump's representation of an unprintable 5303dc99b369Smrg # character.) This should work for all archives with less than 5304dc99b369Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5305dc99b369Smrg # begins with a literal '.' or a single character followed by 5306dc99b369Smrg # a '.'. 5307dc99b369Smrg # 5308dc99b369Smrg # Of those that remain, print the first one. 5309dc99b369Smrg $SED -e '/^\./d;/^.\./d;q' 5310dc99b369Smrg} 5311dc99b369Smrg 5312dc99b369Smrg# func_cygming_dll_for_implib_fallback ARG 5313dc99b369Smrg# Platform-specific function to extract the 5314dc99b369Smrg# name of the DLL associated with the specified 5315dc99b369Smrg# import library ARG. 5316dc99b369Smrg# 5317dc99b369Smrg# This fallback implementation is for use when $DLLTOOL 5318dc99b369Smrg# does not support the --identify-strict option. 5319dc99b369Smrg# Invoked by eval'ing the libtool variable 5320dc99b369Smrg# $sharedlib_from_linklib_cmd 5321dc99b369Smrg# Result is available in the variable 5322dc99b369Smrg# $sharedlib_from_linklib_result 5323dc99b369Smrgfunc_cygming_dll_for_implib_fallback () 5324dc99b369Smrg{ 53255c30ecadSmrg $debug_cmd 53265c30ecadSmrg 53275c30ecadSmrg if func_cygming_gnu_implib_p "$1"; then 5328dc99b369Smrg # binutils import library 5329dc99b369Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53305c30ecadSmrg elif func_cygming_ms_implib_p "$1"; then 5331dc99b369Smrg # ms-generated import library 5332dc99b369Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333dc99b369Smrg else 5334dc99b369Smrg # unknown 53355c30ecadSmrg sharedlib_from_linklib_result= 5336dc99b369Smrg fi 5337dc99b369Smrg} 5338dc99b369Smrg 5339dc99b369Smrg 5340dc99b369Smrg# func_extract_an_archive dir oldlib 5341dc99b369Smrgfunc_extract_an_archive () 5342dc99b369Smrg{ 53435c30ecadSmrg $debug_cmd 53445c30ecadSmrg 53455c30ecadSmrg f_ex_an_ar_dir=$1; shift 53465c30ecadSmrg f_ex_an_ar_oldlib=$1 53475c30ecadSmrg if test yes = "$lock_old_archive_extraction"; then 5348dc99b369Smrg lockfile=$f_ex_an_ar_oldlib.lock 5349dc99b369Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350dc99b369Smrg func_echo "Waiting for $lockfile to be removed" 5351dc99b369Smrg sleep 2 53525eefee25Smacallan done 5353dc99b369Smrg fi 5354dc99b369Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355dc99b369Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53565c30ecadSmrg if test yes = "$lock_old_archive_extraction"; then 5357dc99b369Smrg $opt_dry_run || rm -f "$lockfile" 5358dc99b369Smrg fi 5359dc99b369Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360dc99b369Smrg : 5361dc99b369Smrg else 5362dc99b369Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363dc99b369Smrg fi 5364dc99b369Smrg} 53655eefee25Smacallan 5366dc99b369Smrg 5367dc99b369Smrg# func_extract_archives gentop oldlib ... 5368dc99b369Smrgfunc_extract_archives () 5369dc99b369Smrg{ 53705c30ecadSmrg $debug_cmd 53715c30ecadSmrg 53725c30ecadSmrg my_gentop=$1; shift 5373dc99b369Smrg my_oldlibs=${1+"$@"} 53745c30ecadSmrg my_oldobjs= 53755c30ecadSmrg my_xlib= 53765c30ecadSmrg my_xabs= 53775c30ecadSmrg my_xdir= 5378dc99b369Smrg 5379dc99b369Smrg for my_xlib in $my_oldlibs; do 5380dc99b369Smrg # Extract the objects. 5381dc99b369Smrg case $my_xlib in 53825c30ecadSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383dc99b369Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384dc99b369Smrg esac 5385dc99b369Smrg func_basename "$my_xlib" 53865c30ecadSmrg my_xlib=$func_basename_result 5387dc99b369Smrg my_xlib_u=$my_xlib 5388dc99b369Smrg while :; do 5389dc99b369Smrg case " $extracted_archives " in 5390dc99b369Smrg *" $my_xlib_u "*) 5391dc99b369Smrg func_arith $extracted_serial + 1 5392dc99b369Smrg extracted_serial=$func_arith_result 5393dc99b369Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394dc99b369Smrg *) break ;; 53955eefee25Smacallan esac 53965eefee25Smacallan done 5397dc99b369Smrg extracted_archives="$extracted_archives $my_xlib_u" 53985c30ecadSmrg my_xdir=$my_gentop/$my_xlib_u 53995eefee25Smacallan 5400dc99b369Smrg func_mkdir_p "$my_xdir" 54015eefee25Smacallan 5402dc99b369Smrg case $host in 5403dc99b369Smrg *-darwin*) 5404dc99b369Smrg func_verbose "Extracting $my_xabs" 5405dc99b369Smrg # Do not bother doing anything if just a dry run 5406dc99b369Smrg $opt_dry_run || { 5407dc99b369Smrg darwin_orig_dir=`pwd` 5408dc99b369Smrg cd $my_xdir || exit $? 5409dc99b369Smrg darwin_archive=$my_xabs 5410dc99b369Smrg darwin_curdir=`pwd` 54115c30ecadSmrg func_basename "$darwin_archive" 54125c30ecadSmrg darwin_base_archive=$func_basename_result 5413dc99b369Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414dc99b369Smrg if test -n "$darwin_arches"; then 5415dc99b369Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416dc99b369Smrg darwin_arch= 5417dc99b369Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54185c30ecadSmrg for darwin_arch in $darwin_arches; do 54195c30ecadSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54205c30ecadSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54215c30ecadSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54225c30ecadSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423dc99b369Smrg cd "$darwin_curdir" 54245c30ecadSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425dc99b369Smrg done # $darwin_arches 5426dc99b369Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54275c30ecadSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428dc99b369Smrg darwin_file= 5429dc99b369Smrg darwin_files= 5430dc99b369Smrg for darwin_file in $darwin_filelist; do 5431dc99b369Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432dc99b369Smrg $LIPO -create -output "$darwin_file" $darwin_files 5433dc99b369Smrg done # $darwin_filelist 5434dc99b369Smrg $RM -rf unfat-$$ 5435dc99b369Smrg cd "$darwin_orig_dir" 54365eefee25Smacallan else 5437dc99b369Smrg cd $darwin_orig_dir 5438dc99b369Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439dc99b369Smrg fi # $darwin_arches 5440dc99b369Smrg } # !$opt_dry_run 5441dc99b369Smrg ;; 5442dc99b369Smrg *) 5443dc99b369Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444dc99b369Smrg ;; 5445dc99b369Smrg esac 5446dc99b369Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447dc99b369Smrg done 54485eefee25Smacallan 54495c30ecadSmrg func_extract_archives_result=$my_oldobjs 5450dc99b369Smrg} 54515eefee25Smacallan 54525eefee25Smacallan 5453dc99b369Smrg# func_emit_wrapper [arg=no] 5454dc99b369Smrg# 5455dc99b369Smrg# Emit a libtool wrapper script on stdout. 5456dc99b369Smrg# Don't directly open a file because we may want to 5457dc99b369Smrg# incorporate the script contents within a cygwin/mingw 5458dc99b369Smrg# wrapper executable. Must ONLY be called from within 5459dc99b369Smrg# func_mode_link because it depends on a number of variables 5460dc99b369Smrg# set therein. 5461dc99b369Smrg# 5462dc99b369Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463dc99b369Smrg# variable will take. If 'yes', then the emitted script 54645c30ecadSmrg# will assume that the directory where it is stored is 5465dc99b369Smrg# the $objdir directory. This is a cygwin/mingw-specific 5466dc99b369Smrg# behavior. 5467dc99b369Smrgfunc_emit_wrapper () 5468dc99b369Smrg{ 5469dc99b369Smrg func_emit_wrapper_arg1=${1-no} 54705eefee25Smacallan 5471dc99b369Smrg $ECHO "\ 5472dc99b369Smrg#! $SHELL 54735eefee25Smacallan 5474dc99b369Smrg# $output - temporary wrapper script for $objdir/$outputname 54755c30ecadSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476dc99b369Smrg# 5477dc99b369Smrg# The $output program cannot be directly executed until all the libtool 5478dc99b369Smrg# libraries that it depends on are installed. 5479dc99b369Smrg# 5480dc99b369Smrg# This wrapper script should never be moved out of the build directory. 5481dc99b369Smrg# If it is, it will not operate correctly. 54825eefee25Smacallan 5483dc99b369Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5484dc99b369Smrg# metacharacters that are still active within double-quoted strings. 5485dc99b369Smrgsed_quote_subst='$sed_quote_subst' 54865eefee25Smacallan 5487dc99b369Smrg# Be Bourne compatible 5488dc99b369Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489dc99b369Smrg emulate sh 5490dc99b369Smrg NULLCMD=: 5491dc99b369Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492dc99b369Smrg # is contrary to our usage. Disable this feature. 5493dc99b369Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494dc99b369Smrg setopt NO_GLOB_SUBST 5495dc99b369Smrgelse 5496dc99b369Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497dc99b369Smrgfi 5498dc99b369SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499dc99b369SmrgDUALCASE=1; export DUALCASE # for MKS sh 55005eefee25Smacallan 5501dc99b369Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502dc99b369Smrg# if CDPATH is set. 5503dc99b369Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55045eefee25Smacallan 5505dc99b369Smrgrelink_command=\"$relink_command\" 55065eefee25Smacallan 5507dc99b369Smrg# This environment variable determines our operation mode. 5508dc99b369Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509dc99b369Smrg # install mode needs the following variables: 5510dc99b369Smrg generated_by_libtool_version='$macro_version' 5511dc99b369Smrg notinst_deplibs='$notinst_deplibs' 5512dc99b369Smrgelse 5513dc99b369Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514dc99b369Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515dc99b369Smrg file=\"\$0\"" 55165eefee25Smacallan 55175c30ecadSmrg func_quote_arg pretty "$ECHO" 55185c30ecadSmrg qECHO=$func_quote_arg_result 5519dc99b369Smrg $ECHO "\ 55205eefee25Smacallan 5521dc99b369Smrg# A function that is used when there is no print builtin or printf. 5522dc99b369Smrgfunc_fallback_echo () 5523dc99b369Smrg{ 5524dc99b369Smrg eval 'cat <<_LTECHO_EOF 5525dc99b369Smrg\$1 5526dc99b369Smrg_LTECHO_EOF' 5527dc99b369Smrg} 55285c30ecadSmrg ECHO=$qECHO 5529dc99b369Smrg fi 55305eefee25Smacallan 5531dc99b369Smrg# Very basic option parsing. These options are (a) specific to 5532dc99b369Smrg# the libtool wrapper, (b) are identical between the wrapper 55335c30ecadSmrg# /script/ and the wrapper /executable/ that is used only on 5534dc99b369Smrg# windows platforms, and (c) all begin with the string "--lt-" 55355c30ecadSmrg# (application programs are unlikely to have options that match 5536dc99b369Smrg# this pattern). 5537dc99b369Smrg# 5538dc99b369Smrg# There are only two supported options: --lt-debug and 5539dc99b369Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540dc99b369Smrg# 5541dc99b369Smrg# The first argument to this parsing function should be the 5542dc99b369Smrg# script's $0 value, followed by "$@". 5543dc99b369Smrglt_option_debug= 5544dc99b369Smrgfunc_parse_lt_options () 5545dc99b369Smrg{ 5546dc99b369Smrg lt_script_arg0=\$0 5547dc99b369Smrg shift 5548dc99b369Smrg for lt_opt 5549dc99b369Smrg do 5550dc99b369Smrg case \"\$lt_opt\" in 5551dc99b369Smrg --lt-debug) lt_option_debug=1 ;; 5552dc99b369Smrg --lt-dump-script) 5553dc99b369Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554dc99b369Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555dc99b369Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556dc99b369Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557dc99b369Smrg exit 0 5558dc99b369Smrg ;; 5559dc99b369Smrg --lt-*) 5560dc99b369Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561dc99b369Smrg exit 1 5562dc99b369Smrg ;; 5563dc99b369Smrg esac 5564dc99b369Smrg done 55655eefee25Smacallan 5566dc99b369Smrg # Print the debug banner immediately: 5567dc99b369Smrg if test -n \"\$lt_option_debug\"; then 55685c30ecadSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569dc99b369Smrg fi 5570dc99b369Smrg} 55715eefee25Smacallan 5572dc99b369Smrg# Used when --lt-debug. Prints its arguments to stdout 5573dc99b369Smrg# (redirection is the responsibility of the caller) 5574dc99b369Smrgfunc_lt_dump_args () 5575dc99b369Smrg{ 5576dc99b369Smrg lt_dump_args_N=1; 5577dc99b369Smrg for lt_arg 5578dc99b369Smrg do 55795c30ecadSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580dc99b369Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581dc99b369Smrg done 5582dc99b369Smrg} 55835eefee25Smacallan 5584dc99b369Smrg# Core function for launching the target application 5585dc99b369Smrgfunc_exec_program_core () 5586dc99b369Smrg{ 5587dc99b369Smrg" 5588dc99b369Smrg case $host in 5589dc99b369Smrg # Backslashes separate directories on plain windows 5590dc99b369Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5591dc99b369Smrg $ECHO "\ 5592dc99b369Smrg if test -n \"\$lt_option_debug\"; then 55935c30ecadSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594dc99b369Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595dc99b369Smrg fi 5596dc99b369Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597dc99b369Smrg" 5598dc99b369Smrg ;; 55995eefee25Smacallan 5600dc99b369Smrg *) 5601dc99b369Smrg $ECHO "\ 5602dc99b369Smrg if test -n \"\$lt_option_debug\"; then 56035c30ecadSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604dc99b369Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605dc99b369Smrg fi 5606dc99b369Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607dc99b369Smrg" 5608dc99b369Smrg ;; 5609dc99b369Smrg esac 5610dc99b369Smrg $ECHO "\ 5611dc99b369Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612dc99b369Smrg exit 1 5613dc99b369Smrg} 56145eefee25Smacallan 5615dc99b369Smrg# A function to encapsulate launching the target application 5616dc99b369Smrg# Strips options in the --lt-* namespace from \$@ and 5617dc99b369Smrg# launches target application with the remaining arguments. 5618dc99b369Smrgfunc_exec_program () 5619dc99b369Smrg{ 56205c30ecadSmrg case \" \$* \" in 56215c30ecadSmrg *\\ --lt-*) 56225c30ecadSmrg for lt_wr_arg 56235c30ecadSmrg do 56245c30ecadSmrg case \$lt_wr_arg in 56255c30ecadSmrg --lt-*) ;; 56265c30ecadSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56275c30ecadSmrg esac 56285c30ecadSmrg shift 56295c30ecadSmrg done ;; 56305c30ecadSmrg esac 5631dc99b369Smrg func_exec_program_core \${1+\"\$@\"} 5632dc99b369Smrg} 56335eefee25Smacallan 5634dc99b369Smrg # Parse options 5635dc99b369Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56365eefee25Smacallan 5637dc99b369Smrg # Find the directory that this script lives in. 5638dc99b369Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639dc99b369Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56405eefee25Smacallan 5641dc99b369Smrg # Follow symbolic links until we get to the real thisdir. 5642dc99b369Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643dc99b369Smrg while test -n \"\$file\"; do 5644dc99b369Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56455eefee25Smacallan 5646dc99b369Smrg # If there was a directory component, then change thisdir. 5647dc99b369Smrg if test \"x\$destdir\" != \"x\$file\"; then 5648dc99b369Smrg case \"\$destdir\" in 5649dc99b369Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650dc99b369Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651dc99b369Smrg esac 5652dc99b369Smrg fi 56535eefee25Smacallan 5654dc99b369Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655dc99b369Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656dc99b369Smrg done 56575eefee25Smacallan 5658dc99b369Smrg # Usually 'no', except on cygwin/mingw when embedded into 5659dc99b369Smrg # the cwrapper. 5660dc99b369Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661dc99b369Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662dc99b369Smrg # special case for '.' 5663dc99b369Smrg if test \"\$thisdir\" = \".\"; then 5664dc99b369Smrg thisdir=\`pwd\` 5665dc99b369Smrg fi 5666dc99b369Smrg # remove .libs from thisdir 5667dc99b369Smrg case \"\$thisdir\" in 5668dc99b369Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669dc99b369Smrg $objdir ) thisdir=. ;; 5670dc99b369Smrg esac 5671dc99b369Smrg fi 56725eefee25Smacallan 5673dc99b369Smrg # Try to get the absolute directory name. 5674dc99b369Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5675dc99b369Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676dc99b369Smrg" 56775eefee25Smacallan 56785c30ecadSmrg if test yes = "$fast_install"; then 5679dc99b369Smrg $ECHO "\ 5680dc99b369Smrg program=lt-'$outputname'$exeext 5681dc99b369Smrg progdir=\"\$thisdir/$objdir\" 56825eefee25Smacallan 5683dc99b369Smrg if test ! -f \"\$progdir/\$program\" || 56845c30ecadSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685dc99b369Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56865eefee25Smacallan 5687dc99b369Smrg file=\"\$\$-\$program\" 56885eefee25Smacallan 5689dc99b369Smrg if test ! -d \"\$progdir\"; then 5690dc99b369Smrg $MKDIR \"\$progdir\" 5691dc99b369Smrg else 5692dc99b369Smrg $RM \"\$progdir/\$file\" 5693dc99b369Smrg fi" 56945eefee25Smacallan 5695dc99b369Smrg $ECHO "\ 56965eefee25Smacallan 5697dc99b369Smrg # relink executable if necessary 5698dc99b369Smrg if test -n \"\$relink_command\"; then 5699dc99b369Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700dc99b369Smrg else 57015c30ecadSmrg \$ECHO \"\$relink_command_output\" >&2 5702dc99b369Smrg $RM \"\$progdir/\$file\" 5703dc99b369Smrg exit 1 5704dc99b369Smrg fi 5705dc99b369Smrg fi 57065eefee25Smacallan 5707dc99b369Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708dc99b369Smrg { $RM \"\$progdir/\$program\"; 5709dc99b369Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710dc99b369Smrg $RM \"\$progdir/\$file\" 5711dc99b369Smrg fi" 5712dc99b369Smrg else 5713dc99b369Smrg $ECHO "\ 5714dc99b369Smrg program='$outputname' 5715dc99b369Smrg progdir=\"\$thisdir/$objdir\" 5716dc99b369Smrg" 57175eefee25Smacallan fi 57185eefee25Smacallan 5719dc99b369Smrg $ECHO "\ 57205eefee25Smacallan 5721dc99b369Smrg if test -f \"\$progdir/\$program\"; then" 57225eefee25Smacallan 5723dc99b369Smrg # fixup the dll searchpath if we need to. 5724dc99b369Smrg # 5725dc99b369Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5726dc99b369Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727dc99b369Smrg # libraries must come first. 5728dc99b369Smrg if test -n "$dllsearchpath"; then 5729dc99b369Smrg $ECHO "\ 5730dc99b369Smrg # Add the dll search path components to the executable PATH 5731dc99b369Smrg PATH=$dllsearchpath:\$PATH 5732dc99b369Smrg" 5733dc99b369Smrg fi 57345eefee25Smacallan 5735dc99b369Smrg # Export our shlibpath_var if we have one. 57365c30ecadSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737dc99b369Smrg $ECHO "\ 5738dc99b369Smrg # Add our own library path to $shlibpath_var 5739dc99b369Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57405eefee25Smacallan 5741dc99b369Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742dc99b369Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5743dc99b369Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57445eefee25Smacallan 5745dc99b369Smrg export $shlibpath_var 5746dc99b369Smrg" 5747dc99b369Smrg fi 57485eefee25Smacallan 5749dc99b369Smrg $ECHO "\ 5750dc99b369Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751dc99b369Smrg # Run the actual program with our arguments. 5752dc99b369Smrg func_exec_program \${1+\"\$@\"} 5753dc99b369Smrg fi 5754dc99b369Smrg else 5755dc99b369Smrg # The program doesn't exist. 57565c30ecadSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757dc99b369Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758dc99b369Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759dc99b369Smrg exit 1 5760dc99b369Smrg fi 5761dc99b369Smrgfi\ 5762dc99b369Smrg" 5763dc99b369Smrg} 57645eefee25Smacallan 57655eefee25Smacallan 5766dc99b369Smrg# func_emit_cwrapperexe_src 5767dc99b369Smrg# emit the source code for a wrapper executable on stdout 5768dc99b369Smrg# Must ONLY be called from within func_mode_link because 5769dc99b369Smrg# it depends on a number of variable set therein. 5770dc99b369Smrgfunc_emit_cwrapperexe_src () 5771dc99b369Smrg{ 5772dc99b369Smrg cat <<EOF 57735eefee25Smacallan 5774dc99b369Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57755c30ecadSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57765eefee25Smacallan 5777dc99b369Smrg The $output program cannot be directly executed until all the libtool 5778dc99b369Smrg libraries that it depends on are installed. 57795eefee25Smacallan 5780dc99b369Smrg This wrapper executable should never be moved out of the build directory. 5781dc99b369Smrg If it is, it will not operate correctly. 5782dc99b369Smrg*/ 5783dc99b369SmrgEOF 5784dc99b369Smrg cat <<"EOF" 5785dc99b369Smrg#ifdef _MSC_VER 5786dc99b369Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5787dc99b369Smrg#endif 5788dc99b369Smrg#include <stdio.h> 5789dc99b369Smrg#include <stdlib.h> 5790dc99b369Smrg#ifdef _MSC_VER 5791dc99b369Smrg# include <direct.h> 5792dc99b369Smrg# include <process.h> 5793dc99b369Smrg# include <io.h> 5794dc99b369Smrg#else 5795dc99b369Smrg# include <unistd.h> 5796dc99b369Smrg# include <stdint.h> 5797dc99b369Smrg# ifdef __CYGWIN__ 5798dc99b369Smrg# include <io.h> 5799dc99b369Smrg# endif 5800dc99b369Smrg#endif 5801dc99b369Smrg#include <malloc.h> 5802dc99b369Smrg#include <stdarg.h> 5803dc99b369Smrg#include <assert.h> 5804dc99b369Smrg#include <string.h> 5805dc99b369Smrg#include <ctype.h> 5806dc99b369Smrg#include <errno.h> 5807dc99b369Smrg#include <fcntl.h> 5808dc99b369Smrg#include <sys/stat.h> 58095eefee25Smacallan 58105c30ecadSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58115c30ecadSmrg 5812dc99b369Smrg/* declarations of non-ANSI functions */ 58135c30ecadSmrg#if defined __MINGW32__ 5814dc99b369Smrg# ifdef __STRICT_ANSI__ 5815dc99b369Smrgint _putenv (const char *); 5816dc99b369Smrg# endif 58175c30ecadSmrg#elif defined __CYGWIN__ 5818dc99b369Smrg# ifdef __STRICT_ANSI__ 5819dc99b369Smrgchar *realpath (const char *, char *); 5820dc99b369Smrgint putenv (char *); 5821dc99b369Smrgint setenv (const char *, const char *, int); 5822dc99b369Smrg# endif 58235c30ecadSmrg/* #elif defined other_platform || defined ... */ 5824dc99b369Smrg#endif 58255eefee25Smacallan 5826dc99b369Smrg/* portability defines, excluding path handling macros */ 58275c30ecadSmrg#if defined _MSC_VER 5828dc99b369Smrg# define setmode _setmode 5829dc99b369Smrg# define stat _stat 5830dc99b369Smrg# define chmod _chmod 5831dc99b369Smrg# define getcwd _getcwd 5832dc99b369Smrg# define putenv _putenv 5833dc99b369Smrg# define S_IXUSR _S_IEXEC 58345c30ecadSmrg#elif defined __MINGW32__ 5835dc99b369Smrg# define setmode _setmode 5836dc99b369Smrg# define stat _stat 5837dc99b369Smrg# define chmod _chmod 5838dc99b369Smrg# define getcwd _getcwd 5839dc99b369Smrg# define putenv _putenv 58405c30ecadSmrg#elif defined __CYGWIN__ 5841dc99b369Smrg# define HAVE_SETENV 5842dc99b369Smrg# define FOPEN_WB "wb" 58435c30ecadSmrg/* #elif defined other platforms ... */ 5844dc99b369Smrg#endif 58455eefee25Smacallan 58465c30ecadSmrg#if defined PATH_MAX 5847dc99b369Smrg# define LT_PATHMAX PATH_MAX 58485c30ecadSmrg#elif defined MAXPATHLEN 5849dc99b369Smrg# define LT_PATHMAX MAXPATHLEN 5850dc99b369Smrg#else 5851dc99b369Smrg# define LT_PATHMAX 1024 5852dc99b369Smrg#endif 58535eefee25Smacallan 5854dc99b369Smrg#ifndef S_IXOTH 5855dc99b369Smrg# define S_IXOTH 0 5856dc99b369Smrg#endif 5857dc99b369Smrg#ifndef S_IXGRP 5858dc99b369Smrg# define S_IXGRP 0 5859dc99b369Smrg#endif 58605eefee25Smacallan 5861dc99b369Smrg/* path handling portability macros */ 5862dc99b369Smrg#ifndef DIR_SEPARATOR 5863dc99b369Smrg# define DIR_SEPARATOR '/' 5864dc99b369Smrg# define PATH_SEPARATOR ':' 5865dc99b369Smrg#endif 58665eefee25Smacallan 58675c30ecadSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58685c30ecadSmrg defined __OS2__ 5869dc99b369Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870dc99b369Smrg# define FOPEN_WB "wb" 5871dc99b369Smrg# ifndef DIR_SEPARATOR_2 5872dc99b369Smrg# define DIR_SEPARATOR_2 '\\' 5873dc99b369Smrg# endif 5874dc99b369Smrg# ifndef PATH_SEPARATOR_2 5875dc99b369Smrg# define PATH_SEPARATOR_2 ';' 5876dc99b369Smrg# endif 5877dc99b369Smrg#endif 58785eefee25Smacallan 5879dc99b369Smrg#ifndef DIR_SEPARATOR_2 5880dc99b369Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881dc99b369Smrg#else /* DIR_SEPARATOR_2 */ 5882dc99b369Smrg# define IS_DIR_SEPARATOR(ch) \ 5883dc99b369Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884dc99b369Smrg#endif /* DIR_SEPARATOR_2 */ 58855eefee25Smacallan 5886dc99b369Smrg#ifndef PATH_SEPARATOR_2 5887dc99b369Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888dc99b369Smrg#else /* PATH_SEPARATOR_2 */ 5889dc99b369Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890dc99b369Smrg#endif /* PATH_SEPARATOR_2 */ 58915eefee25Smacallan 5892dc99b369Smrg#ifndef FOPEN_WB 5893dc99b369Smrg# define FOPEN_WB "w" 5894dc99b369Smrg#endif 5895dc99b369Smrg#ifndef _O_BINARY 5896dc99b369Smrg# define _O_BINARY 0 5897dc99b369Smrg#endif 58985eefee25Smacallan 5899dc99b369Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900dc99b369Smrg#define XFREE(stale) do { \ 59015c30ecadSmrg if (stale) { free (stale); stale = 0; } \ 5902dc99b369Smrg} while (0) 59035eefee25Smacallan 59045c30ecadSmrg#if defined LT_DEBUGWRAPPER 5905dc99b369Smrgstatic int lt_debug = 1; 5906dc99b369Smrg#else 5907dc99b369Smrgstatic int lt_debug = 0; 5908dc99b369Smrg#endif 59095eefee25Smacallan 5910dc99b369Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911dc99b369Smrg 5912dc99b369Smrgvoid *xmalloc (size_t num); 5913dc99b369Smrgchar *xstrdup (const char *string); 5914dc99b369Smrgconst char *base_name (const char *name); 5915dc99b369Smrgchar *find_executable (const char *wrapper); 5916dc99b369Smrgchar *chase_symlinks (const char *pathspec); 5917dc99b369Smrgint make_executable (const char *path); 5918dc99b369Smrgint check_executable (const char *path); 5919dc99b369Smrgchar *strendzap (char *str, const char *pat); 5920dc99b369Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921dc99b369Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922dc99b369Smrgstatic const char *nonnull (const char *s); 5923dc99b369Smrgstatic const char *nonempty (const char *s); 5924dc99b369Smrgvoid lt_setenv (const char *name, const char *value); 5925dc99b369Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926dc99b369Smrgvoid lt_update_exe_path (const char *name, const char *value); 5927dc99b369Smrgvoid lt_update_lib_path (const char *name, const char *value); 5928dc99b369Smrgchar **prepare_spawn (char **argv); 5929dc99b369Smrgvoid lt_dump_script (FILE *f); 5930dc99b369SmrgEOF 59315eefee25Smacallan 5932dc99b369Smrg cat <<EOF 59335c30ecadSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59345c30ecadSmrg# define externally_visible volatile 59355c30ecadSmrg#else 59365c30ecadSmrg# define externally_visible __attribute__((externally_visible)) volatile 59375c30ecadSmrg#endif 59385c30ecadSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939dc99b369Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940dc99b369SmrgEOF 59415eefee25Smacallan 59425c30ecadSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943dc99b369Smrg func_to_host_path "$temp_rpath" 5944dc99b369Smrg cat <<EOF 5945dc99b369Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946dc99b369SmrgEOF 5947dc99b369Smrg else 5948dc99b369Smrg cat <<"EOF" 5949dc99b369Smrgconst char * LIB_PATH_VALUE = ""; 5950dc99b369SmrgEOF 5951dc99b369Smrg fi 59525eefee25Smacallan 5953dc99b369Smrg if test -n "$dllsearchpath"; then 5954dc99b369Smrg func_to_host_path "$dllsearchpath:" 5955dc99b369Smrg cat <<EOF 5956dc99b369Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957dc99b369Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958dc99b369SmrgEOF 5959dc99b369Smrg else 5960dc99b369Smrg cat <<"EOF" 5961dc99b369Smrgconst char * EXE_PATH_VARNAME = ""; 5962dc99b369Smrgconst char * EXE_PATH_VALUE = ""; 5963dc99b369SmrgEOF 5964dc99b369Smrg fi 59655eefee25Smacallan 59665c30ecadSmrg if test yes = "$fast_install"; then 5967dc99b369Smrg cat <<EOF 5968dc99b369Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969dc99b369SmrgEOF 5970dc99b369Smrg else 5971dc99b369Smrg cat <<EOF 5972dc99b369Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973dc99b369SmrgEOF 5974dc99b369Smrg fi 59755eefee25Smacallan 59765eefee25Smacallan 5977dc99b369Smrg cat <<"EOF" 59785eefee25Smacallan 5979dc99b369Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59805eefee25Smacallan 5981dc99b369Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982dc99b369Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983dc99b369Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59845eefee25Smacallan 5985dc99b369Smrgint 5986dc99b369Smrgmain (int argc, char *argv[]) 5987dc99b369Smrg{ 5988dc99b369Smrg char **newargz; 5989dc99b369Smrg int newargc; 5990dc99b369Smrg char *tmp_pathspec; 5991dc99b369Smrg char *actual_cwrapper_path; 5992dc99b369Smrg char *actual_cwrapper_name; 5993dc99b369Smrg char *target_name; 5994dc99b369Smrg char *lt_argv_zero; 59955c30ecadSmrg int rval = 127; 5996dc99b369Smrg 5997dc99b369Smrg int i; 5998dc99b369Smrg 5999dc99b369Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60005c30ecadSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001dc99b369Smrg 6002dc99b369Smrg /* very simple arg parsing; don't want to rely on getopt 6003dc99b369Smrg * also, copy all non cwrapper options to newargz, except 6004dc99b369Smrg * argz[0], which is handled differently 6005dc99b369Smrg */ 6006dc99b369Smrg newargc=0; 6007dc99b369Smrg for (i = 1; i < argc; i++) 6008dc99b369Smrg { 60095c30ecadSmrg if (STREQ (argv[i], dumpscript_opt)) 6010dc99b369Smrg { 6011dc99b369SmrgEOF 60125c30ecadSmrg case $host in 6013dc99b369Smrg *mingw* | *cygwin* ) 6014dc99b369Smrg # make stdout use "unix" line endings 6015dc99b369Smrg echo " setmode(1,_O_BINARY);" 60165eefee25Smacallan ;; 60175eefee25Smacallan esac 60185eefee25Smacallan 6019dc99b369Smrg cat <<"EOF" 6020dc99b369Smrg lt_dump_script (stdout); 6021dc99b369Smrg return 0; 6022dc99b369Smrg } 60235c30ecadSmrg if (STREQ (argv[i], debug_opt)) 6024dc99b369Smrg { 6025dc99b369Smrg lt_debug = 1; 6026dc99b369Smrg continue; 6027dc99b369Smrg } 60285c30ecadSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029dc99b369Smrg { 6030dc99b369Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031dc99b369Smrg namespace, but it is not one of the ones we know about and 6032dc99b369Smrg have already dealt with, above (inluding dump-script), then 6033dc99b369Smrg report an error. Otherwise, targets might begin to believe 6034dc99b369Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035dc99b369Smrg namespace. The first time any user complains about this, we'll 6036dc99b369Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037dc99b369Smrg or a configure.ac-settable value. 6038dc99b369Smrg */ 6039dc99b369Smrg lt_fatal (__FILE__, __LINE__, 6040dc99b369Smrg "unrecognized %s option: '%s'", 6041dc99b369Smrg ltwrapper_option_prefix, argv[i]); 6042dc99b369Smrg } 6043dc99b369Smrg /* otherwise ... */ 6044dc99b369Smrg newargz[++newargc] = xstrdup (argv[i]); 6045dc99b369Smrg } 6046dc99b369Smrg newargz[++newargc] = NULL; 60475eefee25Smacallan 6048dc99b369SmrgEOF 6049dc99b369Smrg cat <<EOF 6050dc99b369Smrg /* The GNU banner must be the first non-error debug message */ 60515c30ecadSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052dc99b369SmrgEOF 6053dc99b369Smrg cat <<"EOF" 6054dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056dc99b369Smrg 6057dc99b369Smrg tmp_pathspec = find_executable (argv[0]); 6058dc99b369Smrg if (tmp_pathspec == NULL) 6059dc99b369Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6061dc99b369Smrg "(main) found exe (before symlink chase) at: %s\n", 6062dc99b369Smrg tmp_pathspec); 6063dc99b369Smrg 6064dc99b369Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6066dc99b369Smrg "(main) found exe (after symlink chase) at: %s\n", 6067dc99b369Smrg actual_cwrapper_path); 6068dc99b369Smrg XFREE (tmp_pathspec); 6069dc99b369Smrg 6070dc99b369Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071dc99b369Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072dc99b369Smrg 6073dc99b369Smrg /* wrapper name transforms */ 6074dc99b369Smrg strendzap (actual_cwrapper_name, ".exe"); 6075dc99b369Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076dc99b369Smrg XFREE (actual_cwrapper_name); 6077dc99b369Smrg actual_cwrapper_name = tmp_pathspec; 6078dc99b369Smrg tmp_pathspec = 0; 6079dc99b369Smrg 6080dc99b369Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081dc99b369Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082dc99b369Smrg strendzap (target_name, ".exe"); 6083dc99b369Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084dc99b369Smrg XFREE (target_name); 6085dc99b369Smrg target_name = tmp_pathspec; 6086dc99b369Smrg tmp_pathspec = 0; 6087dc99b369Smrg 6088dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6089dc99b369Smrg "(main) libtool target name: %s\n", 6090dc99b369Smrg target_name); 6091dc99b369SmrgEOF 60925eefee25Smacallan 6093dc99b369Smrg cat <<EOF 6094dc99b369Smrg newargz[0] = 6095dc99b369Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096dc99b369Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097dc99b369Smrg strcpy (newargz[0], actual_cwrapper_path); 6098dc99b369Smrg strcat (newargz[0], "$objdir"); 6099dc99b369Smrg strcat (newargz[0], "/"); 6100dc99b369SmrgEOF 61015eefee25Smacallan 6102dc99b369Smrg cat <<"EOF" 6103dc99b369Smrg /* stop here, and copy so we don't have to do this twice */ 6104dc99b369Smrg tmp_pathspec = xstrdup (newargz[0]); 61055eefee25Smacallan 6106dc99b369Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107dc99b369Smrg strcat (newargz[0], actual_cwrapper_name); 61085eefee25Smacallan 6109dc99b369Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110dc99b369Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111dc99b369Smrg XFREE (tmp_pathspec); 6112dc99b369Smrg tmp_pathspec = NULL; 6113dc99b369SmrgEOF 61145eefee25Smacallan 6115dc99b369Smrg case $host_os in 6116dc99b369Smrg mingw*) 6117dc99b369Smrg cat <<"EOF" 6118dc99b369Smrg { 6119dc99b369Smrg char* p; 6120dc99b369Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121dc99b369Smrg { 6122dc99b369Smrg *p = '/'; 6123dc99b369Smrg } 6124dc99b369Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125dc99b369Smrg { 6126dc99b369Smrg *p = '/'; 6127dc99b369Smrg } 6128dc99b369Smrg } 6129dc99b369SmrgEOF 6130dc99b369Smrg ;; 6131dc99b369Smrg esac 61325eefee25Smacallan 6133dc99b369Smrg cat <<"EOF" 6134dc99b369Smrg XFREE (target_name); 6135dc99b369Smrg XFREE (actual_cwrapper_path); 6136dc99b369Smrg XFREE (actual_cwrapper_name); 6137dc99b369Smrg 6138dc99b369Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139dc99b369Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140dc99b369Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141dc99b369Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142dc99b369Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143dc99b369Smrg libraries must come first. */ 6144dc99b369Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145dc99b369Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146dc99b369Smrg 6147dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148dc99b369Smrg nonnull (lt_argv_zero)); 6149dc99b369Smrg for (i = 0; i < newargc; i++) 6150dc99b369Smrg { 6151dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152dc99b369Smrg i, nonnull (newargz[i])); 6153dc99b369Smrg } 61545eefee25Smacallan 6155dc99b369SmrgEOF 61565eefee25Smacallan 6157dc99b369Smrg case $host_os in 6158dc99b369Smrg mingw*) 6159dc99b369Smrg cat <<"EOF" 6160dc99b369Smrg /* execv doesn't actually work on mingw as expected on unix */ 6161dc99b369Smrg newargz = prepare_spawn (newargz); 61625c30ecadSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163dc99b369Smrg if (rval == -1) 6164dc99b369Smrg { 6165dc99b369Smrg /* failed to start process */ 6166dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6167dc99b369Smrg "(main) failed to launch target \"%s\": %s\n", 6168dc99b369Smrg lt_argv_zero, nonnull (strerror (errno))); 6169dc99b369Smrg return 127; 6170dc99b369Smrg } 6171dc99b369Smrg return rval; 6172dc99b369SmrgEOF 6173dc99b369Smrg ;; 6174dc99b369Smrg *) 6175dc99b369Smrg cat <<"EOF" 6176dc99b369Smrg execv (lt_argv_zero, newargz); 6177dc99b369Smrg return rval; /* =127, but avoids unused variable warning */ 6178dc99b369SmrgEOF 6179dc99b369Smrg ;; 6180dc99b369Smrg esac 61815eefee25Smacallan 6182dc99b369Smrg cat <<"EOF" 6183dc99b369Smrg} 61845eefee25Smacallan 6185dc99b369Smrgvoid * 6186dc99b369Smrgxmalloc (size_t num) 6187dc99b369Smrg{ 6188dc99b369Smrg void *p = (void *) malloc (num); 6189dc99b369Smrg if (!p) 6190dc99b369Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61915eefee25Smacallan 6192dc99b369Smrg return p; 6193dc99b369Smrg} 61945eefee25Smacallan 6195dc99b369Smrgchar * 6196dc99b369Smrgxstrdup (const char *string) 6197dc99b369Smrg{ 6198dc99b369Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199dc99b369Smrg string) : NULL; 6200dc99b369Smrg} 62015eefee25Smacallan 6202dc99b369Smrgconst char * 6203dc99b369Smrgbase_name (const char *name) 6204dc99b369Smrg{ 6205dc99b369Smrg const char *base; 62065eefee25Smacallan 62075c30ecadSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208dc99b369Smrg /* Skip over the disk name in MSDOS pathnames. */ 6209dc99b369Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210dc99b369Smrg name += 2; 6211dc99b369Smrg#endif 62125eefee25Smacallan 6213dc99b369Smrg for (base = name; *name; name++) 6214dc99b369Smrg if (IS_DIR_SEPARATOR (*name)) 6215dc99b369Smrg base = name + 1; 6216dc99b369Smrg return base; 6217dc99b369Smrg} 62185eefee25Smacallan 6219dc99b369Smrgint 6220dc99b369Smrgcheck_executable (const char *path) 6221dc99b369Smrg{ 6222dc99b369Smrg struct stat st; 62235eefee25Smacallan 6224dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225dc99b369Smrg nonempty (path)); 6226dc99b369Smrg if ((!path) || (!*path)) 6227dc99b369Smrg return 0; 62285eefee25Smacallan 6229dc99b369Smrg if ((stat (path, &st) >= 0) 6230dc99b369Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231dc99b369Smrg return 1; 6232dc99b369Smrg else 6233dc99b369Smrg return 0; 6234dc99b369Smrg} 62355eefee25Smacallan 6236dc99b369Smrgint 6237dc99b369Smrgmake_executable (const char *path) 6238dc99b369Smrg{ 6239dc99b369Smrg int rval = 0; 6240dc99b369Smrg struct stat st; 62415eefee25Smacallan 6242dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243dc99b369Smrg nonempty (path)); 6244dc99b369Smrg if ((!path) || (!*path)) 6245dc99b369Smrg return 0; 62465eefee25Smacallan 6247dc99b369Smrg if (stat (path, &st) >= 0) 6248dc99b369Smrg { 6249dc99b369Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250dc99b369Smrg } 6251dc99b369Smrg return rval; 6252dc99b369Smrg} 62535eefee25Smacallan 6254dc99b369Smrg/* Searches for the full path of the wrapper. Returns 6255dc99b369Smrg newly allocated full path name if found, NULL otherwise 6256dc99b369Smrg Does not chase symlinks, even on platforms that support them. 6257dc99b369Smrg*/ 6258dc99b369Smrgchar * 6259dc99b369Smrgfind_executable (const char *wrapper) 6260dc99b369Smrg{ 6261dc99b369Smrg int has_slash = 0; 6262dc99b369Smrg const char *p; 6263dc99b369Smrg const char *p_next; 6264dc99b369Smrg /* static buffer for getcwd */ 6265dc99b369Smrg char tmp[LT_PATHMAX + 1]; 62665c30ecadSmrg size_t tmp_len; 6267dc99b369Smrg char *concat_name; 62685eefee25Smacallan 6269dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270dc99b369Smrg nonempty (wrapper)); 62715eefee25Smacallan 6272dc99b369Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273dc99b369Smrg return NULL; 62745eefee25Smacallan 6275dc99b369Smrg /* Absolute path? */ 62765c30ecadSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277dc99b369Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278dc99b369Smrg { 6279dc99b369Smrg concat_name = xstrdup (wrapper); 6280dc99b369Smrg if (check_executable (concat_name)) 6281dc99b369Smrg return concat_name; 6282dc99b369Smrg XFREE (concat_name); 6283dc99b369Smrg } 6284dc99b369Smrg else 6285dc99b369Smrg { 6286dc99b369Smrg#endif 6287dc99b369Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288dc99b369Smrg { 6289dc99b369Smrg concat_name = xstrdup (wrapper); 6290dc99b369Smrg if (check_executable (concat_name)) 6291dc99b369Smrg return concat_name; 6292dc99b369Smrg XFREE (concat_name); 6293dc99b369Smrg } 62945c30ecadSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295dc99b369Smrg } 6296dc99b369Smrg#endif 62975eefee25Smacallan 6298dc99b369Smrg for (p = wrapper; *p; p++) 6299dc99b369Smrg if (*p == '/') 6300dc99b369Smrg { 6301dc99b369Smrg has_slash = 1; 6302dc99b369Smrg break; 6303dc99b369Smrg } 6304dc99b369Smrg if (!has_slash) 6305dc99b369Smrg { 6306dc99b369Smrg /* no slashes; search PATH */ 6307dc99b369Smrg const char *path = getenv ("PATH"); 6308dc99b369Smrg if (path != NULL) 6309dc99b369Smrg { 6310dc99b369Smrg for (p = path; *p; p = p_next) 6311dc99b369Smrg { 6312dc99b369Smrg const char *q; 6313dc99b369Smrg size_t p_len; 6314dc99b369Smrg for (q = p; *q; q++) 6315dc99b369Smrg if (IS_PATH_SEPARATOR (*q)) 6316dc99b369Smrg break; 63175c30ecadSmrg p_len = (size_t) (q - p); 6318dc99b369Smrg p_next = (*q == '\0' ? q : q + 1); 6319dc99b369Smrg if (p_len == 0) 6320dc99b369Smrg { 6321dc99b369Smrg /* empty path: current directory */ 6322dc99b369Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323dc99b369Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324dc99b369Smrg nonnull (strerror (errno))); 6325dc99b369Smrg tmp_len = strlen (tmp); 6326dc99b369Smrg concat_name = 6327dc99b369Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328dc99b369Smrg memcpy (concat_name, tmp, tmp_len); 6329dc99b369Smrg concat_name[tmp_len] = '/'; 6330dc99b369Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6331dc99b369Smrg } 6332dc99b369Smrg else 6333dc99b369Smrg { 6334dc99b369Smrg concat_name = 6335dc99b369Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336dc99b369Smrg memcpy (concat_name, p, p_len); 6337dc99b369Smrg concat_name[p_len] = '/'; 6338dc99b369Smrg strcpy (concat_name + p_len + 1, wrapper); 6339dc99b369Smrg } 6340dc99b369Smrg if (check_executable (concat_name)) 6341dc99b369Smrg return concat_name; 6342dc99b369Smrg XFREE (concat_name); 6343dc99b369Smrg } 6344dc99b369Smrg } 6345dc99b369Smrg /* not found in PATH; assume curdir */ 6346dc99b369Smrg } 6347dc99b369Smrg /* Relative path | not found in path: prepend cwd */ 6348dc99b369Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349dc99b369Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350dc99b369Smrg nonnull (strerror (errno))); 6351dc99b369Smrg tmp_len = strlen (tmp); 6352dc99b369Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353dc99b369Smrg memcpy (concat_name, tmp, tmp_len); 6354dc99b369Smrg concat_name[tmp_len] = '/'; 6355dc99b369Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356dc99b369Smrg 6357dc99b369Smrg if (check_executable (concat_name)) 6358dc99b369Smrg return concat_name; 6359dc99b369Smrg XFREE (concat_name); 6360dc99b369Smrg return NULL; 63615eefee25Smacallan} 63625eefee25Smacallan 6363dc99b369Smrgchar * 6364dc99b369Smrgchase_symlinks (const char *pathspec) 6365dc99b369Smrg{ 6366dc99b369Smrg#ifndef S_ISLNK 6367dc99b369Smrg return xstrdup (pathspec); 6368dc99b369Smrg#else 6369dc99b369Smrg char buf[LT_PATHMAX]; 6370dc99b369Smrg struct stat s; 6371dc99b369Smrg char *tmp_pathspec = xstrdup (pathspec); 6372dc99b369Smrg char *p; 6373dc99b369Smrg int has_symlinks = 0; 6374dc99b369Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6375dc99b369Smrg { 6376dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6377dc99b369Smrg "checking path component for symlinks: %s\n", 6378dc99b369Smrg tmp_pathspec); 6379dc99b369Smrg if (lstat (tmp_pathspec, &s) == 0) 6380dc99b369Smrg { 6381dc99b369Smrg if (S_ISLNK (s.st_mode) != 0) 6382dc99b369Smrg { 6383dc99b369Smrg has_symlinks = 1; 6384dc99b369Smrg break; 6385dc99b369Smrg } 63865eefee25Smacallan 6387dc99b369Smrg /* search backwards for last DIR_SEPARATOR */ 6388dc99b369Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389dc99b369Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390dc99b369Smrg p--; 6391dc99b369Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392dc99b369Smrg { 6393dc99b369Smrg /* no more DIR_SEPARATORS left */ 6394dc99b369Smrg break; 6395dc99b369Smrg } 6396dc99b369Smrg *p = '\0'; 6397dc99b369Smrg } 6398dc99b369Smrg else 6399dc99b369Smrg { 6400dc99b369Smrg lt_fatal (__FILE__, __LINE__, 6401dc99b369Smrg "error accessing file \"%s\": %s", 6402dc99b369Smrg tmp_pathspec, nonnull (strerror (errno))); 6403dc99b369Smrg } 6404dc99b369Smrg } 6405dc99b369Smrg XFREE (tmp_pathspec); 64065eefee25Smacallan 6407dc99b369Smrg if (!has_symlinks) 6408dc99b369Smrg { 6409dc99b369Smrg return xstrdup (pathspec); 6410dc99b369Smrg } 64115eefee25Smacallan 6412dc99b369Smrg tmp_pathspec = realpath (pathspec, buf); 6413dc99b369Smrg if (tmp_pathspec == 0) 6414dc99b369Smrg { 6415dc99b369Smrg lt_fatal (__FILE__, __LINE__, 6416dc99b369Smrg "could not follow symlinks for %s", pathspec); 6417dc99b369Smrg } 6418dc99b369Smrg return xstrdup (tmp_pathspec); 6419dc99b369Smrg#endif 64205eefee25Smacallan} 64215eefee25Smacallan 6422dc99b369Smrgchar * 6423dc99b369Smrgstrendzap (char *str, const char *pat) 6424dc99b369Smrg{ 6425dc99b369Smrg size_t len, patlen; 64265eefee25Smacallan 6427dc99b369Smrg assert (str != NULL); 6428dc99b369Smrg assert (pat != NULL); 64295eefee25Smacallan 6430dc99b369Smrg len = strlen (str); 6431dc99b369Smrg patlen = strlen (pat); 64325eefee25Smacallan 6433dc99b369Smrg if (patlen <= len) 6434dc99b369Smrg { 6435dc99b369Smrg str += len - patlen; 64365c30ecadSmrg if (STREQ (str, pat)) 6437dc99b369Smrg *str = '\0'; 6438dc99b369Smrg } 6439dc99b369Smrg return str; 6440dc99b369Smrg} 64415eefee25Smacallan 6442dc99b369Smrgvoid 6443dc99b369Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444dc99b369Smrg{ 6445dc99b369Smrg va_list args; 6446dc99b369Smrg if (lt_debug) 6447dc99b369Smrg { 6448dc99b369Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449dc99b369Smrg va_start (args, fmt); 6450dc99b369Smrg (void) vfprintf (stderr, fmt, args); 6451dc99b369Smrg va_end (args); 6452dc99b369Smrg } 6453dc99b369Smrg} 64545eefee25Smacallan 6455dc99b369Smrgstatic void 6456dc99b369Smrglt_error_core (int exit_status, const char *file, 6457dc99b369Smrg int line, const char *mode, 6458dc99b369Smrg const char *message, va_list ap) 6459dc99b369Smrg{ 6460dc99b369Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461dc99b369Smrg vfprintf (stderr, message, ap); 6462dc99b369Smrg fprintf (stderr, ".\n"); 64635eefee25Smacallan 6464dc99b369Smrg if (exit_status >= 0) 6465dc99b369Smrg exit (exit_status); 6466dc99b369Smrg} 64675eefee25Smacallan 6468dc99b369Smrgvoid 6469dc99b369Smrglt_fatal (const char *file, int line, const char *message, ...) 6470dc99b369Smrg{ 6471dc99b369Smrg va_list ap; 6472dc99b369Smrg va_start (ap, message); 6473dc99b369Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474dc99b369Smrg va_end (ap); 6475dc99b369Smrg} 64765eefee25Smacallan 6477dc99b369Smrgstatic const char * 6478dc99b369Smrgnonnull (const char *s) 6479dc99b369Smrg{ 6480dc99b369Smrg return s ? s : "(null)"; 6481dc99b369Smrg} 64825eefee25Smacallan 6483dc99b369Smrgstatic const char * 6484dc99b369Smrgnonempty (const char *s) 6485dc99b369Smrg{ 6486dc99b369Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6487dc99b369Smrg} 64885eefee25Smacallan 6489dc99b369Smrgvoid 6490dc99b369Smrglt_setenv (const char *name, const char *value) 6491dc99b369Smrg{ 6492dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6493dc99b369Smrg "(lt_setenv) setting '%s' to '%s'\n", 6494dc99b369Smrg nonnull (name), nonnull (value)); 6495dc99b369Smrg { 6496dc99b369Smrg#ifdef HAVE_SETENV 6497dc99b369Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498dc99b369Smrg char *str = xstrdup (value); 6499dc99b369Smrg setenv (name, str, 1); 65005eefee25Smacallan#else 65015c30ecadSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502dc99b369Smrg char *str = XMALLOC (char, len); 6503dc99b369Smrg sprintf (str, "%s=%s", name, value); 6504dc99b369Smrg if (putenv (str) != EXIT_SUCCESS) 6505dc99b369Smrg { 6506dc99b369Smrg XFREE (str); 6507dc99b369Smrg } 65085eefee25Smacallan#endif 6509dc99b369Smrg } 6510dc99b369Smrg} 65115eefee25Smacallan 6512dc99b369Smrgchar * 6513dc99b369Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514dc99b369Smrg{ 6515dc99b369Smrg char *new_value; 6516dc99b369Smrg if (orig_value && *orig_value) 6517dc99b369Smrg { 65185c30ecadSmrg size_t orig_value_len = strlen (orig_value); 65195c30ecadSmrg size_t add_len = strlen (add); 6520dc99b369Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521dc99b369Smrg if (to_end) 6522dc99b369Smrg { 6523dc99b369Smrg strcpy (new_value, orig_value); 6524dc99b369Smrg strcpy (new_value + orig_value_len, add); 6525dc99b369Smrg } 6526dc99b369Smrg else 6527dc99b369Smrg { 6528dc99b369Smrg strcpy (new_value, add); 6529dc99b369Smrg strcpy (new_value + add_len, orig_value); 6530dc99b369Smrg } 6531dc99b369Smrg } 6532dc99b369Smrg else 6533dc99b369Smrg { 6534dc99b369Smrg new_value = xstrdup (add); 6535dc99b369Smrg } 6536dc99b369Smrg return new_value; 6537dc99b369Smrg} 65385eefee25Smacallan 6539dc99b369Smrgvoid 6540dc99b369Smrglt_update_exe_path (const char *name, const char *value) 6541dc99b369Smrg{ 6542dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6543dc99b369Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544dc99b369Smrg nonnull (name), nonnull (value)); 65455eefee25Smacallan 6546dc99b369Smrg if (name && *name && value && *value) 6547dc99b369Smrg { 6548dc99b369Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549dc99b369Smrg /* some systems can't cope with a ':'-terminated path #' */ 65505c30ecadSmrg size_t len = strlen (new_value); 65515c30ecadSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552dc99b369Smrg { 65535c30ecadSmrg new_value[--len] = '\0'; 6554dc99b369Smrg } 6555dc99b369Smrg lt_setenv (name, new_value); 6556dc99b369Smrg XFREE (new_value); 6557dc99b369Smrg } 6558dc99b369Smrg} 65595eefee25Smacallan 6560dc99b369Smrgvoid 6561dc99b369Smrglt_update_lib_path (const char *name, const char *value) 65625eefee25Smacallan{ 6563dc99b369Smrg lt_debugprintf (__FILE__, __LINE__, 6564dc99b369Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565dc99b369Smrg nonnull (name), nonnull (value)); 65665eefee25Smacallan 6567dc99b369Smrg if (name && *name && value && *value) 6568dc99b369Smrg { 6569dc99b369Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570dc99b369Smrg lt_setenv (name, new_value); 6571dc99b369Smrg XFREE (new_value); 6572dc99b369Smrg } 6573dc99b369Smrg} 65745eefee25Smacallan 65755eefee25SmacallanEOF 6576dc99b369Smrg case $host_os in 6577dc99b369Smrg mingw*) 6578dc99b369Smrg cat <<"EOF" 6579dc99b369Smrg 6580dc99b369Smrg/* Prepares an argument vector before calling spawn(). 6581dc99b369Smrg Note that spawn() does not by itself call the command interpreter 6582dc99b369Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583dc99b369Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584dc99b369Smrg GetVersionEx(&v); 6585dc99b369Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586dc99b369Smrg }) ? "cmd.exe" : "command.com"). 6587dc99b369Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588dc99b369Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589dc99b369Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590dc99b369Smrg special way: 6591dc99b369Smrg - Space and tab are interpreted as delimiters. They are not treated as 6592dc99b369Smrg delimiters if they are surrounded by double quotes: "...". 6593dc99b369Smrg - Unescaped double quotes are removed from the input. Their only effect is 6594dc99b369Smrg that within double quotes, space and tab are treated like normal 6595dc99b369Smrg characters. 6596dc99b369Smrg - Backslashes not followed by double quotes are not special. 6597dc99b369Smrg - But 2*n+1 backslashes followed by a double quote become 6598dc99b369Smrg n backslashes followed by a double quote (n >= 0): 6599dc99b369Smrg \" -> " 6600dc99b369Smrg \\\" -> \" 6601dc99b369Smrg \\\\\" -> \\" 6602dc99b369Smrg */ 6603dc99b369Smrg#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" 6604dc99b369Smrg#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" 6605dc99b369Smrgchar ** 6606dc99b369Smrgprepare_spawn (char **argv) 6607dc99b369Smrg{ 6608dc99b369Smrg size_t argc; 6609dc99b369Smrg char **new_argv; 6610dc99b369Smrg size_t i; 66115eefee25Smacallan 6612dc99b369Smrg /* Count number of arguments. */ 6613dc99b369Smrg for (argc = 0; argv[argc] != NULL; argc++) 66145eefee25Smacallan ; 66155eefee25Smacallan 6616dc99b369Smrg /* Allocate new argument vector. */ 6617dc99b369Smrg new_argv = XMALLOC (char *, argc + 1); 66185eefee25Smacallan 6619dc99b369Smrg /* Put quoted arguments into the new argument vector. */ 6620dc99b369Smrg for (i = 0; i < argc; i++) 6621dc99b369Smrg { 6622dc99b369Smrg const char *string = argv[i]; 6623dc99b369Smrg 6624dc99b369Smrg if (string[0] == '\0') 6625dc99b369Smrg new_argv[i] = xstrdup ("\"\""); 6626dc99b369Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627dc99b369Smrg { 6628dc99b369Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629dc99b369Smrg size_t length; 6630dc99b369Smrg unsigned int backslashes; 6631dc99b369Smrg const char *s; 6632dc99b369Smrg char *quoted_string; 6633dc99b369Smrg char *p; 6634dc99b369Smrg 6635dc99b369Smrg length = 0; 6636dc99b369Smrg backslashes = 0; 6637dc99b369Smrg if (quote_around) 6638dc99b369Smrg length++; 6639dc99b369Smrg for (s = string; *s != '\0'; s++) 6640dc99b369Smrg { 6641dc99b369Smrg char c = *s; 6642dc99b369Smrg if (c == '"') 6643dc99b369Smrg length += backslashes + 1; 6644dc99b369Smrg length++; 6645dc99b369Smrg if (c == '\\') 6646dc99b369Smrg backslashes++; 6647dc99b369Smrg else 6648dc99b369Smrg backslashes = 0; 6649dc99b369Smrg } 6650dc99b369Smrg if (quote_around) 6651dc99b369Smrg length += backslashes + 1; 6652dc99b369Smrg 6653dc99b369Smrg quoted_string = XMALLOC (char, length + 1); 6654dc99b369Smrg 6655dc99b369Smrg p = quoted_string; 6656dc99b369Smrg backslashes = 0; 6657dc99b369Smrg if (quote_around) 6658dc99b369Smrg *p++ = '"'; 6659dc99b369Smrg for (s = string; *s != '\0'; s++) 6660dc99b369Smrg { 6661dc99b369Smrg char c = *s; 6662dc99b369Smrg if (c == '"') 6663dc99b369Smrg { 6664dc99b369Smrg unsigned int j; 6665dc99b369Smrg for (j = backslashes + 1; j > 0; j--) 6666dc99b369Smrg *p++ = '\\'; 6667dc99b369Smrg } 6668dc99b369Smrg *p++ = c; 6669dc99b369Smrg if (c == '\\') 6670dc99b369Smrg backslashes++; 6671dc99b369Smrg else 6672dc99b369Smrg backslashes = 0; 6673dc99b369Smrg } 6674dc99b369Smrg if (quote_around) 6675dc99b369Smrg { 6676dc99b369Smrg unsigned int j; 6677dc99b369Smrg for (j = backslashes; j > 0; j--) 6678dc99b369Smrg *p++ = '\\'; 6679dc99b369Smrg *p++ = '"'; 6680dc99b369Smrg } 6681dc99b369Smrg *p = '\0'; 6682dc99b369Smrg 6683dc99b369Smrg new_argv[i] = quoted_string; 6684dc99b369Smrg } 6685dc99b369Smrg else 6686dc99b369Smrg new_argv[i] = (char *) string; 6687dc99b369Smrg } 6688dc99b369Smrg new_argv[argc] = NULL; 66895eefee25Smacallan 6690dc99b369Smrg return new_argv; 66915eefee25Smacallan} 6692dc99b369SmrgEOF 6693dc99b369Smrg ;; 6694dc99b369Smrg esac 66955eefee25Smacallan 6696dc99b369Smrg cat <<"EOF" 6697dc99b369Smrgvoid lt_dump_script (FILE* f) 66985eefee25Smacallan{ 6699dc99b369SmrgEOF 6700dc99b369Smrg func_emit_wrapper yes | 67015c30ecadSmrg $SED -n -e ' 67025c30ecadSmrgs/^\(.\{79\}\)\(..*\)/\1\ 67035c30ecadSmrg\2/ 67045c30ecadSmrgh 67055c30ecadSmrgs/\([\\"]\)/\\\1/g 67065c30ecadSmrgs/$/\\n/ 67075c30ecadSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67085c30ecadSmrgg 67095c30ecadSmrgD' 6710dc99b369Smrg cat <<"EOF" 67115eefee25Smacallan} 6712dc99b369SmrgEOF 67135eefee25Smacallan} 6714dc99b369Smrg# end: func_emit_cwrapperexe_src 67155eefee25Smacallan 6716dc99b369Smrg# func_win32_import_lib_p ARG 6717dc99b369Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718dc99b369Smrgfunc_win32_import_lib_p () 67195eefee25Smacallan{ 67205c30ecadSmrg $debug_cmd 67215c30ecadSmrg 6722dc99b369Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723dc99b369Smrg *import*) : ;; 6724dc99b369Smrg *) false ;; 6725dc99b369Smrg esac 67265eefee25Smacallan} 67275eefee25Smacallan 67285c30ecadSmrg# func_suncc_cstd_abi 67295c30ecadSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67305c30ecadSmrg# Several compiler flags select an ABI that is incompatible with the 67315c30ecadSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67325c30ecadSmrgfunc_suncc_cstd_abi () 67335c30ecadSmrg{ 67345c30ecadSmrg $debug_cmd 67355c30ecadSmrg 67365c30ecadSmrg case " $compile_command " in 67375c30ecadSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67385c30ecadSmrg suncc_use_cstd_abi=no 67395c30ecadSmrg ;; 67405c30ecadSmrg *) 67415c30ecadSmrg suncc_use_cstd_abi=yes 67425c30ecadSmrg ;; 67435c30ecadSmrg esac 67445c30ecadSmrg} 67455c30ecadSmrg 6746dc99b369Smrg# func_mode_link arg... 6747dc99b369Smrgfunc_mode_link () 67485eefee25Smacallan{ 67495c30ecadSmrg $debug_cmd 67505c30ecadSmrg 6751dc99b369Smrg case $host in 6752dc99b369Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753dc99b369Smrg # It is impossible to link a dll without this setting, and 6754dc99b369Smrg # we shouldn't force the makefile maintainer to figure out 67555c30ecadSmrg # what system we are compiling for in order to pass an extra 6756dc99b369Smrg # flag for every libtool invocation. 6757dc99b369Smrg # allow_undefined=no 67585eefee25Smacallan 6759dc99b369Smrg # FIXME: Unfortunately, there are problems with the above when trying 67605c30ecadSmrg # to make a dll that has undefined symbols, in which case not 6761dc99b369Smrg # even a static library is built. For now, we need to specify 6762dc99b369Smrg # -no-undefined on the libtool link line when we can be certain 6763dc99b369Smrg # that all symbols are satisfied, otherwise we get a static library. 6764dc99b369Smrg allow_undefined=yes 6765dc99b369Smrg ;; 6766dc99b369Smrg *) 6767dc99b369Smrg allow_undefined=yes 6768dc99b369Smrg ;; 6769dc99b369Smrg esac 6770dc99b369Smrg libtool_args=$nonopt 6771dc99b369Smrg base_compile="$nonopt $@" 6772dc99b369Smrg compile_command=$nonopt 6773dc99b369Smrg finalize_command=$nonopt 67745eefee25Smacallan 6775dc99b369Smrg compile_rpath= 6776dc99b369Smrg finalize_rpath= 6777dc99b369Smrg compile_shlibpath= 6778dc99b369Smrg finalize_shlibpath= 6779dc99b369Smrg convenience= 6780dc99b369Smrg old_convenience= 6781dc99b369Smrg deplibs= 6782dc99b369Smrg old_deplibs= 6783dc99b369Smrg compiler_flags= 6784dc99b369Smrg linker_flags= 6785dc99b369Smrg dllsearchpath= 6786dc99b369Smrg lib_search_path=`pwd` 6787dc99b369Smrg inst_prefix_dir= 6788dc99b369Smrg new_inherited_linker_flags= 67895eefee25Smacallan 6790dc99b369Smrg avoid_version=no 6791dc99b369Smrg bindir= 6792dc99b369Smrg dlfiles= 6793dc99b369Smrg dlprefiles= 6794dc99b369Smrg dlself=no 6795dc99b369Smrg export_dynamic=no 6796dc99b369Smrg export_symbols= 6797dc99b369Smrg export_symbols_regex= 6798dc99b369Smrg generated= 6799dc99b369Smrg libobjs= 6800dc99b369Smrg ltlibs= 6801dc99b369Smrg module=no 6802dc99b369Smrg no_install=no 6803dc99b369Smrg objs= 68045c30ecadSmrg os2dllname= 6805dc99b369Smrg non_pic_objects= 6806dc99b369Smrg precious_files_regex= 6807dc99b369Smrg prefer_static_libs=no 68085c30ecadSmrg preload=false 6809dc99b369Smrg prev= 6810dc99b369Smrg prevarg= 6811dc99b369Smrg release= 6812dc99b369Smrg rpath= 6813dc99b369Smrg xrpath= 6814dc99b369Smrg perm_rpath= 6815dc99b369Smrg temp_rpath= 6816dc99b369Smrg thread_safe=no 6817dc99b369Smrg vinfo= 6818dc99b369Smrg vinfo_number=no 6819dc99b369Smrg weak_libs= 68205c30ecadSmrg single_module=$wl-single_module 6821dc99b369Smrg func_infer_tag $base_compile 68225eefee25Smacallan 6823dc99b369Smrg # We need to know -static, to get the right output filenames. 6824dc99b369Smrg for arg 6825dc99b369Smrg do 6826dc99b369Smrg case $arg in 6827dc99b369Smrg -shared) 68285c30ecadSmrg test yes != "$build_libtool_libs" \ 68295c30ecadSmrg && func_fatal_configuration "cannot build a shared library" 6830dc99b369Smrg build_old_libs=no 6831dc99b369Smrg break 6832dc99b369Smrg ;; 6833dc99b369Smrg -all-static | -static | -static-libtool-libs) 6834dc99b369Smrg case $arg in 6835dc99b369Smrg -all-static) 68365c30ecadSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837dc99b369Smrg func_warning "complete static linking is impossible in this configuration" 6838dc99b369Smrg fi 6839dc99b369Smrg if test -n "$link_static_flag"; then 6840dc99b369Smrg dlopen_self=$dlopen_self_static 6841dc99b369Smrg fi 6842dc99b369Smrg prefer_static_libs=yes 6843dc99b369Smrg ;; 6844dc99b369Smrg -static) 6845dc99b369Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846dc99b369Smrg dlopen_self=$dlopen_self_static 6847dc99b369Smrg fi 6848dc99b369Smrg prefer_static_libs=built 6849dc99b369Smrg ;; 6850dc99b369Smrg -static-libtool-libs) 6851dc99b369Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852dc99b369Smrg dlopen_self=$dlopen_self_static 6853dc99b369Smrg fi 6854dc99b369Smrg prefer_static_libs=yes 6855dc99b369Smrg ;; 6856dc99b369Smrg esac 6857dc99b369Smrg build_libtool_libs=no 6858dc99b369Smrg build_old_libs=yes 6859dc99b369Smrg break 6860dc99b369Smrg ;; 6861dc99b369Smrg esac 6862dc99b369Smrg done 68635eefee25Smacallan 6864dc99b369Smrg # See if our shared archives depend on static archives. 6865dc99b369Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68665eefee25Smacallan 6867dc99b369Smrg # Go through the arguments, transforming them on the way. 6868dc99b369Smrg while test "$#" -gt 0; do 68695c30ecadSmrg arg=$1 6870dc99b369Smrg shift 68715c30ecadSmrg func_quote_arg pretty,unquoted "$arg" 68725c30ecadSmrg qarg=$func_quote_arg_unquoted_result 68735c30ecadSmrg func_append libtool_args " $func_quote_arg_result" 68745eefee25Smacallan 6875dc99b369Smrg # If the previous option needs an argument, assign it. 6876dc99b369Smrg if test -n "$prev"; then 6877dc99b369Smrg case $prev in 6878dc99b369Smrg output) 6879dc99b369Smrg func_append compile_command " @OUTPUT@" 6880dc99b369Smrg func_append finalize_command " @OUTPUT@" 6881dc99b369Smrg ;; 6882dc99b369Smrg esac 68835eefee25Smacallan 6884dc99b369Smrg case $prev in 6885dc99b369Smrg bindir) 68865c30ecadSmrg bindir=$arg 6887dc99b369Smrg prev= 6888dc99b369Smrg continue 6889dc99b369Smrg ;; 6890dc99b369Smrg dlfiles|dlprefiles) 68915c30ecadSmrg $preload || { 6892dc99b369Smrg # Add the symbol object into the linking commands. 6893dc99b369Smrg func_append compile_command " @SYMFILE@" 6894dc99b369Smrg func_append finalize_command " @SYMFILE@" 68955c30ecadSmrg preload=: 68965c30ecadSmrg } 6897dc99b369Smrg case $arg in 6898dc99b369Smrg *.la | *.lo) ;; # We handle these cases below. 6899dc99b369Smrg force) 69005c30ecadSmrg if test no = "$dlself"; then 6901dc99b369Smrg dlself=needless 6902dc99b369Smrg export_dynamic=yes 6903dc99b369Smrg fi 6904dc99b369Smrg prev= 6905dc99b369Smrg continue 6906dc99b369Smrg ;; 6907dc99b369Smrg self) 69085c30ecadSmrg if test dlprefiles = "$prev"; then 6909dc99b369Smrg dlself=yes 69105c30ecadSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911dc99b369Smrg dlself=yes 6912dc99b369Smrg else 6913dc99b369Smrg dlself=needless 6914dc99b369Smrg export_dynamic=yes 6915dc99b369Smrg fi 6916dc99b369Smrg prev= 6917dc99b369Smrg continue 6918dc99b369Smrg ;; 6919dc99b369Smrg *) 69205c30ecadSmrg if test dlfiles = "$prev"; then 6921dc99b369Smrg func_append dlfiles " $arg" 6922dc99b369Smrg else 6923dc99b369Smrg func_append dlprefiles " $arg" 6924dc99b369Smrg fi 6925dc99b369Smrg prev= 6926dc99b369Smrg continue 6927dc99b369Smrg ;; 6928dc99b369Smrg esac 6929dc99b369Smrg ;; 6930dc99b369Smrg expsyms) 69315c30ecadSmrg export_symbols=$arg 6932dc99b369Smrg test -f "$arg" \ 69335c30ecadSmrg || func_fatal_error "symbol file '$arg' does not exist" 6934dc99b369Smrg prev= 6935dc99b369Smrg continue 6936dc99b369Smrg ;; 6937dc99b369Smrg expsyms_regex) 69385c30ecadSmrg export_symbols_regex=$arg 6939dc99b369Smrg prev= 6940dc99b369Smrg continue 6941dc99b369Smrg ;; 6942dc99b369Smrg framework) 6943dc99b369Smrg case $host in 6944dc99b369Smrg *-*-darwin*) 6945dc99b369Smrg case "$deplibs " in 6946dc99b369Smrg *" $qarg.ltframework "*) ;; 6947dc99b369Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948dc99b369Smrg ;; 6949dc99b369Smrg esac 6950dc99b369Smrg ;; 6951dc99b369Smrg esac 6952dc99b369Smrg prev= 6953dc99b369Smrg continue 6954dc99b369Smrg ;; 6955dc99b369Smrg inst_prefix) 69565c30ecadSmrg inst_prefix_dir=$arg 69575c30ecadSmrg prev= 69585c30ecadSmrg continue 69595c30ecadSmrg ;; 69605c30ecadSmrg mllvm) 69615c30ecadSmrg # Clang does not use LLVM to link, so we can simply discard any 69625c30ecadSmrg # '-mllvm $arg' options when doing the link step. 6963dc99b369Smrg prev= 6964dc99b369Smrg continue 6965dc99b369Smrg ;; 6966dc99b369Smrg objectlist) 6967dc99b369Smrg if test -f "$arg"; then 6968dc99b369Smrg save_arg=$arg 6969dc99b369Smrg moreargs= 6970dc99b369Smrg for fil in `cat "$save_arg"` 6971dc99b369Smrg do 6972dc99b369Smrg# func_append moreargs " $fil" 6973dc99b369Smrg arg=$fil 6974dc99b369Smrg # A libtool-controlled object. 69755eefee25Smacallan 6976dc99b369Smrg # Check to see that this really is a libtool object. 6977dc99b369Smrg if func_lalib_unsafe_p "$arg"; then 6978dc99b369Smrg pic_object= 6979dc99b369Smrg non_pic_object= 69805eefee25Smacallan 6981dc99b369Smrg # Read the .lo file 6982dc99b369Smrg func_source "$arg" 69835eefee25Smacallan 6984dc99b369Smrg if test -z "$pic_object" || 6985dc99b369Smrg test -z "$non_pic_object" || 69865c30ecadSmrg test none = "$pic_object" && 69875c30ecadSmrg test none = "$non_pic_object"; then 69885c30ecadSmrg func_fatal_error "cannot find name of object for '$arg'" 6989dc99b369Smrg fi 69905eefee25Smacallan 6991dc99b369Smrg # Extract subdirectory from the argument. 6992dc99b369Smrg func_dirname "$arg" "/" "" 69935c30ecadSmrg xdir=$func_dirname_result 69945eefee25Smacallan 69955c30ecadSmrg if test none != "$pic_object"; then 6996dc99b369Smrg # Prepend the subdirectory the object is found in. 69975c30ecadSmrg pic_object=$xdir$pic_object 69985eefee25Smacallan 69995c30ecadSmrg if test dlfiles = "$prev"; then 70005c30ecadSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001dc99b369Smrg func_append dlfiles " $pic_object" 7002dc99b369Smrg prev= 7003dc99b369Smrg continue 7004dc99b369Smrg else 7005dc99b369Smrg # If libtool objects are unsupported, then we need to preload. 7006dc99b369Smrg prev=dlprefiles 7007dc99b369Smrg fi 7008dc99b369Smrg fi 70095eefee25Smacallan 7010dc99b369Smrg # CHECK ME: I think I busted this. -Ossama 70115c30ecadSmrg if test dlprefiles = "$prev"; then 7012dc99b369Smrg # Preload the old-style object. 7013dc99b369Smrg func_append dlprefiles " $pic_object" 7014dc99b369Smrg prev= 7015dc99b369Smrg fi 701662ab96baSmrg 7017dc99b369Smrg # A PIC object. 7018dc99b369Smrg func_append libobjs " $pic_object" 70195c30ecadSmrg arg=$pic_object 7020dc99b369Smrg fi 70215eefee25Smacallan 7022dc99b369Smrg # Non-PIC object. 70235c30ecadSmrg if test none != "$non_pic_object"; then 7024dc99b369Smrg # Prepend the subdirectory the object is found in. 70255c30ecadSmrg non_pic_object=$xdir$non_pic_object 70265eefee25Smacallan 7027dc99b369Smrg # A standard non-PIC object 7028dc99b369Smrg func_append non_pic_objects " $non_pic_object" 70295c30ecadSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70305c30ecadSmrg arg=$non_pic_object 7031dc99b369Smrg fi 7032dc99b369Smrg else 7033dc99b369Smrg # If the PIC object exists, use it instead. 7034dc99b369Smrg # $xdir was prepended to $pic_object above. 70355c30ecadSmrg non_pic_object=$pic_object 7036dc99b369Smrg func_append non_pic_objects " $non_pic_object" 7037dc99b369Smrg fi 7038dc99b369Smrg else 7039dc99b369Smrg # Only an error if not doing a dry-run. 7040dc99b369Smrg if $opt_dry_run; then 7041dc99b369Smrg # Extract subdirectory from the argument. 7042dc99b369Smrg func_dirname "$arg" "/" "" 70435c30ecadSmrg xdir=$func_dirname_result 7044dc99b369Smrg 7045dc99b369Smrg func_lo2o "$arg" 7046dc99b369Smrg pic_object=$xdir$objdir/$func_lo2o_result 7047dc99b369Smrg non_pic_object=$xdir$func_lo2o_result 7048dc99b369Smrg func_append libobjs " $pic_object" 7049dc99b369Smrg func_append non_pic_objects " $non_pic_object" 7050dc99b369Smrg else 70515c30ecadSmrg func_fatal_error "'$arg' is not a valid libtool object" 7052dc99b369Smrg fi 7053dc99b369Smrg fi 7054dc99b369Smrg done 7055dc99b369Smrg else 70565c30ecadSmrg func_fatal_error "link input file '$arg' does not exist" 7057dc99b369Smrg fi 7058dc99b369Smrg arg=$save_arg 7059dc99b369Smrg prev= 7060dc99b369Smrg continue 7061dc99b369Smrg ;; 70625c30ecadSmrg os2dllname) 70635c30ecadSmrg os2dllname=$arg 70645c30ecadSmrg prev= 70655c30ecadSmrg continue 70665c30ecadSmrg ;; 7067dc99b369Smrg precious_regex) 70685c30ecadSmrg precious_files_regex=$arg 7069dc99b369Smrg prev= 7070dc99b369Smrg continue 7071dc99b369Smrg ;; 7072dc99b369Smrg release) 70735c30ecadSmrg release=-$arg 7074dc99b369Smrg prev= 7075dc99b369Smrg continue 7076dc99b369Smrg ;; 7077dc99b369Smrg rpath | xrpath) 7078dc99b369Smrg # We need an absolute path. 7079dc99b369Smrg case $arg in 7080dc99b369Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081dc99b369Smrg *) 7082dc99b369Smrg func_fatal_error "only absolute run-paths are allowed" 7083dc99b369Smrg ;; 7084dc99b369Smrg esac 70855c30ecadSmrg if test rpath = "$prev"; then 7086dc99b369Smrg case "$rpath " in 7087dc99b369Smrg *" $arg "*) ;; 7088dc99b369Smrg *) func_append rpath " $arg" ;; 7089dc99b369Smrg esac 7090dc99b369Smrg else 7091dc99b369Smrg case "$xrpath " in 7092dc99b369Smrg *" $arg "*) ;; 7093dc99b369Smrg *) func_append xrpath " $arg" ;; 7094dc99b369Smrg esac 7095dc99b369Smrg fi 7096dc99b369Smrg prev= 7097dc99b369Smrg continue 7098dc99b369Smrg ;; 7099dc99b369Smrg shrext) 71005c30ecadSmrg shrext_cmds=$arg 7101dc99b369Smrg prev= 7102dc99b369Smrg continue 7103dc99b369Smrg ;; 7104dc99b369Smrg weak) 7105dc99b369Smrg func_append weak_libs " $arg" 7106dc99b369Smrg prev= 7107dc99b369Smrg continue 7108dc99b369Smrg ;; 71095c30ecadSmrg xassembler) 71105c30ecadSmrg func_append compiler_flags " -Xassembler $qarg" 71115c30ecadSmrg prev= 71125c30ecadSmrg func_append compile_command " -Xassembler $qarg" 71135c30ecadSmrg func_append finalize_command " -Xassembler $qarg" 71145c30ecadSmrg continue 71155c30ecadSmrg ;; 7116dc99b369Smrg xcclinker) 7117dc99b369Smrg func_append linker_flags " $qarg" 7118dc99b369Smrg func_append compiler_flags " $qarg" 7119dc99b369Smrg prev= 7120dc99b369Smrg func_append compile_command " $qarg" 7121dc99b369Smrg func_append finalize_command " $qarg" 7122dc99b369Smrg continue 7123dc99b369Smrg ;; 7124dc99b369Smrg xcompiler) 7125dc99b369Smrg func_append compiler_flags " $qarg" 7126dc99b369Smrg prev= 7127dc99b369Smrg func_append compile_command " $qarg" 7128dc99b369Smrg func_append finalize_command " $qarg" 7129dc99b369Smrg continue 7130dc99b369Smrg ;; 7131dc99b369Smrg xlinker) 7132dc99b369Smrg func_append linker_flags " $qarg" 7133dc99b369Smrg func_append compiler_flags " $wl$qarg" 7134dc99b369Smrg prev= 7135dc99b369Smrg func_append compile_command " $wl$qarg" 7136dc99b369Smrg func_append finalize_command " $wl$qarg" 7137dc99b369Smrg continue 7138dc99b369Smrg ;; 7139dc99b369Smrg *) 7140dc99b369Smrg eval "$prev=\"\$arg\"" 7141dc99b369Smrg prev= 7142dc99b369Smrg continue 7143dc99b369Smrg ;; 7144dc99b369Smrg esac 7145dc99b369Smrg fi # test -n "$prev" 71465eefee25Smacallan 71475c30ecadSmrg prevarg=$arg 71485eefee25Smacallan 7149dc99b369Smrg case $arg in 7150dc99b369Smrg -all-static) 7151dc99b369Smrg if test -n "$link_static_flag"; then 7152dc99b369Smrg # See comment for -static flag below, for more details. 7153dc99b369Smrg func_append compile_command " $link_static_flag" 7154dc99b369Smrg func_append finalize_command " $link_static_flag" 7155dc99b369Smrg fi 7156dc99b369Smrg continue 7157dc99b369Smrg ;; 71585eefee25Smacallan 7159dc99b369Smrg -allow-undefined) 7160dc99b369Smrg # FIXME: remove this flag sometime in the future. 71615c30ecadSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162dc99b369Smrg ;; 71635eefee25Smacallan 7164dc99b369Smrg -avoid-version) 7165dc99b369Smrg avoid_version=yes 7166dc99b369Smrg continue 7167dc99b369Smrg ;; 71685eefee25Smacallan 7169dc99b369Smrg -bindir) 7170dc99b369Smrg prev=bindir 7171dc99b369Smrg continue 7172dc99b369Smrg ;; 7173dc99b369Smrg 7174dc99b369Smrg -dlopen) 7175dc99b369Smrg prev=dlfiles 7176dc99b369Smrg continue 7177dc99b369Smrg ;; 7178dc99b369Smrg 7179dc99b369Smrg -dlpreopen) 7180dc99b369Smrg prev=dlprefiles 7181dc99b369Smrg continue 7182dc99b369Smrg ;; 7183dc99b369Smrg 7184dc99b369Smrg -export-dynamic) 7185dc99b369Smrg export_dynamic=yes 7186dc99b369Smrg continue 7187dc99b369Smrg ;; 7188dc99b369Smrg 7189dc99b369Smrg -export-symbols | -export-symbols-regex) 7190dc99b369Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191dc99b369Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192dc99b369Smrg fi 71935c30ecadSmrg if test X-export-symbols = "X$arg"; then 7194dc99b369Smrg prev=expsyms 7195dc99b369Smrg else 7196dc99b369Smrg prev=expsyms_regex 7197dc99b369Smrg fi 7198dc99b369Smrg continue 7199dc99b369Smrg ;; 7200dc99b369Smrg 7201dc99b369Smrg -framework) 7202dc99b369Smrg prev=framework 7203dc99b369Smrg continue 7204dc99b369Smrg ;; 7205dc99b369Smrg 7206dc99b369Smrg -inst-prefix-dir) 7207dc99b369Smrg prev=inst_prefix 7208dc99b369Smrg continue 7209dc99b369Smrg ;; 7210dc99b369Smrg 7211dc99b369Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212dc99b369Smrg # so, if we see these flags be careful not to treat them like -L 7213dc99b369Smrg -L[A-Z][A-Z]*:*) 7214dc99b369Smrg case $with_gcc/$host in 7215dc99b369Smrg no/*-*-irix* | /*-*-irix*) 7216dc99b369Smrg func_append compile_command " $arg" 7217dc99b369Smrg func_append finalize_command " $arg" 7218dc99b369Smrg ;; 7219dc99b369Smrg esac 7220dc99b369Smrg continue 7221dc99b369Smrg ;; 7222dc99b369Smrg 7223dc99b369Smrg -L*) 7224dc99b369Smrg func_stripname "-L" '' "$arg" 7225dc99b369Smrg if test -z "$func_stripname_result"; then 7226dc99b369Smrg if test "$#" -gt 0; then 72275c30ecadSmrg func_fatal_error "require no space between '-L' and '$1'" 7228dc99b369Smrg else 72295c30ecadSmrg func_fatal_error "need path for '-L' option" 7230dc99b369Smrg fi 7231dc99b369Smrg fi 7232dc99b369Smrg func_resolve_sysroot "$func_stripname_result" 7233dc99b369Smrg dir=$func_resolve_sysroot_result 7234dc99b369Smrg # We need an absolute path. 7235dc99b369Smrg case $dir in 7236dc99b369Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237dc99b369Smrg *) 7238dc99b369Smrg absdir=`cd "$dir" && pwd` 7239dc99b369Smrg test -z "$absdir" && \ 72405c30ecadSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72415c30ecadSmrg dir=$absdir 7242dc99b369Smrg ;; 7243dc99b369Smrg esac 7244dc99b369Smrg case "$deplibs " in 7245dc99b369Smrg *" -L$dir "* | *" $arg "*) 7246dc99b369Smrg # Will only happen for absolute or sysroot arguments 7247dc99b369Smrg ;; 7248dc99b369Smrg *) 7249dc99b369Smrg # Preserve sysroot, but never include relative directories 7250dc99b369Smrg case $dir in 7251dc99b369Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252dc99b369Smrg *) func_append deplibs " -L$dir" ;; 7253dc99b369Smrg esac 7254dc99b369Smrg func_append lib_search_path " $dir" 7255dc99b369Smrg ;; 7256dc99b369Smrg esac 7257dc99b369Smrg case $host in 7258dc99b369Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259dc99b369Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260dc99b369Smrg case :$dllsearchpath: in 7261dc99b369Smrg *":$dir:"*) ;; 7262dc99b369Smrg ::) dllsearchpath=$dir;; 7263dc99b369Smrg *) func_append dllsearchpath ":$dir";; 7264dc99b369Smrg esac 7265dc99b369Smrg case :$dllsearchpath: in 7266dc99b369Smrg *":$testbindir:"*) ;; 7267dc99b369Smrg ::) dllsearchpath=$testbindir;; 7268dc99b369Smrg *) func_append dllsearchpath ":$testbindir";; 7269dc99b369Smrg esac 7270dc99b369Smrg ;; 7271dc99b369Smrg esac 7272dc99b369Smrg continue 7273dc99b369Smrg ;; 7274dc99b369Smrg 7275dc99b369Smrg -l*) 72765c30ecadSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277dc99b369Smrg case $host in 7278dc99b369Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279dc99b369Smrg # These systems don't actually have a C or math library (as such) 7280dc99b369Smrg continue 7281dc99b369Smrg ;; 7282dc99b369Smrg *-*-os2*) 7283dc99b369Smrg # These systems don't actually have a C library (as such) 72845c30ecadSmrg test X-lc = "X$arg" && continue 7285dc99b369Smrg ;; 72865c30ecadSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287dc99b369Smrg # Do not include libc due to us having libc/libc_r. 72885c30ecadSmrg test X-lc = "X$arg" && continue 7289dc99b369Smrg ;; 7290dc99b369Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7291dc99b369Smrg # Rhapsody C and math libraries are in the System framework 7292dc99b369Smrg func_append deplibs " System.ltframework" 7293dc99b369Smrg continue 7294dc99b369Smrg ;; 7295dc99b369Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7296dc99b369Smrg # Causes problems with __ctype 72975c30ecadSmrg test X-lc = "X$arg" && continue 7298dc99b369Smrg ;; 7299dc99b369Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300dc99b369Smrg # Compiler inserts libc in the correct place for threads to work 73015c30ecadSmrg test X-lc = "X$arg" && continue 7302dc99b369Smrg ;; 7303dc99b369Smrg esac 73045c30ecadSmrg elif test X-lc_r = "X$arg"; then 7305dc99b369Smrg case $host in 73065c30ecadSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307dc99b369Smrg # Do not include libc_r directly, use -pthread flag. 7308dc99b369Smrg continue 7309dc99b369Smrg ;; 7310dc99b369Smrg esac 7311dc99b369Smrg fi 7312dc99b369Smrg func_append deplibs " $arg" 7313dc99b369Smrg continue 7314dc99b369Smrg ;; 7315dc99b369Smrg 73165c30ecadSmrg -mllvm) 73175c30ecadSmrg prev=mllvm 73185c30ecadSmrg continue 73195c30ecadSmrg ;; 73205c30ecadSmrg 7321dc99b369Smrg -module) 7322dc99b369Smrg module=yes 7323dc99b369Smrg continue 7324dc99b369Smrg ;; 7325dc99b369Smrg 7326dc99b369Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327dc99b369Smrg # classes, name mangling, and exception handling. 7328dc99b369Smrg # Darwin uses the -arch flag to determine output architecture. 7329dc99b369Smrg -model|-arch|-isysroot|--sysroot) 7330dc99b369Smrg func_append compiler_flags " $arg" 7331dc99b369Smrg func_append compile_command " $arg" 7332dc99b369Smrg func_append finalize_command " $arg" 7333dc99b369Smrg prev=xcompiler 7334dc99b369Smrg continue 7335dc99b369Smrg ;; 73365c30ecadSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73375c30ecadSmrg -pthread) 73385c30ecadSmrg case $host in 73395c30ecadSmrg *solaris2*) ;; 73405c30ecadSmrg *) 73415c30ecadSmrg case "$new_inherited_linker_flags " in 73425c30ecadSmrg *" $arg "*) ;; 73435c30ecadSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73445c30ecadSmrg esac 73455c30ecadSmrg ;; 73465c30ecadSmrg esac 73475c30ecadSmrg continue 73485c30ecadSmrg ;; 73495c30ecadSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73505c30ecadSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351dc99b369Smrg func_append compiler_flags " $arg" 7352dc99b369Smrg func_append compile_command " $arg" 7353dc99b369Smrg func_append finalize_command " $arg" 7354dc99b369Smrg case "$new_inherited_linker_flags " in 7355dc99b369Smrg *" $arg "*) ;; 7356dc99b369Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357dc99b369Smrg esac 7358dc99b369Smrg continue 7359dc99b369Smrg ;; 7360dc99b369Smrg 7361dc99b369Smrg -multi_module) 73625c30ecadSmrg single_module=$wl-multi_module 7363dc99b369Smrg continue 7364dc99b369Smrg ;; 7365dc99b369Smrg 7366dc99b369Smrg -no-fast-install) 7367dc99b369Smrg fast_install=no 7368dc99b369Smrg continue 7369dc99b369Smrg ;; 7370dc99b369Smrg 7371dc99b369Smrg -no-install) 7372dc99b369Smrg case $host in 7373dc99b369Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374dc99b369Smrg # The PATH hackery in wrapper scripts is required on Windows 7375dc99b369Smrg # and Darwin in order for the loader to find any dlls it needs. 73765c30ecadSmrg func_warning "'-no-install' is ignored for $host" 73775c30ecadSmrg func_warning "assuming '-no-fast-install' instead" 7378dc99b369Smrg fast_install=no 7379dc99b369Smrg ;; 7380dc99b369Smrg *) no_install=yes ;; 7381dc99b369Smrg esac 7382dc99b369Smrg continue 7383dc99b369Smrg ;; 7384dc99b369Smrg 7385dc99b369Smrg -no-undefined) 7386dc99b369Smrg allow_undefined=no 7387dc99b369Smrg continue 7388dc99b369Smrg ;; 7389dc99b369Smrg 7390dc99b369Smrg -objectlist) 7391dc99b369Smrg prev=objectlist 7392dc99b369Smrg continue 7393dc99b369Smrg ;; 7394dc99b369Smrg 73955c30ecadSmrg -os2dllname) 73965c30ecadSmrg prev=os2dllname 73975c30ecadSmrg continue 73985c30ecadSmrg ;; 73995c30ecadSmrg 7400dc99b369Smrg -o) prev=output ;; 7401dc99b369Smrg 7402dc99b369Smrg -precious-files-regex) 7403dc99b369Smrg prev=precious_regex 7404dc99b369Smrg continue 7405dc99b369Smrg ;; 7406dc99b369Smrg 7407dc99b369Smrg -release) 7408dc99b369Smrg prev=release 7409dc99b369Smrg continue 7410dc99b369Smrg ;; 7411dc99b369Smrg 7412dc99b369Smrg -rpath) 7413dc99b369Smrg prev=rpath 7414dc99b369Smrg continue 7415dc99b369Smrg ;; 7416dc99b369Smrg 7417dc99b369Smrg -R) 7418dc99b369Smrg prev=xrpath 7419dc99b369Smrg continue 7420dc99b369Smrg ;; 7421dc99b369Smrg 7422dc99b369Smrg -R*) 7423dc99b369Smrg func_stripname '-R' '' "$arg" 7424dc99b369Smrg dir=$func_stripname_result 7425dc99b369Smrg # We need an absolute path. 7426dc99b369Smrg case $dir in 7427dc99b369Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428dc99b369Smrg =*) 7429dc99b369Smrg func_stripname '=' '' "$dir" 7430dc99b369Smrg dir=$lt_sysroot$func_stripname_result 7431dc99b369Smrg ;; 7432dc99b369Smrg *) 7433dc99b369Smrg func_fatal_error "only absolute run-paths are allowed" 7434dc99b369Smrg ;; 7435dc99b369Smrg esac 7436dc99b369Smrg case "$xrpath " in 7437dc99b369Smrg *" $dir "*) ;; 7438dc99b369Smrg *) func_append xrpath " $dir" ;; 7439dc99b369Smrg esac 7440dc99b369Smrg continue 7441dc99b369Smrg ;; 7442dc99b369Smrg 7443dc99b369Smrg -shared) 7444dc99b369Smrg # The effects of -shared are defined in a previous loop. 7445dc99b369Smrg continue 7446dc99b369Smrg ;; 7447dc99b369Smrg 7448dc99b369Smrg -shrext) 7449dc99b369Smrg prev=shrext 7450dc99b369Smrg continue 7451dc99b369Smrg ;; 7452dc99b369Smrg 7453dc99b369Smrg -static | -static-libtool-libs) 7454dc99b369Smrg # The effects of -static are defined in a previous loop. 7455dc99b369Smrg # We used to do the same as -all-static on platforms that 7456dc99b369Smrg # didn't have a PIC flag, but the assumption that the effects 7457dc99b369Smrg # would be equivalent was wrong. It would break on at least 7458dc99b369Smrg # Digital Unix and AIX. 7459dc99b369Smrg continue 7460dc99b369Smrg ;; 7461dc99b369Smrg 7462dc99b369Smrg -thread-safe) 7463dc99b369Smrg thread_safe=yes 7464dc99b369Smrg continue 7465dc99b369Smrg ;; 7466dc99b369Smrg 7467dc99b369Smrg -version-info) 7468dc99b369Smrg prev=vinfo 7469dc99b369Smrg continue 7470dc99b369Smrg ;; 7471dc99b369Smrg 7472dc99b369Smrg -version-number) 7473dc99b369Smrg prev=vinfo 7474dc99b369Smrg vinfo_number=yes 7475dc99b369Smrg continue 7476dc99b369Smrg ;; 7477dc99b369Smrg 7478dc99b369Smrg -weak) 7479dc99b369Smrg prev=weak 7480dc99b369Smrg continue 7481dc99b369Smrg ;; 7482dc99b369Smrg 7483dc99b369Smrg -Wc,*) 7484dc99b369Smrg func_stripname '-Wc,' '' "$arg" 7485dc99b369Smrg args=$func_stripname_result 7486dc99b369Smrg arg= 74875c30ecadSmrg save_ifs=$IFS; IFS=, 7488dc99b369Smrg for flag in $args; do 74895c30ecadSmrg IFS=$save_ifs 74905c30ecadSmrg func_quote_arg pretty "$flag" 74915c30ecadSmrg func_append arg " $func_quote_arg_result" 74925c30ecadSmrg func_append compiler_flags " $func_quote_arg_result" 7493dc99b369Smrg done 74945c30ecadSmrg IFS=$save_ifs 7495dc99b369Smrg func_stripname ' ' '' "$arg" 7496dc99b369Smrg arg=$func_stripname_result 7497dc99b369Smrg ;; 7498dc99b369Smrg 7499dc99b369Smrg -Wl,*) 7500dc99b369Smrg func_stripname '-Wl,' '' "$arg" 7501dc99b369Smrg args=$func_stripname_result 7502dc99b369Smrg arg= 75035c30ecadSmrg save_ifs=$IFS; IFS=, 7504dc99b369Smrg for flag in $args; do 75055c30ecadSmrg IFS=$save_ifs 75065c30ecadSmrg func_quote_arg pretty "$flag" 75075c30ecadSmrg func_append arg " $wl$func_quote_arg_result" 75085c30ecadSmrg func_append compiler_flags " $wl$func_quote_arg_result" 75095c30ecadSmrg func_append linker_flags " $func_quote_arg_result" 7510dc99b369Smrg done 75115c30ecadSmrg IFS=$save_ifs 7512dc99b369Smrg func_stripname ' ' '' "$arg" 7513dc99b369Smrg arg=$func_stripname_result 7514dc99b369Smrg ;; 7515dc99b369Smrg 75165c30ecadSmrg -Xassembler) 75175c30ecadSmrg prev=xassembler 75185c30ecadSmrg continue 75195c30ecadSmrg ;; 75205c30ecadSmrg 7521dc99b369Smrg -Xcompiler) 7522dc99b369Smrg prev=xcompiler 7523dc99b369Smrg continue 7524dc99b369Smrg ;; 7525dc99b369Smrg 7526dc99b369Smrg -Xlinker) 7527dc99b369Smrg prev=xlinker 7528dc99b369Smrg continue 7529dc99b369Smrg ;; 7530dc99b369Smrg 7531dc99b369Smrg -XCClinker) 7532dc99b369Smrg prev=xcclinker 7533dc99b369Smrg continue 7534dc99b369Smrg ;; 7535dc99b369Smrg 7536dc99b369Smrg # -msg_* for osf cc 7537dc99b369Smrg -msg_*) 75385c30ecadSmrg func_quote_arg pretty "$arg" 75395c30ecadSmrg arg=$func_quote_arg_result 7540dc99b369Smrg ;; 7541dc99b369Smrg 7542dc99b369Smrg # Flags to be passed through unchanged, with rationale: 7543dc99b369Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544dc99b369Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545dc99b369Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546dc99b369Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547dc99b369Smrg # -q* compiler args for the IBM compiler 7548dc99b369Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549dc99b369Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7550dc99b369Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75515c30ecadSmrg # -fstack-protector* stack protector flags for GCC 7552dc99b369Smrg # @file GCC response files 7553dc99b369Smrg # -tp=* Portland pgcc target processor selection 7554dc99b369Smrg # --sysroot=* for sysroot support 75555c30ecadSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75565c30ecadSmrg # -specs=* GCC specs files 75575c30ecadSmrg # -stdlib=* select c++ std lib with clang 75585c30ecadSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 75595c30ecadSmrg # -fuse-ld=* Linker select flags for GCC 75605c30ecadSmrg # -Wa,* Pass flags directly to the assembler 7561dc99b369Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562dc99b369Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75635c30ecadSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75645c30ecadSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75655c30ecadSmrg func_quote_arg pretty "$arg" 75665c30ecadSmrg arg=$func_quote_arg_result 7567dc99b369Smrg func_append compile_command " $arg" 7568dc99b369Smrg func_append finalize_command " $arg" 7569dc99b369Smrg func_append compiler_flags " $arg" 7570dc99b369Smrg continue 7571dc99b369Smrg ;; 7572dc99b369Smrg 75735c30ecadSmrg -Z*) 75745c30ecadSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75755c30ecadSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75765c30ecadSmrg compiler_flags="$compiler_flags $arg" 75775c30ecadSmrg func_append compile_command " $arg" 75785c30ecadSmrg func_append finalize_command " $arg" 75795c30ecadSmrg case $arg in 75805c30ecadSmrg -Zlinker | -Zstack) 75815c30ecadSmrg prev=xcompiler 75825c30ecadSmrg ;; 75835c30ecadSmrg esac 75845c30ecadSmrg continue 75855c30ecadSmrg else 75865c30ecadSmrg # Otherwise treat like 'Some other compiler flag' below 75875c30ecadSmrg func_quote_arg pretty "$arg" 75885c30ecadSmrg arg=$func_quote_arg_result 75895c30ecadSmrg fi 75905c30ecadSmrg ;; 75915c30ecadSmrg 7592dc99b369Smrg # Some other compiler flag. 7593dc99b369Smrg -* | +*) 75945c30ecadSmrg func_quote_arg pretty "$arg" 75955c30ecadSmrg arg=$func_quote_arg_result 7596dc99b369Smrg ;; 7597dc99b369Smrg 7598dc99b369Smrg *.$objext) 7599dc99b369Smrg # A standard object. 7600dc99b369Smrg func_append objs " $arg" 7601dc99b369Smrg ;; 7602dc99b369Smrg 7603dc99b369Smrg *.lo) 7604dc99b369Smrg # A libtool-controlled object. 7605dc99b369Smrg 7606dc99b369Smrg # Check to see that this really is a libtool object. 7607dc99b369Smrg if func_lalib_unsafe_p "$arg"; then 7608dc99b369Smrg pic_object= 7609dc99b369Smrg non_pic_object= 7610dc99b369Smrg 7611dc99b369Smrg # Read the .lo file 7612dc99b369Smrg func_source "$arg" 7613dc99b369Smrg 7614dc99b369Smrg if test -z "$pic_object" || 7615dc99b369Smrg test -z "$non_pic_object" || 76165c30ecadSmrg test none = "$pic_object" && 76175c30ecadSmrg test none = "$non_pic_object"; then 76185c30ecadSmrg func_fatal_error "cannot find name of object for '$arg'" 7619dc99b369Smrg fi 7620dc99b369Smrg 7621dc99b369Smrg # Extract subdirectory from the argument. 7622dc99b369Smrg func_dirname "$arg" "/" "" 76235c30ecadSmrg xdir=$func_dirname_result 7624dc99b369Smrg 76255c30ecadSmrg test none = "$pic_object" || { 7626dc99b369Smrg # Prepend the subdirectory the object is found in. 76275c30ecadSmrg pic_object=$xdir$pic_object 7628dc99b369Smrg 76295c30ecadSmrg if test dlfiles = "$prev"; then 76305c30ecadSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631dc99b369Smrg func_append dlfiles " $pic_object" 7632dc99b369Smrg prev= 7633dc99b369Smrg continue 7634dc99b369Smrg else 7635dc99b369Smrg # If libtool objects are unsupported, then we need to preload. 7636dc99b369Smrg prev=dlprefiles 7637dc99b369Smrg fi 7638dc99b369Smrg fi 7639dc99b369Smrg 7640dc99b369Smrg # CHECK ME: I think I busted this. -Ossama 76415c30ecadSmrg if test dlprefiles = "$prev"; then 7642dc99b369Smrg # Preload the old-style object. 7643dc99b369Smrg func_append dlprefiles " $pic_object" 7644dc99b369Smrg prev= 7645dc99b369Smrg fi 7646dc99b369Smrg 7647dc99b369Smrg # A PIC object. 7648dc99b369Smrg func_append libobjs " $pic_object" 76495c30ecadSmrg arg=$pic_object 76505c30ecadSmrg } 7651dc99b369Smrg 7652dc99b369Smrg # Non-PIC object. 76535c30ecadSmrg if test none != "$non_pic_object"; then 7654dc99b369Smrg # Prepend the subdirectory the object is found in. 76555c30ecadSmrg non_pic_object=$xdir$non_pic_object 7656dc99b369Smrg 7657dc99b369Smrg # A standard non-PIC object 7658dc99b369Smrg func_append non_pic_objects " $non_pic_object" 76595c30ecadSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76605c30ecadSmrg arg=$non_pic_object 7661dc99b369Smrg fi 7662dc99b369Smrg else 7663dc99b369Smrg # If the PIC object exists, use it instead. 7664dc99b369Smrg # $xdir was prepended to $pic_object above. 76655c30ecadSmrg non_pic_object=$pic_object 7666dc99b369Smrg func_append non_pic_objects " $non_pic_object" 7667dc99b369Smrg fi 7668dc99b369Smrg else 7669dc99b369Smrg # Only an error if not doing a dry-run. 7670dc99b369Smrg if $opt_dry_run; then 7671dc99b369Smrg # Extract subdirectory from the argument. 7672dc99b369Smrg func_dirname "$arg" "/" "" 76735c30ecadSmrg xdir=$func_dirname_result 7674dc99b369Smrg 7675dc99b369Smrg func_lo2o "$arg" 7676dc99b369Smrg pic_object=$xdir$objdir/$func_lo2o_result 7677dc99b369Smrg non_pic_object=$xdir$func_lo2o_result 7678dc99b369Smrg func_append libobjs " $pic_object" 7679dc99b369Smrg func_append non_pic_objects " $non_pic_object" 7680dc99b369Smrg else 76815c30ecadSmrg func_fatal_error "'$arg' is not a valid libtool object" 7682dc99b369Smrg fi 7683dc99b369Smrg fi 7684dc99b369Smrg ;; 7685dc99b369Smrg 7686dc99b369Smrg *.$libext) 7687dc99b369Smrg # An archive. 7688dc99b369Smrg func_append deplibs " $arg" 7689dc99b369Smrg func_append old_deplibs " $arg" 7690dc99b369Smrg continue 7691dc99b369Smrg ;; 7692dc99b369Smrg 7693dc99b369Smrg *.la) 7694dc99b369Smrg # A libtool-controlled library. 7695dc99b369Smrg 7696dc99b369Smrg func_resolve_sysroot "$arg" 76975c30ecadSmrg if test dlfiles = "$prev"; then 7698dc99b369Smrg # This library was specified with -dlopen. 7699dc99b369Smrg func_append dlfiles " $func_resolve_sysroot_result" 7700dc99b369Smrg prev= 77015c30ecadSmrg elif test dlprefiles = "$prev"; then 7702dc99b369Smrg # The library was specified with -dlpreopen. 7703dc99b369Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7704dc99b369Smrg prev= 7705dc99b369Smrg else 7706dc99b369Smrg func_append deplibs " $func_resolve_sysroot_result" 7707dc99b369Smrg fi 7708dc99b369Smrg continue 7709dc99b369Smrg ;; 7710dc99b369Smrg 7711dc99b369Smrg # Some other compiler argument. 7712dc99b369Smrg *) 7713dc99b369Smrg # Unknown arguments in both finalize_command and compile_command need 7714dc99b369Smrg # to be aesthetically quoted because they are evaled later. 77155c30ecadSmrg func_quote_arg pretty "$arg" 77165c30ecadSmrg arg=$func_quote_arg_result 7717dc99b369Smrg ;; 7718dc99b369Smrg esac # arg 7719dc99b369Smrg 7720dc99b369Smrg # Now actually substitute the argument into the commands. 7721dc99b369Smrg if test -n "$arg"; then 7722dc99b369Smrg func_append compile_command " $arg" 7723dc99b369Smrg func_append finalize_command " $arg" 7724dc99b369Smrg fi 7725dc99b369Smrg done # argument parsing loop 7726dc99b369Smrg 7727dc99b369Smrg test -n "$prev" && \ 77285c30ecadSmrg func_fatal_help "the '$prevarg' option requires an argument" 7729dc99b369Smrg 77305c30ecadSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731dc99b369Smrg eval arg=\"$export_dynamic_flag_spec\" 7732dc99b369Smrg func_append compile_command " $arg" 7733dc99b369Smrg func_append finalize_command " $arg" 7734dc99b369Smrg fi 7735dc99b369Smrg 7736dc99b369Smrg oldlibs= 7737dc99b369Smrg # calculate the name of the file, without its directory 7738dc99b369Smrg func_basename "$output" 77395c30ecadSmrg outputname=$func_basename_result 77405c30ecadSmrg libobjs_save=$libobjs 7741dc99b369Smrg 7742dc99b369Smrg if test -n "$shlibpath_var"; then 7743dc99b369Smrg # get the directories listed in $shlibpath_var 77445c30ecadSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745dc99b369Smrg else 7746dc99b369Smrg shlib_search_path= 7747dc99b369Smrg fi 7748dc99b369Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749dc99b369Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750dc99b369Smrg 77515c30ecadSmrg # Definition is injected by LT_CONFIG during libtool generation. 77525c30ecadSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77535c30ecadSmrg 7754dc99b369Smrg func_dirname "$output" "/" "" 77555c30ecadSmrg output_objdir=$func_dirname_result$objdir 7756dc99b369Smrg func_to_tool_file "$output_objdir/" 7757dc99b369Smrg tool_output_objdir=$func_to_tool_file_result 7758dc99b369Smrg # Create the object directory. 7759dc99b369Smrg func_mkdir_p "$output_objdir" 7760dc99b369Smrg 7761dc99b369Smrg # Determine the type of output 7762dc99b369Smrg case $output in 7763dc99b369Smrg "") 7764dc99b369Smrg func_fatal_help "you must specify an output file" 7765dc99b369Smrg ;; 7766dc99b369Smrg *.$libext) linkmode=oldlib ;; 7767dc99b369Smrg *.lo | *.$objext) linkmode=obj ;; 7768dc99b369Smrg *.la) linkmode=lib ;; 7769dc99b369Smrg *) linkmode=prog ;; # Anything else should be a program. 7770dc99b369Smrg esac 7771dc99b369Smrg 7772dc99b369Smrg specialdeplibs= 7773dc99b369Smrg 7774dc99b369Smrg libs= 7775dc99b369Smrg # Find all interdependent deplibs by searching for libraries 7776dc99b369Smrg # that are linked more than once (e.g. -la -lb -la) 7777dc99b369Smrg for deplib in $deplibs; do 77785c30ecadSmrg if $opt_preserve_dup_deps; then 7779dc99b369Smrg case "$libs " in 7780dc99b369Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781dc99b369Smrg esac 7782dc99b369Smrg fi 7783dc99b369Smrg func_append libs " $deplib" 7784dc99b369Smrg done 7785dc99b369Smrg 77865c30ecadSmrg if test lib = "$linkmode"; then 7787dc99b369Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788dc99b369Smrg 7789dc99b369Smrg # Compute libraries that are listed more than once in $predeps 7790dc99b369Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7791dc99b369Smrg # not to be eliminated). 7792dc99b369Smrg pre_post_deps= 7793dc99b369Smrg if $opt_duplicate_compiler_generated_deps; then 7794dc99b369Smrg for pre_post_dep in $predeps $postdeps; do 7795dc99b369Smrg case "$pre_post_deps " in 7796dc99b369Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797dc99b369Smrg esac 7798dc99b369Smrg func_append pre_post_deps " $pre_post_dep" 7799dc99b369Smrg done 7800dc99b369Smrg fi 7801dc99b369Smrg pre_post_deps= 7802dc99b369Smrg fi 7803dc99b369Smrg 7804dc99b369Smrg deplibs= 7805dc99b369Smrg newdependency_libs= 7806dc99b369Smrg newlib_search_path= 7807dc99b369Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808dc99b369Smrg notinst_deplibs= # not-installed libtool libraries 7809dc99b369Smrg notinst_path= # paths that contain not-installed libtool libraries 7810dc99b369Smrg 7811dc99b369Smrg case $linkmode in 7812dc99b369Smrg lib) 7813dc99b369Smrg passes="conv dlpreopen link" 7814dc99b369Smrg for file in $dlfiles $dlprefiles; do 7815dc99b369Smrg case $file in 7816dc99b369Smrg *.la) ;; 7817dc99b369Smrg *) 78185c30ecadSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819dc99b369Smrg ;; 7820dc99b369Smrg esac 7821dc99b369Smrg done 7822dc99b369Smrg ;; 7823dc99b369Smrg prog) 7824dc99b369Smrg compile_deplibs= 7825dc99b369Smrg finalize_deplibs= 78265c30ecadSmrg alldeplibs=false 7827dc99b369Smrg newdlfiles= 7828dc99b369Smrg newdlprefiles= 7829dc99b369Smrg passes="conv scan dlopen dlpreopen link" 7830dc99b369Smrg ;; 7831dc99b369Smrg *) passes="conv" 7832dc99b369Smrg ;; 7833dc99b369Smrg esac 7834dc99b369Smrg 7835dc99b369Smrg for pass in $passes; do 7836dc99b369Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837dc99b369Smrg # so that -L comes before libs that need it for instance... 78385c30ecadSmrg if test lib,link = "$linkmode,$pass"; then 7839dc99b369Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840dc99b369Smrg ## order, and fix it there properly 7841dc99b369Smrg tmp_deplibs= 7842dc99b369Smrg for deplib in $deplibs; do 7843dc99b369Smrg tmp_deplibs="$deplib $tmp_deplibs" 7844dc99b369Smrg done 78455c30ecadSmrg deplibs=$tmp_deplibs 7846dc99b369Smrg fi 7847dc99b369Smrg 78485c30ecadSmrg if test lib,link = "$linkmode,$pass" || 78495c30ecadSmrg test prog,scan = "$linkmode,$pass"; then 78505c30ecadSmrg libs=$deplibs 7851dc99b369Smrg deplibs= 7852dc99b369Smrg fi 78535c30ecadSmrg if test prog = "$linkmode"; then 7854dc99b369Smrg case $pass in 78555c30ecadSmrg dlopen) libs=$dlfiles ;; 78565c30ecadSmrg dlpreopen) libs=$dlprefiles ;; 7857dc99b369Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858dc99b369Smrg esac 7859dc99b369Smrg fi 78605c30ecadSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861dc99b369Smrg # Collect and forward deplibs of preopened libtool libs 7862dc99b369Smrg for lib in $dlprefiles; do 7863dc99b369Smrg # Ignore non-libtool-libs 7864dc99b369Smrg dependency_libs= 7865dc99b369Smrg func_resolve_sysroot "$lib" 7866dc99b369Smrg case $lib in 7867dc99b369Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868dc99b369Smrg esac 7869dc99b369Smrg 7870dc99b369Smrg # Collect preopened libtool deplibs, except any this library 7871dc99b369Smrg # has declared as weak libs 7872dc99b369Smrg for deplib in $dependency_libs; do 7873dc99b369Smrg func_basename "$deplib" 7874dc99b369Smrg deplib_base=$func_basename_result 7875dc99b369Smrg case " $weak_libs " in 7876dc99b369Smrg *" $deplib_base "*) ;; 7877dc99b369Smrg *) func_append deplibs " $deplib" ;; 7878dc99b369Smrg esac 7879dc99b369Smrg done 7880dc99b369Smrg done 78815c30ecadSmrg libs=$dlprefiles 7882dc99b369Smrg fi 78835c30ecadSmrg if test dlopen = "$pass"; then 7884dc99b369Smrg # Collect dlpreopened libraries 78855c30ecadSmrg save_deplibs=$deplibs 7886dc99b369Smrg deplibs= 7887dc99b369Smrg fi 7888dc99b369Smrg 7889dc99b369Smrg for deplib in $libs; do 7890dc99b369Smrg lib= 78915c30ecadSmrg found=false 7892dc99b369Smrg case $deplib in 78935c30ecadSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78945c30ecadSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78955c30ecadSmrg if test prog,link = "$linkmode,$pass"; then 7896dc99b369Smrg compile_deplibs="$deplib $compile_deplibs" 7897dc99b369Smrg finalize_deplibs="$deplib $finalize_deplibs" 7898dc99b369Smrg else 7899dc99b369Smrg func_append compiler_flags " $deplib" 79005c30ecadSmrg if test lib = "$linkmode"; then 7901dc99b369Smrg case "$new_inherited_linker_flags " in 7902dc99b369Smrg *" $deplib "*) ;; 7903dc99b369Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904dc99b369Smrg esac 7905dc99b369Smrg fi 7906dc99b369Smrg fi 7907dc99b369Smrg continue 7908dc99b369Smrg ;; 7909dc99b369Smrg -l*) 79105c30ecadSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79115c30ecadSmrg func_warning "'-l' is ignored for archives/objects" 7912dc99b369Smrg continue 7913dc99b369Smrg fi 7914dc99b369Smrg func_stripname '-l' '' "$deplib" 7915dc99b369Smrg name=$func_stripname_result 79165c30ecadSmrg if test lib = "$linkmode"; then 7917dc99b369Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918dc99b369Smrg else 7919dc99b369Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920dc99b369Smrg fi 7921dc99b369Smrg for searchdir in $searchdirs; do 7922dc99b369Smrg for search_ext in .la $std_shrext .so .a; do 7923dc99b369Smrg # Search the libtool library 79245c30ecadSmrg lib=$searchdir/lib$name$search_ext 7925dc99b369Smrg if test -f "$lib"; then 79265c30ecadSmrg if test .la = "$search_ext"; then 79275c30ecadSmrg found=: 7928dc99b369Smrg else 79295c30ecadSmrg found=false 7930dc99b369Smrg fi 7931dc99b369Smrg break 2 7932dc99b369Smrg fi 7933dc99b369Smrg done 7934dc99b369Smrg done 79355c30ecadSmrg if $found; then 79365c30ecadSmrg # deplib is a libtool library 7937dc99b369Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938dc99b369Smrg # We need to do some special things here, and not later. 79395c30ecadSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940dc99b369Smrg case " $predeps $postdeps " in 7941dc99b369Smrg *" $deplib "*) 7942dc99b369Smrg if func_lalib_p "$lib"; then 7943dc99b369Smrg library_names= 7944dc99b369Smrg old_library= 7945dc99b369Smrg func_source "$lib" 7946dc99b369Smrg for l in $old_library $library_names; do 79475c30ecadSmrg ll=$l 7948dc99b369Smrg done 79495c30ecadSmrg if test "X$ll" = "X$old_library"; then # only static version available 79505c30ecadSmrg found=false 7951dc99b369Smrg func_dirname "$lib" "" "." 79525c30ecadSmrg ladir=$func_dirname_result 7953dc99b369Smrg lib=$ladir/$old_library 79545c30ecadSmrg if test prog,link = "$linkmode,$pass"; then 7955dc99b369Smrg compile_deplibs="$deplib $compile_deplibs" 7956dc99b369Smrg finalize_deplibs="$deplib $finalize_deplibs" 7957dc99b369Smrg else 7958dc99b369Smrg deplibs="$deplib $deplibs" 79595c30ecadSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960dc99b369Smrg fi 7961dc99b369Smrg continue 7962dc99b369Smrg fi 7963dc99b369Smrg fi 7964dc99b369Smrg ;; 7965dc99b369Smrg *) ;; 7966dc99b369Smrg esac 7967dc99b369Smrg fi 79685c30ecadSmrg else 79695c30ecadSmrg # deplib doesn't seem to be a libtool library 79705c30ecadSmrg if test prog,link = "$linkmode,$pass"; then 79715c30ecadSmrg compile_deplibs="$deplib $compile_deplibs" 79725c30ecadSmrg finalize_deplibs="$deplib $finalize_deplibs" 79735c30ecadSmrg else 79745c30ecadSmrg deplibs="$deplib $deplibs" 79755c30ecadSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79765c30ecadSmrg fi 79775c30ecadSmrg continue 7978dc99b369Smrg fi 7979dc99b369Smrg ;; # -l 7980dc99b369Smrg *.ltframework) 79815c30ecadSmrg if test prog,link = "$linkmode,$pass"; then 7982dc99b369Smrg compile_deplibs="$deplib $compile_deplibs" 7983dc99b369Smrg finalize_deplibs="$deplib $finalize_deplibs" 7984dc99b369Smrg else 7985dc99b369Smrg deplibs="$deplib $deplibs" 79865c30ecadSmrg if test lib = "$linkmode"; then 7987dc99b369Smrg case "$new_inherited_linker_flags " in 7988dc99b369Smrg *" $deplib "*) ;; 7989dc99b369Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990dc99b369Smrg esac 7991dc99b369Smrg fi 7992dc99b369Smrg fi 7993dc99b369Smrg continue 7994dc99b369Smrg ;; 7995dc99b369Smrg -L*) 7996dc99b369Smrg case $linkmode in 7997dc99b369Smrg lib) 7998dc99b369Smrg deplibs="$deplib $deplibs" 79995c30ecadSmrg test conv = "$pass" && continue 8000dc99b369Smrg newdependency_libs="$deplib $newdependency_libs" 8001dc99b369Smrg func_stripname '-L' '' "$deplib" 8002dc99b369Smrg func_resolve_sysroot "$func_stripname_result" 8003dc99b369Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004dc99b369Smrg ;; 8005dc99b369Smrg prog) 80065c30ecadSmrg if test conv = "$pass"; then 8007dc99b369Smrg deplibs="$deplib $deplibs" 8008dc99b369Smrg continue 8009dc99b369Smrg fi 80105c30ecadSmrg if test scan = "$pass"; then 8011dc99b369Smrg deplibs="$deplib $deplibs" 8012dc99b369Smrg else 8013dc99b369Smrg compile_deplibs="$deplib $compile_deplibs" 8014dc99b369Smrg finalize_deplibs="$deplib $finalize_deplibs" 8015dc99b369Smrg fi 8016dc99b369Smrg func_stripname '-L' '' "$deplib" 8017dc99b369Smrg func_resolve_sysroot "$func_stripname_result" 8018dc99b369Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019dc99b369Smrg ;; 8020dc99b369Smrg *) 80215c30ecadSmrg func_warning "'-L' is ignored for archives/objects" 8022dc99b369Smrg ;; 8023dc99b369Smrg esac # linkmode 8024dc99b369Smrg continue 8025dc99b369Smrg ;; # -L 8026dc99b369Smrg -R*) 80275c30ecadSmrg if test link = "$pass"; then 8028dc99b369Smrg func_stripname '-R' '' "$deplib" 8029dc99b369Smrg func_resolve_sysroot "$func_stripname_result" 8030dc99b369Smrg dir=$func_resolve_sysroot_result 8031dc99b369Smrg # Make sure the xrpath contains only unique directories. 8032dc99b369Smrg case "$xrpath " in 8033dc99b369Smrg *" $dir "*) ;; 8034dc99b369Smrg *) func_append xrpath " $dir" ;; 8035dc99b369Smrg esac 8036dc99b369Smrg fi 8037dc99b369Smrg deplibs="$deplib $deplibs" 8038dc99b369Smrg continue 8039dc99b369Smrg ;; 8040dc99b369Smrg *.la) 8041dc99b369Smrg func_resolve_sysroot "$deplib" 8042dc99b369Smrg lib=$func_resolve_sysroot_result 8043dc99b369Smrg ;; 8044dc99b369Smrg *.$libext) 80455c30ecadSmrg if test conv = "$pass"; then 8046dc99b369Smrg deplibs="$deplib $deplibs" 8047dc99b369Smrg continue 8048dc99b369Smrg fi 8049dc99b369Smrg case $linkmode in 8050dc99b369Smrg lib) 8051dc99b369Smrg # Linking convenience modules into shared libraries is allowed, 8052dc99b369Smrg # but linking other static libraries is non-portable. 8053dc99b369Smrg case " $dlpreconveniencelibs " in 8054dc99b369Smrg *" $deplib "*) ;; 8055dc99b369Smrg *) 80565c30ecadSmrg valid_a_lib=false 8057dc99b369Smrg case $deplibs_check_method in 8058dc99b369Smrg match_pattern*) 8059dc99b369Smrg set dummy $deplibs_check_method; shift 8060dc99b369Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061dc99b369Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062dc99b369Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80635c30ecadSmrg valid_a_lib=: 8064dc99b369Smrg fi 8065dc99b369Smrg ;; 8066dc99b369Smrg pass_all) 80675c30ecadSmrg valid_a_lib=: 8068dc99b369Smrg ;; 8069dc99b369Smrg esac 80705c30ecadSmrg if $valid_a_lib; then 80715c30ecadSmrg echo 80725c30ecadSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80735c30ecadSmrg $ECHO "*** static library $deplib is not portable!" 80745c30ecadSmrg deplibs="$deplib $deplibs" 80755c30ecadSmrg else 8076dc99b369Smrg echo 8077dc99b369Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078dc99b369Smrg echo "*** I have the capability to make that library automatically link in when" 8079dc99b369Smrg echo "*** you link to this library. But I can only do this if you have a" 8080dc99b369Smrg echo "*** shared version of the library, which you do not appear to have" 8081dc99b369Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082dc99b369Smrg echo "*** that it is just a static archive that I should not use here." 8083dc99b369Smrg fi 8084dc99b369Smrg ;; 8085dc99b369Smrg esac 8086dc99b369Smrg continue 8087dc99b369Smrg ;; 8088dc99b369Smrg prog) 80895c30ecadSmrg if test link != "$pass"; then 8090dc99b369Smrg deplibs="$deplib $deplibs" 8091dc99b369Smrg else 8092dc99b369Smrg compile_deplibs="$deplib $compile_deplibs" 8093dc99b369Smrg finalize_deplibs="$deplib $finalize_deplibs" 8094dc99b369Smrg fi 8095dc99b369Smrg continue 8096dc99b369Smrg ;; 8097dc99b369Smrg esac # linkmode 8098dc99b369Smrg ;; # *.$libext 8099dc99b369Smrg *.lo | *.$objext) 81005c30ecadSmrg if test conv = "$pass"; then 8101dc99b369Smrg deplibs="$deplib $deplibs" 81025c30ecadSmrg elif test prog = "$linkmode"; then 81035c30ecadSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104dc99b369Smrg # If there is no dlopen support or we're linking statically, 8105dc99b369Smrg # we need to preload. 8106dc99b369Smrg func_append newdlprefiles " $deplib" 8107dc99b369Smrg compile_deplibs="$deplib $compile_deplibs" 8108dc99b369Smrg finalize_deplibs="$deplib $finalize_deplibs" 8109dc99b369Smrg else 8110dc99b369Smrg func_append newdlfiles " $deplib" 8111dc99b369Smrg fi 8112dc99b369Smrg fi 8113dc99b369Smrg continue 8114dc99b369Smrg ;; 8115dc99b369Smrg %DEPLIBS%) 81165c30ecadSmrg alldeplibs=: 8117dc99b369Smrg continue 8118dc99b369Smrg ;; 8119dc99b369Smrg esac # case $deplib 8120dc99b369Smrg 81215c30ecadSmrg $found || test -f "$lib" \ 81225c30ecadSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123dc99b369Smrg 8124dc99b369Smrg # Check to see that this really is a libtool archive. 8125dc99b369Smrg func_lalib_unsafe_p "$lib" \ 81265c30ecadSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127dc99b369Smrg 8128dc99b369Smrg func_dirname "$lib" "" "." 81295c30ecadSmrg ladir=$func_dirname_result 8130dc99b369Smrg 8131dc99b369Smrg dlname= 8132dc99b369Smrg dlopen= 8133dc99b369Smrg dlpreopen= 8134dc99b369Smrg libdir= 8135dc99b369Smrg library_names= 8136dc99b369Smrg old_library= 8137dc99b369Smrg inherited_linker_flags= 8138dc99b369Smrg # If the library was installed with an old release of libtool, 8139dc99b369Smrg # it will not redefine variables installed, or shouldnotlink 8140dc99b369Smrg installed=yes 8141dc99b369Smrg shouldnotlink=no 8142dc99b369Smrg avoidtemprpath= 8143dc99b369Smrg 8144dc99b369Smrg 8145dc99b369Smrg # Read the .la file 8146dc99b369Smrg func_source "$lib" 8147dc99b369Smrg 8148dc99b369Smrg # Convert "-framework foo" to "foo.ltframework" 8149dc99b369Smrg if test -n "$inherited_linker_flags"; then 8150dc99b369Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151dc99b369Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152dc99b369Smrg case " $new_inherited_linker_flags " in 8153dc99b369Smrg *" $tmp_inherited_linker_flag "*) ;; 8154dc99b369Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155dc99b369Smrg esac 8156dc99b369Smrg done 8157dc99b369Smrg fi 8158dc99b369Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81595c30ecadSmrg if test lib,link = "$linkmode,$pass" || 81605c30ecadSmrg test prog,scan = "$linkmode,$pass" || 81615c30ecadSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162dc99b369Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163dc99b369Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164dc99b369Smrg fi 8165dc99b369Smrg 81665c30ecadSmrg if test conv = "$pass"; then 8167dc99b369Smrg # Only check for convenience libraries 8168dc99b369Smrg deplibs="$lib $deplibs" 8169dc99b369Smrg if test -z "$libdir"; then 8170dc99b369Smrg if test -z "$old_library"; then 81715c30ecadSmrg func_fatal_error "cannot find name of link library for '$lib'" 8172dc99b369Smrg fi 8173dc99b369Smrg # It is a libtool convenience library, so add in its objects. 8174dc99b369Smrg func_append convenience " $ladir/$objdir/$old_library" 8175dc99b369Smrg func_append old_convenience " $ladir/$objdir/$old_library" 81765c30ecadSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81775c30ecadSmrg func_fatal_error "'$lib' is not a convenience library" 8178dc99b369Smrg fi 8179dc99b369Smrg tmp_libs= 8180dc99b369Smrg for deplib in $dependency_libs; do 8181dc99b369Smrg deplibs="$deplib $deplibs" 81825c30ecadSmrg if $opt_preserve_dup_deps; then 8183dc99b369Smrg case "$tmp_libs " in 8184dc99b369Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185dc99b369Smrg esac 8186dc99b369Smrg fi 8187dc99b369Smrg func_append tmp_libs " $deplib" 8188dc99b369Smrg done 8189dc99b369Smrg continue 8190dc99b369Smrg fi # $pass = conv 8191dc99b369Smrg 8192dc99b369Smrg 8193dc99b369Smrg # Get the name of the library we link against. 8194dc99b369Smrg linklib= 8195dc99b369Smrg if test -n "$old_library" && 81965c30ecadSmrg { test yes = "$prefer_static_libs" || 81975c30ecadSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198dc99b369Smrg linklib=$old_library 8199dc99b369Smrg else 8200dc99b369Smrg for l in $old_library $library_names; do 82015c30ecadSmrg linklib=$l 8202dc99b369Smrg done 8203dc99b369Smrg fi 8204dc99b369Smrg if test -z "$linklib"; then 82055c30ecadSmrg func_fatal_error "cannot find name of link library for '$lib'" 8206dc99b369Smrg fi 8207dc99b369Smrg 8208dc99b369Smrg # This library was specified with -dlopen. 82095c30ecadSmrg if test dlopen = "$pass"; then 82105c30ecadSmrg test -z "$libdir" \ 82115c30ecadSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212dc99b369Smrg if test -z "$dlname" || 82135c30ecadSmrg test yes != "$dlopen_support" || 82145c30ecadSmrg test no = "$build_libtool_libs" 82155c30ecadSmrg then 8216dc99b369Smrg # If there is no dlname, no dlopen support or we're linking 8217dc99b369Smrg # statically, we need to preload. We also need to preload any 8218dc99b369Smrg # dependent libraries so libltdl's deplib preloader doesn't 8219dc99b369Smrg # bomb out in the load deplibs phase. 8220dc99b369Smrg func_append dlprefiles " $lib $dependency_libs" 8221dc99b369Smrg else 8222dc99b369Smrg func_append newdlfiles " $lib" 8223dc99b369Smrg fi 8224dc99b369Smrg continue 8225dc99b369Smrg fi # $pass = dlopen 8226dc99b369Smrg 8227dc99b369Smrg # We need an absolute path. 8228dc99b369Smrg case $ladir in 82295c30ecadSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230dc99b369Smrg *) 8231dc99b369Smrg abs_ladir=`cd "$ladir" && pwd` 8232dc99b369Smrg if test -z "$abs_ladir"; then 82335c30ecadSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8234dc99b369Smrg func_warning "passing it literally to the linker, although it might fail" 82355c30ecadSmrg abs_ladir=$ladir 8236dc99b369Smrg fi 8237dc99b369Smrg ;; 8238dc99b369Smrg esac 8239dc99b369Smrg func_basename "$lib" 82405c30ecadSmrg laname=$func_basename_result 8241dc99b369Smrg 8242dc99b369Smrg # Find the relevant object directory and library name. 82435c30ecadSmrg if test yes = "$installed"; then 8244dc99b369Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82455c30ecadSmrg func_warning "library '$lib' was moved." 82465c30ecadSmrg dir=$ladir 82475c30ecadSmrg absdir=$abs_ladir 82485c30ecadSmrg libdir=$abs_ladir 8249dc99b369Smrg else 82505c30ecadSmrg dir=$lt_sysroot$libdir 82515c30ecadSmrg absdir=$lt_sysroot$libdir 8252dc99b369Smrg fi 82535c30ecadSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254dc99b369Smrg else 8255dc99b369Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82565c30ecadSmrg dir=$ladir 82575c30ecadSmrg absdir=$abs_ladir 8258dc99b369Smrg # Remove this search path later 8259dc99b369Smrg func_append notinst_path " $abs_ladir" 8260dc99b369Smrg else 82615c30ecadSmrg dir=$ladir/$objdir 82625c30ecadSmrg absdir=$abs_ladir/$objdir 8263dc99b369Smrg # Remove this search path later 8264dc99b369Smrg func_append notinst_path " $abs_ladir" 8265dc99b369Smrg fi 8266dc99b369Smrg fi # $installed = yes 8267dc99b369Smrg func_stripname 'lib' '.la' "$laname" 8268dc99b369Smrg name=$func_stripname_result 8269dc99b369Smrg 8270dc99b369Smrg # This library was specified with -dlpreopen. 82715c30ecadSmrg if test dlpreopen = "$pass"; then 82725c30ecadSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82735c30ecadSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274dc99b369Smrg fi 82755c30ecadSmrg case $host in 8276dc99b369Smrg # special handling for platforms with PE-DLLs. 8277dc99b369Smrg *cygwin* | *mingw* | *cegcc* ) 8278dc99b369Smrg # Linker will automatically link against shared library if both 8279dc99b369Smrg # static and shared are present. Therefore, ensure we extract 8280dc99b369Smrg # symbols from the import library if a shared library is present 8281dc99b369Smrg # (otherwise, the dlopen module name will be incorrect). We do 8282dc99b369Smrg # this by putting the import library name into $newdlprefiles. 8283dc99b369Smrg # We recover the dlopen module name by 'saving' the la file 8284dc99b369Smrg # name in a special purpose variable, and (later) extracting the 8285dc99b369Smrg # dlname from the la file. 8286dc99b369Smrg if test -n "$dlname"; then 8287dc99b369Smrg func_tr_sh "$dir/$linklib" 8288dc99b369Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289dc99b369Smrg func_append newdlprefiles " $dir/$linklib" 8290dc99b369Smrg else 8291dc99b369Smrg func_append newdlprefiles " $dir/$old_library" 8292dc99b369Smrg # Keep a list of preopened convenience libraries to check 8293dc99b369Smrg # that they are being used correctly in the link pass. 8294dc99b369Smrg test -z "$libdir" && \ 8295dc99b369Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8296dc99b369Smrg fi 8297dc99b369Smrg ;; 8298dc99b369Smrg * ) 8299dc99b369Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300dc99b369Smrg # are required to link). 8301dc99b369Smrg if test -n "$old_library"; then 8302dc99b369Smrg func_append newdlprefiles " $dir/$old_library" 8303dc99b369Smrg # Keep a list of preopened convenience libraries to check 8304dc99b369Smrg # that they are being used correctly in the link pass. 8305dc99b369Smrg test -z "$libdir" && \ 8306dc99b369Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8307dc99b369Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308dc99b369Smrg elif test -n "$dlname"; then 8309dc99b369Smrg func_append newdlprefiles " $dir/$dlname" 8310dc99b369Smrg else 8311dc99b369Smrg func_append newdlprefiles " $dir/$linklib" 8312dc99b369Smrg fi 8313dc99b369Smrg ;; 8314dc99b369Smrg esac 8315dc99b369Smrg fi # $pass = dlpreopen 8316dc99b369Smrg 8317dc99b369Smrg if test -z "$libdir"; then 8318dc99b369Smrg # Link the convenience library 83195c30ecadSmrg if test lib = "$linkmode"; then 8320dc99b369Smrg deplibs="$dir/$old_library $deplibs" 83215c30ecadSmrg elif test prog,link = "$linkmode,$pass"; then 8322dc99b369Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323dc99b369Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324dc99b369Smrg else 8325dc99b369Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8326dc99b369Smrg fi 8327dc99b369Smrg continue 8328dc99b369Smrg fi 8329dc99b369Smrg 8330dc99b369Smrg 83315c30ecadSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332dc99b369Smrg func_append newlib_search_path " $ladir" 8333dc99b369Smrg deplibs="$lib $deplibs" 8334dc99b369Smrg 83355c30ecadSmrg linkalldeplibs=false 83365c30ecadSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83375c30ecadSmrg test no = "$build_libtool_libs"; then 83385c30ecadSmrg linkalldeplibs=: 8339dc99b369Smrg fi 8340dc99b369Smrg 8341dc99b369Smrg tmp_libs= 8342dc99b369Smrg for deplib in $dependency_libs; do 8343dc99b369Smrg case $deplib in 8344dc99b369Smrg -L*) func_stripname '-L' '' "$deplib" 8345dc99b369Smrg func_resolve_sysroot "$func_stripname_result" 8346dc99b369Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347dc99b369Smrg ;; 8348dc99b369Smrg esac 8349dc99b369Smrg # Need to link against all dependency_libs? 83505c30ecadSmrg if $linkalldeplibs; then 8351dc99b369Smrg deplibs="$deplib $deplibs" 8352dc99b369Smrg else 8353dc99b369Smrg # Need to hardcode shared library paths 8354dc99b369Smrg # or/and link against static libraries 8355dc99b369Smrg newdependency_libs="$deplib $newdependency_libs" 8356dc99b369Smrg fi 83575c30ecadSmrg if $opt_preserve_dup_deps; then 8358dc99b369Smrg case "$tmp_libs " in 8359dc99b369Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360dc99b369Smrg esac 8361dc99b369Smrg fi 8362dc99b369Smrg func_append tmp_libs " $deplib" 8363dc99b369Smrg done # for deplib 8364dc99b369Smrg continue 8365dc99b369Smrg fi # $linkmode = prog... 8366dc99b369Smrg 83675c30ecadSmrg if test prog,link = "$linkmode,$pass"; then 8368dc99b369Smrg if test -n "$library_names" && 83695c30ecadSmrg { { test no = "$prefer_static_libs" || 83705c30ecadSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8371dc99b369Smrg test -z "$old_library"; }; then 8372dc99b369Smrg # We need to hardcode the library path 83735c30ecadSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374dc99b369Smrg # Make sure the rpath contains only unique directories. 83755c30ecadSmrg case $temp_rpath: in 8376dc99b369Smrg *"$absdir:"*) ;; 8377dc99b369Smrg *) func_append temp_rpath "$absdir:" ;; 8378dc99b369Smrg esac 8379dc99b369Smrg fi 8380dc99b369Smrg 8381dc99b369Smrg # Hardcode the library path. 8382dc99b369Smrg # Skip directories that are in the system default run-time 8383dc99b369Smrg # search path. 8384dc99b369Smrg case " $sys_lib_dlsearch_path " in 8385dc99b369Smrg *" $absdir "*) ;; 8386dc99b369Smrg *) 8387dc99b369Smrg case "$compile_rpath " in 8388dc99b369Smrg *" $absdir "*) ;; 8389dc99b369Smrg *) func_append compile_rpath " $absdir" ;; 8390dc99b369Smrg esac 8391dc99b369Smrg ;; 8392dc99b369Smrg esac 8393dc99b369Smrg case " $sys_lib_dlsearch_path " in 8394dc99b369Smrg *" $libdir "*) ;; 8395dc99b369Smrg *) 8396dc99b369Smrg case "$finalize_rpath " in 8397dc99b369Smrg *" $libdir "*) ;; 8398dc99b369Smrg *) func_append finalize_rpath " $libdir" ;; 8399dc99b369Smrg esac 8400dc99b369Smrg ;; 8401dc99b369Smrg esac 8402dc99b369Smrg fi # $linkmode,$pass = prog,link... 8403dc99b369Smrg 84045c30ecadSmrg if $alldeplibs && 84055c30ecadSmrg { test pass_all = "$deplibs_check_method" || 84065c30ecadSmrg { test yes = "$build_libtool_libs" && 8407dc99b369Smrg test -n "$library_names"; }; }; then 8408dc99b369Smrg # We only need to search for static libraries 8409dc99b369Smrg continue 8410dc99b369Smrg fi 8411dc99b369Smrg fi 8412dc99b369Smrg 8413dc99b369Smrg link_static=no # Whether the deplib will be linked statically 8414dc99b369Smrg use_static_libs=$prefer_static_libs 84155c30ecadSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416dc99b369Smrg use_static_libs=no 8417dc99b369Smrg fi 8418dc99b369Smrg if test -n "$library_names" && 84195c30ecadSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420dc99b369Smrg case $host in 84215c30ecadSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422dc99b369Smrg # No point in relinking DLLs because paths are not encoded 8423dc99b369Smrg func_append notinst_deplibs " $lib" 8424dc99b369Smrg need_relink=no 8425dc99b369Smrg ;; 8426dc99b369Smrg *) 84275c30ecadSmrg if test no = "$installed"; then 8428dc99b369Smrg func_append notinst_deplibs " $lib" 8429dc99b369Smrg need_relink=yes 8430dc99b369Smrg fi 8431dc99b369Smrg ;; 8432dc99b369Smrg esac 8433dc99b369Smrg # This is a shared library 8434dc99b369Smrg 8435dc99b369Smrg # Warn about portability, can't link against -module's on some 8436dc99b369Smrg # systems (darwin). Don't bleat about dlopened modules though! 84375c30ecadSmrg dlopenmodule= 8438dc99b369Smrg for dlpremoduletest in $dlprefiles; do 8439dc99b369Smrg if test "X$dlpremoduletest" = "X$lib"; then 84405c30ecadSmrg dlopenmodule=$dlpremoduletest 8441dc99b369Smrg break 8442dc99b369Smrg fi 8443dc99b369Smrg done 84445c30ecadSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445dc99b369Smrg echo 84465c30ecadSmrg if test prog = "$linkmode"; then 8447dc99b369Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448dc99b369Smrg else 8449dc99b369Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450dc99b369Smrg fi 8451dc99b369Smrg $ECHO "*** $linklib is not portable!" 8452dc99b369Smrg fi 84535c30ecadSmrg if test lib = "$linkmode" && 84545c30ecadSmrg test yes = "$hardcode_into_libs"; then 8455dc99b369Smrg # Hardcode the library path. 8456dc99b369Smrg # Skip directories that are in the system default run-time 8457dc99b369Smrg # search path. 8458dc99b369Smrg case " $sys_lib_dlsearch_path " in 8459dc99b369Smrg *" $absdir "*) ;; 8460dc99b369Smrg *) 8461dc99b369Smrg case "$compile_rpath " in 8462dc99b369Smrg *" $absdir "*) ;; 8463dc99b369Smrg *) func_append compile_rpath " $absdir" ;; 8464dc99b369Smrg esac 8465dc99b369Smrg ;; 8466dc99b369Smrg esac 8467dc99b369Smrg case " $sys_lib_dlsearch_path " in 8468dc99b369Smrg *" $libdir "*) ;; 8469dc99b369Smrg *) 8470dc99b369Smrg case "$finalize_rpath " in 8471dc99b369Smrg *" $libdir "*) ;; 8472dc99b369Smrg *) func_append finalize_rpath " $libdir" ;; 8473dc99b369Smrg esac 8474dc99b369Smrg ;; 8475dc99b369Smrg esac 8476dc99b369Smrg fi 8477dc99b369Smrg 8478dc99b369Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8479dc99b369Smrg # figure out the soname 8480dc99b369Smrg set dummy $library_names 8481dc99b369Smrg shift 84825c30ecadSmrg realname=$1 8483dc99b369Smrg shift 8484dc99b369Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485dc99b369Smrg # use dlname if we got it. it's perfectly good, no? 8486dc99b369Smrg if test -n "$dlname"; then 84875c30ecadSmrg soname=$dlname 8488dc99b369Smrg elif test -n "$soname_spec"; then 8489dc99b369Smrg # bleh windows 8490dc99b369Smrg case $host in 84915c30ecadSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8492dc99b369Smrg func_arith $current - $age 8493dc99b369Smrg major=$func_arith_result 84945c30ecadSmrg versuffix=-$major 8495dc99b369Smrg ;; 8496dc99b369Smrg esac 8497dc99b369Smrg eval soname=\"$soname_spec\" 8498dc99b369Smrg else 84995c30ecadSmrg soname=$realname 8500dc99b369Smrg fi 8501dc99b369Smrg 8502dc99b369Smrg # Make a new name for the extract_expsyms_cmds to use 85035c30ecadSmrg soroot=$soname 8504dc99b369Smrg func_basename "$soroot" 85055c30ecadSmrg soname=$func_basename_result 8506dc99b369Smrg func_stripname 'lib' '.dll' "$soname" 8507dc99b369Smrg newlib=libimp-$func_stripname_result.a 8508dc99b369Smrg 8509dc99b369Smrg # If the library has no export list, then create one now 8510dc99b369Smrg if test -f "$output_objdir/$soname-def"; then : 8511dc99b369Smrg else 85125c30ecadSmrg func_verbose "extracting exported symbol list from '$soname'" 8513dc99b369Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514dc99b369Smrg fi 8515dc99b369Smrg 8516dc99b369Smrg # Create $newlib 8517dc99b369Smrg if test -f "$output_objdir/$newlib"; then :; else 85185c30ecadSmrg func_verbose "generating import library for '$soname'" 8519dc99b369Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520dc99b369Smrg fi 8521dc99b369Smrg # make sure the library variables are pointing to the new library 8522dc99b369Smrg dir=$output_objdir 8523dc99b369Smrg linklib=$newlib 8524dc99b369Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8525dc99b369Smrg 85265c30ecadSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527dc99b369Smrg add_shlibpath= 8528dc99b369Smrg add_dir= 8529dc99b369Smrg add= 8530dc99b369Smrg lib_linked=yes 8531dc99b369Smrg case $hardcode_action in 8532dc99b369Smrg immediate | unsupported) 85335c30ecadSmrg if test no = "$hardcode_direct"; then 85345c30ecadSmrg add=$dir/$linklib 8535dc99b369Smrg case $host in 85365c30ecadSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85375c30ecadSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538dc99b369Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85395c30ecadSmrg *-*-unixware7*) add_dir=-L$dir ;; 8540dc99b369Smrg *-*-darwin* ) 85415c30ecadSmrg # if the lib is a (non-dlopened) module then we cannot 8542dc99b369Smrg # link against it, someone is ignoring the earlier warnings 8543dc99b369Smrg if /usr/bin/file -L $add 2> /dev/null | 85445c30ecadSmrg $GREP ": [^:]* bundle" >/dev/null; then 8545dc99b369Smrg if test "X$dlopenmodule" != "X$lib"; then 8546dc99b369Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85475c30ecadSmrg if test -z "$old_library"; then 8548dc99b369Smrg echo 8549dc99b369Smrg echo "*** And there doesn't seem to be a static archive available" 8550dc99b369Smrg echo "*** The link will probably fail, sorry" 8551dc99b369Smrg else 85525c30ecadSmrg add=$dir/$old_library 8553dc99b369Smrg fi 8554dc99b369Smrg elif test -n "$old_library"; then 85555c30ecadSmrg add=$dir/$old_library 8556dc99b369Smrg fi 8557dc99b369Smrg fi 8558dc99b369Smrg esac 85595c30ecadSmrg elif test no = "$hardcode_minus_L"; then 8560dc99b369Smrg case $host in 85615c30ecadSmrg *-*-sunos*) add_shlibpath=$dir ;; 8562dc99b369Smrg esac 85635c30ecadSmrg add_dir=-L$dir 85645c30ecadSmrg add=-l$name 85655c30ecadSmrg elif test no = "$hardcode_shlibpath_var"; then 85665c30ecadSmrg add_shlibpath=$dir 85675c30ecadSmrg add=-l$name 8568dc99b369Smrg else 8569dc99b369Smrg lib_linked=no 8570dc99b369Smrg fi 8571dc99b369Smrg ;; 8572dc99b369Smrg relink) 85735c30ecadSmrg if test yes = "$hardcode_direct" && 85745c30ecadSmrg test no = "$hardcode_direct_absolute"; then 85755c30ecadSmrg add=$dir/$linklib 85765c30ecadSmrg elif test yes = "$hardcode_minus_L"; then 85775c30ecadSmrg add_dir=-L$absdir 8578dc99b369Smrg # Try looking first in the location we're being installed to. 8579dc99b369Smrg if test -n "$inst_prefix_dir"; then 8580dc99b369Smrg case $libdir in 8581dc99b369Smrg [\\/]*) 8582dc99b369Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583dc99b369Smrg ;; 8584dc99b369Smrg esac 8585dc99b369Smrg fi 85865c30ecadSmrg add=-l$name 85875c30ecadSmrg elif test yes = "$hardcode_shlibpath_var"; then 85885c30ecadSmrg add_shlibpath=$dir 85895c30ecadSmrg add=-l$name 8590dc99b369Smrg else 8591dc99b369Smrg lib_linked=no 8592dc99b369Smrg fi 8593dc99b369Smrg ;; 8594dc99b369Smrg *) lib_linked=no ;; 8595dc99b369Smrg esac 8596dc99b369Smrg 85975c30ecadSmrg if test yes != "$lib_linked"; then 8598dc99b369Smrg func_fatal_configuration "unsupported hardcode properties" 8599dc99b369Smrg fi 8600dc99b369Smrg 8601dc99b369Smrg if test -n "$add_shlibpath"; then 8602dc99b369Smrg case :$compile_shlibpath: in 8603dc99b369Smrg *":$add_shlibpath:"*) ;; 8604dc99b369Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605dc99b369Smrg esac 8606dc99b369Smrg fi 86075c30ecadSmrg if test prog = "$linkmode"; then 8608dc99b369Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609dc99b369Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610dc99b369Smrg else 8611dc99b369Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612dc99b369Smrg test -n "$add" && deplibs="$add $deplibs" 86135c30ecadSmrg if test yes != "$hardcode_direct" && 86145c30ecadSmrg test yes != "$hardcode_minus_L" && 86155c30ecadSmrg test yes = "$hardcode_shlibpath_var"; then 8616dc99b369Smrg case :$finalize_shlibpath: in 8617dc99b369Smrg *":$libdir:"*) ;; 8618dc99b369Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8619dc99b369Smrg esac 8620dc99b369Smrg fi 8621dc99b369Smrg fi 8622dc99b369Smrg fi 8623dc99b369Smrg 86245c30ecadSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625dc99b369Smrg add_shlibpath= 8626dc99b369Smrg add_dir= 8627dc99b369Smrg add= 8628dc99b369Smrg # Finalize command for both is simple: just hardcode it. 86295c30ecadSmrg if test yes = "$hardcode_direct" && 86305c30ecadSmrg test no = "$hardcode_direct_absolute"; then 86315c30ecadSmrg add=$libdir/$linklib 86325c30ecadSmrg elif test yes = "$hardcode_minus_L"; then 86335c30ecadSmrg add_dir=-L$libdir 86345c30ecadSmrg add=-l$name 86355c30ecadSmrg elif test yes = "$hardcode_shlibpath_var"; then 8636dc99b369Smrg case :$finalize_shlibpath: in 8637dc99b369Smrg *":$libdir:"*) ;; 8638dc99b369Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8639dc99b369Smrg esac 86405c30ecadSmrg add=-l$name 86415c30ecadSmrg elif test yes = "$hardcode_automatic"; then 8642dc99b369Smrg if test -n "$inst_prefix_dir" && 86435c30ecadSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86445c30ecadSmrg add=$inst_prefix_dir$libdir/$linklib 8645dc99b369Smrg else 86465c30ecadSmrg add=$libdir/$linklib 8647dc99b369Smrg fi 8648dc99b369Smrg else 8649dc99b369Smrg # We cannot seem to hardcode it, guess we'll fake it. 86505c30ecadSmrg add_dir=-L$libdir 8651dc99b369Smrg # Try looking first in the location we're being installed to. 8652dc99b369Smrg if test -n "$inst_prefix_dir"; then 8653dc99b369Smrg case $libdir in 8654dc99b369Smrg [\\/]*) 8655dc99b369Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656dc99b369Smrg ;; 8657dc99b369Smrg esac 8658dc99b369Smrg fi 86595c30ecadSmrg add=-l$name 8660dc99b369Smrg fi 8661dc99b369Smrg 86625c30ecadSmrg if test prog = "$linkmode"; then 8663dc99b369Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664dc99b369Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665dc99b369Smrg else 8666dc99b369Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667dc99b369Smrg test -n "$add" && deplibs="$add $deplibs" 8668dc99b369Smrg fi 8669dc99b369Smrg fi 86705c30ecadSmrg elif test prog = "$linkmode"; then 8671dc99b369Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672dc99b369Smrg # is not unsupported. This is valid on all known static and 8673dc99b369Smrg # shared platforms. 86745c30ecadSmrg if test unsupported != "$hardcode_direct"; then 86755c30ecadSmrg test -n "$old_library" && linklib=$old_library 8676dc99b369Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677dc99b369Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678dc99b369Smrg else 8679dc99b369Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680dc99b369Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681dc99b369Smrg fi 86825c30ecadSmrg elif test yes = "$build_libtool_libs"; then 8683dc99b369Smrg # Not a shared library 86845c30ecadSmrg if test pass_all != "$deplibs_check_method"; then 8685dc99b369Smrg # We're trying link a shared library against a static one 8686dc99b369Smrg # but the system doesn't support it. 8687dc99b369Smrg 8688dc99b369Smrg # Just print a warning and add the library to dependency_libs so 8689dc99b369Smrg # that the program can be linked against the static library. 8690dc99b369Smrg echo 86915c30ecadSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692dc99b369Smrg echo "*** I have the capability to make that library automatically link in when" 8693dc99b369Smrg echo "*** you link to this library. But I can only do this if you have a" 8694dc99b369Smrg echo "*** shared version of the library, which you do not appear to have." 86955c30ecadSmrg if test yes = "$module"; then 8696dc99b369Smrg echo "*** But as you try to build a module library, libtool will still create " 8697dc99b369Smrg echo "*** a static module, that should work as long as the dlopening application" 8698dc99b369Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699dc99b369Smrg if test -z "$global_symbol_pipe"; then 8700dc99b369Smrg echo 8701dc99b369Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87025c30ecadSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703dc99b369Smrg echo "*** not find such a program. So, this module is probably useless." 87045c30ecadSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705dc99b369Smrg fi 87065c30ecadSmrg if test no = "$build_old_libs"; then 8707dc99b369Smrg build_libtool_libs=module 8708dc99b369Smrg build_old_libs=yes 8709dc99b369Smrg else 8710dc99b369Smrg build_libtool_libs=no 8711dc99b369Smrg fi 8712dc99b369Smrg fi 8713dc99b369Smrg else 8714dc99b369Smrg deplibs="$dir/$old_library $deplibs" 8715dc99b369Smrg link_static=yes 8716dc99b369Smrg fi 8717dc99b369Smrg fi # link shared/static library? 8718dc99b369Smrg 87195c30ecadSmrg if test lib = "$linkmode"; then 8720dc99b369Smrg if test -n "$dependency_libs" && 87215c30ecadSmrg { test yes != "$hardcode_into_libs" || 87225c30ecadSmrg test yes = "$build_old_libs" || 87235c30ecadSmrg test yes = "$link_static"; }; then 8724dc99b369Smrg # Extract -R from dependency_libs 8725dc99b369Smrg temp_deplibs= 8726dc99b369Smrg for libdir in $dependency_libs; do 8727dc99b369Smrg case $libdir in 8728dc99b369Smrg -R*) func_stripname '-R' '' "$libdir" 8729dc99b369Smrg temp_xrpath=$func_stripname_result 8730dc99b369Smrg case " $xrpath " in 8731dc99b369Smrg *" $temp_xrpath "*) ;; 8732dc99b369Smrg *) func_append xrpath " $temp_xrpath";; 8733dc99b369Smrg esac;; 8734dc99b369Smrg *) func_append temp_deplibs " $libdir";; 8735dc99b369Smrg esac 8736dc99b369Smrg done 87375c30ecadSmrg dependency_libs=$temp_deplibs 8738dc99b369Smrg fi 8739dc99b369Smrg 8740dc99b369Smrg func_append newlib_search_path " $absdir" 8741dc99b369Smrg # Link against this library 87425c30ecadSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743dc99b369Smrg # ... and its dependency_libs 8744dc99b369Smrg tmp_libs= 8745dc99b369Smrg for deplib in $dependency_libs; do 8746dc99b369Smrg newdependency_libs="$deplib $newdependency_libs" 8747dc99b369Smrg case $deplib in 8748dc99b369Smrg -L*) func_stripname '-L' '' "$deplib" 8749dc99b369Smrg func_resolve_sysroot "$func_stripname_result";; 8750dc99b369Smrg *) func_resolve_sysroot "$deplib" ;; 8751dc99b369Smrg esac 87525c30ecadSmrg if $opt_preserve_dup_deps; then 8753dc99b369Smrg case "$tmp_libs " in 8754dc99b369Smrg *" $func_resolve_sysroot_result "*) 8755dc99b369Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756dc99b369Smrg esac 8757dc99b369Smrg fi 8758dc99b369Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8759dc99b369Smrg done 8760dc99b369Smrg 87615c30ecadSmrg if test no != "$link_all_deplibs"; then 8762dc99b369Smrg # Add the search paths of all dependency libraries 8763dc99b369Smrg for deplib in $dependency_libs; do 8764dc99b369Smrg path= 8765dc99b369Smrg case $deplib in 87665c30ecadSmrg -L*) path=$deplib ;; 8767dc99b369Smrg *.la) 8768dc99b369Smrg func_resolve_sysroot "$deplib" 8769dc99b369Smrg deplib=$func_resolve_sysroot_result 8770dc99b369Smrg func_dirname "$deplib" "" "." 8771dc99b369Smrg dir=$func_dirname_result 8772dc99b369Smrg # We need an absolute path. 8773dc99b369Smrg case $dir in 87745c30ecadSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775dc99b369Smrg *) 8776dc99b369Smrg absdir=`cd "$dir" && pwd` 8777dc99b369Smrg if test -z "$absdir"; then 87785c30ecadSmrg func_warning "cannot determine absolute directory name of '$dir'" 87795c30ecadSmrg absdir=$dir 8780dc99b369Smrg fi 8781dc99b369Smrg ;; 8782dc99b369Smrg esac 8783dc99b369Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8784dc99b369Smrg case $host in 8785dc99b369Smrg *-*-darwin*) 8786dc99b369Smrg depdepl= 87875c30ecadSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87885c30ecadSmrg if test -n "$deplibrary_names"; then 87895c30ecadSmrg for tmp in $deplibrary_names; do 8790dc99b369Smrg depdepl=$tmp 8791dc99b369Smrg done 87925c30ecadSmrg if test -f "$absdir/$objdir/$depdepl"; then 87935c30ecadSmrg depdepl=$absdir/$objdir/$depdepl 87945c30ecadSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795dc99b369Smrg if test -z "$darwin_install_name"; then 87965c30ecadSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797dc99b369Smrg fi 87985c30ecadSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87995c30ecadSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800dc99b369Smrg path= 8801dc99b369Smrg fi 8802dc99b369Smrg fi 8803dc99b369Smrg ;; 8804dc99b369Smrg *) 88055c30ecadSmrg path=-L$absdir/$objdir 8806dc99b369Smrg ;; 8807dc99b369Smrg esac 8808dc99b369Smrg else 88095c30ecadSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810dc99b369Smrg test -z "$libdir" && \ 88115c30ecadSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812dc99b369Smrg test "$absdir" != "$libdir" && \ 88135c30ecadSmrg func_warning "'$deplib' seems to be moved" 8814dc99b369Smrg 88155c30ecadSmrg path=-L$absdir 8816dc99b369Smrg fi 8817dc99b369Smrg ;; 8818dc99b369Smrg esac 8819dc99b369Smrg case " $deplibs " in 8820dc99b369Smrg *" $path "*) ;; 8821dc99b369Smrg *) deplibs="$path $deplibs" ;; 8822dc99b369Smrg esac 8823dc99b369Smrg done 8824dc99b369Smrg fi # link_all_deplibs != no 8825dc99b369Smrg fi # linkmode = lib 8826dc99b369Smrg done # for deplib in $libs 88275c30ecadSmrg if test link = "$pass"; then 88285c30ecadSmrg if test prog = "$linkmode"; then 8829dc99b369Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830dc99b369Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831dc99b369Smrg else 8832dc99b369Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833dc99b369Smrg fi 8834dc99b369Smrg fi 88355c30ecadSmrg dependency_libs=$newdependency_libs 88365c30ecadSmrg if test dlpreopen = "$pass"; then 8837dc99b369Smrg # Link the dlpreopened libraries before other libraries 8838dc99b369Smrg for deplib in $save_deplibs; do 8839dc99b369Smrg deplibs="$deplib $deplibs" 8840dc99b369Smrg done 8841dc99b369Smrg fi 88425c30ecadSmrg if test dlopen != "$pass"; then 88435c30ecadSmrg test conv = "$pass" || { 8844dc99b369Smrg # Make sure lib_search_path contains only unique directories. 8845dc99b369Smrg lib_search_path= 8846dc99b369Smrg for dir in $newlib_search_path; do 8847dc99b369Smrg case "$lib_search_path " in 8848dc99b369Smrg *" $dir "*) ;; 8849dc99b369Smrg *) func_append lib_search_path " $dir" ;; 8850dc99b369Smrg esac 8851dc99b369Smrg done 8852dc99b369Smrg newlib_search_path= 88535c30ecadSmrg } 8854dc99b369Smrg 88555c30ecadSmrg if test prog,link = "$linkmode,$pass"; then 8856dc99b369Smrg vars="compile_deplibs finalize_deplibs" 88575c30ecadSmrg else 88585c30ecadSmrg vars=deplibs 8859dc99b369Smrg fi 8860dc99b369Smrg for var in $vars dependency_libs; do 8861dc99b369Smrg # Add libraries to $var in reverse order 8862dc99b369Smrg eval tmp_libs=\"\$$var\" 8863dc99b369Smrg new_libs= 8864dc99b369Smrg for deplib in $tmp_libs; do 8865dc99b369Smrg # FIXME: Pedantically, this is the right thing to do, so 8866dc99b369Smrg # that some nasty dependency loop isn't accidentally 8867dc99b369Smrg # broken: 8868dc99b369Smrg #new_libs="$deplib $new_libs" 8869dc99b369Smrg # Pragmatically, this seems to cause very few problems in 8870dc99b369Smrg # practice: 8871dc99b369Smrg case $deplib in 8872dc99b369Smrg -L*) new_libs="$deplib $new_libs" ;; 8873dc99b369Smrg -R*) ;; 8874dc99b369Smrg *) 8875dc99b369Smrg # And here is the reason: when a library appears more 8876dc99b369Smrg # than once as an explicit dependence of a library, or 8877dc99b369Smrg # is implicitly linked in more than once by the 8878dc99b369Smrg # compiler, it is considered special, and multiple 8879dc99b369Smrg # occurrences thereof are not removed. Compare this 8880dc99b369Smrg # with having the same library being listed as a 8881dc99b369Smrg # dependency of multiple other libraries: in this case, 8882dc99b369Smrg # we know (pedantically, we assume) the library does not 8883dc99b369Smrg # need to be listed more than once, so we keep only the 8884dc99b369Smrg # last copy. This is not always right, but it is rare 8885dc99b369Smrg # enough that we require users that really mean to play 8886dc99b369Smrg # such unportable linking tricks to link the library 8887dc99b369Smrg # using -Wl,-lname, so that libtool does not consider it 8888dc99b369Smrg # for duplicate removal. 8889dc99b369Smrg case " $specialdeplibs " in 8890dc99b369Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891dc99b369Smrg *) 8892dc99b369Smrg case " $new_libs " in 8893dc99b369Smrg *" $deplib "*) ;; 8894dc99b369Smrg *) new_libs="$deplib $new_libs" ;; 8895dc99b369Smrg esac 8896dc99b369Smrg ;; 8897dc99b369Smrg esac 8898dc99b369Smrg ;; 8899dc99b369Smrg esac 8900dc99b369Smrg done 8901dc99b369Smrg tmp_libs= 8902dc99b369Smrg for deplib in $new_libs; do 8903dc99b369Smrg case $deplib in 8904dc99b369Smrg -L*) 8905dc99b369Smrg case " $tmp_libs " in 8906dc99b369Smrg *" $deplib "*) ;; 8907dc99b369Smrg *) func_append tmp_libs " $deplib" ;; 8908dc99b369Smrg esac 8909dc99b369Smrg ;; 8910dc99b369Smrg *) func_append tmp_libs " $deplib" ;; 8911dc99b369Smrg esac 8912dc99b369Smrg done 8913dc99b369Smrg eval $var=\"$tmp_libs\" 8914dc99b369Smrg done # for var 8915dc99b369Smrg fi 89165c30ecadSmrg 89175c30ecadSmrg # Add Sun CC postdeps if required: 89185c30ecadSmrg test CXX = "$tagname" && { 89195c30ecadSmrg case $host_os in 89205c30ecadSmrg linux*) 89215c30ecadSmrg case `$CC -V 2>&1 | $SED 5q` in 89225c30ecadSmrg *Sun\ C*) # Sun C++ 5.9 89235c30ecadSmrg func_suncc_cstd_abi 89245c30ecadSmrg 89255c30ecadSmrg if test no != "$suncc_use_cstd_abi"; then 89265c30ecadSmrg func_append postdeps ' -library=Cstd -library=Crun' 89275c30ecadSmrg fi 89285c30ecadSmrg ;; 89295c30ecadSmrg esac 89305c30ecadSmrg ;; 89315c30ecadSmrg 89325c30ecadSmrg solaris*) 89335c30ecadSmrg func_cc_basename "$CC" 89345c30ecadSmrg case $func_cc_basename_result in 89355c30ecadSmrg CC* | sunCC*) 89365c30ecadSmrg func_suncc_cstd_abi 89375c30ecadSmrg 89385c30ecadSmrg if test no != "$suncc_use_cstd_abi"; then 89395c30ecadSmrg func_append postdeps ' -library=Cstd -library=Crun' 89405c30ecadSmrg fi 89415c30ecadSmrg ;; 89425c30ecadSmrg esac 89435c30ecadSmrg ;; 89445c30ecadSmrg esac 89455c30ecadSmrg } 89465c30ecadSmrg 8947dc99b369Smrg # Last step: remove runtime libs from dependency_libs 8948dc99b369Smrg # (they stay in deplibs) 8949dc99b369Smrg tmp_libs= 89505c30ecadSmrg for i in $dependency_libs; do 8951dc99b369Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8952dc99b369Smrg *" $i "*) 89535c30ecadSmrg i= 8954dc99b369Smrg ;; 8955dc99b369Smrg esac 89565c30ecadSmrg if test -n "$i"; then 8957dc99b369Smrg func_append tmp_libs " $i" 8958dc99b369Smrg fi 8959dc99b369Smrg done 8960dc99b369Smrg dependency_libs=$tmp_libs 8961dc99b369Smrg done # for pass 89625c30ecadSmrg if test prog = "$linkmode"; then 89635c30ecadSmrg dlfiles=$newdlfiles 8964dc99b369Smrg fi 89655c30ecadSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89665c30ecadSmrg dlprefiles=$newdlprefiles 8967dc99b369Smrg fi 8968dc99b369Smrg 8969dc99b369Smrg case $linkmode in 8970dc99b369Smrg oldlib) 89715c30ecadSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89725c30ecadSmrg func_warning "'-dlopen' is ignored for archives" 8973dc99b369Smrg fi 8974dc99b369Smrg 8975dc99b369Smrg case " $deplibs" in 8976dc99b369Smrg *\ -l* | *\ -L*) 89775c30ecadSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978dc99b369Smrg esac 8979dc99b369Smrg 8980dc99b369Smrg test -n "$rpath" && \ 89815c30ecadSmrg func_warning "'-rpath' is ignored for archives" 8982dc99b369Smrg 8983dc99b369Smrg test -n "$xrpath" && \ 89845c30ecadSmrg func_warning "'-R' is ignored for archives" 8985dc99b369Smrg 8986dc99b369Smrg test -n "$vinfo" && \ 89875c30ecadSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8988dc99b369Smrg 8989dc99b369Smrg test -n "$release" && \ 89905c30ecadSmrg func_warning "'-release' is ignored for archives" 8991dc99b369Smrg 8992dc99b369Smrg test -n "$export_symbols$export_symbols_regex" && \ 89935c30ecadSmrg func_warning "'-export-symbols' is ignored for archives" 8994dc99b369Smrg 8995dc99b369Smrg # Now set the variables for building old libraries. 8996dc99b369Smrg build_libtool_libs=no 89975c30ecadSmrg oldlibs=$output 8998dc99b369Smrg func_append objs "$old_deplibs" 8999dc99b369Smrg ;; 9000dc99b369Smrg 9001dc99b369Smrg lib) 90025c30ecadSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003dc99b369Smrg case $outputname in 9004dc99b369Smrg lib*) 9005dc99b369Smrg func_stripname 'lib' '.la' "$outputname" 9006dc99b369Smrg name=$func_stripname_result 9007dc99b369Smrg eval shared_ext=\"$shrext_cmds\" 9008dc99b369Smrg eval libname=\"$libname_spec\" 9009dc99b369Smrg ;; 9010dc99b369Smrg *) 90115c30ecadSmrg test no = "$module" \ 90125c30ecadSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013dc99b369Smrg 90145c30ecadSmrg if test no != "$need_lib_prefix"; then 9015dc99b369Smrg # Add the "lib" prefix for modules if required 9016dc99b369Smrg func_stripname '' '.la' "$outputname" 9017dc99b369Smrg name=$func_stripname_result 9018dc99b369Smrg eval shared_ext=\"$shrext_cmds\" 9019dc99b369Smrg eval libname=\"$libname_spec\" 9020dc99b369Smrg else 9021dc99b369Smrg func_stripname '' '.la' "$outputname" 9022dc99b369Smrg libname=$func_stripname_result 9023dc99b369Smrg fi 9024dc99b369Smrg ;; 9025dc99b369Smrg esac 9026dc99b369Smrg 9027dc99b369Smrg if test -n "$objs"; then 90285c30ecadSmrg if test pass_all != "$deplibs_check_method"; then 90295c30ecadSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030dc99b369Smrg else 9031dc99b369Smrg echo 9032dc99b369Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033dc99b369Smrg $ECHO "*** objects $objs is not portable!" 9034dc99b369Smrg func_append libobjs " $objs" 9035dc99b369Smrg fi 9036dc99b369Smrg fi 9037dc99b369Smrg 90385c30ecadSmrg test no = "$dlself" \ 90395c30ecadSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040dc99b369Smrg 9041dc99b369Smrg set dummy $rpath 9042dc99b369Smrg shift 90435c30ecadSmrg test 1 -lt "$#" \ 90445c30ecadSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045dc99b369Smrg 90465c30ecadSmrg install_libdir=$1 9047dc99b369Smrg 9048dc99b369Smrg oldlibs= 9049dc99b369Smrg if test -z "$rpath"; then 90505c30ecadSmrg if test yes = "$build_libtool_libs"; then 9051dc99b369Smrg # Building a libtool convenience library. 90525c30ecadSmrg # Some compilers have problems with a '.al' extension so 9053dc99b369Smrg # convenience libraries should have the same extension an 9054dc99b369Smrg # archive normally would. 9055dc99b369Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056dc99b369Smrg build_libtool_libs=convenience 9057dc99b369Smrg build_old_libs=yes 9058dc99b369Smrg fi 9059dc99b369Smrg 9060dc99b369Smrg test -n "$vinfo" && \ 90615c30ecadSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062dc99b369Smrg 9063dc99b369Smrg test -n "$release" && \ 90645c30ecadSmrg func_warning "'-release' is ignored for convenience libraries" 9065dc99b369Smrg else 9066dc99b369Smrg 9067dc99b369Smrg # Parse the version information argument. 90685c30ecadSmrg save_ifs=$IFS; IFS=: 9069dc99b369Smrg set dummy $vinfo 0 0 0 9070dc99b369Smrg shift 90715c30ecadSmrg IFS=$save_ifs 9072dc99b369Smrg 9073dc99b369Smrg test -n "$7" && \ 90745c30ecadSmrg func_fatal_help "too many parameters to '-version-info'" 9075dc99b369Smrg 9076dc99b369Smrg # convert absolute version numbers to libtool ages 9077dc99b369Smrg # this retains compatibility with .la files and attempts 9078dc99b369Smrg # to make the code below a bit more comprehensible 9079dc99b369Smrg 9080dc99b369Smrg case $vinfo_number in 9081dc99b369Smrg yes) 90825c30ecadSmrg number_major=$1 90835c30ecadSmrg number_minor=$2 90845c30ecadSmrg number_revision=$3 9085dc99b369Smrg # 9086dc99b369Smrg # There are really only two kinds -- those that 9087dc99b369Smrg # use the current revision as the major version 9088dc99b369Smrg # and those that subtract age and use age as 9089dc99b369Smrg # a minor version. But, then there is irix 90905c30ecadSmrg # that has an extra 1 added just for fun 9091dc99b369Smrg # 9092dc99b369Smrg case $version_type in 90935c30ecadSmrg # correct linux to gnu/linux during the next big refactor 90945c30ecadSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095dc99b369Smrg func_arith $number_major + $number_minor 9096dc99b369Smrg current=$func_arith_result 90975c30ecadSmrg age=$number_minor 90985c30ecadSmrg revision=$number_revision 9099dc99b369Smrg ;; 91005c30ecadSmrg freebsd-aout|qnx|sunos) 91015c30ecadSmrg current=$number_major 91025c30ecadSmrg revision=$number_minor 91035c30ecadSmrg age=0 9104dc99b369Smrg ;; 9105dc99b369Smrg irix|nonstopux) 9106dc99b369Smrg func_arith $number_major + $number_minor 9107dc99b369Smrg current=$func_arith_result 91085c30ecadSmrg age=$number_minor 91095c30ecadSmrg revision=$number_minor 9110dc99b369Smrg lt_irix_increment=no 9111dc99b369Smrg ;; 9112dc99b369Smrg esac 9113dc99b369Smrg ;; 9114dc99b369Smrg no) 91155c30ecadSmrg current=$1 91165c30ecadSmrg revision=$2 91175c30ecadSmrg age=$3 9118dc99b369Smrg ;; 9119dc99b369Smrg esac 9120dc99b369Smrg 9121dc99b369Smrg # Check that each of the things are valid numbers. 9122dc99b369Smrg case $current in 9123dc99b369Smrg 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]) ;; 9124dc99b369Smrg *) 91255c30ecadSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91265c30ecadSmrg func_fatal_error "'$vinfo' is not valid version information" 9127dc99b369Smrg ;; 9128dc99b369Smrg esac 9129dc99b369Smrg 9130dc99b369Smrg case $revision in 9131dc99b369Smrg 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]) ;; 9132dc99b369Smrg *) 91335c30ecadSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91345c30ecadSmrg func_fatal_error "'$vinfo' is not valid version information" 9135dc99b369Smrg ;; 9136dc99b369Smrg esac 9137dc99b369Smrg 9138dc99b369Smrg case $age in 9139dc99b369Smrg 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]) ;; 9140dc99b369Smrg *) 91415c30ecadSmrg func_error "AGE '$age' must be a nonnegative integer" 91425c30ecadSmrg func_fatal_error "'$vinfo' is not valid version information" 9143dc99b369Smrg ;; 9144dc99b369Smrg esac 9145dc99b369Smrg 9146dc99b369Smrg if test "$age" -gt "$current"; then 91475c30ecadSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91485c30ecadSmrg func_fatal_error "'$vinfo' is not valid version information" 9149dc99b369Smrg fi 9150dc99b369Smrg 9151dc99b369Smrg # Calculate the version variables. 9152dc99b369Smrg major= 9153dc99b369Smrg versuffix= 9154dc99b369Smrg verstring= 9155dc99b369Smrg case $version_type in 9156dc99b369Smrg none) ;; 9157dc99b369Smrg 9158dc99b369Smrg darwin) 9159dc99b369Smrg # Like Linux, but with the current version available in 9160dc99b369Smrg # verstring for coding it into the library header 9161dc99b369Smrg func_arith $current - $age 9162dc99b369Smrg major=.$func_arith_result 91635c30ecadSmrg versuffix=$major.$age.$revision 9164dc99b369Smrg # Darwin ld doesn't like 0 for these options... 9165dc99b369Smrg func_arith $current + 1 9166dc99b369Smrg minor_current=$func_arith_result 91675c30ecadSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168dc99b369Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91695c30ecadSmrg # On Darwin other compilers 91705c30ecadSmrg case $CC in 91715c30ecadSmrg nagfor*) 91725c30ecadSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91735c30ecadSmrg ;; 91745c30ecadSmrg *) 91755c30ecadSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91765c30ecadSmrg ;; 91775c30ecadSmrg esac 9178dc99b369Smrg ;; 9179dc99b369Smrg 9180dc99b369Smrg freebsd-aout) 91815c30ecadSmrg major=.$current 91825c30ecadSmrg versuffix=.$current.$revision 9183dc99b369Smrg ;; 9184dc99b369Smrg 91855c30ecadSmrg freebsd-elf | midnightbsd-elf) 91865c30ecadSmrg func_arith $current - $age 91875c30ecadSmrg major=.$func_arith_result 91885c30ecadSmrg versuffix=$major.$age.$revision 9189dc99b369Smrg ;; 9190dc99b369Smrg 9191dc99b369Smrg irix | nonstopux) 91925c30ecadSmrg if test no = "$lt_irix_increment"; then 9193dc99b369Smrg func_arith $current - $age 9194dc99b369Smrg else 9195dc99b369Smrg func_arith $current - $age + 1 9196dc99b369Smrg fi 9197dc99b369Smrg major=$func_arith_result 9198dc99b369Smrg 9199dc99b369Smrg case $version_type in 9200dc99b369Smrg nonstopux) verstring_prefix=nonstopux ;; 9201dc99b369Smrg *) verstring_prefix=sgi ;; 9202dc99b369Smrg esac 92035c30ecadSmrg verstring=$verstring_prefix$major.$revision 9204dc99b369Smrg 9205dc99b369Smrg # Add in all the interfaces that we are compatible with. 9206dc99b369Smrg loop=$revision 92075c30ecadSmrg while test 0 -ne "$loop"; do 9208dc99b369Smrg func_arith $revision - $loop 9209dc99b369Smrg iface=$func_arith_result 9210dc99b369Smrg func_arith $loop - 1 9211dc99b369Smrg loop=$func_arith_result 92125c30ecadSmrg verstring=$verstring_prefix$major.$iface:$verstring 9213dc99b369Smrg done 9214dc99b369Smrg 92155c30ecadSmrg # Before this point, $major must not contain '.'. 9216dc99b369Smrg major=.$major 92175c30ecadSmrg versuffix=$major.$revision 9218dc99b369Smrg ;; 9219dc99b369Smrg 92205c30ecadSmrg linux) # correct to gnu/linux during the next big refactor 9221dc99b369Smrg func_arith $current - $age 9222dc99b369Smrg major=.$func_arith_result 92235c30ecadSmrg versuffix=$major.$age.$revision 9224dc99b369Smrg ;; 9225dc99b369Smrg 9226dc99b369Smrg osf) 9227dc99b369Smrg func_arith $current - $age 9228dc99b369Smrg major=.$func_arith_result 92295c30ecadSmrg versuffix=.$current.$age.$revision 92305c30ecadSmrg verstring=$current.$age.$revision 9231dc99b369Smrg 9232dc99b369Smrg # Add in all the interfaces that we are compatible with. 9233dc99b369Smrg loop=$age 92345c30ecadSmrg while test 0 -ne "$loop"; do 9235dc99b369Smrg func_arith $current - $loop 9236dc99b369Smrg iface=$func_arith_result 9237dc99b369Smrg func_arith $loop - 1 9238dc99b369Smrg loop=$func_arith_result 92395c30ecadSmrg verstring=$verstring:$iface.0 9240dc99b369Smrg done 9241dc99b369Smrg 9242dc99b369Smrg # Make executables depend on our current version. 92435c30ecadSmrg func_append verstring ":$current.0" 9244dc99b369Smrg ;; 9245dc99b369Smrg 9246dc99b369Smrg qnx) 92475c30ecadSmrg major=.$current 92485c30ecadSmrg versuffix=.$current 92495c30ecadSmrg ;; 92505c30ecadSmrg 92515c30ecadSmrg sco) 92525c30ecadSmrg major=.$current 92535c30ecadSmrg versuffix=.$current 9254dc99b369Smrg ;; 9255dc99b369Smrg 9256dc99b369Smrg sunos) 92575c30ecadSmrg major=.$current 92585c30ecadSmrg versuffix=.$current.$revision 9259dc99b369Smrg ;; 9260dc99b369Smrg 9261dc99b369Smrg windows) 9262dc99b369Smrg # Use '-' rather than '.', since we only want one 92635c30ecadSmrg # extension on DOS 8.3 file systems. 9264dc99b369Smrg func_arith $current - $age 9265dc99b369Smrg major=$func_arith_result 92665c30ecadSmrg versuffix=-$major 9267dc99b369Smrg ;; 9268dc99b369Smrg 9269dc99b369Smrg *) 92705c30ecadSmrg func_fatal_configuration "unknown library version type '$version_type'" 9271dc99b369Smrg ;; 9272dc99b369Smrg esac 9273dc99b369Smrg 9274dc99b369Smrg # Clear the version info if we defaulted, and they specified a release. 9275dc99b369Smrg if test -z "$vinfo" && test -n "$release"; then 9276dc99b369Smrg major= 9277dc99b369Smrg case $version_type in 9278dc99b369Smrg darwin) 9279dc99b369Smrg # we can't check for "0.0" in archive_cmds due to quoting 9280dc99b369Smrg # problems, so we reset it completely 9281dc99b369Smrg verstring= 9282dc99b369Smrg ;; 9283dc99b369Smrg *) 92845c30ecadSmrg verstring=0.0 9285dc99b369Smrg ;; 9286dc99b369Smrg esac 92875c30ecadSmrg if test no = "$need_version"; then 9288dc99b369Smrg versuffix= 9289dc99b369Smrg else 92905c30ecadSmrg versuffix=.0.0 9291dc99b369Smrg fi 9292dc99b369Smrg fi 9293dc99b369Smrg 9294dc99b369Smrg # Remove version info from name if versioning should be avoided 92955c30ecadSmrg if test yes,no = "$avoid_version,$need_version"; then 9296dc99b369Smrg major= 9297dc99b369Smrg versuffix= 92985c30ecadSmrg verstring= 9299dc99b369Smrg fi 9300dc99b369Smrg 9301dc99b369Smrg # Check to see if the archive will have undefined symbols. 93025c30ecadSmrg if test yes = "$allow_undefined"; then 93035c30ecadSmrg if test unsupported = "$allow_undefined_flag"; then 93045c30ecadSmrg if test yes = "$build_old_libs"; then 93055c30ecadSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93065c30ecadSmrg build_libtool_libs=no 93075c30ecadSmrg else 93085c30ecadSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93095c30ecadSmrg fi 9310dc99b369Smrg fi 9311dc99b369Smrg else 9312dc99b369Smrg # Don't allow undefined symbols. 93135c30ecadSmrg allow_undefined_flag=$no_undefined_flag 9314dc99b369Smrg fi 9315dc99b369Smrg 9316dc99b369Smrg fi 9317dc99b369Smrg 93185c30ecadSmrg func_generate_dlsyms "$libname" "$libname" : 9319dc99b369Smrg func_append libobjs " $symfileobj" 93205c30ecadSmrg test " " = "$libobjs" && libobjs= 9321dc99b369Smrg 93225c30ecadSmrg if test relink != "$opt_mode"; then 9323dc99b369Smrg # Remove our outputs, but don't remove object files since they 9324dc99b369Smrg # may have been created when compiling PIC objects. 9325dc99b369Smrg removelist= 9326dc99b369Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9327dc99b369Smrg for p in $tempremovelist; do 9328dc99b369Smrg case $p in 9329dc99b369Smrg *.$objext | *.gcno) 9330dc99b369Smrg ;; 93315c30ecadSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93325c30ecadSmrg if test -n "$precious_files_regex"; then 9333dc99b369Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334dc99b369Smrg then 9335dc99b369Smrg continue 9336dc99b369Smrg fi 9337dc99b369Smrg fi 9338dc99b369Smrg func_append removelist " $p" 9339dc99b369Smrg ;; 9340dc99b369Smrg *) ;; 9341dc99b369Smrg esac 9342dc99b369Smrg done 9343dc99b369Smrg test -n "$removelist" && \ 9344dc99b369Smrg func_show_eval "${RM}r \$removelist" 9345dc99b369Smrg fi 9346dc99b369Smrg 9347dc99b369Smrg # Now set the variables for building old libraries. 93485c30ecadSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349dc99b369Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9350dc99b369Smrg 9351dc99b369Smrg # Transform .lo files to .o files. 93525c30ecadSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353dc99b369Smrg fi 9354dc99b369Smrg 9355dc99b369Smrg # Eliminate all temporary directories. 9356dc99b369Smrg #for path in $notinst_path; do 9357dc99b369Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358dc99b369Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359dc99b369Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360dc99b369Smrg #done 9361dc99b369Smrg 9362dc99b369Smrg if test -n "$xrpath"; then 9363dc99b369Smrg # If the user specified any rpath flags, then add them. 9364dc99b369Smrg temp_xrpath= 9365dc99b369Smrg for libdir in $xrpath; do 9366dc99b369Smrg func_replace_sysroot "$libdir" 9367dc99b369Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368dc99b369Smrg case "$finalize_rpath " in 9369dc99b369Smrg *" $libdir "*) ;; 9370dc99b369Smrg *) func_append finalize_rpath " $libdir" ;; 9371dc99b369Smrg esac 9372dc99b369Smrg done 93735c30ecadSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374dc99b369Smrg dependency_libs="$temp_xrpath $dependency_libs" 9375dc99b369Smrg fi 9376dc99b369Smrg fi 9377dc99b369Smrg 9378dc99b369Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93795c30ecadSmrg old_dlfiles=$dlfiles 9380dc99b369Smrg dlfiles= 9381dc99b369Smrg for lib in $old_dlfiles; do 9382dc99b369Smrg case " $dlprefiles $dlfiles " in 9383dc99b369Smrg *" $lib "*) ;; 9384dc99b369Smrg *) func_append dlfiles " $lib" ;; 9385dc99b369Smrg esac 9386dc99b369Smrg done 9387dc99b369Smrg 9388dc99b369Smrg # Make sure dlprefiles contains only unique files 93895c30ecadSmrg old_dlprefiles=$dlprefiles 9390dc99b369Smrg dlprefiles= 9391dc99b369Smrg for lib in $old_dlprefiles; do 9392dc99b369Smrg case "$dlprefiles " in 9393dc99b369Smrg *" $lib "*) ;; 9394dc99b369Smrg *) func_append dlprefiles " $lib" ;; 9395dc99b369Smrg esac 9396dc99b369Smrg done 9397dc99b369Smrg 93985c30ecadSmrg if test yes = "$build_libtool_libs"; then 9399dc99b369Smrg if test -n "$rpath"; then 9400dc99b369Smrg case $host in 9401dc99b369Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402dc99b369Smrg # these systems don't actually have a c library (as such)! 9403dc99b369Smrg ;; 9404dc99b369Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9405dc99b369Smrg # Rhapsody C library is in the System framework 9406dc99b369Smrg func_append deplibs " System.ltframework" 9407dc99b369Smrg ;; 9408dc99b369Smrg *-*-netbsd*) 9409dc99b369Smrg # Don't link with libc until the a.out ld.so is fixed. 9410dc99b369Smrg ;; 94115c30ecadSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412dc99b369Smrg # Do not include libc due to us having libc/libc_r. 9413dc99b369Smrg ;; 9414dc99b369Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9415dc99b369Smrg # Causes problems with __ctype 9416dc99b369Smrg ;; 9417dc99b369Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418dc99b369Smrg # Compiler inserts libc in the correct place for threads to work 9419dc99b369Smrg ;; 9420dc99b369Smrg *) 9421dc99b369Smrg # Add libc to deplibs on all other systems if necessary. 94225c30ecadSmrg if test yes = "$build_libtool_need_lc"; then 9423dc99b369Smrg func_append deplibs " -lc" 9424dc99b369Smrg fi 9425dc99b369Smrg ;; 9426dc99b369Smrg esac 9427dc99b369Smrg fi 9428dc99b369Smrg 9429dc99b369Smrg # Transform deplibs into only deplibs that can be linked in shared. 9430dc99b369Smrg name_save=$name 9431dc99b369Smrg libname_save=$libname 9432dc99b369Smrg release_save=$release 9433dc99b369Smrg versuffix_save=$versuffix 9434dc99b369Smrg major_save=$major 9435dc99b369Smrg # I'm not sure if I'm treating the release correctly. I think 9436dc99b369Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437dc99b369Smrg # add it in twice. Is that correct? 94385c30ecadSmrg release= 94395c30ecadSmrg versuffix= 94405c30ecadSmrg major= 9441dc99b369Smrg newdeplibs= 9442dc99b369Smrg droppeddeps=no 9443dc99b369Smrg case $deplibs_check_method in 9444dc99b369Smrg pass_all) 9445dc99b369Smrg # Don't check for shared/static. Everything works. 9446dc99b369Smrg # This might be a little naive. We might want to check 9447dc99b369Smrg # whether the library exists or not. But this is on 9448dc99b369Smrg # osf3 & osf4 and I'm not really sure... Just 9449dc99b369Smrg # implementing what was already the behavior. 9450dc99b369Smrg newdeplibs=$deplibs 9451dc99b369Smrg ;; 9452dc99b369Smrg test_compile) 9453dc99b369Smrg # This code stresses the "libraries are programs" paradigm to its 9454dc99b369Smrg # limits. Maybe even breaks it. We compile a program, linking it 9455dc99b369Smrg # against the deplibs as a proxy for the library. Then we can check 9456dc99b369Smrg # whether they linked in statically or dynamically with ldd. 9457dc99b369Smrg $opt_dry_run || $RM conftest.c 9458dc99b369Smrg cat > conftest.c <<EOF 9459dc99b369Smrg int main() { return 0; } 9460dc99b369SmrgEOF 9461dc99b369Smrg $opt_dry_run || $RM conftest 9462dc99b369Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463dc99b369Smrg ldd_output=`ldd conftest` 9464dc99b369Smrg for i in $deplibs; do 9465dc99b369Smrg case $i in 9466dc99b369Smrg -l*) 9467dc99b369Smrg func_stripname -l '' "$i" 9468dc99b369Smrg name=$func_stripname_result 94695c30ecadSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470dc99b369Smrg case " $predeps $postdeps " in 9471dc99b369Smrg *" $i "*) 9472dc99b369Smrg func_append newdeplibs " $i" 94735c30ecadSmrg i= 9474dc99b369Smrg ;; 9475dc99b369Smrg esac 9476dc99b369Smrg fi 94775c30ecadSmrg if test -n "$i"; then 9478dc99b369Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479dc99b369Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480dc99b369Smrg set dummy $deplib_matches; shift 9481dc99b369Smrg deplib_match=$1 94825c30ecadSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483dc99b369Smrg func_append newdeplibs " $i" 9484dc99b369Smrg else 9485dc99b369Smrg droppeddeps=yes 9486dc99b369Smrg echo 9487dc99b369Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488dc99b369Smrg echo "*** I have the capability to make that library automatically link in when" 9489dc99b369Smrg echo "*** you link to this library. But I can only do this if you have a" 9490dc99b369Smrg echo "*** shared version of the library, which I believe you do not have" 9491dc99b369Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492dc99b369Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493dc99b369Smrg fi 9494dc99b369Smrg fi 9495dc99b369Smrg ;; 9496dc99b369Smrg *) 9497dc99b369Smrg func_append newdeplibs " $i" 9498dc99b369Smrg ;; 9499dc99b369Smrg esac 9500dc99b369Smrg done 9501dc99b369Smrg else 9502dc99b369Smrg # Error occurred in the first compile. Let's try to salvage 9503dc99b369Smrg # the situation: Compile a separate program for each library. 9504dc99b369Smrg for i in $deplibs; do 9505dc99b369Smrg case $i in 9506dc99b369Smrg -l*) 9507dc99b369Smrg func_stripname -l '' "$i" 9508dc99b369Smrg name=$func_stripname_result 9509dc99b369Smrg $opt_dry_run || $RM conftest 9510dc99b369Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511dc99b369Smrg ldd_output=`ldd conftest` 95125c30ecadSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513dc99b369Smrg case " $predeps $postdeps " in 9514dc99b369Smrg *" $i "*) 9515dc99b369Smrg func_append newdeplibs " $i" 95165c30ecadSmrg i= 9517dc99b369Smrg ;; 9518dc99b369Smrg esac 9519dc99b369Smrg fi 95205c30ecadSmrg if test -n "$i"; then 9521dc99b369Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522dc99b369Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523dc99b369Smrg set dummy $deplib_matches; shift 9524dc99b369Smrg deplib_match=$1 95255c30ecadSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526dc99b369Smrg func_append newdeplibs " $i" 9527dc99b369Smrg else 9528dc99b369Smrg droppeddeps=yes 9529dc99b369Smrg echo 9530dc99b369Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531dc99b369Smrg echo "*** I have the capability to make that library automatically link in when" 9532dc99b369Smrg echo "*** you link to this library. But I can only do this if you have a" 9533dc99b369Smrg echo "*** shared version of the library, which you do not appear to have" 9534dc99b369Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535dc99b369Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536dc99b369Smrg fi 9537dc99b369Smrg fi 9538dc99b369Smrg else 9539dc99b369Smrg droppeddeps=yes 9540dc99b369Smrg echo 9541dc99b369Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542dc99b369Smrg echo "*** make it link in! You will probably need to install it or some" 9543dc99b369Smrg echo "*** library that it depends on before this library will be fully" 9544dc99b369Smrg echo "*** functional. Installing it before continuing would be even better." 9545dc99b369Smrg fi 9546dc99b369Smrg ;; 9547dc99b369Smrg *) 9548dc99b369Smrg func_append newdeplibs " $i" 9549dc99b369Smrg ;; 9550dc99b369Smrg esac 9551dc99b369Smrg done 9552dc99b369Smrg fi 9553dc99b369Smrg ;; 9554dc99b369Smrg file_magic*) 9555dc99b369Smrg set dummy $deplibs_check_method; shift 9556dc99b369Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557dc99b369Smrg for a_deplib in $deplibs; do 9558dc99b369Smrg case $a_deplib in 9559dc99b369Smrg -l*) 9560dc99b369Smrg func_stripname -l '' "$a_deplib" 9561dc99b369Smrg name=$func_stripname_result 95625c30ecadSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563dc99b369Smrg case " $predeps $postdeps " in 9564dc99b369Smrg *" $a_deplib "*) 9565dc99b369Smrg func_append newdeplibs " $a_deplib" 95665c30ecadSmrg a_deplib= 9567dc99b369Smrg ;; 9568dc99b369Smrg esac 9569dc99b369Smrg fi 95705c30ecadSmrg if test -n "$a_deplib"; then 9571dc99b369Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572dc99b369Smrg if test -n "$file_magic_glob"; then 9573dc99b369Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574dc99b369Smrg else 9575dc99b369Smrg libnameglob=$libname 9576dc99b369Smrg fi 95775c30ecadSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578dc99b369Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95795c30ecadSmrg if test yes = "$want_nocaseglob"; then 9580dc99b369Smrg shopt -s nocaseglob 9581dc99b369Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582dc99b369Smrg $nocaseglob 9583dc99b369Smrg else 9584dc99b369Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585dc99b369Smrg fi 9586dc99b369Smrg for potent_lib in $potential_libs; do 9587dc99b369Smrg # Follow soft links. 9588dc99b369Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9589dc99b369Smrg $GREP " -> " >/dev/null; then 9590dc99b369Smrg continue 9591dc99b369Smrg fi 9592dc99b369Smrg # The statement above tries to avoid entering an 9593dc99b369Smrg # endless loop below, in case of cyclic links. 9594dc99b369Smrg # We might still enter an endless loop, since a link 9595dc99b369Smrg # loop can be closed while we follow links, 9596dc99b369Smrg # but so what? 95975c30ecadSmrg potlib=$potent_lib 9598dc99b369Smrg while test -h "$potlib" 2>/dev/null; do 95995c30ecadSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600dc99b369Smrg case $potliblink in 96015c30ecadSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96025c30ecadSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603dc99b369Smrg esac 9604dc99b369Smrg done 9605dc99b369Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606dc99b369Smrg $SED -e 10q | 9607dc99b369Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608dc99b369Smrg func_append newdeplibs " $a_deplib" 96095c30ecadSmrg a_deplib= 9610dc99b369Smrg break 2 9611dc99b369Smrg fi 9612dc99b369Smrg done 9613dc99b369Smrg done 9614dc99b369Smrg fi 96155c30ecadSmrg if test -n "$a_deplib"; then 9616dc99b369Smrg droppeddeps=yes 9617dc99b369Smrg echo 9618dc99b369Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619dc99b369Smrg echo "*** I have the capability to make that library automatically link in when" 9620dc99b369Smrg echo "*** you link to this library. But I can only do this if you have a" 9621dc99b369Smrg echo "*** shared version of the library, which you do not appear to have" 9622dc99b369Smrg echo "*** because I did check the linker path looking for a file starting" 96235c30ecadSmrg if test -z "$potlib"; then 9624dc99b369Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625dc99b369Smrg else 9626dc99b369Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627dc99b369Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628dc99b369Smrg fi 9629dc99b369Smrg fi 9630dc99b369Smrg ;; 9631dc99b369Smrg *) 9632dc99b369Smrg # Add a -L argument. 9633dc99b369Smrg func_append newdeplibs " $a_deplib" 9634dc99b369Smrg ;; 9635dc99b369Smrg esac 9636dc99b369Smrg done # Gone through all deplibs. 9637dc99b369Smrg ;; 9638dc99b369Smrg match_pattern*) 9639dc99b369Smrg set dummy $deplibs_check_method; shift 9640dc99b369Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641dc99b369Smrg for a_deplib in $deplibs; do 9642dc99b369Smrg case $a_deplib in 9643dc99b369Smrg -l*) 9644dc99b369Smrg func_stripname -l '' "$a_deplib" 9645dc99b369Smrg name=$func_stripname_result 96465c30ecadSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647dc99b369Smrg case " $predeps $postdeps " in 9648dc99b369Smrg *" $a_deplib "*) 9649dc99b369Smrg func_append newdeplibs " $a_deplib" 96505c30ecadSmrg a_deplib= 9651dc99b369Smrg ;; 9652dc99b369Smrg esac 9653dc99b369Smrg fi 96545c30ecadSmrg if test -n "$a_deplib"; then 9655dc99b369Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656dc99b369Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657dc99b369Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658dc99b369Smrg for potent_lib in $potential_libs; do 96595c30ecadSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9660dc99b369Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661dc99b369Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662dc99b369Smrg func_append newdeplibs " $a_deplib" 96635c30ecadSmrg a_deplib= 9664dc99b369Smrg break 2 9665dc99b369Smrg fi 9666dc99b369Smrg done 9667dc99b369Smrg done 9668dc99b369Smrg fi 96695c30ecadSmrg if test -n "$a_deplib"; then 9670dc99b369Smrg droppeddeps=yes 9671dc99b369Smrg echo 9672dc99b369Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673dc99b369Smrg echo "*** I have the capability to make that library automatically link in when" 9674dc99b369Smrg echo "*** you link to this library. But I can only do this if you have a" 9675dc99b369Smrg echo "*** shared version of the library, which you do not appear to have" 9676dc99b369Smrg echo "*** because I did check the linker path looking for a file starting" 96775c30ecadSmrg if test -z "$potlib"; then 9678dc99b369Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679dc99b369Smrg else 9680dc99b369Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681dc99b369Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682dc99b369Smrg fi 9683dc99b369Smrg fi 9684dc99b369Smrg ;; 9685dc99b369Smrg *) 9686dc99b369Smrg # Add a -L argument. 9687dc99b369Smrg func_append newdeplibs " $a_deplib" 9688dc99b369Smrg ;; 9689dc99b369Smrg esac 9690dc99b369Smrg done # Gone through all deplibs. 9691dc99b369Smrg ;; 9692dc99b369Smrg none | unknown | *) 96935c30ecadSmrg newdeplibs= 9694dc99b369Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96955c30ecadSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96965c30ecadSmrg for i in $predeps $postdeps; do 9697dc99b369Smrg # can't use Xsed below, because $i might contain '/' 96985c30ecadSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699dc99b369Smrg done 9700dc99b369Smrg fi 9701dc99b369Smrg case $tmp_deplibs in 9702dc99b369Smrg *[!\ \ ]*) 9703dc99b369Smrg echo 97045c30ecadSmrg if test none = "$deplibs_check_method"; then 9705dc99b369Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706dc99b369Smrg else 9707dc99b369Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708dc99b369Smrg fi 9709dc99b369Smrg echo "*** All declared inter-library dependencies are being dropped." 9710dc99b369Smrg droppeddeps=yes 9711dc99b369Smrg ;; 9712dc99b369Smrg esac 9713dc99b369Smrg ;; 9714dc99b369Smrg esac 9715dc99b369Smrg versuffix=$versuffix_save 9716dc99b369Smrg major=$major_save 9717dc99b369Smrg release=$release_save 9718dc99b369Smrg libname=$libname_save 9719dc99b369Smrg name=$name_save 9720dc99b369Smrg 9721dc99b369Smrg case $host in 9722dc99b369Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9723dc99b369Smrg # On Rhapsody replace the C library with the System framework 9724dc99b369Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725dc99b369Smrg ;; 9726dc99b369Smrg esac 9727dc99b369Smrg 97285c30ecadSmrg if test yes = "$droppeddeps"; then 97295c30ecadSmrg if test yes = "$module"; then 9730dc99b369Smrg echo 9731dc99b369Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732dc99b369Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733dc99b369Smrg echo "*** a static module, that should work as long as the dlopening" 9734dc99b369Smrg echo "*** application is linked with the -dlopen flag." 9735dc99b369Smrg if test -z "$global_symbol_pipe"; then 9736dc99b369Smrg echo 9737dc99b369Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97385c30ecadSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739dc99b369Smrg echo "*** not find such a program. So, this module is probably useless." 97405c30ecadSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741dc99b369Smrg fi 97425c30ecadSmrg if test no = "$build_old_libs"; then 97435c30ecadSmrg oldlibs=$output_objdir/$libname.$libext 9744dc99b369Smrg build_libtool_libs=module 9745dc99b369Smrg build_old_libs=yes 9746dc99b369Smrg else 9747dc99b369Smrg build_libtool_libs=no 9748dc99b369Smrg fi 9749dc99b369Smrg else 9750dc99b369Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9751dc99b369Smrg echo "*** automatically added whenever a program is linked with this library" 9752dc99b369Smrg echo "*** or is declared to -dlopen it." 97535eefee25Smacallan 97545c30ecadSmrg if test no = "$allow_undefined"; then 9755dc99b369Smrg echo 9756dc99b369Smrg echo "*** Since this library must not contain undefined symbols," 9757dc99b369Smrg echo "*** because either the platform does not support them or" 9758dc99b369Smrg echo "*** it was explicitly requested with -no-undefined," 9759dc99b369Smrg echo "*** libtool will only create a static version of it." 97605c30ecadSmrg if test no = "$build_old_libs"; then 97615c30ecadSmrg oldlibs=$output_objdir/$libname.$libext 9762dc99b369Smrg build_libtool_libs=module 9763dc99b369Smrg build_old_libs=yes 9764dc99b369Smrg else 9765dc99b369Smrg build_libtool_libs=no 9766dc99b369Smrg fi 9767dc99b369Smrg fi 9768dc99b369Smrg fi 9769dc99b369Smrg fi 9770dc99b369Smrg # Done checking deplibs! 9771dc99b369Smrg deplibs=$newdeplibs 9772dc99b369Smrg fi 9773dc99b369Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774dc99b369Smrg case $host in 9775dc99b369Smrg *-*-darwin*) 9776dc99b369Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777dc99b369Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778dc99b369Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779dc99b369Smrg ;; 9780dc99b369Smrg esac 97815eefee25Smacallan 9782dc99b369Smrg # move library search paths that coincide with paths to not yet 9783dc99b369Smrg # installed libraries to the beginning of the library search list 9784dc99b369Smrg new_libs= 9785dc99b369Smrg for path in $notinst_path; do 9786dc99b369Smrg case " $new_libs " in 9787dc99b369Smrg *" -L$path/$objdir "*) ;; 9788dc99b369Smrg *) 9789dc99b369Smrg case " $deplibs " in 9790dc99b369Smrg *" -L$path/$objdir "*) 9791dc99b369Smrg func_append new_libs " -L$path/$objdir" ;; 9792dc99b369Smrg esac 9793dc99b369Smrg ;; 9794dc99b369Smrg esac 9795dc99b369Smrg done 9796dc99b369Smrg for deplib in $deplibs; do 9797dc99b369Smrg case $deplib in 9798dc99b369Smrg -L*) 9799dc99b369Smrg case " $new_libs " in 9800dc99b369Smrg *" $deplib "*) ;; 9801dc99b369Smrg *) func_append new_libs " $deplib" ;; 9802dc99b369Smrg esac 9803dc99b369Smrg ;; 9804dc99b369Smrg *) func_append new_libs " $deplib" ;; 9805dc99b369Smrg esac 9806dc99b369Smrg done 98075c30ecadSmrg deplibs=$new_libs 98085eefee25Smacallan 9809dc99b369Smrg # All the library-specific variables (install_libdir is set above). 9810dc99b369Smrg library_names= 9811dc99b369Smrg old_library= 9812dc99b369Smrg dlname= 98135eefee25Smacallan 9814dc99b369Smrg # Test again, we may have decided not to build it any more 98155c30ecadSmrg if test yes = "$build_libtool_libs"; then 98165c30ecadSmrg # Remove $wl instances when linking with ld. 98175c30ecadSmrg # FIXME: should test the right _cmds variable. 98185c30ecadSmrg case $archive_cmds in 98195c30ecadSmrg *\$LD\ *) wl= ;; 98205c30ecadSmrg esac 98215c30ecadSmrg if test yes = "$hardcode_into_libs"; then 9822dc99b369Smrg # Hardcode the library paths 9823dc99b369Smrg hardcode_libdirs= 9824dc99b369Smrg dep_rpath= 98255c30ecadSmrg rpath=$finalize_rpath 98265c30ecadSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827dc99b369Smrg for libdir in $rpath; do 9828dc99b369Smrg if test -n "$hardcode_libdir_flag_spec"; then 9829dc99b369Smrg if test -n "$hardcode_libdir_separator"; then 9830dc99b369Smrg func_replace_sysroot "$libdir" 9831dc99b369Smrg libdir=$func_replace_sysroot_result 9832dc99b369Smrg if test -z "$hardcode_libdirs"; then 98335c30ecadSmrg hardcode_libdirs=$libdir 9834dc99b369Smrg else 9835dc99b369Smrg # Just accumulate the unique libdirs. 9836dc99b369Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837dc99b369Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838dc99b369Smrg ;; 9839dc99b369Smrg *) 9840dc99b369Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841dc99b369Smrg ;; 9842dc99b369Smrg esac 9843dc99b369Smrg fi 9844dc99b369Smrg else 9845dc99b369Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846dc99b369Smrg func_append dep_rpath " $flag" 9847dc99b369Smrg fi 9848dc99b369Smrg elif test -n "$runpath_var"; then 9849dc99b369Smrg case "$perm_rpath " in 9850dc99b369Smrg *" $libdir "*) ;; 98515c30ecadSmrg *) func_append perm_rpath " $libdir" ;; 9852dc99b369Smrg esac 9853dc99b369Smrg fi 9854dc99b369Smrg done 9855dc99b369Smrg # Substitute the hardcoded libdirs into the rpath. 9856dc99b369Smrg if test -n "$hardcode_libdir_separator" && 9857dc99b369Smrg test -n "$hardcode_libdirs"; then 98585c30ecadSmrg libdir=$hardcode_libdirs 98595c30ecadSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860dc99b369Smrg fi 9861dc99b369Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862dc99b369Smrg # We should set the runpath_var. 9863dc99b369Smrg rpath= 9864dc99b369Smrg for dir in $perm_rpath; do 9865dc99b369Smrg func_append rpath "$dir:" 9866dc99b369Smrg done 9867dc99b369Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868dc99b369Smrg fi 9869dc99b369Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870dc99b369Smrg fi 98715eefee25Smacallan 98725c30ecadSmrg shlibpath=$finalize_shlibpath 98735c30ecadSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874dc99b369Smrg if test -n "$shlibpath"; then 9875dc99b369Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876dc99b369Smrg fi 98775eefee25Smacallan 9878dc99b369Smrg # Get the real and link names of the library. 9879dc99b369Smrg eval shared_ext=\"$shrext_cmds\" 9880dc99b369Smrg eval library_names=\"$library_names_spec\" 9881dc99b369Smrg set dummy $library_names 9882dc99b369Smrg shift 98835c30ecadSmrg realname=$1 9884dc99b369Smrg shift 98855eefee25Smacallan 9886dc99b369Smrg if test -n "$soname_spec"; then 9887dc99b369Smrg eval soname=\"$soname_spec\" 98885eefee25Smacallan else 98895c30ecadSmrg soname=$realname 9890dc99b369Smrg fi 9891dc99b369Smrg if test -z "$dlname"; then 9892dc99b369Smrg dlname=$soname 98935eefee25Smacallan fi 98945eefee25Smacallan 98955c30ecadSmrg lib=$output_objdir/$realname 9896dc99b369Smrg linknames= 9897dc99b369Smrg for link 9898dc99b369Smrg do 9899dc99b369Smrg func_append linknames " $link" 9900dc99b369Smrg done 99015eefee25Smacallan 9902dc99b369Smrg # Use standard objects if they are pic 9903dc99b369Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904dc99b369Smrg test "X$libobjs" = "X " && libobjs= 99055eefee25Smacallan 9906dc99b369Smrg delfiles= 9907dc99b369Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908dc99b369Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99095c30ecadSmrg export_symbols=$output_objdir/$libname.uexp 9910dc99b369Smrg func_append delfiles " $export_symbols" 9911dc99b369Smrg fi 99125eefee25Smacallan 9913dc99b369Smrg orig_export_symbols= 9914dc99b369Smrg case $host_os in 9915dc99b369Smrg cygwin* | mingw* | cegcc*) 9916dc99b369Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917dc99b369Smrg # exporting using user supplied symfile 99185c30ecadSmrg func_dll_def_p "$export_symbols" || { 9919dc99b369Smrg # and it's NOT already a .def file. Must figure out 9920dc99b369Smrg # which of the given symbols are data symbols and tag 9921dc99b369Smrg # them as such. So, trigger use of export_symbols_cmds. 9922dc99b369Smrg # export_symbols gets reassigned inside the "prepare 9923dc99b369Smrg # the list of exported symbols" if statement, so the 9924dc99b369Smrg # include_expsyms logic still works. 99255c30ecadSmrg orig_export_symbols=$export_symbols 9926dc99b369Smrg export_symbols= 9927dc99b369Smrg always_export_symbols=yes 99285c30ecadSmrg } 9929dc99b369Smrg fi 9930dc99b369Smrg ;; 9931dc99b369Smrg esac 99325eefee25Smacallan 9933dc99b369Smrg # Prepare the list of exported symbols 9934dc99b369Smrg if test -z "$export_symbols"; then 99355c30ecadSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99365c30ecadSmrg func_verbose "generating symbol list for '$libname.la'" 99375c30ecadSmrg export_symbols=$output_objdir/$libname.exp 9938dc99b369Smrg $opt_dry_run || $RM $export_symbols 9939dc99b369Smrg cmds=$export_symbols_cmds 99405c30ecadSmrg save_ifs=$IFS; IFS='~' 9941dc99b369Smrg for cmd1 in $cmds; do 99425c30ecadSmrg IFS=$save_ifs 9943dc99b369Smrg # Take the normal branch if the nm_file_list_spec branch 9944dc99b369Smrg # doesn't work or if tool conversion is not needed. 9945dc99b369Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9946dc99b369Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947dc99b369Smrg try_normal_branch=yes 9948dc99b369Smrg eval cmd=\"$cmd1\" 9949dc99b369Smrg func_len " $cmd" 9950dc99b369Smrg len=$func_len_result 9951dc99b369Smrg ;; 9952dc99b369Smrg *) 9953dc99b369Smrg try_normal_branch=no 9954dc99b369Smrg ;; 9955dc99b369Smrg esac 99565c30ecadSmrg if test yes = "$try_normal_branch" \ 9957dc99b369Smrg && { test "$len" -lt "$max_cmd_len" \ 9958dc99b369Smrg || test "$max_cmd_len" -le -1; } 9959dc99b369Smrg then 9960dc99b369Smrg func_show_eval "$cmd" 'exit $?' 9961dc99b369Smrg skipped_export=false 9962dc99b369Smrg elif test -n "$nm_file_list_spec"; then 9963dc99b369Smrg func_basename "$output" 9964dc99b369Smrg output_la=$func_basename_result 9965dc99b369Smrg save_libobjs=$libobjs 9966dc99b369Smrg save_output=$output 99675c30ecadSmrg output=$output_objdir/$output_la.nm 9968dc99b369Smrg func_to_tool_file "$output" 9969dc99b369Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970dc99b369Smrg func_append delfiles " $output" 9971dc99b369Smrg func_verbose "creating $NM input file list: $output" 9972dc99b369Smrg for obj in $save_libobjs; do 9973dc99b369Smrg func_to_tool_file "$obj" 9974dc99b369Smrg $ECHO "$func_to_tool_file_result" 9975dc99b369Smrg done > "$output" 9976dc99b369Smrg eval cmd=\"$cmd1\" 9977dc99b369Smrg func_show_eval "$cmd" 'exit $?' 9978dc99b369Smrg output=$save_output 9979dc99b369Smrg libobjs=$save_libobjs 9980dc99b369Smrg skipped_export=false 9981dc99b369Smrg else 9982dc99b369Smrg # The command line is too long to execute in one step. 9983dc99b369Smrg func_verbose "using reloadable object file for export list..." 9984dc99b369Smrg skipped_export=: 9985dc99b369Smrg # Break out early, otherwise skipped_export may be 9986dc99b369Smrg # set to false by a later but shorter cmd. 9987dc99b369Smrg break 9988dc99b369Smrg fi 9989dc99b369Smrg done 99905c30ecadSmrg IFS=$save_ifs 99915c30ecadSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992dc99b369Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993dc99b369Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994dc99b369Smrg fi 9995dc99b369Smrg fi 99965eefee25Smacallan fi 99975eefee25Smacallan 9998dc99b369Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99995c30ecadSmrg tmp_export_symbols=$export_symbols 100005c30ecadSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001dc99b369Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100025eefee25Smacallan fi 100035eefee25Smacallan 100045c30ecadSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005dc99b369Smrg # The given exports_symbols file has to be filtered, so filter it. 100065c30ecadSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007dc99b369Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100085c30ecadSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009dc99b369Smrg # though. Also, the filter scales superlinearly with the number of 10010dc99b369Smrg # global variables. join(1) would be nice here, but unfortunately 10011dc99b369Smrg # isn't a blessed tool. 10012dc99b369Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013dc99b369Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014dc99b369Smrg export_symbols=$output_objdir/$libname.def 10015dc99b369Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016dc99b369Smrg fi 100175eefee25Smacallan 10018dc99b369Smrg tmp_deplibs= 10019dc99b369Smrg for test_deplib in $deplibs; do 10020dc99b369Smrg case " $convenience " in 10021dc99b369Smrg *" $test_deplib "*) ;; 10022dc99b369Smrg *) 10023dc99b369Smrg func_append tmp_deplibs " $test_deplib" 10024dc99b369Smrg ;; 10025dc99b369Smrg esac 10026dc99b369Smrg done 100275c30ecadSmrg deplibs=$tmp_deplibs 100285eefee25Smacallan 10029dc99b369Smrg if test -n "$convenience"; then 10030dc99b369Smrg if test -n "$whole_archive_flag_spec" && 100315c30ecadSmrg test yes = "$compiler_needs_object" && 10032dc99b369Smrg test -z "$libobjs"; then 10033dc99b369Smrg # extract the archives, so we have objects to list. 10034dc99b369Smrg # TODO: could optimize this to just extract one archive. 10035dc99b369Smrg whole_archive_flag_spec= 10036dc99b369Smrg fi 10037dc99b369Smrg if test -n "$whole_archive_flag_spec"; then 10038dc99b369Smrg save_libobjs=$libobjs 10039dc99b369Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040dc99b369Smrg test "X$libobjs" = "X " && libobjs= 10041dc99b369Smrg else 100425c30ecadSmrg gentop=$output_objdir/${outputname}x 10043dc99b369Smrg func_append generated " $gentop" 100445eefee25Smacallan 10045dc99b369Smrg func_extract_archives $gentop $convenience 10046dc99b369Smrg func_append libobjs " $func_extract_archives_result" 10047dc99b369Smrg test "X$libobjs" = "X " && libobjs= 10048dc99b369Smrg fi 100495eefee25Smacallan fi 100505eefee25Smacallan 100515c30ecadSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052dc99b369Smrg eval flag=\"$thread_safe_flag_spec\" 10053dc99b369Smrg func_append linker_flags " $flag" 10054dc99b369Smrg fi 100555eefee25Smacallan 10056dc99b369Smrg # Make a backup of the uninstalled library when relinking 100575c30ecadSmrg if test relink = "$opt_mode"; then 10058dc99b369Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059dc99b369Smrg fi 10060dc99b369Smrg 10061dc99b369Smrg # Do each of the archive commands. 100625c30ecadSmrg if test yes = "$module" && test -n "$module_cmds"; then 10063dc99b369Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064dc99b369Smrg eval test_cmds=\"$module_expsym_cmds\" 10065dc99b369Smrg cmds=$module_expsym_cmds 10066dc99b369Smrg else 10067dc99b369Smrg eval test_cmds=\"$module_cmds\" 10068dc99b369Smrg cmds=$module_cmds 10069dc99b369Smrg fi 10070dc99b369Smrg else 10071dc99b369Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072dc99b369Smrg eval test_cmds=\"$archive_expsym_cmds\" 10073dc99b369Smrg cmds=$archive_expsym_cmds 10074dc99b369Smrg else 10075dc99b369Smrg eval test_cmds=\"$archive_cmds\" 10076dc99b369Smrg cmds=$archive_cmds 10077dc99b369Smrg fi 10078dc99b369Smrg fi 100795eefee25Smacallan 100805c30ecadSmrg if test : != "$skipped_export" && 10081dc99b369Smrg func_len " $test_cmds" && 10082dc99b369Smrg len=$func_len_result && 10083dc99b369Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100845eefee25Smacallan : 100855eefee25Smacallan else 10086dc99b369Smrg # The command line is too long to link in one step, link piecewise 10087dc99b369Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10088dc99b369Smrg # script. 100895eefee25Smacallan 10090dc99b369Smrg # Save the value of $output and $libobjs because we want to 10091dc99b369Smrg # use them later. If we have whole_archive_flag_spec, we 10092dc99b369Smrg # want to use save_libobjs as it was before 10093dc99b369Smrg # whole_archive_flag_spec was expanded, because we can't 10094dc99b369Smrg # assume the linker understands whole_archive_flag_spec. 10095dc99b369Smrg # This may have to be revisited, in case too many 10096dc99b369Smrg # convenience libraries get linked in and end up exceeding 10097dc99b369Smrg # the spec. 10098dc99b369Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099dc99b369Smrg save_libobjs=$libobjs 101005eefee25Smacallan fi 10101dc99b369Smrg save_output=$output 10102dc99b369Smrg func_basename "$output" 10103dc99b369Smrg output_la=$func_basename_result 101045eefee25Smacallan 10105dc99b369Smrg # Clear the reloadable object creation command queue and 10106dc99b369Smrg # initialize k to one. 10107dc99b369Smrg test_cmds= 101085eefee25Smacallan concat_cmds= 10109dc99b369Smrg objlist= 10110dc99b369Smrg last_robj= 10111dc99b369Smrg k=1 101125eefee25Smacallan 101135c30ecadSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101145c30ecadSmrg output=$output_objdir/$output_la.lnkscript 10115dc99b369Smrg func_verbose "creating GNU ld script: $output" 10116dc99b369Smrg echo 'INPUT (' > $output 10117dc99b369Smrg for obj in $save_libobjs 10118dc99b369Smrg do 10119dc99b369Smrg func_to_tool_file "$obj" 10120dc99b369Smrg $ECHO "$func_to_tool_file_result" >> $output 10121dc99b369Smrg done 10122dc99b369Smrg echo ')' >> $output 10123dc99b369Smrg func_append delfiles " $output" 10124dc99b369Smrg func_to_tool_file "$output" 10125dc99b369Smrg output=$func_to_tool_file_result 101265c30ecadSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101275c30ecadSmrg output=$output_objdir/$output_la.lnk 10128dc99b369Smrg func_verbose "creating linker input file list: $output" 10129dc99b369Smrg : > $output 10130dc99b369Smrg set x $save_libobjs 10131dc99b369Smrg shift 10132dc99b369Smrg firstobj= 101335c30ecadSmrg if test yes = "$compiler_needs_object"; then 10134dc99b369Smrg firstobj="$1 " 10135dc99b369Smrg shift 10136dc99b369Smrg fi 10137dc99b369Smrg for obj 10138dc99b369Smrg do 10139dc99b369Smrg func_to_tool_file "$obj" 10140dc99b369Smrg $ECHO "$func_to_tool_file_result" >> $output 10141dc99b369Smrg done 10142dc99b369Smrg func_append delfiles " $output" 10143dc99b369Smrg func_to_tool_file "$output" 10144dc99b369Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145dc99b369Smrg else 10146dc99b369Smrg if test -n "$save_libobjs"; then 10147dc99b369Smrg func_verbose "creating reloadable object files..." 101485c30ecadSmrg output=$output_objdir/$output_la-$k.$objext 10149dc99b369Smrg eval test_cmds=\"$reload_cmds\" 10150dc99b369Smrg func_len " $test_cmds" 10151dc99b369Smrg len0=$func_len_result 10152dc99b369Smrg len=$len0 10153dc99b369Smrg 10154dc99b369Smrg # Loop over the list of objects to be linked. 10155dc99b369Smrg for obj in $save_libobjs 10156dc99b369Smrg do 10157dc99b369Smrg func_len " $obj" 10158dc99b369Smrg func_arith $len + $func_len_result 10159dc99b369Smrg len=$func_arith_result 101605c30ecadSmrg if test -z "$objlist" || 10161dc99b369Smrg test "$len" -lt "$max_cmd_len"; then 10162dc99b369Smrg func_append objlist " $obj" 10163dc99b369Smrg else 10164dc99b369Smrg # The command $test_cmds is almost too long, add a 10165dc99b369Smrg # command to the queue. 101665c30ecadSmrg if test 1 -eq "$k"; then 10167dc99b369Smrg # The first file doesn't have a previous command to add. 10168dc99b369Smrg reload_objs=$objlist 10169dc99b369Smrg eval concat_cmds=\"$reload_cmds\" 10170dc99b369Smrg else 10171dc99b369Smrg # All subsequent reloadable object files will link in 10172dc99b369Smrg # the last one created. 10173dc99b369Smrg reload_objs="$objlist $last_robj" 10174dc99b369Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175dc99b369Smrg fi 101765c30ecadSmrg last_robj=$output_objdir/$output_la-$k.$objext 10177dc99b369Smrg func_arith $k + 1 10178dc99b369Smrg k=$func_arith_result 101795c30ecadSmrg output=$output_objdir/$output_la-$k.$objext 10180dc99b369Smrg objlist=" $obj" 10181dc99b369Smrg func_len " $last_robj" 10182dc99b369Smrg func_arith $len0 + $func_len_result 10183dc99b369Smrg len=$func_arith_result 10184dc99b369Smrg fi 10185dc99b369Smrg done 10186dc99b369Smrg # Handle the remaining objects by creating one last 10187dc99b369Smrg # reloadable object file. All subsequent reloadable object 10188dc99b369Smrg # files will link in the last one created. 10189dc99b369Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190dc99b369Smrg reload_objs="$objlist $last_robj" 101915c30ecadSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192dc99b369Smrg if test -n "$last_robj"; then 101935c30ecadSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 101945eefee25Smacallan fi 10195dc99b369Smrg func_append delfiles " $output" 10196dc99b369Smrg 10197dc99b369Smrg else 10198dc99b369Smrg output= 10199dc99b369Smrg fi 10200dc99b369Smrg 102015c30ecadSmrg ${skipped_export-false} && { 102025c30ecadSmrg func_verbose "generating symbol list for '$libname.la'" 102035c30ecadSmrg export_symbols=$output_objdir/$libname.exp 10204dc99b369Smrg $opt_dry_run || $RM $export_symbols 10205dc99b369Smrg libobjs=$output 10206dc99b369Smrg # Append the command to create the export file. 102075eefee25Smacallan test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208dc99b369Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209dc99b369Smrg if test -n "$last_robj"; then 10210dc99b369Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211dc99b369Smrg fi 102125c30ecadSmrg } 10213dc99b369Smrg 10214dc99b369Smrg test -n "$save_libobjs" && 10215dc99b369Smrg func_verbose "creating a temporary reloadable object file: $output" 10216dc99b369Smrg 10217dc99b369Smrg # Loop through the commands generated above and execute them. 102185c30ecadSmrg save_ifs=$IFS; IFS='~' 10219dc99b369Smrg for cmd in $concat_cmds; do 102205c30ecadSmrg IFS=$save_ifs 102215c30ecadSmrg $opt_quiet || { 102225c30ecadSmrg func_quote_arg expand,pretty "$cmd" 102235c30ecadSmrg eval "func_echo $func_quote_arg_result" 10224dc99b369Smrg } 10225dc99b369Smrg $opt_dry_run || eval "$cmd" || { 10226dc99b369Smrg lt_exit=$? 10227dc99b369Smrg 10228dc99b369Smrg # Restore the uninstalled library and exit 102295c30ecadSmrg if test relink = "$opt_mode"; then 10230dc99b369Smrg ( cd "$output_objdir" && \ 10231dc99b369Smrg $RM "${realname}T" && \ 10232dc99b369Smrg $MV "${realname}U" "$realname" ) 10233dc99b369Smrg fi 10234dc99b369Smrg 10235dc99b369Smrg exit $lt_exit 10236dc99b369Smrg } 10237dc99b369Smrg done 102385c30ecadSmrg IFS=$save_ifs 10239dc99b369Smrg 10240dc99b369Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241dc99b369Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242dc99b369Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102435eefee25Smacallan fi 102445eefee25Smacallan fi 102455eefee25Smacallan 102465c30ecadSmrg ${skipped_export-false} && { 10247dc99b369Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102485c30ecadSmrg tmp_export_symbols=$export_symbols 102495c30ecadSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250dc99b369Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251dc99b369Smrg fi 102525eefee25Smacallan 10253dc99b369Smrg if test -n "$orig_export_symbols"; then 10254dc99b369Smrg # The given exports_symbols file has to be filtered, so filter it. 102555c30ecadSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256dc99b369Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102575c30ecadSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258dc99b369Smrg # though. Also, the filter scales superlinearly with the number of 10259dc99b369Smrg # global variables. join(1) would be nice here, but unfortunately 10260dc99b369Smrg # isn't a blessed tool. 10261dc99b369Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262dc99b369Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263dc99b369Smrg export_symbols=$output_objdir/$libname.def 10264dc99b369Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265dc99b369Smrg fi 102665c30ecadSmrg } 102675eefee25Smacallan 10268dc99b369Smrg libobjs=$output 10269dc99b369Smrg # Restore the value of output. 10270dc99b369Smrg output=$save_output 102715eefee25Smacallan 10272dc99b369Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273dc99b369Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274dc99b369Smrg test "X$libobjs" = "X " && libobjs= 10275dc99b369Smrg fi 10276dc99b369Smrg # Expand the library linking commands again to reset the 10277dc99b369Smrg # value of $libobjs for piecewise linking. 102785eefee25Smacallan 10279dc99b369Smrg # Do each of the archive commands. 102805c30ecadSmrg if test yes = "$module" && test -n "$module_cmds"; then 10281dc99b369Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282dc99b369Smrg cmds=$module_expsym_cmds 10283dc99b369Smrg else 10284dc99b369Smrg cmds=$module_cmds 102855eefee25Smacallan fi 102865eefee25Smacallan else 10287dc99b369Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288dc99b369Smrg cmds=$archive_expsym_cmds 10289dc99b369Smrg else 10290dc99b369Smrg cmds=$archive_cmds 10291dc99b369Smrg fi 102925eefee25Smacallan fi 10293dc99b369Smrg fi 102945eefee25Smacallan 10295dc99b369Smrg if test -n "$delfiles"; then 10296dc99b369Smrg # Append the command to remove temporary files to $cmds. 10297dc99b369Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298dc99b369Smrg fi 102995eefee25Smacallan 10300dc99b369Smrg # Add any objects from preloaded convenience libraries 10301dc99b369Smrg if test -n "$dlprefiles"; then 103025c30ecadSmrg gentop=$output_objdir/${outputname}x 10303dc99b369Smrg func_append generated " $gentop" 103045eefee25Smacallan 10305dc99b369Smrg func_extract_archives $gentop $dlprefiles 10306dc99b369Smrg func_append libobjs " $func_extract_archives_result" 10307dc99b369Smrg test "X$libobjs" = "X " && libobjs= 10308dc99b369Smrg fi 103095eefee25Smacallan 103105c30ecadSmrg save_ifs=$IFS; IFS='~' 10311dc99b369Smrg for cmd in $cmds; do 103125c30ecadSmrg IFS=$sp$nl 10313dc99b369Smrg eval cmd=\"$cmd\" 103145c30ecadSmrg IFS=$save_ifs 103155c30ecadSmrg $opt_quiet || { 103165c30ecadSmrg func_quote_arg expand,pretty "$cmd" 103175c30ecadSmrg eval "func_echo $func_quote_arg_result" 10318dc99b369Smrg } 10319dc99b369Smrg $opt_dry_run || eval "$cmd" || { 10320dc99b369Smrg lt_exit=$? 103215eefee25Smacallan 10322dc99b369Smrg # Restore the uninstalled library and exit 103235c30ecadSmrg if test relink = "$opt_mode"; then 10324dc99b369Smrg ( cd "$output_objdir" && \ 10325dc99b369Smrg $RM "${realname}T" && \ 10326dc99b369Smrg $MV "${realname}U" "$realname" ) 10327dc99b369Smrg fi 103285eefee25Smacallan 10329dc99b369Smrg exit $lt_exit 10330dc99b369Smrg } 10331dc99b369Smrg done 103325c30ecadSmrg IFS=$save_ifs 103335eefee25Smacallan 10334dc99b369Smrg # Restore the uninstalled library and exit 103355c30ecadSmrg if test relink = "$opt_mode"; then 10336dc99b369Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103375eefee25Smacallan 10338dc99b369Smrg if test -n "$convenience"; then 10339dc99b369Smrg if test -z "$whole_archive_flag_spec"; then 10340dc99b369Smrg func_show_eval '${RM}r "$gentop"' 10341dc99b369Smrg fi 10342dc99b369Smrg fi 103435eefee25Smacallan 10344dc99b369Smrg exit $EXIT_SUCCESS 10345dc99b369Smrg fi 10346dc99b369Smrg 10347dc99b369Smrg # Create links to the real library. 10348dc99b369Smrg for linkname in $linknames; do 10349dc99b369Smrg if test "$realname" != "$linkname"; then 10350dc99b369Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103515eefee25Smacallan fi 103525eefee25Smacallan done 103535eefee25Smacallan 10354dc99b369Smrg # If -module or -export-dynamic was specified, set the dlname. 103555c30ecadSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356dc99b369Smrg # On all known operating systems, these are identical. 103575c30ecadSmrg dlname=$soname 10358dc99b369Smrg fi 10359dc99b369Smrg fi 103605eefee25Smacallan ;; 103615eefee25Smacallan 10362dc99b369Smrg obj) 103635c30ecadSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103645c30ecadSmrg func_warning "'-dlopen' is ignored for objects" 10365dc99b369Smrg fi 103665eefee25Smacallan 10367dc99b369Smrg case " $deplibs" in 10368dc99b369Smrg *\ -l* | *\ -L*) 103695c30ecadSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 103705eefee25Smacallan esac 103715eefee25Smacallan 10372dc99b369Smrg test -n "$rpath" && \ 103735c30ecadSmrg func_warning "'-rpath' is ignored for objects" 103745eefee25Smacallan 10375dc99b369Smrg test -n "$xrpath" && \ 103765c30ecadSmrg func_warning "'-R' is ignored for objects" 103775eefee25Smacallan 10378dc99b369Smrg test -n "$vinfo" && \ 103795c30ecadSmrg func_warning "'-version-info' is ignored for objects" 10380dc99b369Smrg 10381dc99b369Smrg test -n "$release" && \ 103825c30ecadSmrg func_warning "'-release' is ignored for objects" 10383dc99b369Smrg 10384dc99b369Smrg case $output in 10385dc99b369Smrg *.lo) 10386dc99b369Smrg test -n "$objs$old_deplibs" && \ 103875c30ecadSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388dc99b369Smrg 10389dc99b369Smrg libobj=$output 10390dc99b369Smrg func_lo2o "$libobj" 10391dc99b369Smrg obj=$func_lo2o_result 103925eefee25Smacallan ;; 103935eefee25Smacallan *) 10394dc99b369Smrg libobj= 103955c30ecadSmrg obj=$output 103965eefee25Smacallan ;; 103975eefee25Smacallan esac 103985eefee25Smacallan 10399dc99b369Smrg # Delete the old objects. 10400dc99b369Smrg $opt_dry_run || $RM $obj $libobj 104015eefee25Smacallan 10402dc99b369Smrg # Objects from convenience libraries. This assumes 10403dc99b369Smrg # single-version convenience libraries. Whenever we create 10404dc99b369Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405dc99b369Smrg # the extraction. 10406dc99b369Smrg reload_conv_objs= 10407dc99b369Smrg gentop= 104085c30ecadSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104095c30ecadSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104105c30ecadSmrg # into space. 104115c30ecadSmrg case $reload_cmds in 104125c30ecadSmrg *\$LD[\ \$]*) wl= ;; 104135c30ecadSmrg esac 10414dc99b369Smrg if test -n "$convenience"; then 10415dc99b369Smrg if test -n "$whole_archive_flag_spec"; then 10416dc99b369Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104175c30ecadSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104185c30ecadSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419dc99b369Smrg else 104205c30ecadSmrg gentop=$output_objdir/${obj}x 10421dc99b369Smrg func_append generated " $gentop" 104225eefee25Smacallan 10423dc99b369Smrg func_extract_archives $gentop $convenience 10424dc99b369Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425dc99b369Smrg fi 104265eefee25Smacallan fi 104275eefee25Smacallan 10428dc99b369Smrg # If we're not building shared, we need to use non_pic_objs 104295c30ecadSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104305eefee25Smacallan 10431dc99b369Smrg # Create the old-style object. 104325c30ecadSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104335eefee25Smacallan 104345c30ecadSmrg output=$obj 10435dc99b369Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10436dc99b369Smrg 10437dc99b369Smrg # Exit if we aren't doing a library object file. 10438dc99b369Smrg if test -z "$libobj"; then 10439dc99b369Smrg if test -n "$gentop"; then 10440dc99b369Smrg func_show_eval '${RM}r "$gentop"' 10441dc99b369Smrg fi 10442dc99b369Smrg 10443dc99b369Smrg exit $EXIT_SUCCESS 104445eefee25Smacallan fi 10445dc99b369Smrg 104465c30ecadSmrg test yes = "$build_libtool_libs" || { 10447dc99b369Smrg if test -n "$gentop"; then 10448dc99b369Smrg func_show_eval '${RM}r "$gentop"' 10449dc99b369Smrg fi 10450dc99b369Smrg 10451dc99b369Smrg # Create an invalid libtool object if no PIC, so that we don't 10452dc99b369Smrg # accidentally link it into a program. 10453dc99b369Smrg # $show "echo timestamp > $libobj" 10454dc99b369Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455dc99b369Smrg exit $EXIT_SUCCESS 104565c30ecadSmrg } 10457dc99b369Smrg 104585c30ecadSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459dc99b369Smrg # Only do commands if we really have different PIC objects. 10460dc99b369Smrg reload_objs="$libobjs $reload_conv_objs" 104615c30ecadSmrg output=$libobj 10462dc99b369Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463dc99b369Smrg fi 10464dc99b369Smrg 10465dc99b369Smrg if test -n "$gentop"; then 10466dc99b369Smrg func_show_eval '${RM}r "$gentop"' 10467dc99b369Smrg fi 10468dc99b369Smrg 10469dc99b369Smrg exit $EXIT_SUCCESS 104705eefee25Smacallan ;; 104715eefee25Smacallan 10472dc99b369Smrg prog) 10473dc99b369Smrg case $host in 10474dc99b369Smrg *cygwin*) func_stripname '' '.exe' "$output" 10475dc99b369Smrg output=$func_stripname_result.exe;; 10476dc99b369Smrg esac 10477dc99b369Smrg test -n "$vinfo" && \ 104785c30ecadSmrg func_warning "'-version-info' is ignored for programs" 104795eefee25Smacallan 10480dc99b369Smrg test -n "$release" && \ 104815c30ecadSmrg func_warning "'-release' is ignored for programs" 104825eefee25Smacallan 104835c30ecadSmrg $preload \ 104845c30ecadSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104855c30ecadSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486dc99b369Smrg 10487dc99b369Smrg case $host in 10488dc99b369Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10489dc99b369Smrg # On Rhapsody replace the C library is the System framework 10490dc99b369Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491dc99b369Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104925eefee25Smacallan ;; 10493dc99b369Smrg esac 104945eefee25Smacallan 10495dc99b369Smrg case $host in 10496dc99b369Smrg *-*-darwin*) 10497dc99b369Smrg # Don't allow lazy linking, it breaks C++ global constructors 10498dc99b369Smrg # But is supposedly fixed on 10.4 or later (yay!). 104995c30ecadSmrg if test CXX = "$tagname"; then 10500dc99b369Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501dc99b369Smrg 10.[0123]) 105025c30ecadSmrg func_append compile_command " $wl-bind_at_load" 105035c30ecadSmrg func_append finalize_command " $wl-bind_at_load" 10504dc99b369Smrg ;; 10505dc99b369Smrg esac 105065eefee25Smacallan fi 10507dc99b369Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508dc99b369Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509dc99b369Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510dc99b369Smrg ;; 10511dc99b369Smrg esac 105125eefee25Smacallan 105135eefee25Smacallan 10514dc99b369Smrg # move library search paths that coincide with paths to not yet 10515dc99b369Smrg # installed libraries to the beginning of the library search list 10516dc99b369Smrg new_libs= 10517dc99b369Smrg for path in $notinst_path; do 10518dc99b369Smrg case " $new_libs " in 10519dc99b369Smrg *" -L$path/$objdir "*) ;; 10520dc99b369Smrg *) 10521dc99b369Smrg case " $compile_deplibs " in 10522dc99b369Smrg *" -L$path/$objdir "*) 10523dc99b369Smrg func_append new_libs " -L$path/$objdir" ;; 105245eefee25Smacallan esac 10525dc99b369Smrg ;; 10526dc99b369Smrg esac 10527dc99b369Smrg done 10528dc99b369Smrg for deplib in $compile_deplibs; do 10529dc99b369Smrg case $deplib in 10530dc99b369Smrg -L*) 10531dc99b369Smrg case " $new_libs " in 10532dc99b369Smrg *" $deplib "*) ;; 10533dc99b369Smrg *) func_append new_libs " $deplib" ;; 105345eefee25Smacallan esac 10535dc99b369Smrg ;; 10536dc99b369Smrg *) func_append new_libs " $deplib" ;; 10537dc99b369Smrg esac 10538dc99b369Smrg done 105395c30ecadSmrg compile_deplibs=$new_libs 105405eefee25Smacallan 105415eefee25Smacallan 10542dc99b369Smrg func_append compile_command " $compile_deplibs" 10543dc99b369Smrg func_append finalize_command " $finalize_deplibs" 105445eefee25Smacallan 10545dc99b369Smrg if test -n "$rpath$xrpath"; then 10546dc99b369Smrg # If the user specified any rpath flags, then add them. 10547dc99b369Smrg for libdir in $rpath $xrpath; do 10548dc99b369Smrg # This is the magic to use -rpath. 10549dc99b369Smrg case "$finalize_rpath " in 10550dc99b369Smrg *" $libdir "*) ;; 10551dc99b369Smrg *) func_append finalize_rpath " $libdir" ;; 10552dc99b369Smrg esac 10553dc99b369Smrg done 10554dc99b369Smrg fi 105555eefee25Smacallan 10556dc99b369Smrg # Now hardcode the library paths 10557dc99b369Smrg rpath= 10558dc99b369Smrg hardcode_libdirs= 10559dc99b369Smrg for libdir in $compile_rpath $finalize_rpath; do 10560dc99b369Smrg if test -n "$hardcode_libdir_flag_spec"; then 10561dc99b369Smrg if test -n "$hardcode_libdir_separator"; then 10562dc99b369Smrg if test -z "$hardcode_libdirs"; then 105635c30ecadSmrg hardcode_libdirs=$libdir 10564dc99b369Smrg else 10565dc99b369Smrg # Just accumulate the unique libdirs. 10566dc99b369Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567dc99b369Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568dc99b369Smrg ;; 10569dc99b369Smrg *) 10570dc99b369Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571dc99b369Smrg ;; 10572dc99b369Smrg esac 10573dc99b369Smrg fi 105745eefee25Smacallan else 10575dc99b369Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576dc99b369Smrg func_append rpath " $flag" 105775eefee25Smacallan fi 10578dc99b369Smrg elif test -n "$runpath_var"; then 10579dc99b369Smrg case "$perm_rpath " in 10580dc99b369Smrg *" $libdir "*) ;; 10581dc99b369Smrg *) func_append perm_rpath " $libdir" ;; 10582dc99b369Smrg esac 10583dc99b369Smrg fi 10584dc99b369Smrg case $host in 10585dc99b369Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105865c30ecadSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587dc99b369Smrg case :$dllsearchpath: in 10588dc99b369Smrg *":$libdir:"*) ;; 10589dc99b369Smrg ::) dllsearchpath=$libdir;; 10590dc99b369Smrg *) func_append dllsearchpath ":$libdir";; 10591dc99b369Smrg esac 10592dc99b369Smrg case :$dllsearchpath: in 10593dc99b369Smrg *":$testbindir:"*) ;; 10594dc99b369Smrg ::) dllsearchpath=$testbindir;; 10595dc99b369Smrg *) func_append dllsearchpath ":$testbindir";; 10596dc99b369Smrg esac 10597dc99b369Smrg ;; 10598dc99b369Smrg esac 10599dc99b369Smrg done 10600dc99b369Smrg # Substitute the hardcoded libdirs into the rpath. 10601dc99b369Smrg if test -n "$hardcode_libdir_separator" && 10602dc99b369Smrg test -n "$hardcode_libdirs"; then 106035c30ecadSmrg libdir=$hardcode_libdirs 10604dc99b369Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605dc99b369Smrg fi 106065c30ecadSmrg compile_rpath=$rpath 106075eefee25Smacallan 10608dc99b369Smrg rpath= 10609dc99b369Smrg hardcode_libdirs= 10610dc99b369Smrg for libdir in $finalize_rpath; do 10611dc99b369Smrg if test -n "$hardcode_libdir_flag_spec"; then 10612dc99b369Smrg if test -n "$hardcode_libdir_separator"; then 10613dc99b369Smrg if test -z "$hardcode_libdirs"; then 106145c30ecadSmrg hardcode_libdirs=$libdir 10615dc99b369Smrg else 10616dc99b369Smrg # Just accumulate the unique libdirs. 10617dc99b369Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618dc99b369Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619dc99b369Smrg ;; 10620dc99b369Smrg *) 10621dc99b369Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622dc99b369Smrg ;; 10623dc99b369Smrg esac 10624dc99b369Smrg fi 106255eefee25Smacallan else 10626dc99b369Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627dc99b369Smrg func_append rpath " $flag" 106285eefee25Smacallan fi 10629dc99b369Smrg elif test -n "$runpath_var"; then 10630dc99b369Smrg case "$finalize_perm_rpath " in 10631dc99b369Smrg *" $libdir "*) ;; 10632dc99b369Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10633dc99b369Smrg esac 106345eefee25Smacallan fi 10635dc99b369Smrg done 10636dc99b369Smrg # Substitute the hardcoded libdirs into the rpath. 10637dc99b369Smrg if test -n "$hardcode_libdir_separator" && 10638dc99b369Smrg test -n "$hardcode_libdirs"; then 106395c30ecadSmrg libdir=$hardcode_libdirs 10640dc99b369Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641dc99b369Smrg fi 106425c30ecadSmrg finalize_rpath=$rpath 106435eefee25Smacallan 106445c30ecadSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645dc99b369Smrg # Transform all the library objects into standard objects. 10646dc99b369Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647dc99b369Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648dc99b369Smrg fi 106495eefee25Smacallan 106505c30ecadSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106515eefee25Smacallan 10652dc99b369Smrg # template prelinking step 10653dc99b369Smrg if test -n "$prelink_cmds"; then 10654dc99b369Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655dc99b369Smrg fi 106565eefee25Smacallan 106575c30ecadSmrg wrappers_required=: 10658dc99b369Smrg case $host in 10659dc99b369Smrg *cegcc* | *mingw32ce*) 10660dc99b369Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106615c30ecadSmrg wrappers_required=false 10662dc99b369Smrg ;; 10663dc99b369Smrg *cygwin* | *mingw* ) 106645c30ecadSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10665dc99b369Smrg ;; 10666dc99b369Smrg *) 106675c30ecadSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106685c30ecadSmrg wrappers_required=false 10669dc99b369Smrg fi 10670dc99b369Smrg ;; 10671dc99b369Smrg esac 106725c30ecadSmrg $wrappers_required || { 10673dc99b369Smrg # Replace the output file specification. 10674dc99b369Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106755c30ecadSmrg link_command=$compile_command$compile_rpath 106765eefee25Smacallan 10677dc99b369Smrg # We have no uninstalled library dependencies, so finalize right now. 10678dc99b369Smrg exit_status=0 10679dc99b369Smrg func_show_eval "$link_command" 'exit_status=$?' 106805eefee25Smacallan 10681dc99b369Smrg if test -n "$postlink_cmds"; then 10682dc99b369Smrg func_to_tool_file "$output" 10683dc99b369Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684dc99b369Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 106855eefee25Smacallan fi 106865eefee25Smacallan 10687dc99b369Smrg # Delete the generated files. 106885c30ecadSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 106895c30ecadSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690dc99b369Smrg fi 106915eefee25Smacallan 10692dc99b369Smrg exit $exit_status 106935c30ecadSmrg } 106945eefee25Smacallan 10695dc99b369Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696dc99b369Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697dc99b369Smrg fi 10698dc99b369Smrg if test -n "$finalize_shlibpath"; then 10699dc99b369Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700dc99b369Smrg fi 107015eefee25Smacallan 10702dc99b369Smrg compile_var= 10703dc99b369Smrg finalize_var= 10704dc99b369Smrg if test -n "$runpath_var"; then 10705dc99b369Smrg if test -n "$perm_rpath"; then 10706dc99b369Smrg # We should set the runpath_var. 10707dc99b369Smrg rpath= 10708dc99b369Smrg for dir in $perm_rpath; do 10709dc99b369Smrg func_append rpath "$dir:" 10710dc99b369Smrg done 10711dc99b369Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107125eefee25Smacallan fi 10713dc99b369Smrg if test -n "$finalize_perm_rpath"; then 10714dc99b369Smrg # We should set the runpath_var. 10715dc99b369Smrg rpath= 10716dc99b369Smrg for dir in $finalize_perm_rpath; do 10717dc99b369Smrg func_append rpath "$dir:" 10718dc99b369Smrg done 10719dc99b369Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107205eefee25Smacallan fi 10721dc99b369Smrg fi 107225eefee25Smacallan 107235c30ecadSmrg if test yes = "$no_install"; then 10724dc99b369Smrg # We don't need to create a wrapper script. 107255c30ecadSmrg link_command=$compile_var$compile_command$compile_rpath 10726dc99b369Smrg # Replace the output file specification. 10727dc99b369Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728dc99b369Smrg # Delete the old output file. 10729dc99b369Smrg $opt_dry_run || $RM $output 10730dc99b369Smrg # Link the executable and exit 10731dc99b369Smrg func_show_eval "$link_command" 'exit $?' 107325eefee25Smacallan 10733dc99b369Smrg if test -n "$postlink_cmds"; then 10734dc99b369Smrg func_to_tool_file "$output" 10735dc99b369Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736dc99b369Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107375eefee25Smacallan fi 10738dc99b369Smrg 107395eefee25Smacallan exit $EXIT_SUCCESS 10740dc99b369Smrg fi 107415eefee25Smacallan 107425c30ecadSmrg case $hardcode_action,$fast_install in 107435c30ecadSmrg relink,*) 107445c30ecadSmrg # Fast installation is not supported 107455c30ecadSmrg link_command=$compile_var$compile_command$compile_rpath 107465c30ecadSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747dc99b369Smrg 107485c30ecadSmrg func_warning "this platform does not like uninstalled shared libraries" 107495c30ecadSmrg func_warning "'$output' will be relinked during installation" 107505c30ecadSmrg ;; 107515c30ecadSmrg *,yes) 107525c30ecadSmrg link_command=$finalize_var$compile_command$finalize_rpath 107535c30ecadSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107545c30ecadSmrg ;; 107555c30ecadSmrg *,no) 107565c30ecadSmrg link_command=$compile_var$compile_command$compile_rpath 107575c30ecadSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107585c30ecadSmrg ;; 107595c30ecadSmrg *,needless) 107605c30ecadSmrg link_command=$finalize_var$compile_command$finalize_rpath 107615c30ecadSmrg relink_command= 107625c30ecadSmrg ;; 107635c30ecadSmrg esac 107645eefee25Smacallan 10765dc99b369Smrg # Replace the output file specification. 10766dc99b369Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107675eefee25Smacallan 10768dc99b369Smrg # Delete the old output files. 10769dc99b369Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107705eefee25Smacallan 10771dc99b369Smrg func_show_eval "$link_command" 'exit $?' 107725eefee25Smacallan 10773dc99b369Smrg if test -n "$postlink_cmds"; then 10774dc99b369Smrg func_to_tool_file "$output_objdir/$outputname" 10775dc99b369Smrg 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'` 10776dc99b369Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777dc99b369Smrg fi 107785eefee25Smacallan 10779dc99b369Smrg # Now create the wrapper script. 10780dc99b369Smrg func_verbose "creating $output" 107815eefee25Smacallan 10782dc99b369Smrg # Quote the relink command for shipping. 10783dc99b369Smrg if test -n "$relink_command"; then 10784dc99b369Smrg # Preserve any variables that may affect compiler behavior 10785dc99b369Smrg for var in $variables_saved_for_relink; do 10786dc99b369Smrg if eval test -z \"\${$var+set}\"; then 10787dc99b369Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788dc99b369Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10789dc99b369Smrg relink_command="$var=; export $var; $relink_command" 107905eefee25Smacallan else 107915c30ecadSmrg func_quote_arg pretty "$var_value" 107925c30ecadSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107935eefee25Smacallan fi 10794dc99b369Smrg done 107955c30ecadSmrg func_quote eval cd "`pwd`" 107965c30ecadSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107975c30ecadSmrg relink_command=$func_quote_arg_unquoted_result 10798dc99b369Smrg fi 10799dc99b369Smrg 10800dc99b369Smrg # Only actually do things if not in dry run mode. 10801dc99b369Smrg $opt_dry_run || { 10802dc99b369Smrg # win32 will think the script is a binary if it has 10803dc99b369Smrg # a .exe suffix, so we strip it off here. 10804dc99b369Smrg case $output in 10805dc99b369Smrg *.exe) func_stripname '' '.exe' "$output" 10806dc99b369Smrg output=$func_stripname_result ;; 108075eefee25Smacallan esac 10808dc99b369Smrg # test for cygwin because mv fails w/o .exe extensions 10809dc99b369Smrg case $host in 10810dc99b369Smrg *cygwin*) 10811dc99b369Smrg exeext=.exe 10812dc99b369Smrg func_stripname '' '.exe' "$outputname" 10813dc99b369Smrg outputname=$func_stripname_result ;; 10814dc99b369Smrg *) exeext= ;; 10815dc99b369Smrg esac 10816dc99b369Smrg case $host in 10817dc99b369Smrg *cygwin* | *mingw* ) 10818dc99b369Smrg func_dirname_and_basename "$output" "" "." 10819dc99b369Smrg output_name=$func_basename_result 10820dc99b369Smrg output_path=$func_dirname_result 108215c30ecadSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108225c30ecadSmrg cwrapper=$output_path/$output_name.exe 10823dc99b369Smrg $RM $cwrappersource $cwrapper 10824dc99b369Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825dc99b369Smrg 10826dc99b369Smrg func_emit_cwrapperexe_src > $cwrappersource 10827dc99b369Smrg 10828dc99b369Smrg # The wrapper executable is built using the $host compiler, 10829dc99b369Smrg # because it contains $host paths and files. If cross- 10830dc99b369Smrg # compiling, it, like the target executable, must be 10831dc99b369Smrg # executed on the $host or under an emulation environment. 10832dc99b369Smrg $opt_dry_run || { 10833dc99b369Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834dc99b369Smrg $STRIP $cwrapper 10835dc99b369Smrg } 108365eefee25Smacallan 10837dc99b369Smrg # Now, create the wrapper script for func_source use: 10838dc99b369Smrg func_ltwrapper_scriptname $cwrapper 10839dc99b369Smrg $RM $func_ltwrapper_scriptname_result 10840dc99b369Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841dc99b369Smrg $opt_dry_run || { 10842dc99b369Smrg # note: this script will not be executed, so do not chmod. 108435c30ecadSmrg if test "x$build" = "x$host"; then 10844dc99b369Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845dc99b369Smrg else 10846dc99b369Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847dc99b369Smrg fi 10848dc99b369Smrg } 10849dc99b369Smrg ;; 10850dc99b369Smrg * ) 10851dc99b369Smrg $RM $output 10852dc99b369Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108535eefee25Smacallan 10854dc99b369Smrg func_emit_wrapper no > $output 10855dc99b369Smrg chmod +x $output 10856dc99b369Smrg ;; 10857dc99b369Smrg esac 10858dc99b369Smrg } 10859dc99b369Smrg exit $EXIT_SUCCESS 10860dc99b369Smrg ;; 10861dc99b369Smrg esac 108625eefee25Smacallan 10863dc99b369Smrg # See if we need to build an old-fashioned archive. 10864dc99b369Smrg for oldlib in $oldlibs; do 108655eefee25Smacallan 108665c30ecadSmrg case $build_libtool_libs in 108675c30ecadSmrg convenience) 108685c30ecadSmrg oldobjs="$libobjs_save $symfileobj" 108695c30ecadSmrg addlibs=$convenience 10870dc99b369Smrg build_libtool_libs=no 108715c30ecadSmrg ;; 108725c30ecadSmrg module) 108735c30ecadSmrg oldobjs=$libobjs_save 108745c30ecadSmrg addlibs=$old_convenience 108755c30ecadSmrg build_libtool_libs=no 108765c30ecadSmrg ;; 108775c30ecadSmrg *) 10878dc99b369Smrg oldobjs="$old_deplibs $non_pic_objects" 108795c30ecadSmrg $preload && test -f "$symfileobj" \ 108805c30ecadSmrg && func_append oldobjs " $symfileobj" 108815c30ecadSmrg addlibs=$old_convenience 108825c30ecadSmrg ;; 108835c30ecadSmrg esac 108845eefee25Smacallan 10885dc99b369Smrg if test -n "$addlibs"; then 108865c30ecadSmrg gentop=$output_objdir/${outputname}x 10887dc99b369Smrg func_append generated " $gentop" 108885eefee25Smacallan 10889dc99b369Smrg func_extract_archives $gentop $addlibs 10890dc99b369Smrg func_append oldobjs " $func_extract_archives_result" 10891dc99b369Smrg fi 108925eefee25Smacallan 10893dc99b369Smrg # Do each command in the archive commands. 108945c30ecadSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895dc99b369Smrg cmds=$old_archive_from_new_cmds 10896dc99b369Smrg else 108975eefee25Smacallan 10898dc99b369Smrg # Add any objects from preloaded convenience libraries 10899dc99b369Smrg if test -n "$dlprefiles"; then 109005c30ecadSmrg gentop=$output_objdir/${outputname}x 10901dc99b369Smrg func_append generated " $gentop" 109025eefee25Smacallan 10903dc99b369Smrg func_extract_archives $gentop $dlprefiles 10904dc99b369Smrg func_append oldobjs " $func_extract_archives_result" 10905dc99b369Smrg fi 109065eefee25Smacallan 10907dc99b369Smrg # POSIX demands no paths to be encoded in archives. We have 10908dc99b369Smrg # to avoid creating archives with duplicate basenames if we 10909dc99b369Smrg # might have to extract them afterwards, e.g., when creating a 10910dc99b369Smrg # static archive out of a convenience library, or when linking 10911dc99b369Smrg # the entirety of a libtool archive into another (currently 10912dc99b369Smrg # not supported by libtool). 10913dc99b369Smrg if (for obj in $oldobjs 10914dc99b369Smrg do 10915dc99b369Smrg func_basename "$obj" 10916dc99b369Smrg $ECHO "$func_basename_result" 10917dc99b369Smrg done | sort | sort -uc >/dev/null 2>&1); then 10918dc99b369Smrg : 10919dc99b369Smrg else 10920dc99b369Smrg echo "copying selected object files to avoid basename conflicts..." 109215c30ecadSmrg gentop=$output_objdir/${outputname}x 10922dc99b369Smrg func_append generated " $gentop" 10923dc99b369Smrg func_mkdir_p "$gentop" 10924dc99b369Smrg save_oldobjs=$oldobjs 10925dc99b369Smrg oldobjs= 10926dc99b369Smrg counter=1 10927dc99b369Smrg for obj in $save_oldobjs 10928dc99b369Smrg do 10929dc99b369Smrg func_basename "$obj" 109305c30ecadSmrg objbase=$func_basename_result 10931dc99b369Smrg case " $oldobjs " in 10932dc99b369Smrg " ") oldobjs=$obj ;; 10933dc99b369Smrg *[\ /]"$objbase "*) 10934dc99b369Smrg while :; do 10935dc99b369Smrg # Make sure we don't pick an alternate name that also 10936dc99b369Smrg # overlaps. 10937dc99b369Smrg newobj=lt$counter-$objbase 10938dc99b369Smrg func_arith $counter + 1 10939dc99b369Smrg counter=$func_arith_result 10940dc99b369Smrg case " $oldobjs " in 10941dc99b369Smrg *[\ /]"$newobj "*) ;; 10942dc99b369Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943dc99b369Smrg esac 10944dc99b369Smrg done 10945dc99b369Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946dc99b369Smrg func_append oldobjs " $gentop/$newobj" 10947dc99b369Smrg ;; 10948dc99b369Smrg *) func_append oldobjs " $obj" ;; 10949dc99b369Smrg esac 109505eefee25Smacallan done 109515eefee25Smacallan fi 109525c30ecadSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109535c30ecadSmrg tool_oldlib=$func_to_tool_file_result 10954dc99b369Smrg eval cmds=\"$old_archive_cmds\" 109555eefee25Smacallan 10956dc99b369Smrg func_len " $cmds" 10957dc99b369Smrg len=$func_len_result 10958dc99b369Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959dc99b369Smrg cmds=$old_archive_cmds 10960dc99b369Smrg elif test -n "$archiver_list_spec"; then 10961dc99b369Smrg func_verbose "using command file archive linking..." 10962dc99b369Smrg for obj in $oldobjs 10963dc99b369Smrg do 10964dc99b369Smrg func_to_tool_file "$obj" 10965dc99b369Smrg $ECHO "$func_to_tool_file_result" 10966dc99b369Smrg done > $output_objdir/$libname.libcmd 10967dc99b369Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968dc99b369Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969dc99b369Smrg cmds=$old_archive_cmds 10970dc99b369Smrg else 10971dc99b369Smrg # the command line is too long to link in one step, link in parts 10972dc99b369Smrg func_verbose "using piecewise archive linking..." 10973dc99b369Smrg save_RANLIB=$RANLIB 10974dc99b369Smrg RANLIB=: 10975dc99b369Smrg objlist= 10976dc99b369Smrg concat_cmds= 10977dc99b369Smrg save_oldobjs=$oldobjs 10978dc99b369Smrg oldobjs= 10979dc99b369Smrg # Is there a better way of finding the last object in the list? 10980dc99b369Smrg for obj in $save_oldobjs 10981dc99b369Smrg do 10982dc99b369Smrg last_oldobj=$obj 10983dc99b369Smrg done 10984dc99b369Smrg eval test_cmds=\"$old_archive_cmds\" 10985dc99b369Smrg func_len " $test_cmds" 10986dc99b369Smrg len0=$func_len_result 10987dc99b369Smrg len=$len0 10988dc99b369Smrg for obj in $save_oldobjs 10989dc99b369Smrg do 10990dc99b369Smrg func_len " $obj" 10991dc99b369Smrg func_arith $len + $func_len_result 10992dc99b369Smrg len=$func_arith_result 10993dc99b369Smrg func_append objlist " $obj" 10994dc99b369Smrg if test "$len" -lt "$max_cmd_len"; then 10995dc99b369Smrg : 10996dc99b369Smrg else 10997dc99b369Smrg # the above command should be used before it gets too long 10998dc99b369Smrg oldobjs=$objlist 109995c30ecadSmrg if test "$obj" = "$last_oldobj"; then 11000dc99b369Smrg RANLIB=$save_RANLIB 11001dc99b369Smrg fi 11002dc99b369Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110035c30ecadSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004dc99b369Smrg objlist= 11005dc99b369Smrg len=$len0 11006dc99b369Smrg fi 11007dc99b369Smrg done 11008dc99b369Smrg RANLIB=$save_RANLIB 11009dc99b369Smrg oldobjs=$objlist 110105c30ecadSmrg if test -z "$oldobjs"; then 11011dc99b369Smrg eval cmds=\"\$concat_cmds\" 11012dc99b369Smrg else 11013dc99b369Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014dc99b369Smrg fi 11015dc99b369Smrg fi 11016dc99b369Smrg fi 11017dc99b369Smrg func_execute_cmds "$cmds" 'exit $?' 110185eefee25Smacallan done 110195eefee25Smacallan 11020dc99b369Smrg test -n "$generated" && \ 11021dc99b369Smrg func_show_eval "${RM}r$generated" 110225eefee25Smacallan 11023dc99b369Smrg # Now create the libtool archive. 11024dc99b369Smrg case $output in 11025dc99b369Smrg *.la) 11026dc99b369Smrg old_library= 110275c30ecadSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028dc99b369Smrg func_verbose "creating $output" 110295eefee25Smacallan 11030dc99b369Smrg # Preserve any variables that may affect compiler behavior 11031dc99b369Smrg for var in $variables_saved_for_relink; do 11032dc99b369Smrg if eval test -z \"\${$var+set}\"; then 11033dc99b369Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034dc99b369Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11035dc99b369Smrg relink_command="$var=; export $var; $relink_command" 110365eefee25Smacallan else 110375c30ecadSmrg func_quote_arg pretty,unquoted "$var_value" 110385c30ecadSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110395eefee25Smacallan fi 11040dc99b369Smrg done 11041dc99b369Smrg # Quote the link command for shipping. 110425c30ecadSmrg func_quote eval cd "`pwd`" 110435c30ecadSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110445c30ecadSmrg func_quote_arg pretty,unquoted "$relink_command" 110455c30ecadSmrg relink_command=$func_quote_arg_unquoted_result 110465c30ecadSmrg if test yes = "$hardcode_automatic"; then 11047dc99b369Smrg relink_command= 11048dc99b369Smrg fi 110495eefee25Smacallan 11050dc99b369Smrg # Only create the output if not a dry run. 11051dc99b369Smrg $opt_dry_run || { 11052dc99b369Smrg for installed in no yes; do 110535c30ecadSmrg if test yes = "$installed"; then 11054dc99b369Smrg if test -z "$install_libdir"; then 11055dc99b369Smrg break 11056dc99b369Smrg fi 110575c30ecadSmrg output=$output_objdir/${outputname}i 11058dc99b369Smrg # Replace all uninstalled libtool libraries with the installed ones 11059dc99b369Smrg newdependency_libs= 11060dc99b369Smrg for deplib in $dependency_libs; do 11061dc99b369Smrg case $deplib in 11062dc99b369Smrg *.la) 11063dc99b369Smrg func_basename "$deplib" 110645c30ecadSmrg name=$func_basename_result 110655c30ecadSmrg func_resolve_sysroot "$deplib" 110665c30ecadSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067dc99b369Smrg test -z "$libdir" && \ 110685c30ecadSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069dc99b369Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070dc99b369Smrg ;; 11071dc99b369Smrg -L*) 11072dc99b369Smrg func_stripname -L '' "$deplib" 11073dc99b369Smrg func_replace_sysroot "$func_stripname_result" 11074dc99b369Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075dc99b369Smrg ;; 11076dc99b369Smrg -R*) 11077dc99b369Smrg func_stripname -R '' "$deplib" 11078dc99b369Smrg func_replace_sysroot "$func_stripname_result" 11079dc99b369Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080dc99b369Smrg ;; 11081dc99b369Smrg *) func_append newdependency_libs " $deplib" ;; 11082dc99b369Smrg esac 11083dc99b369Smrg done 110845c30ecadSmrg dependency_libs=$newdependency_libs 11085dc99b369Smrg newdlfiles= 11086dc99b369Smrg 11087dc99b369Smrg for lib in $dlfiles; do 11088dc99b369Smrg case $lib in 11089dc99b369Smrg *.la) 11090dc99b369Smrg func_basename "$lib" 110915c30ecadSmrg name=$func_basename_result 110925c30ecadSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093dc99b369Smrg test -z "$libdir" && \ 110945c30ecadSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095dc99b369Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096dc99b369Smrg ;; 11097dc99b369Smrg *) func_append newdlfiles " $lib" ;; 11098dc99b369Smrg esac 11099dc99b369Smrg done 111005c30ecadSmrg dlfiles=$newdlfiles 11101dc99b369Smrg newdlprefiles= 11102dc99b369Smrg for lib in $dlprefiles; do 11103dc99b369Smrg case $lib in 11104dc99b369Smrg *.la) 11105dc99b369Smrg # Only pass preopened files to the pseudo-archive (for 11106dc99b369Smrg # eventual linking with the app. that links it) if we 11107dc99b369Smrg # didn't already link the preopened objects directly into 11108dc99b369Smrg # the library: 11109dc99b369Smrg func_basename "$lib" 111105c30ecadSmrg name=$func_basename_result 111115c30ecadSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112dc99b369Smrg test -z "$libdir" && \ 111135c30ecadSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114dc99b369Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115dc99b369Smrg ;; 11116dc99b369Smrg esac 11117dc99b369Smrg done 111185c30ecadSmrg dlprefiles=$newdlprefiles 11119dc99b369Smrg else 11120dc99b369Smrg newdlfiles= 11121dc99b369Smrg for lib in $dlfiles; do 11122dc99b369Smrg case $lib in 111235c30ecadSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124dc99b369Smrg *) abs=`pwd`"/$lib" ;; 11125dc99b369Smrg esac 11126dc99b369Smrg func_append newdlfiles " $abs" 11127dc99b369Smrg done 111285c30ecadSmrg dlfiles=$newdlfiles 11129dc99b369Smrg newdlprefiles= 11130dc99b369Smrg for lib in $dlprefiles; do 11131dc99b369Smrg case $lib in 111325c30ecadSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133dc99b369Smrg *) abs=`pwd`"/$lib" ;; 11134dc99b369Smrg esac 11135dc99b369Smrg func_append newdlprefiles " $abs" 11136dc99b369Smrg done 111375c30ecadSmrg dlprefiles=$newdlprefiles 11138dc99b369Smrg fi 11139dc99b369Smrg $RM $output 11140dc99b369Smrg # place dlname in correct position for cygwin 11141dc99b369Smrg # In fact, it would be nice if we could use this code for all target 11142dc99b369Smrg # systems that can't hard-code library paths into their executables 11143dc99b369Smrg # and that have no shared library path variable independent of PATH, 11144dc99b369Smrg # but it turns out we can't easily determine that from inspecting 11145dc99b369Smrg # libtool variables, so we have to hard-code the OSs to which it 11146dc99b369Smrg # applies here; at the moment, that means platforms that use the PE 11147dc99b369Smrg # object format with DLL files. See the long comment at the top of 11148dc99b369Smrg # tests/bindir.at for full details. 11149dc99b369Smrg tdlname=$dlname 11150dc99b369Smrg case $host,$output,$installed,$module,$dlname in 11151dc99b369Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152dc99b369Smrg # If a -bindir argument was supplied, place the dll there. 111535c30ecadSmrg if test -n "$bindir"; then 11154dc99b369Smrg func_relative_path "$install_libdir" "$bindir" 111555c30ecadSmrg tdlname=$func_relative_path_result/$dlname 11156dc99b369Smrg else 11157dc99b369Smrg # Otherwise fall back on heuristic. 11158dc99b369Smrg tdlname=../bin/$dlname 11159dc99b369Smrg fi 11160dc99b369Smrg ;; 11161dc99b369Smrg esac 11162dc99b369Smrg $ECHO > $output "\ 11163dc99b369Smrg# $outputname - a libtool library file 111645c30ecadSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165dc99b369Smrg# 11166dc99b369Smrg# Please DO NOT delete this file! 11167dc99b369Smrg# It is necessary for linking the library. 111685eefee25Smacallan 11169dc99b369Smrg# The name that we can dlopen(3). 11170dc99b369Smrgdlname='$tdlname' 111715eefee25Smacallan 11172dc99b369Smrg# Names of this library. 11173dc99b369Smrglibrary_names='$library_names' 111745eefee25Smacallan 11175dc99b369Smrg# The name of the static archive. 11176dc99b369Smrgold_library='$old_library' 111775eefee25Smacallan 111785c30ecadSmrg# Linker flags that cannot go in dependency_libs. 11179dc99b369Smrginherited_linker_flags='$new_inherited_linker_flags' 111805eefee25Smacallan 11181dc99b369Smrg# Libraries that this one depends upon. 11182dc99b369Smrgdependency_libs='$dependency_libs' 111835eefee25Smacallan 11184dc99b369Smrg# Names of additional weak libraries provided by this library 11185dc99b369Smrgweak_library_names='$weak_libs' 111865eefee25Smacallan 11187dc99b369Smrg# Version information for $libname. 11188dc99b369Smrgcurrent=$current 11189dc99b369Smrgage=$age 11190dc99b369Smrgrevision=$revision 111915eefee25Smacallan 11192dc99b369Smrg# Is this an already installed library? 11193dc99b369Smrginstalled=$installed 111945eefee25Smacallan 11195dc99b369Smrg# Should we warn about portability when linking against -modules? 11196dc99b369Smrgshouldnotlink=$module 111975eefee25Smacallan 11198dc99b369Smrg# Files to dlopen/dlpreopen 11199dc99b369Smrgdlopen='$dlfiles' 11200dc99b369Smrgdlpreopen='$dlprefiles' 112015eefee25Smacallan 11202dc99b369Smrg# Directory that this library needs to be installed in: 11203dc99b369Smrglibdir='$install_libdir'" 112045c30ecadSmrg if test no,yes = "$installed,$need_relink"; then 11205dc99b369Smrg $ECHO >> $output "\ 11206dc99b369Smrgrelink_command=\"$relink_command\"" 11207dc99b369Smrg fi 11208dc99b369Smrg done 11209dc99b369Smrg } 112105eefee25Smacallan 11211dc99b369Smrg # Do a symbolic link so that the libtool archive can be found in 11212dc99b369Smrg # LD_LIBRARY_PATH before the program is installed. 11213dc99b369Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214dc99b369Smrg ;; 11215dc99b369Smrg esac 11216dc99b369Smrg exit $EXIT_SUCCESS 11217dc99b369Smrg} 112185eefee25Smacallan 112195c30ecadSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112205c30ecadSmrg func_mode_link ${1+"$@"} 112215c30ecadSmrgfi 112225eefee25Smacallan 112235eefee25Smacallan 11224dc99b369Smrg# func_mode_uninstall arg... 11225dc99b369Smrgfunc_mode_uninstall () 11226dc99b369Smrg{ 112275c30ecadSmrg $debug_cmd 112285c30ecadSmrg 112295c30ecadSmrg RM=$nonopt 112305eefee25Smacallan files= 112315c30ecadSmrg rmforce=false 112325eefee25Smacallan exit_status=0 112335eefee25Smacallan 112345eefee25Smacallan # This variable tells wrapper scripts just to set variables rather 112355eefee25Smacallan # than running their programs. 112365c30ecadSmrg libtool_install_magic=$magic 112375eefee25Smacallan 112385eefee25Smacallan for arg 112395eefee25Smacallan do 112405eefee25Smacallan case $arg in 112415c30ecadSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242dc99b369Smrg -*) func_append RM " $arg" ;; 11243dc99b369Smrg *) func_append files " $arg" ;; 112445eefee25Smacallan esac 112455eefee25Smacallan done 112465eefee25Smacallan 11247dc99b369Smrg test -z "$RM" && \ 11248dc99b369Smrg func_fatal_help "you must specify an RM program" 112495eefee25Smacallan 112505eefee25Smacallan rmdirs= 112515eefee25Smacallan 112525eefee25Smacallan for file in $files; do 11253dc99b369Smrg func_dirname "$file" "" "." 112545c30ecadSmrg dir=$func_dirname_result 112555c30ecadSmrg if test . = "$dir"; then 112565c30ecadSmrg odir=$objdir 112575eefee25Smacallan else 112585c30ecadSmrg odir=$dir/$objdir 112595eefee25Smacallan fi 11260dc99b369Smrg func_basename "$file" 112615c30ecadSmrg name=$func_basename_result 112625c30ecadSmrg test uninstall = "$opt_mode" && odir=$dir 112635eefee25Smacallan 11264dc99b369Smrg # Remember odir for removal later, being careful to avoid duplicates 112655c30ecadSmrg if test clean = "$opt_mode"; then 112665eefee25Smacallan case " $rmdirs " in 11267dc99b369Smrg *" $odir "*) ;; 11268dc99b369Smrg *) func_append rmdirs " $odir" ;; 112695eefee25Smacallan esac 112705eefee25Smacallan fi 112715eefee25Smacallan 112725eefee25Smacallan # Don't error if the file doesn't exist and rm -f was used. 11273dc99b369Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11274dc99b369Smrg { test -h "$file"; } >/dev/null 2>&1 || 11275dc99b369Smrg test -f "$file"; then 112765eefee25Smacallan : 112775eefee25Smacallan elif test -d "$file"; then 112785eefee25Smacallan exit_status=1 112795eefee25Smacallan continue 112805c30ecadSmrg elif $rmforce; then 112815eefee25Smacallan continue 112825eefee25Smacallan fi 112835eefee25Smacallan 112845c30ecadSmrg rmfiles=$file 112855eefee25Smacallan 112865eefee25Smacallan case $name in 112875eefee25Smacallan *.la) 112885eefee25Smacallan # Possibly a libtool archive, so verify it. 11289dc99b369Smrg if func_lalib_p "$file"; then 11290dc99b369Smrg func_source $dir/$name 112915eefee25Smacallan 112925eefee25Smacallan # Delete the libtool libraries and symlinks. 112935eefee25Smacallan for n in $library_names; do 11294dc99b369Smrg func_append rmfiles " $odir/$n" 112955eefee25Smacallan done 11296dc99b369Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112975eefee25Smacallan 112985c30ecadSmrg case $opt_mode in 112995eefee25Smacallan clean) 11300dc99b369Smrg case " $library_names " in 113015eefee25Smacallan *" $dlname "*) ;; 11302dc99b369Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113035eefee25Smacallan esac 11304dc99b369Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113055eefee25Smacallan ;; 113065eefee25Smacallan uninstall) 113075eefee25Smacallan if test -n "$library_names"; then 113085eefee25Smacallan # Do each command in the postuninstall commands. 113095c30ecadSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113105eefee25Smacallan fi 113115eefee25Smacallan 113125eefee25Smacallan if test -n "$old_library"; then 113135eefee25Smacallan # Do each command in the old_postuninstall commands. 113145c30ecadSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113155eefee25Smacallan fi 113165eefee25Smacallan # FIXME: should reinstall the best remaining shared library. 113175eefee25Smacallan ;; 113185eefee25Smacallan esac 113195eefee25Smacallan fi 113205eefee25Smacallan ;; 113215eefee25Smacallan 113225eefee25Smacallan *.lo) 113235eefee25Smacallan # Possibly a libtool object, so verify it. 11324dc99b369Smrg if func_lalib_p "$file"; then 113255eefee25Smacallan 113265eefee25Smacallan # Read the .lo file 11327dc99b369Smrg func_source $dir/$name 113285eefee25Smacallan 113295eefee25Smacallan # Add PIC object to the list of files to remove. 113305c30ecadSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331dc99b369Smrg func_append rmfiles " $dir/$pic_object" 113325eefee25Smacallan fi 113335eefee25Smacallan 113345eefee25Smacallan # Add non-PIC object to the list of files to remove. 113355c30ecadSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336dc99b369Smrg func_append rmfiles " $dir/$non_pic_object" 113375eefee25Smacallan fi 113385eefee25Smacallan fi 113395eefee25Smacallan ;; 113405eefee25Smacallan 113415eefee25Smacallan *) 113425c30ecadSmrg if test clean = "$opt_mode"; then 113435eefee25Smacallan noexename=$name 113445eefee25Smacallan case $file in 113455eefee25Smacallan *.exe) 11346dc99b369Smrg func_stripname '' '.exe' "$file" 11347dc99b369Smrg file=$func_stripname_result 11348dc99b369Smrg func_stripname '' '.exe' "$name" 11349dc99b369Smrg noexename=$func_stripname_result 113505eefee25Smacallan # $file with .exe has already been added to rmfiles, 113515eefee25Smacallan # add $file without .exe 11352dc99b369Smrg func_append rmfiles " $file" 113535eefee25Smacallan ;; 113545eefee25Smacallan esac 113555eefee25Smacallan # Do a test to see if this is a libtool program. 11356dc99b369Smrg if func_ltwrapper_p "$file"; then 11357dc99b369Smrg if func_ltwrapper_executable_p "$file"; then 11358dc99b369Smrg func_ltwrapper_scriptname "$file" 11359dc99b369Smrg relink_command= 11360dc99b369Smrg func_source $func_ltwrapper_scriptname_result 11361dc99b369Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362dc99b369Smrg else 11363dc99b369Smrg relink_command= 11364dc99b369Smrg func_source $dir/$noexename 11365dc99b369Smrg fi 113665eefee25Smacallan 113675eefee25Smacallan # note $name still contains .exe if it was in $file originally 113685eefee25Smacallan # as does the version of $file that was added into $rmfiles 113695c30ecadSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113705c30ecadSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371dc99b369Smrg func_append rmfiles " $odir/lt-$name" 113725eefee25Smacallan fi 113735c30ecadSmrg if test "X$noexename" != "X$name"; then 113745c30ecadSmrg func_append rmfiles " $odir/lt-$noexename.c" 113755eefee25Smacallan fi 113765eefee25Smacallan fi 113775eefee25Smacallan fi 113785eefee25Smacallan ;; 113795eefee25Smacallan esac 11380dc99b369Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113815eefee25Smacallan done 113825eefee25Smacallan 113835c30ecadSmrg # Try to remove the $objdir's in the directories where we deleted files 113845eefee25Smacallan for dir in $rmdirs; do 113855eefee25Smacallan if test -d "$dir"; then 11386dc99b369Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113875eefee25Smacallan fi 113885eefee25Smacallan done 113895eefee25Smacallan 113905eefee25Smacallan exit $exit_status 11391dc99b369Smrg} 113925eefee25Smacallan 113935c30ecadSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113945c30ecadSmrg func_mode_uninstall ${1+"$@"} 113955c30ecadSmrgfi 113965eefee25Smacallan 11397dc99b369Smrgtest -z "$opt_mode" && { 113985c30ecadSmrg help=$generic_help 11399dc99b369Smrg func_fatal_help "you must specify a MODE" 11400dc99b369Smrg} 11401dc99b369Smrg 11402dc99b369Smrgtest -z "$exec_cmd" && \ 114035c30ecadSmrg func_fatal_help "invalid operation mode '$opt_mode'" 114045eefee25Smacallan 114055eefee25Smacallanif test -n "$exec_cmd"; then 11406dc99b369Smrg eval exec "$exec_cmd" 114075eefee25Smacallan exit $EXIT_FAILURE 114085eefee25Smacallanfi 114095eefee25Smacallan 11410dc99b369Smrgexit $exit_status 114115eefee25Smacallan 114125eefee25Smacallan 114135eefee25Smacallan# The TAGs below are defined such that we never get into a situation 114145c30ecadSmrg# where we disable both kinds of libraries. Given conflicting 114155eefee25Smacallan# choices, we go for a static library, that is the most portable, 114165eefee25Smacallan# since we can't tell whether shared libraries were disabled because 114175eefee25Smacallan# the user asked for that or because the platform doesn't support 114185eefee25Smacallan# them. This is particularly important on AIX, because we don't 114195eefee25Smacallan# support having both static and shared libraries enabled at the same 114205eefee25Smacallan# time on that platform, so we default to a shared-only configuration. 114215eefee25Smacallan# If a disable-shared tag is given, we'll fallback to a static-only 114225eefee25Smacallan# configuration. But we'll never go from static-only to shared-only. 114235eefee25Smacallan 114245eefee25Smacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425dc99b369Smrgbuild_libtool_libs=no 11426dc99b369Smrgbuild_old_libs=yes 114275eefee25Smacallan# ### END LIBTOOL TAG CONFIG: disable-shared 114285eefee25Smacallan 114295eefee25Smacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430dc99b369Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114315eefee25Smacallan# ### END LIBTOOL TAG CONFIG: disable-static 114325eefee25Smacallan 114335eefee25Smacallan# Local Variables: 114345eefee25Smacallan# mode:shell-script 114355eefee25Smacallan# sh-indentation:2 114365eefee25Smacallan# End: 11437