ltmain.sh revision 5ec34c4c
15ec34c4cSmrg#! /bin/sh 25ec34c4cSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 35ec34c4cSmrg## by inline-source v2014-01-03.01 4994689c1Smrg 55ec34c4cSmrg# libtool (GNU libtool) 2.4.6 65ec34c4cSmrg# Provide generalized library-building support services. 7994689c1Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8994689c1Smrg 95ec34c4cSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10994689c1Smrg# This is free software; see the source for copying conditions. There is NO 11994689c1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12994689c1Smrg 13994689c1Smrg# GNU Libtool is free software; you can redistribute it and/or modify 147a84e134Smrg# it under the terms of the GNU General Public License as published by 157a84e134Smrg# the Free Software Foundation; either version 2 of the License, or 167a84e134Smrg# (at your option) any later version. 177a84e134Smrg# 18994689c1Smrg# As a special exception to the GNU General Public License, 19994689c1Smrg# if you distribute this file as part of a program or library that 20994689c1Smrg# is built using GNU Libtool, you may include this file under the 21994689c1Smrg# same distribution terms that you use for the rest of that program. 22994689c1Smrg# 23994689c1Smrg# GNU Libtool is distributed in the hope that it will be useful, but 247a84e134Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 257a84e134Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 267a84e134Smrg# General Public License for more details. 277a84e134Smrg# 287a84e134Smrg# You should have received a copy of the GNU General Public License 295ec34c4cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30e1e1713cSmrg 317a84e134Smrg 32994689c1SmrgPROGRAM=libtool 337a84e134SmrgPACKAGE=libtool 345ec34c4cSmrgVERSION=2.4.6 355ec34c4cSmrgpackage_revision=2.4.6 36ab902922Smrg 375ec34c4cSmrg 385ec34c4cSmrg## ------ ## 395ec34c4cSmrg## Usage. ## 405ec34c4cSmrg## ------ ## 415ec34c4cSmrg 425ec34c4cSmrg# Run './libtool --help' for help with using this script from the 435ec34c4cSmrg# command line. 445ec34c4cSmrg 455ec34c4cSmrg 465ec34c4cSmrg## ------------------------------- ## 475ec34c4cSmrg## User overridable command paths. ## 485ec34c4cSmrg## ------------------------------- ## 495ec34c4cSmrg 505ec34c4cSmrg# After configure completes, it has a better idea of some of the 515ec34c4cSmrg# shell tools we need than the defaults used by the functions shared 525ec34c4cSmrg# with bootstrap, so set those here where they can still be over- 535ec34c4cSmrg# ridden by the user, but otherwise take precedence. 545ec34c4cSmrg 555ec34c4cSmrg: ${AUTOCONF="autoconf"} 565ec34c4cSmrg: ${AUTOMAKE="automake"} 575ec34c4cSmrg 585ec34c4cSmrg 595ec34c4cSmrg## -------------------------- ## 605ec34c4cSmrg## Source external libraries. ## 615ec34c4cSmrg## -------------------------- ## 625ec34c4cSmrg 635ec34c4cSmrg# Much of our low-level functionality needs to be sourced from external 645ec34c4cSmrg# libraries, which are installed to $pkgauxdir. 655ec34c4cSmrg 665ec34c4cSmrg# Set a version string for this script. 675ec34c4cSmrgscriptversion=2015-10-04.22; # UTC 685ec34c4cSmrg 695ec34c4cSmrg# General shell script boiler plate, and helper functions. 705ec34c4cSmrg# Written by Gary V. Vaughan, 2004 715ec34c4cSmrg 725ec34c4cSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 735ec34c4cSmrg# This is free software; see the source for copying conditions. There is NO 745ec34c4cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 755ec34c4cSmrg 765ec34c4cSmrg# This program is free software; you can redistribute it and/or modify 775ec34c4cSmrg# it under the terms of the GNU General Public License as published by 785ec34c4cSmrg# the Free Software Foundation; either version 3 of the License, or 795ec34c4cSmrg# (at your option) any later version. 805ec34c4cSmrg 815ec34c4cSmrg# As a special exception to the GNU General Public License, if you distribute 825ec34c4cSmrg# this file as part of a program or library that is built using GNU Libtool, 835ec34c4cSmrg# you may include this file under the same distribution terms that you use 845ec34c4cSmrg# for the rest of that program. 855ec34c4cSmrg 865ec34c4cSmrg# This program is distributed in the hope that it will be useful, 875ec34c4cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 885ec34c4cSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 895ec34c4cSmrg# General Public License for more details. 905ec34c4cSmrg 915ec34c4cSmrg# You should have received a copy of the GNU General Public License 925ec34c4cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 935ec34c4cSmrg 945ec34c4cSmrg# Please report bugs or propose patches to gary@gnu.org. 955ec34c4cSmrg 965ec34c4cSmrg 975ec34c4cSmrg## ------ ## 985ec34c4cSmrg## Usage. ## 995ec34c4cSmrg## ------ ## 1005ec34c4cSmrg 1015ec34c4cSmrg# Evaluate this file near the top of your script to gain access to 1025ec34c4cSmrg# the functions and variables defined here: 1035ec34c4cSmrg# 1045ec34c4cSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 1055ec34c4cSmrg# 1065ec34c4cSmrg# If you need to override any of the default environment variable 1075ec34c4cSmrg# settings, do that before evaluating this file. 1085ec34c4cSmrg 1095ec34c4cSmrg 1105ec34c4cSmrg## -------------------- ## 1115ec34c4cSmrg## Shell normalisation. ## 1125ec34c4cSmrg## -------------------- ## 1135ec34c4cSmrg 1145ec34c4cSmrg# Some shells need a little help to be as Bourne compatible as possible. 1155ec34c4cSmrg# Before doing anything else, make sure all that help has been provided! 1165ec34c4cSmrg 1175ec34c4cSmrgDUALCASE=1; export DUALCASE # for MKS sh 1185ec34c4cSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119ab902922Smrg emulate sh 120ab902922Smrg NULLCMD=: 1215ec34c4cSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122ab902922Smrg # is contrary to our usage. Disable this feature. 123ab902922Smrg alias -g '${1+"$@"}'='"$@"' 1247a84e134Smrg setopt NO_GLOB_SUBST 125ab902922Smrgelse 1265ec34c4cSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1277a84e134Smrgfi 128e1e1713cSmrg 1295ec34c4cSmrg# NLS nuisances: We save the old values in case they are required later. 1305ec34c4cSmrg_G_user_locale= 1315ec34c4cSmrg_G_safe_locale= 1325ec34c4cSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133ab902922Smrgdo 1345ec34c4cSmrg eval "if test set = \"\${$_G_var+set}\"; then 1355ec34c4cSmrg save_$_G_var=\$$_G_var 1365ec34c4cSmrg $_G_var=C 1375ec34c4cSmrg export $_G_var 1385ec34c4cSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1395ec34c4cSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140ab902922Smrg fi" 141ab902922Smrgdone 142ab902922Smrg 1435ec34c4cSmrg# CDPATH. 1445ec34c4cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145994689c1Smrg 1465ec34c4cSmrg# Make sure IFS has a sensible default 1475ec34c4cSmrgsp=' ' 1485ec34c4cSmrgnl=' 1495ec34c4cSmrg' 1505ec34c4cSmrgIFS="$sp $nl" 1515ec34c4cSmrg 1525ec34c4cSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1535ec34c4cSmrgif test "${PATH_SEPARATOR+set}" != set; then 1545ec34c4cSmrg PATH_SEPARATOR=: 1555ec34c4cSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1565ec34c4cSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1575ec34c4cSmrg PATH_SEPARATOR=';' 1585ec34c4cSmrg } 1595ec34c4cSmrgfi 160994689c1Smrg 161994689c1Smrg 162994689c1Smrg 1635ec34c4cSmrg## ------------------------- ## 1645ec34c4cSmrg## Locate command utilities. ## 1655ec34c4cSmrg## ------------------------- ## 1665ec34c4cSmrg 1675ec34c4cSmrg 1685ec34c4cSmrg# func_executable_p FILE 1695ec34c4cSmrg# ---------------------- 1705ec34c4cSmrg# Check that FILE is an executable regular file. 1715ec34c4cSmrgfunc_executable_p () 1725ec34c4cSmrg{ 1735ec34c4cSmrg test -f "$1" && test -x "$1" 1745ec34c4cSmrg} 1755ec34c4cSmrg 1765ec34c4cSmrg 1775ec34c4cSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1785ec34c4cSmrg# -------------------------------------------- 1795ec34c4cSmrg# Search for either a program that responds to --version with output 1805ec34c4cSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1815ec34c4cSmrg# trying all the directories in PATH with each of the elements of 1825ec34c4cSmrg# PROGS_LIST. 1835ec34c4cSmrg# 1845ec34c4cSmrg# CHECK_FUNC should accept the path to a candidate program, and 1855ec34c4cSmrg# set $func_check_prog_result if it truncates its output less than 1865ec34c4cSmrg# $_G_path_prog_max characters. 1875ec34c4cSmrgfunc_path_progs () 1885ec34c4cSmrg{ 1895ec34c4cSmrg _G_progs_list=$1 1905ec34c4cSmrg _G_check_func=$2 1915ec34c4cSmrg _G_PATH=${3-"$PATH"} 1925ec34c4cSmrg 1935ec34c4cSmrg _G_path_prog_max=0 1945ec34c4cSmrg _G_path_prog_found=false 1955ec34c4cSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 1965ec34c4cSmrg for _G_dir in $_G_PATH; do 1975ec34c4cSmrg IFS=$_G_save_IFS 1985ec34c4cSmrg test -z "$_G_dir" && _G_dir=. 1995ec34c4cSmrg for _G_prog_name in $_G_progs_list; do 2005ec34c4cSmrg for _exeext in '' .EXE; do 2015ec34c4cSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2025ec34c4cSmrg func_executable_p "$_G_path_prog" || continue 2035ec34c4cSmrg case `"$_G_path_prog" --version 2>&1` in 2045ec34c4cSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2055ec34c4cSmrg *) $_G_check_func $_G_path_prog 2065ec34c4cSmrg func_path_progs_result=$func_check_prog_result 2075ec34c4cSmrg ;; 2085ec34c4cSmrg esac 2095ec34c4cSmrg $_G_path_prog_found && break 3 2105ec34c4cSmrg done 2115ec34c4cSmrg done 2125ec34c4cSmrg done 2135ec34c4cSmrg IFS=$_G_save_IFS 2145ec34c4cSmrg test -z "$func_path_progs_result" && { 2155ec34c4cSmrg echo "no acceptable sed could be found in \$PATH" >&2 2165ec34c4cSmrg exit 1 2175ec34c4cSmrg } 2185ec34c4cSmrg} 2195ec34c4cSmrg 2205ec34c4cSmrg 2215ec34c4cSmrg# We want to be able to use the functions in this file before configure 2225ec34c4cSmrg# has figured out where the best binaries are kept, which means we have 2235ec34c4cSmrg# to search for them ourselves - except when the results are already set 2245ec34c4cSmrg# where we skip the searches. 2255ec34c4cSmrg 2265ec34c4cSmrg# Unless the user overrides by setting SED, search the path for either GNU 2275ec34c4cSmrg# sed, or the sed that truncates its output the least. 2285ec34c4cSmrgtest -z "$SED" && { 2295ec34c4cSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2305ec34c4cSmrg for _G_i in 1 2 3 4 5 6 7; do 2315ec34c4cSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2325ec34c4cSmrg done 2335ec34c4cSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2345ec34c4cSmrg _G_sed_script= 2355ec34c4cSmrg 2365ec34c4cSmrg func_check_prog_sed () 2375ec34c4cSmrg { 2385ec34c4cSmrg _G_path_prog=$1 2395ec34c4cSmrg 2405ec34c4cSmrg _G_count=0 2415ec34c4cSmrg printf 0123456789 >conftest.in 2425ec34c4cSmrg while : 2435ec34c4cSmrg do 2445ec34c4cSmrg cat conftest.in conftest.in >conftest.tmp 2455ec34c4cSmrg mv conftest.tmp conftest.in 2465ec34c4cSmrg cp conftest.in conftest.nl 2475ec34c4cSmrg echo '' >> conftest.nl 2485ec34c4cSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2495ec34c4cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2505ec34c4cSmrg _G_count=`expr $_G_count + 1` 2515ec34c4cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2525ec34c4cSmrg # Best one so far, save it but keep looking for a better one 2535ec34c4cSmrg func_check_prog_result=$_G_path_prog 2545ec34c4cSmrg _G_path_prog_max=$_G_count 2555ec34c4cSmrg fi 2565ec34c4cSmrg # 10*(2^10) chars as input seems more than enough 2575ec34c4cSmrg test 10 -lt "$_G_count" && break 2585ec34c4cSmrg done 2595ec34c4cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2605ec34c4cSmrg } 2615ec34c4cSmrg 2625ec34c4cSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 2635ec34c4cSmrg rm -f conftest.sed 2645ec34c4cSmrg SED=$func_path_progs_result 2655ec34c4cSmrg} 2665ec34c4cSmrg 2675ec34c4cSmrg 2685ec34c4cSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2695ec34c4cSmrg# grep, or the grep that truncates its output the least. 2705ec34c4cSmrgtest -z "$GREP" && { 2715ec34c4cSmrg func_check_prog_grep () 2725ec34c4cSmrg { 2735ec34c4cSmrg _G_path_prog=$1 2745ec34c4cSmrg 2755ec34c4cSmrg _G_count=0 2765ec34c4cSmrg _G_path_prog_max=0 2775ec34c4cSmrg printf 0123456789 >conftest.in 2785ec34c4cSmrg while : 2795ec34c4cSmrg do 2805ec34c4cSmrg cat conftest.in conftest.in >conftest.tmp 2815ec34c4cSmrg mv conftest.tmp conftest.in 2825ec34c4cSmrg cp conftest.in conftest.nl 2835ec34c4cSmrg echo 'GREP' >> conftest.nl 2845ec34c4cSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2855ec34c4cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2865ec34c4cSmrg _G_count=`expr $_G_count + 1` 2875ec34c4cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2885ec34c4cSmrg # Best one so far, save it but keep looking for a better one 2895ec34c4cSmrg func_check_prog_result=$_G_path_prog 2905ec34c4cSmrg _G_path_prog_max=$_G_count 2915ec34c4cSmrg fi 2925ec34c4cSmrg # 10*(2^10) chars as input seems more than enough 2935ec34c4cSmrg test 10 -lt "$_G_count" && break 2945ec34c4cSmrg done 2955ec34c4cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2965ec34c4cSmrg } 2975ec34c4cSmrg 2985ec34c4cSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 2995ec34c4cSmrg GREP=$func_path_progs_result 3005ec34c4cSmrg} 3015ec34c4cSmrg 3025ec34c4cSmrg 3035ec34c4cSmrg## ------------------------------- ## 3045ec34c4cSmrg## User overridable command paths. ## 3055ec34c4cSmrg## ------------------------------- ## 3065ec34c4cSmrg 3075ec34c4cSmrg# All uppercase variable names are used for environment variables. These 3085ec34c4cSmrg# variables can be overridden by the user before calling a script that 3095ec34c4cSmrg# uses them if a suitable command of that name is not already available 3105ec34c4cSmrg# in the command search PATH. 311994689c1Smrg 312994689c1Smrg: ${CP="cp -f"} 3135ec34c4cSmrg: ${ECHO="printf %s\n"} 3145ec34c4cSmrg: ${EGREP="$GREP -E"} 3155ec34c4cSmrg: ${FGREP="$GREP -F"} 3165ec34c4cSmrg: ${LN_S="ln -s"} 317994689c1Smrg: ${MAKE="make"} 318994689c1Smrg: ${MKDIR="mkdir"} 319994689c1Smrg: ${MV="mv -f"} 320994689c1Smrg: ${RM="rm -f"} 321994689c1Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3227a84e134Smrg 323994689c1Smrg 3245ec34c4cSmrg## -------------------- ## 3255ec34c4cSmrg## Useful sed snippets. ## 3265ec34c4cSmrg## -------------------- ## 327f353fbadSmrg 3285ec34c4cSmrgsed_dirname='s|/[^/]*$||' 3295ec34c4cSmrgsed_basename='s|^.*/||' 330f353fbadSmrg 3315ec34c4cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3325ec34c4cSmrg# metacharacters that are still active within double-quoted strings. 3335ec34c4cSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334f353fbadSmrg 3355ec34c4cSmrg# Same as above, but do not quote variable references. 3365ec34c4cSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337f353fbadSmrg 3385ec34c4cSmrg# Sed substitution that turns a string into a regex matching for the 3395ec34c4cSmrg# string literally. 3405ec34c4cSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341f353fbadSmrg 3425ec34c4cSmrg# Sed substitution that converts a w32 file name or path 3435ec34c4cSmrg# that contains forward slashes, into one that contains 3445ec34c4cSmrg# (escaped) backslashes. A very naive implementation. 3455ec34c4cSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3465ec34c4cSmrg 3475ec34c4cSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3485ec34c4cSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3495ec34c4cSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3505ec34c4cSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3515ec34c4cSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3525ec34c4cSmrg_G_bs='\\' 3535ec34c4cSmrg_G_bs2='\\\\' 3545ec34c4cSmrg_G_bs4='\\\\\\\\' 3555ec34c4cSmrg_G_dollar='\$' 3565ec34c4cSmrgsed_double_backslash="\ 3575ec34c4cSmrg s/$_G_bs4/&\\ 3585ec34c4cSmrg/g 3595ec34c4cSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3605ec34c4cSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3615ec34c4cSmrg s/\n//g" 362f353fbadSmrg 363775e7de9Smrg 3645ec34c4cSmrg## ----------------- ## 3655ec34c4cSmrg## Global variables. ## 3665ec34c4cSmrg## ----------------- ## 367994689c1Smrg 3685ec34c4cSmrg# Except for the global variables explicitly listed below, the following 3695ec34c4cSmrg# functions in the '^func_' namespace, and the '^require_' namespace 3705ec34c4cSmrg# variables initialised in the 'Resource management' section, sourcing 3715ec34c4cSmrg# this file will not pollute your global namespace with anything 3725ec34c4cSmrg# else. There's no portable way to scope variables in Bourne shell 3735ec34c4cSmrg# though, so actually running these functions will sometimes place 3745ec34c4cSmrg# results into a variable named after the function, and often use 3755ec34c4cSmrg# temporary variables in the '^_G_' namespace. If you are careful to 3765ec34c4cSmrg# avoid using those namespaces casually in your sourcing script, things 3775ec34c4cSmrg# should continue to work as you expect. And, of course, you can freely 3785ec34c4cSmrg# overwrite any of the functions or variables defined here before 3795ec34c4cSmrg# calling anything to customize them. 380994689c1Smrg 3815ec34c4cSmrgEXIT_SUCCESS=0 3825ec34c4cSmrgEXIT_FAILURE=1 3835ec34c4cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 3845ec34c4cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385994689c1Smrg 3865ec34c4cSmrg# Allow overriding, eg assuming that you follow the convention of 3875ec34c4cSmrg# putting '$debug_cmd' at the start of all your functions, you can get 3885ec34c4cSmrg# bash to show function call trace with: 3895ec34c4cSmrg# 3905ec34c4cSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 3915ec34c4cSmrgdebug_cmd=${debug_cmd-":"} 3925ec34c4cSmrgexit_cmd=: 393994689c1Smrg 3945ec34c4cSmrg# By convention, finish your script with: 3955ec34c4cSmrg# 3965ec34c4cSmrg# exit $exit_status 3975ec34c4cSmrg# 3985ec34c4cSmrg# so that you can set exit_status to non-zero if you want to indicate 3995ec34c4cSmrg# something went wrong during execution without actually bailing out at 4005ec34c4cSmrg# the point of failure. 4015ec34c4cSmrgexit_status=$EXIT_SUCCESS 402994689c1Smrg 4035ec34c4cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4045ec34c4cSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4055ec34c4cSmrg# the _XPG environment variable is not equal to 1 (one), the special 4065ec34c4cSmrg# positional parameter $0, within a function call, is the name of the 4075ec34c4cSmrg# function. 4085ec34c4cSmrgprogpath=$0 409994689c1Smrg 4105ec34c4cSmrg# The name of this program. 4115ec34c4cSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412994689c1Smrg 4135ec34c4cSmrg# Make sure we have an absolute progpath for reexecution: 414994689c1Smrgcase $progpath in 415994689c1Smrg [\\/]*|[A-Za-z]:\\*) ;; 416994689c1Smrg *[\\/]*) 4175ec34c4cSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418994689c1Smrg progdir=`cd "$progdir" && pwd` 4195ec34c4cSmrg progpath=$progdir/$progname 420994689c1Smrg ;; 421994689c1Smrg *) 4225ec34c4cSmrg _G_IFS=$IFS 423421c997bSmrg IFS=${PATH_SEPARATOR-:} 424994689c1Smrg for progdir in $PATH; do 4255ec34c4cSmrg IFS=$_G_IFS 426994689c1Smrg test -x "$progdir/$progname" && break 427994689c1Smrg done 4285ec34c4cSmrg IFS=$_G_IFS 429994689c1Smrg test -n "$progdir" || progdir=`pwd` 4305ec34c4cSmrg progpath=$progdir/$progname 431994689c1Smrg ;; 432994689c1Smrgesac 433994689c1Smrg 434994689c1Smrg 4355ec34c4cSmrg## ----------------- ## 4365ec34c4cSmrg## Standard options. ## 4375ec34c4cSmrg## ----------------- ## 438f353fbadSmrg 4395ec34c4cSmrg# The following options affect the operation of the functions defined 4405ec34c4cSmrg# below, and should be set appropriately depending on run-time para- 4415ec34c4cSmrg# meters passed on the command line. 442994689c1Smrg 443994689c1Smrgopt_dry_run=false 444994689c1Smrgopt_quiet=false 445994689c1Smrgopt_verbose=false 446994689c1Smrg 4475ec34c4cSmrg# Categories 'all' and 'none' are always available. Append any others 4485ec34c4cSmrg# you will pass as the first argument to func_warning from your own 4495ec34c4cSmrg# code. 4505ec34c4cSmrgwarning_categories= 451994689c1Smrg 4525ec34c4cSmrg# By default, display warnings according to 'opt_warning_types'. Set 4535ec34c4cSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4545ec34c4cSmrg# treat the next displayed warning as a fatal error. 4555ec34c4cSmrgwarning_func=func_warn_and_continue 456994689c1Smrg 4575ec34c4cSmrg# Set to 'all' to display all warnings, 'none' to suppress all 4585ec34c4cSmrg# warnings, or a space delimited list of some subset of 4595ec34c4cSmrg# 'warning_categories' to display only the listed warnings. 4605ec34c4cSmrgopt_warning_types=all 461994689c1Smrg 462994689c1Smrg 4635ec34c4cSmrg## -------------------- ## 4645ec34c4cSmrg## Resource management. ## 4655ec34c4cSmrg## -------------------- ## 466994689c1Smrg 4675ec34c4cSmrg# This section contains definitions for functions that each ensure a 4685ec34c4cSmrg# particular resource (a file, or a non-empty configuration variable for 4695ec34c4cSmrg# example) is available, and if appropriate to extract default values 4705ec34c4cSmrg# from pertinent package files. Call them using their associated 4715ec34c4cSmrg# 'require_*' variable to ensure that they are executed, at most, once. 4725ec34c4cSmrg# 4735ec34c4cSmrg# It's entirely deliberate that calling these functions can set 4745ec34c4cSmrg# variables that don't obey the namespace limitations obeyed by the rest 4755ec34c4cSmrg# of this file, in order that that they be as useful as possible to 4765ec34c4cSmrg# callers. 477994689c1Smrg 478994689c1Smrg 4795ec34c4cSmrg# require_term_colors 4805ec34c4cSmrg# ------------------- 4815ec34c4cSmrg# Allow display of bold text on terminals that support it. 4825ec34c4cSmrgrequire_term_colors=func_require_term_colors 4835ec34c4cSmrgfunc_require_term_colors () 484994689c1Smrg{ 4855ec34c4cSmrg $debug_cmd 4865ec34c4cSmrg 4875ec34c4cSmrg test -t 1 && { 4885ec34c4cSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 4895ec34c4cSmrg # precedence, because most terminfo databases neglect to describe 4905ec34c4cSmrg # whether color sequences are supported. 4915ec34c4cSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 4925ec34c4cSmrg 4935ec34c4cSmrg if test 1 = "$USE_ANSI_COLORS"; then 4945ec34c4cSmrg # Standard ANSI escape sequences 4955ec34c4cSmrg tc_reset='[0m' 4965ec34c4cSmrg tc_bold='[1m'; tc_standout='[7m' 4975ec34c4cSmrg tc_red='[31m'; tc_green='[32m' 4985ec34c4cSmrg tc_blue='[34m'; tc_cyan='[36m' 4995ec34c4cSmrg else 5005ec34c4cSmrg # Otherwise trust the terminfo database after all. 5015ec34c4cSmrg test -n "`tput sgr0 2>/dev/null`" && { 5025ec34c4cSmrg tc_reset=`tput sgr0` 5035ec34c4cSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5045ec34c4cSmrg tc_standout=$tc_bold 5055ec34c4cSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5065ec34c4cSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5075ec34c4cSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5085ec34c4cSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5095ec34c4cSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5105ec34c4cSmrg } 5115ec34c4cSmrg fi 5125ec34c4cSmrg } 513994689c1Smrg 5145ec34c4cSmrg require_term_colors=: 515994689c1Smrg} 516994689c1Smrg 517994689c1Smrg 5185ec34c4cSmrg## ----------------- ## 5195ec34c4cSmrg## Function library. ## 5205ec34c4cSmrg## ----------------- ## 5215ec34c4cSmrg 5225ec34c4cSmrg# This section contains a variety of useful functions to call in your 5235ec34c4cSmrg# scripts. Take note of the portable wrappers for features provided by 5245ec34c4cSmrg# some modern shells, which will fall back to slower equivalents on 5255ec34c4cSmrg# less featureful shells. 5265ec34c4cSmrg 5275ec34c4cSmrg 5285ec34c4cSmrg# func_append VAR VALUE 5295ec34c4cSmrg# --------------------- 5305ec34c4cSmrg# Append VALUE onto the existing contents of VAR. 5315ec34c4cSmrg 5325ec34c4cSmrg # We should try to minimise forks, especially on Windows where they are 5335ec34c4cSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5345ec34c4cSmrg # being used: 5355ec34c4cSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5365ec34c4cSmrg : ${_G_HAVE_ARITH_OP="yes"} 5375ec34c4cSmrg : ${_G_HAVE_XSI_OPS="yes"} 5385ec34c4cSmrg # The += operator was introduced in bash 3.1 5395ec34c4cSmrg case $BASH_VERSION in 5405ec34c4cSmrg [12].* | 3.0 | 3.0*) ;; 5415ec34c4cSmrg *) 5425ec34c4cSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5435ec34c4cSmrg ;; 5445ec34c4cSmrg esac 5455ec34c4cSmrg fi 5465ec34c4cSmrg 5475ec34c4cSmrg # _G_HAVE_PLUSEQ_OP 5485ec34c4cSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5495ec34c4cSmrg # useable or anything else if it does not work. 5505ec34c4cSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5515ec34c4cSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5525ec34c4cSmrg && _G_HAVE_PLUSEQ_OP=yes 5535ec34c4cSmrg 5545ec34c4cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5555ec34c4cSmrgthen 5565ec34c4cSmrg # This is an XSI compatible shell, allowing a faster implementation... 5575ec34c4cSmrg eval 'func_append () 5585ec34c4cSmrg { 5595ec34c4cSmrg $debug_cmd 5605ec34c4cSmrg 5615ec34c4cSmrg eval "$1+=\$2" 5625ec34c4cSmrg }' 5635ec34c4cSmrgelse 5645ec34c4cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 5655ec34c4cSmrg func_append () 5665ec34c4cSmrg { 5675ec34c4cSmrg $debug_cmd 5685ec34c4cSmrg 5695ec34c4cSmrg eval "$1=\$$1\$2" 5705ec34c4cSmrg } 5715ec34c4cSmrgfi 5725ec34c4cSmrg 5735ec34c4cSmrg 5745ec34c4cSmrg# func_append_quoted VAR VALUE 5755ec34c4cSmrg# ---------------------------- 5765ec34c4cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 5775ec34c4cSmrg# by a space. 5785ec34c4cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 5795ec34c4cSmrg eval 'func_append_quoted () 5805ec34c4cSmrg { 5815ec34c4cSmrg $debug_cmd 5825ec34c4cSmrg 5835ec34c4cSmrg func_quote_for_eval "$2" 5845ec34c4cSmrg eval "$1+=\\ \$func_quote_for_eval_result" 5855ec34c4cSmrg }' 5865ec34c4cSmrgelse 5875ec34c4cSmrg func_append_quoted () 5885ec34c4cSmrg { 5895ec34c4cSmrg $debug_cmd 5905ec34c4cSmrg 5915ec34c4cSmrg func_quote_for_eval "$2" 5925ec34c4cSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 5935ec34c4cSmrg } 5945ec34c4cSmrgfi 5955ec34c4cSmrg 5965ec34c4cSmrg 5975ec34c4cSmrg# func_append_uniq VAR VALUE 5985ec34c4cSmrg# -------------------------- 5995ec34c4cSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6005ec34c4cSmrg# entries are delimited by the first character of VALUE. For example: 6015ec34c4cSmrg# 6025ec34c4cSmrg# func_append_uniq options " --another-option option-argument" 6035ec34c4cSmrg# 6045ec34c4cSmrg# will only append to $options if " --another-option option-argument " 6055ec34c4cSmrg# is not already present somewhere in $options already (note spaces at 6065ec34c4cSmrg# each end implied by leading space in second argument). 6075ec34c4cSmrgfunc_append_uniq () 6085ec34c4cSmrg{ 6095ec34c4cSmrg $debug_cmd 6105ec34c4cSmrg 6115ec34c4cSmrg eval _G_current_value='`$ECHO $'$1'`' 6125ec34c4cSmrg _G_delim=`expr "$2" : '\(.\)'` 6135ec34c4cSmrg 6145ec34c4cSmrg case $_G_delim$_G_current_value$_G_delim in 6155ec34c4cSmrg *"$2$_G_delim"*) ;; 6165ec34c4cSmrg *) func_append "$@" ;; 6175ec34c4cSmrg esac 6185ec34c4cSmrg} 6195ec34c4cSmrg 6205ec34c4cSmrg 6215ec34c4cSmrg# func_arith TERM... 6225ec34c4cSmrg# ------------------ 6235ec34c4cSmrg# Set func_arith_result to the result of evaluating TERMs. 6245ec34c4cSmrg test -z "$_G_HAVE_ARITH_OP" \ 6255ec34c4cSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6265ec34c4cSmrg && _G_HAVE_ARITH_OP=yes 6275ec34c4cSmrg 6285ec34c4cSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6295ec34c4cSmrg eval 'func_arith () 6305ec34c4cSmrg { 6315ec34c4cSmrg $debug_cmd 6325ec34c4cSmrg 6335ec34c4cSmrg func_arith_result=$(( $* )) 6345ec34c4cSmrg }' 6355ec34c4cSmrgelse 6365ec34c4cSmrg func_arith () 6375ec34c4cSmrg { 6385ec34c4cSmrg $debug_cmd 6395ec34c4cSmrg 6405ec34c4cSmrg func_arith_result=`expr "$@"` 6415ec34c4cSmrg } 6425ec34c4cSmrgfi 6435ec34c4cSmrg 6445ec34c4cSmrg 6455ec34c4cSmrg# func_basename FILE 6465ec34c4cSmrg# ------------------ 6475ec34c4cSmrg# Set func_basename_result to FILE with everything up to and including 6485ec34c4cSmrg# the last / stripped. 6495ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6505ec34c4cSmrg # If this shell supports suffix pattern removal, then use it to avoid 6515ec34c4cSmrg # forking. Hide the definitions single quotes in case the shell chokes 6525ec34c4cSmrg # on unsupported syntax... 6535ec34c4cSmrg _b='func_basename_result=${1##*/}' 6545ec34c4cSmrg _d='case $1 in 6555ec34c4cSmrg */*) func_dirname_result=${1%/*}$2 ;; 6565ec34c4cSmrg * ) func_dirname_result=$3 ;; 6575ec34c4cSmrg esac' 6585ec34c4cSmrg 6595ec34c4cSmrgelse 6605ec34c4cSmrg # ...otherwise fall back to using sed. 6615ec34c4cSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 6625ec34c4cSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 6635ec34c4cSmrg if test "X$func_dirname_result" = "X$1"; then 6645ec34c4cSmrg func_dirname_result=$3 6655ec34c4cSmrg else 6665ec34c4cSmrg func_append func_dirname_result "$2" 6675ec34c4cSmrg fi' 6685ec34c4cSmrgfi 6695ec34c4cSmrg 6705ec34c4cSmrgeval 'func_basename () 6715ec34c4cSmrg{ 6725ec34c4cSmrg $debug_cmd 6735ec34c4cSmrg 6745ec34c4cSmrg '"$_b"' 6755ec34c4cSmrg}' 6765ec34c4cSmrg 6775ec34c4cSmrg 6785ec34c4cSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 6795ec34c4cSmrg# ------------------------------------------- 6805ec34c4cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 6815ec34c4cSmrg# otherwise set result to NONDIR_REPLACEMENT. 6825ec34c4cSmrgeval 'func_dirname () 6835ec34c4cSmrg{ 6845ec34c4cSmrg $debug_cmd 6855ec34c4cSmrg 6865ec34c4cSmrg '"$_d"' 6875ec34c4cSmrg}' 6885ec34c4cSmrg 6895ec34c4cSmrg 6905ec34c4cSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 6915ec34c4cSmrg# -------------------------------------------------------- 6925ec34c4cSmrg# Perform func_basename and func_dirname in a single function 6935ec34c4cSmrg# call: 6945ec34c4cSmrg# dirname: Compute the dirname of FILE. If nonempty, 6955ec34c4cSmrg# add APPEND to the result, otherwise set result 6965ec34c4cSmrg# to NONDIR_REPLACEMENT. 6975ec34c4cSmrg# value returned in "$func_dirname_result" 6985ec34c4cSmrg# basename: Compute filename of FILE. 6995ec34c4cSmrg# value retuned in "$func_basename_result" 7005ec34c4cSmrg# For efficiency, we do not delegate to the functions above but instead 7015ec34c4cSmrg# duplicate the functionality here. 7025ec34c4cSmrgeval 'func_dirname_and_basename () 7035ec34c4cSmrg{ 7045ec34c4cSmrg $debug_cmd 7055ec34c4cSmrg 7065ec34c4cSmrg '"$_b"' 7075ec34c4cSmrg '"$_d"' 7085ec34c4cSmrg}' 7095ec34c4cSmrg 7105ec34c4cSmrg 7115ec34c4cSmrg# func_echo ARG... 7125ec34c4cSmrg# ---------------- 7135ec34c4cSmrg# Echo program name prefixed message. 7145ec34c4cSmrgfunc_echo () 7155ec34c4cSmrg{ 7165ec34c4cSmrg $debug_cmd 7175ec34c4cSmrg 7185ec34c4cSmrg _G_message=$* 7195ec34c4cSmrg 7205ec34c4cSmrg func_echo_IFS=$IFS 7215ec34c4cSmrg IFS=$nl 7225ec34c4cSmrg for _G_line in $_G_message; do 7235ec34c4cSmrg IFS=$func_echo_IFS 7245ec34c4cSmrg $ECHO "$progname: $_G_line" 7255ec34c4cSmrg done 7265ec34c4cSmrg IFS=$func_echo_IFS 7275ec34c4cSmrg} 7285ec34c4cSmrg 7295ec34c4cSmrg 7305ec34c4cSmrg# func_echo_all ARG... 7315ec34c4cSmrg# -------------------- 7325ec34c4cSmrg# Invoke $ECHO with all args, space-separated. 7335ec34c4cSmrgfunc_echo_all () 7345ec34c4cSmrg{ 7355ec34c4cSmrg $ECHO "$*" 7365ec34c4cSmrg} 7375ec34c4cSmrg 7385ec34c4cSmrg 7395ec34c4cSmrg# func_echo_infix_1 INFIX ARG... 7405ec34c4cSmrg# ------------------------------ 7415ec34c4cSmrg# Echo program name, followed by INFIX on the first line, with any 7425ec34c4cSmrg# additional lines not showing INFIX. 7435ec34c4cSmrgfunc_echo_infix_1 () 7445ec34c4cSmrg{ 7455ec34c4cSmrg $debug_cmd 7465ec34c4cSmrg 7475ec34c4cSmrg $require_term_colors 7485ec34c4cSmrg 7495ec34c4cSmrg _G_infix=$1; shift 7505ec34c4cSmrg _G_indent=$_G_infix 7515ec34c4cSmrg _G_prefix="$progname: $_G_infix: " 7525ec34c4cSmrg _G_message=$* 7535ec34c4cSmrg 7545ec34c4cSmrg # Strip color escape sequences before counting printable length 7555ec34c4cSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7565ec34c4cSmrg do 7575ec34c4cSmrg test -n "$_G_tc" && { 7585ec34c4cSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 7595ec34c4cSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 7605ec34c4cSmrg } 7615ec34c4cSmrg done 7625ec34c4cSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 7635ec34c4cSmrg 7645ec34c4cSmrg func_echo_infix_1_IFS=$IFS 7655ec34c4cSmrg IFS=$nl 7665ec34c4cSmrg for _G_line in $_G_message; do 7675ec34c4cSmrg IFS=$func_echo_infix_1_IFS 7685ec34c4cSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 7695ec34c4cSmrg _G_prefix=$_G_indent 7705ec34c4cSmrg done 7715ec34c4cSmrg IFS=$func_echo_infix_1_IFS 7725ec34c4cSmrg} 7735ec34c4cSmrg 7745ec34c4cSmrg 7755ec34c4cSmrg# func_error ARG... 7765ec34c4cSmrg# ----------------- 7775ec34c4cSmrg# Echo program name prefixed message to standard error. 7785ec34c4cSmrgfunc_error () 7795ec34c4cSmrg{ 7805ec34c4cSmrg $debug_cmd 7815ec34c4cSmrg 7825ec34c4cSmrg $require_term_colors 7835ec34c4cSmrg 7845ec34c4cSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 7855ec34c4cSmrg} 7865ec34c4cSmrg 7875ec34c4cSmrg 7885ec34c4cSmrg# func_fatal_error ARG... 7895ec34c4cSmrg# ----------------------- 7905ec34c4cSmrg# Echo program name prefixed message to standard error, and exit. 7915ec34c4cSmrgfunc_fatal_error () 7925ec34c4cSmrg{ 7935ec34c4cSmrg $debug_cmd 7945ec34c4cSmrg 7955ec34c4cSmrg func_error "$*" 7965ec34c4cSmrg exit $EXIT_FAILURE 7975ec34c4cSmrg} 7985ec34c4cSmrg 7995ec34c4cSmrg 8005ec34c4cSmrg# func_grep EXPRESSION FILENAME 8015ec34c4cSmrg# ----------------------------- 802994689c1Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803994689c1Smrgfunc_grep () 804994689c1Smrg{ 8055ec34c4cSmrg $debug_cmd 8065ec34c4cSmrg 807994689c1Smrg $GREP "$1" "$2" >/dev/null 2>&1 808994689c1Smrg} 809994689c1Smrg 810994689c1Smrg 8115ec34c4cSmrg# func_len STRING 8125ec34c4cSmrg# --------------- 8135ec34c4cSmrg# Set func_len_result to the length of STRING. STRING may not 8145ec34c4cSmrg# start with a hyphen. 8155ec34c4cSmrg test -z "$_G_HAVE_XSI_OPS" \ 8165ec34c4cSmrg && (eval 'x=a/b/c; 8175ec34c4cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8185ec34c4cSmrg && _G_HAVE_XSI_OPS=yes 8195ec34c4cSmrg 8205ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8215ec34c4cSmrg eval 'func_len () 8225ec34c4cSmrg { 8235ec34c4cSmrg $debug_cmd 8245ec34c4cSmrg 8255ec34c4cSmrg func_len_result=${#1} 8265ec34c4cSmrg }' 8275ec34c4cSmrgelse 8285ec34c4cSmrg func_len () 8295ec34c4cSmrg { 8305ec34c4cSmrg $debug_cmd 8315ec34c4cSmrg 8325ec34c4cSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8335ec34c4cSmrg } 8345ec34c4cSmrgfi 8355ec34c4cSmrg 8365ec34c4cSmrg 8375ec34c4cSmrg# func_mkdir_p DIRECTORY-PATH 8385ec34c4cSmrg# --------------------------- 839994689c1Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840994689c1Smrgfunc_mkdir_p () 841994689c1Smrg{ 8425ec34c4cSmrg $debug_cmd 8435ec34c4cSmrg 8445ec34c4cSmrg _G_directory_path=$1 8455ec34c4cSmrg _G_dir_list= 846994689c1Smrg 8475ec34c4cSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848994689c1Smrg 8495ec34c4cSmrg # Protect directory names starting with '-' 8505ec34c4cSmrg case $_G_directory_path in 8515ec34c4cSmrg -*) _G_directory_path=./$_G_directory_path ;; 852994689c1Smrg esac 853994689c1Smrg 854994689c1Smrg # While some portion of DIR does not yet exist... 8555ec34c4cSmrg while test ! -d "$_G_directory_path"; do 856994689c1Smrg # ...make a list in topmost first order. Use a colon delimited 857994689c1Smrg # list incase some portion of path contains whitespace. 8585ec34c4cSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 859994689c1Smrg 860994689c1Smrg # If the last portion added has no slash in it, the list is done 8615ec34c4cSmrg case $_G_directory_path in */*) ;; *) break ;; esac 862994689c1Smrg 863994689c1Smrg # ...otherwise throw away the child directory and loop 8645ec34c4cSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865994689c1Smrg done 8665ec34c4cSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867994689c1Smrg 8685ec34c4cSmrg func_mkdir_p_IFS=$IFS; IFS=: 8695ec34c4cSmrg for _G_dir in $_G_dir_list; do 8705ec34c4cSmrg IFS=$func_mkdir_p_IFS 8715ec34c4cSmrg # mkdir can fail with a 'File exist' error if two processes 872994689c1Smrg # try to create one of the directories concurrently. Don't 873994689c1Smrg # stop in that case! 8745ec34c4cSmrg $MKDIR "$_G_dir" 2>/dev/null || : 875994689c1Smrg done 8765ec34c4cSmrg IFS=$func_mkdir_p_IFS 877994689c1Smrg 878994689c1Smrg # Bail out if we (or some other process) failed to create a directory. 8795ec34c4cSmrg test -d "$_G_directory_path" || \ 8805ec34c4cSmrg func_fatal_error "Failed to create '$1'" 881994689c1Smrg fi 882994689c1Smrg} 8837a84e134Smrg 8847a84e134Smrg 8855ec34c4cSmrg# func_mktempdir [BASENAME] 8865ec34c4cSmrg# ------------------------- 8877a84e134Smrg# Make a temporary directory that won't clash with other running 8887a84e134Smrg# libtool processes, and avoids race conditions if possible. If 8895ec34c4cSmrg# given, BASENAME is the basename for that directory. 8907a84e134Smrgfunc_mktempdir () 8917a84e134Smrg{ 8925ec34c4cSmrg $debug_cmd 8935ec34c4cSmrg 8945ec34c4cSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 8957a84e134Smrg 8965ec34c4cSmrg if test : = "$opt_dry_run"; then 8977a84e134Smrg # Return a directory name, but don't create it in dry-run mode 8985ec34c4cSmrg _G_tmpdir=$_G_template-$$ 8997a84e134Smrg else 9007a84e134Smrg 9017a84e134Smrg # If mktemp works, use that first and foremost 9025ec34c4cSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9037a84e134Smrg 9045ec34c4cSmrg if test ! -d "$_G_tmpdir"; then 905994689c1Smrg # Failing that, at least try and use $RANDOM to avoid a race 9065ec34c4cSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9077a84e134Smrg 9085ec34c4cSmrg func_mktempdir_umask=`umask` 909994689c1Smrg umask 0077 9105ec34c4cSmrg $MKDIR "$_G_tmpdir" 9115ec34c4cSmrg umask $func_mktempdir_umask 9127a84e134Smrg fi 9137a84e134Smrg 9147a84e134Smrg # If we're not in dry-run mode, bomb out on failure 9155ec34c4cSmrg test -d "$_G_tmpdir" || \ 9165ec34c4cSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9177a84e134Smrg fi 9187a84e134Smrg 9195ec34c4cSmrg $ECHO "$_G_tmpdir" 9205ec34c4cSmrg} 9215ec34c4cSmrg 9225ec34c4cSmrg 9235ec34c4cSmrg# func_normal_abspath PATH 9245ec34c4cSmrg# ------------------------ 9255ec34c4cSmrg# Remove doubled-up and trailing slashes, "." path components, 9265ec34c4cSmrg# and cancel out any ".." path components in PATH after making 9275ec34c4cSmrg# it an absolute path. 9285ec34c4cSmrgfunc_normal_abspath () 9295ec34c4cSmrg{ 9305ec34c4cSmrg $debug_cmd 9315ec34c4cSmrg 9325ec34c4cSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9335ec34c4cSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9345ec34c4cSmrg _G_pathcdr='s|^/[^/]*||' 9355ec34c4cSmrg _G_removedotparts=':dotsl 9365ec34c4cSmrg s|/\./|/|g 9375ec34c4cSmrg t dotsl 9385ec34c4cSmrg s|/\.$|/|' 9395ec34c4cSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9405ec34c4cSmrg _G_finalslash='s|/*$|/|' 9415ec34c4cSmrg 9425ec34c4cSmrg # Start from root dir and reassemble the path. 9435ec34c4cSmrg func_normal_abspath_result= 9445ec34c4cSmrg func_normal_abspath_tpath=$1 9455ec34c4cSmrg func_normal_abspath_altnamespace= 9465ec34c4cSmrg case $func_normal_abspath_tpath in 9475ec34c4cSmrg "") 9485ec34c4cSmrg # Empty path, that just means $cwd. 9495ec34c4cSmrg func_stripname '' '/' "`pwd`" 9505ec34c4cSmrg func_normal_abspath_result=$func_stripname_result 9515ec34c4cSmrg return 9525ec34c4cSmrg ;; 9535ec34c4cSmrg # The next three entries are used to spot a run of precisely 9545ec34c4cSmrg # two leading slashes without using negated character classes; 9555ec34c4cSmrg # we take advantage of case's first-match behaviour. 9565ec34c4cSmrg ///*) 9575ec34c4cSmrg # Unusual form of absolute path, do nothing. 9585ec34c4cSmrg ;; 9595ec34c4cSmrg //*) 9605ec34c4cSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 9615ec34c4cSmrg # and for example Cygwin uses it to access remote file shares 9625ec34c4cSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 9635ec34c4cSmrg func_normal_abspath_altnamespace=/ 9645ec34c4cSmrg ;; 9655ec34c4cSmrg /*) 9665ec34c4cSmrg # Absolute path, do nothing. 9675ec34c4cSmrg ;; 9685ec34c4cSmrg *) 9695ec34c4cSmrg # Relative path, prepend $cwd. 9705ec34c4cSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 9715ec34c4cSmrg ;; 9725ec34c4cSmrg esac 9735ec34c4cSmrg 9745ec34c4cSmrg # Cancel out all the simple stuff to save iterations. We also want 9755ec34c4cSmrg # the path to end with a slash for ease of parsing, so make sure 9765ec34c4cSmrg # there is one (and only one) here. 9775ec34c4cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9785ec34c4cSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 9795ec34c4cSmrg while :; do 9805ec34c4cSmrg # Processed it all yet? 9815ec34c4cSmrg if test / = "$func_normal_abspath_tpath"; then 9825ec34c4cSmrg # If we ascended to the root using ".." the result may be empty now. 9835ec34c4cSmrg if test -z "$func_normal_abspath_result"; then 9845ec34c4cSmrg func_normal_abspath_result=/ 9855ec34c4cSmrg fi 9865ec34c4cSmrg break 9875ec34c4cSmrg fi 9885ec34c4cSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9895ec34c4cSmrg -e "$_G_pathcar"` 9905ec34c4cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 9915ec34c4cSmrg -e "$_G_pathcdr"` 9925ec34c4cSmrg # Figure out what to do with it 9935ec34c4cSmrg case $func_normal_abspath_tcomponent in 9945ec34c4cSmrg "") 9955ec34c4cSmrg # Trailing empty path component, ignore it. 9965ec34c4cSmrg ;; 9975ec34c4cSmrg ..) 9985ec34c4cSmrg # Parent dir; strip last assembled component from result. 9995ec34c4cSmrg func_dirname "$func_normal_abspath_result" 10005ec34c4cSmrg func_normal_abspath_result=$func_dirname_result 10015ec34c4cSmrg ;; 10025ec34c4cSmrg *) 10035ec34c4cSmrg # Actual path component, append it. 10045ec34c4cSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10055ec34c4cSmrg ;; 10065ec34c4cSmrg esac 10075ec34c4cSmrg done 10085ec34c4cSmrg # Restore leading double-slash if one was found on entry. 10095ec34c4cSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10105ec34c4cSmrg} 10115ec34c4cSmrg 10125ec34c4cSmrg 10135ec34c4cSmrg# func_notquiet ARG... 10145ec34c4cSmrg# -------------------- 10155ec34c4cSmrg# Echo program name prefixed message only when not in quiet mode. 10165ec34c4cSmrgfunc_notquiet () 10175ec34c4cSmrg{ 10185ec34c4cSmrg $debug_cmd 10195ec34c4cSmrg 10205ec34c4cSmrg $opt_quiet || func_echo ${1+"$@"} 10215ec34c4cSmrg 10225ec34c4cSmrg # A bug in bash halts the script if the last line of a function 10235ec34c4cSmrg # fails when set -e is in force, so we need another command to 10245ec34c4cSmrg # work around that: 10255ec34c4cSmrg : 10265ec34c4cSmrg} 10275ec34c4cSmrg 10285ec34c4cSmrg 10295ec34c4cSmrg# func_relative_path SRCDIR DSTDIR 10305ec34c4cSmrg# -------------------------------- 10315ec34c4cSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10325ec34c4cSmrgfunc_relative_path () 10335ec34c4cSmrg{ 10345ec34c4cSmrg $debug_cmd 10355ec34c4cSmrg 10365ec34c4cSmrg func_relative_path_result= 10375ec34c4cSmrg func_normal_abspath "$1" 10385ec34c4cSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10395ec34c4cSmrg func_normal_abspath "$2" 10405ec34c4cSmrg func_relative_path_tbindir=$func_normal_abspath_result 10415ec34c4cSmrg 10425ec34c4cSmrg # Ascend the tree starting from libdir 10435ec34c4cSmrg while :; do 10445ec34c4cSmrg # check if we have found a prefix of bindir 10455ec34c4cSmrg case $func_relative_path_tbindir in 10465ec34c4cSmrg $func_relative_path_tlibdir) 10475ec34c4cSmrg # found an exact match 10485ec34c4cSmrg func_relative_path_tcancelled= 10495ec34c4cSmrg break 10505ec34c4cSmrg ;; 10515ec34c4cSmrg $func_relative_path_tlibdir*) 10525ec34c4cSmrg # found a matching prefix 10535ec34c4cSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10545ec34c4cSmrg func_relative_path_tcancelled=$func_stripname_result 10555ec34c4cSmrg if test -z "$func_relative_path_result"; then 10565ec34c4cSmrg func_relative_path_result=. 10575ec34c4cSmrg fi 10585ec34c4cSmrg break 10595ec34c4cSmrg ;; 10605ec34c4cSmrg *) 10615ec34c4cSmrg func_dirname $func_relative_path_tlibdir 10625ec34c4cSmrg func_relative_path_tlibdir=$func_dirname_result 10635ec34c4cSmrg if test -z "$func_relative_path_tlibdir"; then 10645ec34c4cSmrg # Have to descend all the way to the root! 10655ec34c4cSmrg func_relative_path_result=../$func_relative_path_result 10665ec34c4cSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 10675ec34c4cSmrg break 10685ec34c4cSmrg fi 10695ec34c4cSmrg func_relative_path_result=../$func_relative_path_result 10705ec34c4cSmrg ;; 10715ec34c4cSmrg esac 10725ec34c4cSmrg done 10735ec34c4cSmrg 10745ec34c4cSmrg # Now calculate path; take care to avoid doubling-up slashes. 10755ec34c4cSmrg func_stripname '' '/' "$func_relative_path_result" 10765ec34c4cSmrg func_relative_path_result=$func_stripname_result 10775ec34c4cSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 10785ec34c4cSmrg if test -n "$func_stripname_result"; then 10795ec34c4cSmrg func_append func_relative_path_result "/$func_stripname_result" 10805ec34c4cSmrg fi 10815ec34c4cSmrg 10825ec34c4cSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 10835ec34c4cSmrg if test -n "$func_relative_path_result"; then 10845ec34c4cSmrg func_stripname './' '' "$func_relative_path_result" 10855ec34c4cSmrg func_relative_path_result=$func_stripname_result 10865ec34c4cSmrg fi 10875ec34c4cSmrg 10885ec34c4cSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 10895ec34c4cSmrg 10905ec34c4cSmrg : 10915ec34c4cSmrg} 10925ec34c4cSmrg 10935ec34c4cSmrg 10945ec34c4cSmrg# func_quote ARG 10955ec34c4cSmrg# -------------- 10965ec34c4cSmrg# Aesthetically quote one ARG, store the result into $func_quote_result. Note 10975ec34c4cSmrg# that we keep attention to performance here (so far O(N) complexity as long as 10985ec34c4cSmrg# func_append is O(1)). 10995ec34c4cSmrgfunc_quote () 11005ec34c4cSmrg{ 11015ec34c4cSmrg $debug_cmd 11025ec34c4cSmrg 11035ec34c4cSmrg func_quote_result=$1 11045ec34c4cSmrg 11055ec34c4cSmrg case $func_quote_result in 11065ec34c4cSmrg *[\\\`\"\$]*) 11075ec34c4cSmrg case $func_quote_result in 11085ec34c4cSmrg *[\[\*\?]*) 11095ec34c4cSmrg func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"` 11105ec34c4cSmrg return 0 11115ec34c4cSmrg ;; 11125ec34c4cSmrg esac 11135ec34c4cSmrg 11145ec34c4cSmrg func_quote_old_IFS=$IFS 11155ec34c4cSmrg for _G_char in '\' '`' '"' '$' 11165ec34c4cSmrg do 11175ec34c4cSmrg # STATE($1) PREV($2) SEPARATOR($3) 11185ec34c4cSmrg set start "" "" 11195ec34c4cSmrg func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy 11205ec34c4cSmrg IFS=$_G_char 11215ec34c4cSmrg for _G_part in $func_quote_result 11225ec34c4cSmrg do 11235ec34c4cSmrg case $1 in 11245ec34c4cSmrg quote) 11255ec34c4cSmrg func_append func_quote_result "$3$2" 11265ec34c4cSmrg set quote "$_G_part" "\\$_G_char" 11275ec34c4cSmrg ;; 11285ec34c4cSmrg start) 11295ec34c4cSmrg set first "" "" 11305ec34c4cSmrg func_quote_result= 11315ec34c4cSmrg ;; 11325ec34c4cSmrg first) 11335ec34c4cSmrg set quote "$_G_part" "" 11345ec34c4cSmrg ;; 11355ec34c4cSmrg esac 11365ec34c4cSmrg done 11375ec34c4cSmrg IFS=$func_quote_old_IFS 11385ec34c4cSmrg done 11395ec34c4cSmrg ;; 11405ec34c4cSmrg *) ;; 11415ec34c4cSmrg esac 11427a84e134Smrg} 11437a84e134Smrg 11447a84e134Smrg 11455ec34c4cSmrg# func_quote_for_eval ARG... 11465ec34c4cSmrg# -------------------------- 11475ec34c4cSmrg# Aesthetically quote ARGs to be evaled later. 11485ec34c4cSmrg# This function returns two values: 11495ec34c4cSmrg# i) func_quote_for_eval_result 11505ec34c4cSmrg# double-quoted, suitable for a subsequent eval 11515ec34c4cSmrg# ii) func_quote_for_eval_unquoted_result 11525ec34c4cSmrg# has all characters that are still active within double 11535ec34c4cSmrg# quotes backslashified. 1154994689c1Smrgfunc_quote_for_eval () 11557a84e134Smrg{ 11565ec34c4cSmrg $debug_cmd 11575ec34c4cSmrg 11585ec34c4cSmrg func_quote_for_eval_unquoted_result= 11595ec34c4cSmrg func_quote_for_eval_result= 11605ec34c4cSmrg while test 0 -lt $#; do 11615ec34c4cSmrg func_quote "$1" 11625ec34c4cSmrg _G_unquoted_arg=$func_quote_result 11635ec34c4cSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 11645ec34c4cSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 11655ec34c4cSmrg else 11665ec34c4cSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 11675ec34c4cSmrg fi 11685ec34c4cSmrg 11695ec34c4cSmrg case $_G_unquoted_arg in 11705ec34c4cSmrg # Double-quote args containing shell metacharacters to delay 11715ec34c4cSmrg # word splitting, command substitution and variable expansion 11725ec34c4cSmrg # for a subsequent eval. 11735ec34c4cSmrg # Many Bourne shells cannot handle close brackets correctly 11745ec34c4cSmrg # in scan sets, so we specify it separately. 11755ec34c4cSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11765ec34c4cSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 11775ec34c4cSmrg ;; 11785ec34c4cSmrg *) 11795ec34c4cSmrg _G_quoted_arg=$_G_unquoted_arg 11805ec34c4cSmrg ;; 11815ec34c4cSmrg esac 11825ec34c4cSmrg 11835ec34c4cSmrg if test -n "$func_quote_for_eval_result"; then 11845ec34c4cSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 11855ec34c4cSmrg else 11865ec34c4cSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 11875ec34c4cSmrg fi 11885ec34c4cSmrg shift 11895ec34c4cSmrg done 11905ec34c4cSmrg} 11915ec34c4cSmrg 11925ec34c4cSmrg 11935ec34c4cSmrg# func_quote_for_expand ARG 11945ec34c4cSmrg# ------------------------- 11955ec34c4cSmrg# Aesthetically quote ARG to be evaled later; same as above, 11965ec34c4cSmrg# but do not quote variable references. 11975ec34c4cSmrgfunc_quote_for_expand () 11985ec34c4cSmrg{ 11995ec34c4cSmrg $debug_cmd 12005ec34c4cSmrg 1201994689c1Smrg case $1 in 12025ec34c4cSmrg *[\\\`\"]*) 12035ec34c4cSmrg _G_arg=`$ECHO "$1" | $SED \ 12045ec34c4cSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1205994689c1Smrg *) 12065ec34c4cSmrg _G_arg=$1 ;; 1207994689c1Smrg esac 1208994689c1Smrg 12095ec34c4cSmrg case $_G_arg in 1210994689c1Smrg # Double-quote args containing shell metacharacters to delay 12115ec34c4cSmrg # word splitting and command substitution for a subsequent eval. 1212994689c1Smrg # Many Bourne shells cannot handle close brackets correctly 1213994689c1Smrg # in scan sets, so we specify it separately. 1214994689c1Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12155ec34c4cSmrg _G_arg=\"$_G_arg\" 1216994689c1Smrg ;; 12175ec34c4cSmrg esac 12185ec34c4cSmrg 12195ec34c4cSmrg func_quote_for_expand_result=$_G_arg 12205ec34c4cSmrg} 12215ec34c4cSmrg 12225ec34c4cSmrg 12235ec34c4cSmrg# func_stripname PREFIX SUFFIX NAME 12245ec34c4cSmrg# --------------------------------- 12255ec34c4cSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 12265ec34c4cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 12275ec34c4cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 12285ec34c4cSmrg# dot (in which case that matches only a dot). 12295ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 12305ec34c4cSmrg eval 'func_stripname () 12315ec34c4cSmrg { 12325ec34c4cSmrg $debug_cmd 12335ec34c4cSmrg 12345ec34c4cSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 12355ec34c4cSmrg # positional parameters, so assign one to ordinary variable first. 12365ec34c4cSmrg func_stripname_result=$3 12375ec34c4cSmrg func_stripname_result=${func_stripname_result#"$1"} 12385ec34c4cSmrg func_stripname_result=${func_stripname_result%"$2"} 12395ec34c4cSmrg }' 12405ec34c4cSmrgelse 12415ec34c4cSmrg func_stripname () 12425ec34c4cSmrg { 12435ec34c4cSmrg $debug_cmd 12445ec34c4cSmrg 12455ec34c4cSmrg case $2 in 12465ec34c4cSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 12475ec34c4cSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 12485ec34c4cSmrg esac 12495ec34c4cSmrg } 12505ec34c4cSmrgfi 12515ec34c4cSmrg 12525ec34c4cSmrg 12535ec34c4cSmrg# func_show_eval CMD [FAIL_EXP] 12545ec34c4cSmrg# ----------------------------- 12555ec34c4cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 12565ec34c4cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 12575ec34c4cSmrg# is given, then evaluate it. 12585ec34c4cSmrgfunc_show_eval () 12595ec34c4cSmrg{ 12605ec34c4cSmrg $debug_cmd 12615ec34c4cSmrg 12625ec34c4cSmrg _G_cmd=$1 12635ec34c4cSmrg _G_fail_exp=${2-':'} 12645ec34c4cSmrg 12655ec34c4cSmrg func_quote_for_expand "$_G_cmd" 12665ec34c4cSmrg eval "func_notquiet $func_quote_for_expand_result" 12675ec34c4cSmrg 12685ec34c4cSmrg $opt_dry_run || { 12695ec34c4cSmrg eval "$_G_cmd" 12705ec34c4cSmrg _G_status=$? 12715ec34c4cSmrg if test 0 -ne "$_G_status"; then 12725ec34c4cSmrg eval "(exit $_G_status); $_G_fail_exp" 12735ec34c4cSmrg fi 12745ec34c4cSmrg } 12755ec34c4cSmrg} 12765ec34c4cSmrg 12775ec34c4cSmrg 12785ec34c4cSmrg# func_show_eval_locale CMD [FAIL_EXP] 12795ec34c4cSmrg# ------------------------------------ 12805ec34c4cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 12815ec34c4cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 12825ec34c4cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 12835ec34c4cSmrgfunc_show_eval_locale () 12845ec34c4cSmrg{ 12855ec34c4cSmrg $debug_cmd 12865ec34c4cSmrg 12875ec34c4cSmrg _G_cmd=$1 12885ec34c4cSmrg _G_fail_exp=${2-':'} 12895ec34c4cSmrg 12905ec34c4cSmrg $opt_quiet || { 12915ec34c4cSmrg func_quote_for_expand "$_G_cmd" 12925ec34c4cSmrg eval "func_echo $func_quote_for_expand_result" 12935ec34c4cSmrg } 12945ec34c4cSmrg 12955ec34c4cSmrg $opt_dry_run || { 12965ec34c4cSmrg eval "$_G_user_locale 12975ec34c4cSmrg $_G_cmd" 12985ec34c4cSmrg _G_status=$? 12995ec34c4cSmrg eval "$_G_safe_locale" 13005ec34c4cSmrg if test 0 -ne "$_G_status"; then 13015ec34c4cSmrg eval "(exit $_G_status); $_G_fail_exp" 13025ec34c4cSmrg fi 13035ec34c4cSmrg } 13045ec34c4cSmrg} 13055ec34c4cSmrg 13065ec34c4cSmrg 13075ec34c4cSmrg# func_tr_sh 13085ec34c4cSmrg# ---------- 13095ec34c4cSmrg# Turn $1 into a string suitable for a shell variable name. 13105ec34c4cSmrg# Result is stored in $func_tr_sh_result. All characters 13115ec34c4cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 13125ec34c4cSmrg# if $1 begins with a digit, a '_' is prepended as well. 13135ec34c4cSmrgfunc_tr_sh () 13145ec34c4cSmrg{ 13155ec34c4cSmrg $debug_cmd 13165ec34c4cSmrg 13175ec34c4cSmrg case $1 in 13185ec34c4cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 13195ec34c4cSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 13205ec34c4cSmrg ;; 13215ec34c4cSmrg * ) 13225ec34c4cSmrg func_tr_sh_result=$1 13235ec34c4cSmrg ;; 13247a84e134Smrg esac 13257a84e134Smrg} 13267a84e134Smrg 13277a84e134Smrg 13285ec34c4cSmrg# func_verbose ARG... 13295ec34c4cSmrg# ------------------- 13305ec34c4cSmrg# Echo program name prefixed message in verbose mode only. 13315ec34c4cSmrgfunc_verbose () 13325ec34c4cSmrg{ 13335ec34c4cSmrg $debug_cmd 13345ec34c4cSmrg 13355ec34c4cSmrg $opt_verbose && func_echo "$*" 13365ec34c4cSmrg 13375ec34c4cSmrg : 13385ec34c4cSmrg} 13395ec34c4cSmrg 13405ec34c4cSmrg 13415ec34c4cSmrg# func_warn_and_continue ARG... 13425ec34c4cSmrg# ----------------------------- 13435ec34c4cSmrg# Echo program name prefixed warning message to standard error. 13445ec34c4cSmrgfunc_warn_and_continue () 13455ec34c4cSmrg{ 13465ec34c4cSmrg $debug_cmd 13475ec34c4cSmrg 13485ec34c4cSmrg $require_term_colors 13495ec34c4cSmrg 13505ec34c4cSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 13515ec34c4cSmrg} 13525ec34c4cSmrg 13535ec34c4cSmrg 13545ec34c4cSmrg# func_warning CATEGORY ARG... 13555ec34c4cSmrg# ---------------------------- 13565ec34c4cSmrg# Echo program name prefixed warning message to standard error. Warning 13575ec34c4cSmrg# messages can be filtered according to CATEGORY, where this function 13585ec34c4cSmrg# elides messages where CATEGORY is not listed in the global variable 13595ec34c4cSmrg# 'opt_warning_types'. 13605ec34c4cSmrgfunc_warning () 13615ec34c4cSmrg{ 13625ec34c4cSmrg $debug_cmd 13635ec34c4cSmrg 13645ec34c4cSmrg # CATEGORY must be in the warning_categories list! 13655ec34c4cSmrg case " $warning_categories " in 13665ec34c4cSmrg *" $1 "*) ;; 13675ec34c4cSmrg *) func_internal_error "invalid warning category '$1'" ;; 13685ec34c4cSmrg esac 13695ec34c4cSmrg 13705ec34c4cSmrg _G_category=$1 13715ec34c4cSmrg shift 13725ec34c4cSmrg 13735ec34c4cSmrg case " $opt_warning_types " in 13745ec34c4cSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 13755ec34c4cSmrg esac 13765ec34c4cSmrg} 13775ec34c4cSmrg 13785ec34c4cSmrg 13795ec34c4cSmrg# func_sort_ver VER1 VER2 13805ec34c4cSmrg# ----------------------- 13815ec34c4cSmrg# 'sort -V' is not generally available. 13825ec34c4cSmrg# Note this deviates from the version comparison in automake 13835ec34c4cSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 13845ec34c4cSmrg# but this should suffice as we won't be specifying old 13855ec34c4cSmrg# version formats or redundant trailing .0 in bootstrap.conf. 13865ec34c4cSmrg# If we did want full compatibility then we should probably 13875ec34c4cSmrg# use m4_version_compare from autoconf. 13885ec34c4cSmrgfunc_sort_ver () 13895ec34c4cSmrg{ 13905ec34c4cSmrg $debug_cmd 13915ec34c4cSmrg 13925ec34c4cSmrg printf '%s\n%s\n' "$1" "$2" \ 13935ec34c4cSmrg | 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 13945ec34c4cSmrg} 13955ec34c4cSmrg 13965ec34c4cSmrg# func_lt_ver PREV CURR 13975ec34c4cSmrg# --------------------- 13985ec34c4cSmrg# Return true if PREV and CURR are in the correct order according to 13995ec34c4cSmrg# func_sort_ver, otherwise false. Use it like this: 14005ec34c4cSmrg# 14015ec34c4cSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 14025ec34c4cSmrgfunc_lt_ver () 14035ec34c4cSmrg{ 14045ec34c4cSmrg $debug_cmd 14055ec34c4cSmrg 14065ec34c4cSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 14075ec34c4cSmrg} 14085ec34c4cSmrg 14095ec34c4cSmrg 14105ec34c4cSmrg# Local variables: 14115ec34c4cSmrg# mode: shell-script 14125ec34c4cSmrg# sh-indentation: 2 14135ec34c4cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 14145ec34c4cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 14155ec34c4cSmrg# time-stamp-time-zone: "UTC" 14165ec34c4cSmrg# End: 14175ec34c4cSmrg#! /bin/sh 14185ec34c4cSmrg 14195ec34c4cSmrg# Set a version string for this script. 14205ec34c4cSmrgscriptversion=2014-01-07.03; # UTC 14215ec34c4cSmrg 14225ec34c4cSmrg# A portable, pluggable option parser for Bourne shell. 14235ec34c4cSmrg# Written by Gary V. Vaughan, 2010 14245ec34c4cSmrg 14255ec34c4cSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 14265ec34c4cSmrg# This is free software; see the source for copying conditions. There is NO 14275ec34c4cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14285ec34c4cSmrg 14295ec34c4cSmrg# This program is free software: you can redistribute it and/or modify 14305ec34c4cSmrg# it under the terms of the GNU General Public License as published by 14315ec34c4cSmrg# the Free Software Foundation, either version 3 of the License, or 14325ec34c4cSmrg# (at your option) any later version. 14335ec34c4cSmrg 14345ec34c4cSmrg# This program is distributed in the hope that it will be useful, 14355ec34c4cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 14365ec34c4cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14375ec34c4cSmrg# GNU General Public License for more details. 14385ec34c4cSmrg 14395ec34c4cSmrg# You should have received a copy of the GNU General Public License 14405ec34c4cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 14415ec34c4cSmrg 14425ec34c4cSmrg# Please report bugs or propose patches to gary@gnu.org. 14435ec34c4cSmrg 14445ec34c4cSmrg 14455ec34c4cSmrg## ------ ## 14465ec34c4cSmrg## Usage. ## 14475ec34c4cSmrg## ------ ## 14485ec34c4cSmrg 14495ec34c4cSmrg# This file is a library for parsing options in your shell scripts along 14505ec34c4cSmrg# with assorted other useful supporting features that you can make use 14515ec34c4cSmrg# of too. 14525ec34c4cSmrg# 14535ec34c4cSmrg# For the simplest scripts you might need only: 14545ec34c4cSmrg# 14555ec34c4cSmrg# #!/bin/sh 14565ec34c4cSmrg# . relative/path/to/funclib.sh 14575ec34c4cSmrg# . relative/path/to/options-parser 14585ec34c4cSmrg# scriptversion=1.0 14595ec34c4cSmrg# func_options ${1+"$@"} 14605ec34c4cSmrg# eval set dummy "$func_options_result"; shift 14615ec34c4cSmrg# ...rest of your script... 14625ec34c4cSmrg# 14635ec34c4cSmrg# In order for the '--version' option to work, you will need to have a 14645ec34c4cSmrg# suitably formatted comment like the one at the top of this file 14655ec34c4cSmrg# starting with '# Written by ' and ending with '# warranty; '. 14665ec34c4cSmrg# 14675ec34c4cSmrg# For '-h' and '--help' to work, you will also need a one line 14685ec34c4cSmrg# description of your script's purpose in a comment directly above the 14695ec34c4cSmrg# '# Written by ' line, like the one at the top of this file. 14705ec34c4cSmrg# 14715ec34c4cSmrg# The default options also support '--debug', which will turn on shell 14725ec34c4cSmrg# execution tracing (see the comment above debug_cmd below for another 14735ec34c4cSmrg# use), and '--verbose' and the func_verbose function to allow your script 14745ec34c4cSmrg# to display verbose messages only when your user has specified 14755ec34c4cSmrg# '--verbose'. 14765ec34c4cSmrg# 14775ec34c4cSmrg# After sourcing this file, you can plug processing for additional 14785ec34c4cSmrg# options by amending the variables from the 'Configuration' section 14795ec34c4cSmrg# below, and following the instructions in the 'Option parsing' 14805ec34c4cSmrg# section further down. 14815ec34c4cSmrg 14825ec34c4cSmrg## -------------- ## 14835ec34c4cSmrg## Configuration. ## 14845ec34c4cSmrg## -------------- ## 14855ec34c4cSmrg 14865ec34c4cSmrg# You should override these variables in your script after sourcing this 14875ec34c4cSmrg# file so that they reflect the customisations you have added to the 14885ec34c4cSmrg# option parser. 14895ec34c4cSmrg 14905ec34c4cSmrg# The usage line for option parsing errors and the start of '-h' and 14915ec34c4cSmrg# '--help' output messages. You can embed shell variables for delayed 14925ec34c4cSmrg# expansion at the time the message is displayed, but you will need to 14935ec34c4cSmrg# quote other shell meta-characters carefully to prevent them being 14945ec34c4cSmrg# expanded when the contents are evaled. 14955ec34c4cSmrgusage='$progpath [OPTION]...' 14965ec34c4cSmrg 14975ec34c4cSmrg# Short help message in response to '-h' and '--help'. Add to this or 14985ec34c4cSmrg# override it after sourcing this library to reflect the full set of 14995ec34c4cSmrg# options your script accepts. 15005ec34c4cSmrgusage_message="\ 15015ec34c4cSmrg --debug enable verbose shell tracing 15025ec34c4cSmrg -W, --warnings=CATEGORY 15035ec34c4cSmrg report the warnings falling in CATEGORY [all] 15045ec34c4cSmrg -v, --verbose verbosely report processing 15055ec34c4cSmrg --version print version information and exit 15065ec34c4cSmrg -h, --help print short or long help message and exit 15075ec34c4cSmrg" 15085ec34c4cSmrg 15095ec34c4cSmrg# Additional text appended to 'usage_message' in response to '--help'. 15105ec34c4cSmrglong_help_message=" 15115ec34c4cSmrgWarning categories include: 15125ec34c4cSmrg 'all' show all warnings 15135ec34c4cSmrg 'none' turn off all the warnings 15145ec34c4cSmrg 'error' warnings are treated as fatal errors" 15155ec34c4cSmrg 15165ec34c4cSmrg# Help message printed before fatal option parsing errors. 15175ec34c4cSmrgfatal_help="Try '\$progname --help' for more information." 15185ec34c4cSmrg 15195ec34c4cSmrg 15205ec34c4cSmrg 15215ec34c4cSmrg## ------------------------- ## 15225ec34c4cSmrg## Hook function management. ## 15235ec34c4cSmrg## ------------------------- ## 15245ec34c4cSmrg 15255ec34c4cSmrg# This section contains functions for adding, removing, and running hooks 15265ec34c4cSmrg# to the main code. A hook is just a named list of of function, that can 15275ec34c4cSmrg# be run in order later on. 15285ec34c4cSmrg 15295ec34c4cSmrg# func_hookable FUNC_NAME 15305ec34c4cSmrg# ----------------------- 15315ec34c4cSmrg# Declare that FUNC_NAME will run hooks added with 15325ec34c4cSmrg# 'func_add_hook FUNC_NAME ...'. 15335ec34c4cSmrgfunc_hookable () 15345ec34c4cSmrg{ 15355ec34c4cSmrg $debug_cmd 15365ec34c4cSmrg 15375ec34c4cSmrg func_append hookable_fns " $1" 15385ec34c4cSmrg} 15395ec34c4cSmrg 15405ec34c4cSmrg 15415ec34c4cSmrg# func_add_hook FUNC_NAME HOOK_FUNC 15425ec34c4cSmrg# --------------------------------- 15435ec34c4cSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 15445ec34c4cSmrg# first have been declared "hookable" by a call to 'func_hookable'. 15455ec34c4cSmrgfunc_add_hook () 15465ec34c4cSmrg{ 15475ec34c4cSmrg $debug_cmd 15485ec34c4cSmrg 15495ec34c4cSmrg case " $hookable_fns " in 15505ec34c4cSmrg *" $1 "*) ;; 15515ec34c4cSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 15525ec34c4cSmrg esac 15535ec34c4cSmrg 15545ec34c4cSmrg eval func_append ${1}_hooks '" $2"' 15555ec34c4cSmrg} 15565ec34c4cSmrg 15575ec34c4cSmrg 15585ec34c4cSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 15595ec34c4cSmrg# ------------------------------------ 15605ec34c4cSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 15615ec34c4cSmrgfunc_remove_hook () 15625ec34c4cSmrg{ 15635ec34c4cSmrg $debug_cmd 15645ec34c4cSmrg 15655ec34c4cSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 15665ec34c4cSmrg} 15675ec34c4cSmrg 15685ec34c4cSmrg 15695ec34c4cSmrg# func_run_hooks FUNC_NAME [ARG]... 15705ec34c4cSmrg# --------------------------------- 15715ec34c4cSmrg# Run all hook functions registered to FUNC_NAME. 15725ec34c4cSmrg# It is assumed that the list of hook functions contains nothing more 15735ec34c4cSmrg# than a whitespace-delimited list of legal shell function names, and 15745ec34c4cSmrg# no effort is wasted trying to catch shell meta-characters or preserve 15755ec34c4cSmrg# whitespace. 15765ec34c4cSmrgfunc_run_hooks () 15775ec34c4cSmrg{ 15785ec34c4cSmrg $debug_cmd 15795ec34c4cSmrg 15805ec34c4cSmrg case " $hookable_fns " in 15815ec34c4cSmrg *" $1 "*) ;; 15825ec34c4cSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 15835ec34c4cSmrg esac 15845ec34c4cSmrg 15855ec34c4cSmrg eval _G_hook_fns=\$$1_hooks; shift 15865ec34c4cSmrg 15875ec34c4cSmrg for _G_hook in $_G_hook_fns; do 15885ec34c4cSmrg eval $_G_hook '"$@"' 15895ec34c4cSmrg 15905ec34c4cSmrg # store returned options list back into positional 15915ec34c4cSmrg # parameters for next 'cmd' execution. 15925ec34c4cSmrg eval _G_hook_result=\$${_G_hook}_result 15935ec34c4cSmrg eval set dummy "$_G_hook_result"; shift 15945ec34c4cSmrg done 15955ec34c4cSmrg 15965ec34c4cSmrg func_quote_for_eval ${1+"$@"} 15975ec34c4cSmrg func_run_hooks_result=$func_quote_for_eval_result 15985ec34c4cSmrg} 15995ec34c4cSmrg 16005ec34c4cSmrg 16015ec34c4cSmrg 16025ec34c4cSmrg## --------------- ## 16035ec34c4cSmrg## Option parsing. ## 16045ec34c4cSmrg## --------------- ## 16055ec34c4cSmrg 16065ec34c4cSmrg# In order to add your own option parsing hooks, you must accept the 16075ec34c4cSmrg# full positional parameter list in your hook function, remove any 16085ec34c4cSmrg# options that you action, and then pass back the remaining unprocessed 16095ec34c4cSmrg# options in '<hooked_function_name>_result', escaped suitably for 16105ec34c4cSmrg# 'eval'. Like this: 16115ec34c4cSmrg# 16125ec34c4cSmrg# my_options_prep () 16135ec34c4cSmrg# { 16145ec34c4cSmrg# $debug_cmd 16155ec34c4cSmrg# 16165ec34c4cSmrg# # Extend the existing usage message. 16175ec34c4cSmrg# usage_message=$usage_message' 16185ec34c4cSmrg# -s, --silent don'\''t print informational messages 16195ec34c4cSmrg# ' 16205ec34c4cSmrg# 16215ec34c4cSmrg# func_quote_for_eval ${1+"$@"} 16225ec34c4cSmrg# my_options_prep_result=$func_quote_for_eval_result 16235ec34c4cSmrg# } 16245ec34c4cSmrg# func_add_hook func_options_prep my_options_prep 16255ec34c4cSmrg# 16265ec34c4cSmrg# 16275ec34c4cSmrg# my_silent_option () 16285ec34c4cSmrg# { 16295ec34c4cSmrg# $debug_cmd 16305ec34c4cSmrg# 16315ec34c4cSmrg# # Note that for efficiency, we parse as many options as we can 16325ec34c4cSmrg# # recognise in a loop before passing the remainder back to the 16335ec34c4cSmrg# # caller on the first unrecognised argument we encounter. 16345ec34c4cSmrg# while test $# -gt 0; do 16355ec34c4cSmrg# opt=$1; shift 16365ec34c4cSmrg# case $opt in 16375ec34c4cSmrg# --silent|-s) opt_silent=: ;; 16385ec34c4cSmrg# # Separate non-argument short options: 16395ec34c4cSmrg# -s*) func_split_short_opt "$_G_opt" 16405ec34c4cSmrg# set dummy "$func_split_short_opt_name" \ 16415ec34c4cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 16425ec34c4cSmrg# shift 16435ec34c4cSmrg# ;; 16445ec34c4cSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 16455ec34c4cSmrg# esac 16465ec34c4cSmrg# done 16475ec34c4cSmrg# 16485ec34c4cSmrg# func_quote_for_eval ${1+"$@"} 16495ec34c4cSmrg# my_silent_option_result=$func_quote_for_eval_result 16505ec34c4cSmrg# } 16515ec34c4cSmrg# func_add_hook func_parse_options my_silent_option 16525ec34c4cSmrg# 16535ec34c4cSmrg# 16545ec34c4cSmrg# my_option_validation () 16555ec34c4cSmrg# { 16565ec34c4cSmrg# $debug_cmd 16575ec34c4cSmrg# 16585ec34c4cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 16595ec34c4cSmrg# '--silent' and '--verbose' options are mutually exclusive." 16605ec34c4cSmrg# 16615ec34c4cSmrg# func_quote_for_eval ${1+"$@"} 16625ec34c4cSmrg# my_option_validation_result=$func_quote_for_eval_result 16635ec34c4cSmrg# } 16645ec34c4cSmrg# func_add_hook func_validate_options my_option_validation 16655ec34c4cSmrg# 16665ec34c4cSmrg# You'll alse need to manually amend $usage_message to reflect the extra 16675ec34c4cSmrg# options you parse. It's preferable to append if you can, so that 16685ec34c4cSmrg# multiple option parsing hooks can be added safely. 16695ec34c4cSmrg 16705ec34c4cSmrg 16715ec34c4cSmrg# func_options [ARG]... 16725ec34c4cSmrg# --------------------- 16735ec34c4cSmrg# All the functions called inside func_options are hookable. See the 16745ec34c4cSmrg# individual implementations for details. 16755ec34c4cSmrgfunc_hookable func_options 16765ec34c4cSmrgfunc_options () 16777a84e134Smrg{ 16785ec34c4cSmrg $debug_cmd 1679994689c1Smrg 16805ec34c4cSmrg func_options_prep ${1+"$@"} 16815ec34c4cSmrg eval func_parse_options \ 16825ec34c4cSmrg ${func_options_prep_result+"$func_options_prep_result"} 16835ec34c4cSmrg eval func_validate_options \ 16845ec34c4cSmrg ${func_parse_options_result+"$func_parse_options_result"} 1685994689c1Smrg 16865ec34c4cSmrg eval func_run_hooks func_options \ 16875ec34c4cSmrg ${func_validate_options_result+"$func_validate_options_result"} 16885ec34c4cSmrg 16895ec34c4cSmrg # save modified positional parameters for caller 16905ec34c4cSmrg func_options_result=$func_run_hooks_result 16917a84e134Smrg} 16927a84e134Smrg 16937a84e134Smrg 16945ec34c4cSmrg# func_options_prep [ARG]... 16955ec34c4cSmrg# -------------------------- 16965ec34c4cSmrg# All initialisations required before starting the option parse loop. 16975ec34c4cSmrg# Note that when calling hook functions, we pass through the list of 16985ec34c4cSmrg# positional parameters. If a hook function modifies that list, and 16995ec34c4cSmrg# needs to propogate that back to rest of this script, then the complete 17005ec34c4cSmrg# modified list must be put in 'func_run_hooks_result' before 17015ec34c4cSmrg# returning. 17025ec34c4cSmrgfunc_hookable func_options_prep 17035ec34c4cSmrgfunc_options_prep () 17047a84e134Smrg{ 17055ec34c4cSmrg $debug_cmd 1706775e7de9Smrg 17075ec34c4cSmrg # Option defaults: 17085ec34c4cSmrg opt_verbose=false 17095ec34c4cSmrg opt_warning_types= 1710994689c1Smrg 17115ec34c4cSmrg func_run_hooks func_options_prep ${1+"$@"} 17125ec34c4cSmrg 17135ec34c4cSmrg # save modified positional parameters for caller 17145ec34c4cSmrg func_options_prep_result=$func_run_hooks_result 17157a84e134Smrg} 17167a84e134Smrg 1717994689c1Smrg 17185ec34c4cSmrg# func_parse_options [ARG]... 17195ec34c4cSmrg# --------------------------- 17205ec34c4cSmrg# The main option parsing loop. 17215ec34c4cSmrgfunc_hookable func_parse_options 17225ec34c4cSmrgfunc_parse_options () 17237a84e134Smrg{ 17245ec34c4cSmrg $debug_cmd 17257a84e134Smrg 17265ec34c4cSmrg func_parse_options_result= 1727775e7de9Smrg 17285ec34c4cSmrg # this just eases exit handling 17295ec34c4cSmrg while test $# -gt 0; do 17305ec34c4cSmrg # Defer to hook functions for initial option parsing, so they 17315ec34c4cSmrg # get priority in the event of reusing an option name. 17325ec34c4cSmrg func_run_hooks func_parse_options ${1+"$@"} 1733775e7de9Smrg 17345ec34c4cSmrg # Adjust func_parse_options positional parameters to match 17355ec34c4cSmrg eval set dummy "$func_run_hooks_result"; shift 17365ec34c4cSmrg 17375ec34c4cSmrg # Break out of the loop if we already parsed every option. 17385ec34c4cSmrg test $# -gt 0 || break 17395ec34c4cSmrg 17405ec34c4cSmrg _G_opt=$1 17415ec34c4cSmrg shift 17425ec34c4cSmrg case $_G_opt in 17435ec34c4cSmrg --debug|-x) debug_cmd='set -x' 17445ec34c4cSmrg func_echo "enabling shell trace mode" 17455ec34c4cSmrg $debug_cmd 17465ec34c4cSmrg ;; 17475ec34c4cSmrg 17485ec34c4cSmrg --no-warnings|--no-warning|--no-warn) 17495ec34c4cSmrg set dummy --warnings none ${1+"$@"} 17505ec34c4cSmrg shift 17515ec34c4cSmrg ;; 17525ec34c4cSmrg 17535ec34c4cSmrg --warnings|--warning|-W) 17545ec34c4cSmrg test $# = 0 && func_missing_arg $_G_opt && break 17555ec34c4cSmrg case " $warning_categories $1" in 17565ec34c4cSmrg *" $1 "*) 17575ec34c4cSmrg # trailing space prevents matching last $1 above 17585ec34c4cSmrg func_append_uniq opt_warning_types " $1" 17595ec34c4cSmrg ;; 17605ec34c4cSmrg *all) 17615ec34c4cSmrg opt_warning_types=$warning_categories 17625ec34c4cSmrg ;; 17635ec34c4cSmrg *none) 17645ec34c4cSmrg opt_warning_types=none 17655ec34c4cSmrg warning_func=: 17665ec34c4cSmrg ;; 17675ec34c4cSmrg *error) 17685ec34c4cSmrg opt_warning_types=$warning_categories 17695ec34c4cSmrg warning_func=func_fatal_error 17705ec34c4cSmrg ;; 17715ec34c4cSmrg *) 17725ec34c4cSmrg func_fatal_error \ 17735ec34c4cSmrg "unsupported warning category: '$1'" 17745ec34c4cSmrg ;; 17755ec34c4cSmrg esac 17765ec34c4cSmrg shift 17775ec34c4cSmrg ;; 17785ec34c4cSmrg 17795ec34c4cSmrg --verbose|-v) opt_verbose=: ;; 17805ec34c4cSmrg --version) func_version ;; 17815ec34c4cSmrg -\?|-h) func_usage ;; 17825ec34c4cSmrg --help) func_help ;; 17835ec34c4cSmrg 17845ec34c4cSmrg # Separate optargs to long options (plugins may need this): 17855ec34c4cSmrg --*=*) func_split_equals "$_G_opt" 17865ec34c4cSmrg set dummy "$func_split_equals_lhs" \ 17875ec34c4cSmrg "$func_split_equals_rhs" ${1+"$@"} 17885ec34c4cSmrg shift 17895ec34c4cSmrg ;; 17905ec34c4cSmrg 17915ec34c4cSmrg # Separate optargs to short options: 17925ec34c4cSmrg -W*) 17935ec34c4cSmrg func_split_short_opt "$_G_opt" 17945ec34c4cSmrg set dummy "$func_split_short_opt_name" \ 17955ec34c4cSmrg "$func_split_short_opt_arg" ${1+"$@"} 17965ec34c4cSmrg shift 17975ec34c4cSmrg ;; 17985ec34c4cSmrg 17995ec34c4cSmrg # Separate non-argument short options: 18005ec34c4cSmrg -\?*|-h*|-v*|-x*) 18015ec34c4cSmrg func_split_short_opt "$_G_opt" 18025ec34c4cSmrg set dummy "$func_split_short_opt_name" \ 18035ec34c4cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 18045ec34c4cSmrg shift 18055ec34c4cSmrg ;; 18065ec34c4cSmrg 18075ec34c4cSmrg --) break ;; 18085ec34c4cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 18095ec34c4cSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 18105ec34c4cSmrg esac 18115ec34c4cSmrg done 18125ec34c4cSmrg 18135ec34c4cSmrg # save modified positional parameters for caller 18145ec34c4cSmrg func_quote_for_eval ${1+"$@"} 18155ec34c4cSmrg func_parse_options_result=$func_quote_for_eval_result 1816f353fbadSmrg} 1817f353fbadSmrg 1818775e7de9Smrg 18195ec34c4cSmrg# func_validate_options [ARG]... 18205ec34c4cSmrg# ------------------------------ 18215ec34c4cSmrg# Perform any sanity checks on option settings and/or unconsumed 18225ec34c4cSmrg# arguments. 18235ec34c4cSmrgfunc_hookable func_validate_options 18245ec34c4cSmrgfunc_validate_options () 1825994689c1Smrg{ 18265ec34c4cSmrg $debug_cmd 1827f353fbadSmrg 18285ec34c4cSmrg # Display all warnings if -W was not given. 18295ec34c4cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 18305ec34c4cSmrg 18315ec34c4cSmrg func_run_hooks func_validate_options ${1+"$@"} 18325ec34c4cSmrg 18335ec34c4cSmrg # Bail if the options were screwed! 18345ec34c4cSmrg $exit_cmd $EXIT_FAILURE 18355ec34c4cSmrg 18365ec34c4cSmrg # save modified positional parameters for caller 18375ec34c4cSmrg func_validate_options_result=$func_run_hooks_result 1838994689c1Smrg} 1839775e7de9Smrg 18405ec34c4cSmrg 18415ec34c4cSmrg 18425ec34c4cSmrg## ----------------- ## 18435ec34c4cSmrg## Helper functions. ## 18445ec34c4cSmrg## ----------------- ## 18455ec34c4cSmrg 18465ec34c4cSmrg# This section contains the helper functions used by the rest of the 18475ec34c4cSmrg# hookable option parser framework in ascii-betical order. 18485ec34c4cSmrg 18495ec34c4cSmrg 18505ec34c4cSmrg# func_fatal_help ARG... 18515ec34c4cSmrg# ---------------------- 18525ec34c4cSmrg# Echo program name prefixed message to standard error, followed by 18535ec34c4cSmrg# a help hint, and exit. 18545ec34c4cSmrgfunc_fatal_help () 1855994689c1Smrg{ 18565ec34c4cSmrg $debug_cmd 1857f353fbadSmrg 18585ec34c4cSmrg eval \$ECHO \""Usage: $usage"\" 18595ec34c4cSmrg eval \$ECHO \""$fatal_help"\" 18605ec34c4cSmrg func_error ${1+"$@"} 18615ec34c4cSmrg exit $EXIT_FAILURE 1862994689c1Smrg} 18637a84e134Smrg 18645ec34c4cSmrg 18655ec34c4cSmrg# func_help 18665ec34c4cSmrg# --------- 18675ec34c4cSmrg# Echo long help message to standard output and exit. 1868994689c1Smrgfunc_help () 1869994689c1Smrg{ 18705ec34c4cSmrg $debug_cmd 18715ec34c4cSmrg 18725ec34c4cSmrg func_usage_message 18735ec34c4cSmrg $ECHO "$long_help_message" 18745ec34c4cSmrg exit 0 1875994689c1Smrg} 18767a84e134Smrg 18775ec34c4cSmrg 18785ec34c4cSmrg# func_missing_arg ARGNAME 18795ec34c4cSmrg# ------------------------ 1880994689c1Smrg# Echo program name prefixed message to standard error and set global 1881994689c1Smrg# exit_cmd. 1882994689c1Smrgfunc_missing_arg () 1883994689c1Smrg{ 18845ec34c4cSmrg $debug_cmd 1885f353fbadSmrg 18865ec34c4cSmrg func_error "Missing argument for '$1'." 1887994689c1Smrg exit_cmd=exit 1888994689c1Smrg} 18897a84e134Smrg 1890775e7de9Smrg 18915ec34c4cSmrg# func_split_equals STRING 18925ec34c4cSmrg# ------------------------ 18935ec34c4cSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 18945ec34c4cSmrg# splitting STRING at the '=' sign. 18955ec34c4cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 18965ec34c4cSmrg && (eval 'x=a/b/c; 18975ec34c4cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 18985ec34c4cSmrg && _G_HAVE_XSI_OPS=yes 18995ec34c4cSmrg 19005ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS" 19015ec34c4cSmrgthen 19025ec34c4cSmrg # This is an XSI compatible shell, allowing a faster implementation... 19035ec34c4cSmrg eval 'func_split_equals () 19045ec34c4cSmrg { 19055ec34c4cSmrg $debug_cmd 19065ec34c4cSmrg 19075ec34c4cSmrg func_split_equals_lhs=${1%%=*} 19085ec34c4cSmrg func_split_equals_rhs=${1#*=} 19095ec34c4cSmrg test "x$func_split_equals_lhs" = "x$1" \ 19105ec34c4cSmrg && func_split_equals_rhs= 19115ec34c4cSmrg }' 19125ec34c4cSmrgelse 19135ec34c4cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 19145ec34c4cSmrg func_split_equals () 19155ec34c4cSmrg { 19165ec34c4cSmrg $debug_cmd 19175ec34c4cSmrg 19185ec34c4cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 19195ec34c4cSmrg func_split_equals_rhs= 19205ec34c4cSmrg test "x$func_split_equals_lhs" = "x$1" \ 19215ec34c4cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 19225ec34c4cSmrg } 19235ec34c4cSmrgfi #func_split_equals 19245ec34c4cSmrg 19255ec34c4cSmrg 19265ec34c4cSmrg# func_split_short_opt SHORTOPT 19275ec34c4cSmrg# ----------------------------- 1928f353fbadSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1929f353fbadSmrg# variables after splitting SHORTOPT after the 2nd character. 19305ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS" 19315ec34c4cSmrgthen 19325ec34c4cSmrg # This is an XSI compatible shell, allowing a faster implementation... 19335ec34c4cSmrg eval 'func_split_short_opt () 19345ec34c4cSmrg { 19355ec34c4cSmrg $debug_cmd 19365ec34c4cSmrg 19375ec34c4cSmrg func_split_short_opt_arg=${1#??} 19385ec34c4cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 19395ec34c4cSmrg }' 19405ec34c4cSmrgelse 19415ec34c4cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 19425ec34c4cSmrg func_split_short_opt () 19435ec34c4cSmrg { 19445ec34c4cSmrg $debug_cmd 19455ec34c4cSmrg 19465ec34c4cSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 19475ec34c4cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 19485ec34c4cSmrg } 19495ec34c4cSmrgfi #func_split_short_opt 19505ec34c4cSmrg 19515ec34c4cSmrg 19525ec34c4cSmrg# func_usage 19535ec34c4cSmrg# ---------- 19545ec34c4cSmrg# Echo short help message to standard output and exit. 19555ec34c4cSmrgfunc_usage () 1956f353fbadSmrg{ 19575ec34c4cSmrg $debug_cmd 1958f353fbadSmrg 19595ec34c4cSmrg func_usage_message 19605ec34c4cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 19615ec34c4cSmrg exit 0 19625ec34c4cSmrg} 1963f353fbadSmrg 1964f353fbadSmrg 19655ec34c4cSmrg# func_usage_message 19665ec34c4cSmrg# ------------------ 19675ec34c4cSmrg# Echo short help message to standard output. 19685ec34c4cSmrgfunc_usage_message () 1969f353fbadSmrg{ 19705ec34c4cSmrg $debug_cmd 1971f353fbadSmrg 19725ec34c4cSmrg eval \$ECHO \""Usage: $usage"\" 19735ec34c4cSmrg echo 19745ec34c4cSmrg $SED -n 's|^# || 19755ec34c4cSmrg /^Written by/{ 19765ec34c4cSmrg x;p;x 19775ec34c4cSmrg } 19785ec34c4cSmrg h 19795ec34c4cSmrg /^Written by/q' < "$progpath" 19805ec34c4cSmrg echo 19815ec34c4cSmrg eval \$ECHO \""$usage_message"\" 19825ec34c4cSmrg} 1983f353fbadSmrg 19847a84e134Smrg 19855ec34c4cSmrg# func_version 19865ec34c4cSmrg# ------------ 19875ec34c4cSmrg# Echo version message to standard output and exit. 19885ec34c4cSmrgfunc_version () 19895ec34c4cSmrg{ 19905ec34c4cSmrg $debug_cmd 1991ab902922Smrg 19925ec34c4cSmrg printf '%s\n' "$progname $scriptversion" 19935ec34c4cSmrg $SED -n ' 19945ec34c4cSmrg /(C)/!b go 19955ec34c4cSmrg :more 19965ec34c4cSmrg /\./!{ 19975ec34c4cSmrg N 19985ec34c4cSmrg s|\n# | | 19995ec34c4cSmrg b more 20005ec34c4cSmrg } 20015ec34c4cSmrg :go 20025ec34c4cSmrg /^# Written by /,/# warranty; / { 20035ec34c4cSmrg s|^# || 20045ec34c4cSmrg s|^# *$|| 20055ec34c4cSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 20065ec34c4cSmrg p 20075ec34c4cSmrg } 20085ec34c4cSmrg /^# Written by / { 20095ec34c4cSmrg s|^# || 20105ec34c4cSmrg p 20115ec34c4cSmrg } 20125ec34c4cSmrg /^warranty; /q' < "$progpath" 2013775e7de9Smrg 20145ec34c4cSmrg exit $? 20155ec34c4cSmrg} 20167a84e134Smrg 2017994689c1Smrg 20185ec34c4cSmrg# Local variables: 20195ec34c4cSmrg# mode: shell-script 20205ec34c4cSmrg# sh-indentation: 2 20215ec34c4cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 20225ec34c4cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 20235ec34c4cSmrg# time-stamp-time-zone: "UTC" 20245ec34c4cSmrg# End: 2025994689c1Smrg 20265ec34c4cSmrg# Set a version string. 20275ec34c4cSmrgscriptversion='(GNU libtool) 2.4.6' 2028994689c1Smrg 2029994689c1Smrg 20305ec34c4cSmrg# func_echo ARG... 20315ec34c4cSmrg# ---------------- 20325ec34c4cSmrg# Libtool also displays the current mode in messages, so override 20335ec34c4cSmrg# funclib.sh func_echo with this custom definition. 20345ec34c4cSmrgfunc_echo () 2035f353fbadSmrg{ 20365ec34c4cSmrg $debug_cmd 2037f353fbadSmrg 20385ec34c4cSmrg _G_message=$* 2039f353fbadSmrg 20405ec34c4cSmrg func_echo_IFS=$IFS 20415ec34c4cSmrg IFS=$nl 20425ec34c4cSmrg for _G_line in $_G_message; do 20435ec34c4cSmrg IFS=$func_echo_IFS 20445ec34c4cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 20455ec34c4cSmrg done 20465ec34c4cSmrg IFS=$func_echo_IFS 20475ec34c4cSmrg} 2048f353fbadSmrg 20495ec34c4cSmrg 20505ec34c4cSmrg# func_warning ARG... 20515ec34c4cSmrg# ------------------- 20525ec34c4cSmrg# Libtool warnings are not categorized, so override funclib.sh 20535ec34c4cSmrg# func_warning with this simpler definition. 20545ec34c4cSmrgfunc_warning () 2055f353fbadSmrg{ 20565ec34c4cSmrg $debug_cmd 2057f353fbadSmrg 20585ec34c4cSmrg $warning_func ${1+"$@"} 20595ec34c4cSmrg} 2060f353fbadSmrg 2061f353fbadSmrg 20625ec34c4cSmrg## ---------------- ## 20635ec34c4cSmrg## Options parsing. ## 20645ec34c4cSmrg## ---------------- ## 20655ec34c4cSmrg 20665ec34c4cSmrg# Hook in the functions to make sure our own options are parsed during 20675ec34c4cSmrg# the option parsing loop. 20685ec34c4cSmrg 20695ec34c4cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 20705ec34c4cSmrg 20715ec34c4cSmrg# Short help message in response to '-h'. 20725ec34c4cSmrgusage_message="Options: 20735ec34c4cSmrg --config show all configuration variables 20745ec34c4cSmrg --debug enable verbose shell tracing 20755ec34c4cSmrg -n, --dry-run display commands without modifying any files 20765ec34c4cSmrg --features display basic configuration information and exit 20775ec34c4cSmrg --mode=MODE use operation mode MODE 20785ec34c4cSmrg --no-warnings equivalent to '-Wnone' 20795ec34c4cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 20805ec34c4cSmrg --quiet, --silent don't print informational messages 20815ec34c4cSmrg --tag=TAG use configuration variables from tag TAG 20825ec34c4cSmrg -v, --verbose print more informational messages than default 20835ec34c4cSmrg --version print version information 20845ec34c4cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 20855ec34c4cSmrg -h, --help, --help-all print short, long, or detailed help message 20865ec34c4cSmrg" 2087f353fbadSmrg 20885ec34c4cSmrg# Additional text appended to 'usage_message' in response to '--help'. 20895ec34c4cSmrgfunc_help () 2090f353fbadSmrg{ 20915ec34c4cSmrg $debug_cmd 20925ec34c4cSmrg 20935ec34c4cSmrg func_usage_message 20945ec34c4cSmrg $ECHO "$long_help_message 20955ec34c4cSmrg 20965ec34c4cSmrgMODE must be one of the following: 20975ec34c4cSmrg 20985ec34c4cSmrg clean remove files from the build directory 20995ec34c4cSmrg compile compile a source file into a libtool object 21005ec34c4cSmrg execute automatically set library path, then run a program 21015ec34c4cSmrg finish complete the installation of libtool libraries 21025ec34c4cSmrg install install libraries or executables 21035ec34c4cSmrg link create a library or an executable 21045ec34c4cSmrg uninstall remove libraries from an installed directory 21055ec34c4cSmrg 21065ec34c4cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 21075ec34c4cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 21085ec34c4cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 21095ec34c4cSmrg 21105ec34c4cSmrgWhen reporting a bug, please describe a test case to reproduce it and 21115ec34c4cSmrginclude the following information: 21125ec34c4cSmrg 21135ec34c4cSmrg host-triplet: $host 21145ec34c4cSmrg shell: $SHELL 21155ec34c4cSmrg compiler: $LTCC 21165ec34c4cSmrg compiler flags: $LTCFLAGS 21175ec34c4cSmrg linker: $LD (gnu? $with_gnu_ld) 21185ec34c4cSmrg version: $progname (GNU libtool) 2.4.6 21195ec34c4cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 21205ec34c4cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 21215ec34c4cSmrg 21225ec34c4cSmrgReport bugs to <bug-libtool@gnu.org>. 21235ec34c4cSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 21245ec34c4cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 21255ec34c4cSmrg exit 0 21265ec34c4cSmrg} 2127f353fbadSmrg 2128f353fbadSmrg 21295ec34c4cSmrg# func_lo2o OBJECT-NAME 21305ec34c4cSmrg# --------------------- 21315ec34c4cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 21325ec34c4cSmrg# object suffix. 21335ec34c4cSmrg 21345ec34c4cSmrglo2o=s/\\.lo\$/.$objext/ 21355ec34c4cSmrgo2lo=s/\\.$objext\$/.lo/ 21365ec34c4cSmrg 21375ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 21385ec34c4cSmrg eval 'func_lo2o () 21395ec34c4cSmrg { 21405ec34c4cSmrg case $1 in 21415ec34c4cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 21425ec34c4cSmrg * ) func_lo2o_result=$1 ;; 21435ec34c4cSmrg esac 21445ec34c4cSmrg }' 21455ec34c4cSmrg 21465ec34c4cSmrg # func_xform LIBOBJ-OR-SOURCE 21475ec34c4cSmrg # --------------------------- 21485ec34c4cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 21495ec34c4cSmrg # suffix to a '.lo' libtool-object suffix. 21505ec34c4cSmrg eval 'func_xform () 21515ec34c4cSmrg { 21525ec34c4cSmrg func_xform_result=${1%.*}.lo 21535ec34c4cSmrg }' 21545ec34c4cSmrgelse 21555ec34c4cSmrg # ...otherwise fall back to using sed. 21565ec34c4cSmrg func_lo2o () 21575ec34c4cSmrg { 21585ec34c4cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 21595ec34c4cSmrg } 21605ec34c4cSmrg 21615ec34c4cSmrg func_xform () 21625ec34c4cSmrg { 21635ec34c4cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 21645ec34c4cSmrg } 21655ec34c4cSmrgfi 2166f353fbadSmrg 2167f353fbadSmrg 21685ec34c4cSmrg# func_fatal_configuration ARG... 21695ec34c4cSmrg# ------------------------------- 2170994689c1Smrg# Echo program name prefixed message to standard error, followed by 2171994689c1Smrg# a configuration failure hint, and exit. 2172994689c1Smrgfunc_fatal_configuration () 2173994689c1Smrg{ 21745ec34c4cSmrg func__fatal_error ${1+"$@"} \ 21755ec34c4cSmrg "See the $PACKAGE documentation for more information." \ 21765ec34c4cSmrg "Fatal configuration error." 2177994689c1Smrg} 2178994689c1Smrg 2179994689c1Smrg 2180994689c1Smrg# func_config 21815ec34c4cSmrg# ----------- 2182994689c1Smrg# Display the configuration for all the tags in this script. 2183994689c1Smrgfunc_config () 2184994689c1Smrg{ 2185994689c1Smrg re_begincf='^# ### BEGIN LIBTOOL' 2186994689c1Smrg re_endcf='^# ### END LIBTOOL' 2187994689c1Smrg 2188994689c1Smrg # Default configuration. 2189994689c1Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2190994689c1Smrg 21917a84e134Smrg # Now print the configurations for the tags. 21927a84e134Smrg for tagname in $taglist; do 2193994689c1Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 21947a84e134Smrg done 2195e1e1713cSmrg 2196994689c1Smrg exit $? 2197994689c1Smrg} 2198e1e1713cSmrg 21995ec34c4cSmrg 2200994689c1Smrg# func_features 22015ec34c4cSmrg# ------------- 2202994689c1Smrg# Display the features supported by this script. 2203994689c1Smrgfunc_features () 2204994689c1Smrg{ 2205994689c1Smrg echo "host: $host" 22065ec34c4cSmrg if test yes = "$build_libtool_libs"; then 2207994689c1Smrg echo "enable shared libraries" 22087a84e134Smrg else 2209994689c1Smrg echo "disable shared libraries" 22107a84e134Smrg fi 22115ec34c4cSmrg if test yes = "$build_old_libs"; then 2212994689c1Smrg echo "enable static libraries" 22137a84e134Smrg else 2214994689c1Smrg echo "disable static libraries" 22157a84e134Smrg fi 2216994689c1Smrg 22177a84e134Smrg exit $? 2218994689c1Smrg} 22197a84e134Smrg 22205ec34c4cSmrg 22215ec34c4cSmrg# func_enable_tag TAGNAME 22225ec34c4cSmrg# ----------------------- 2223994689c1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2224994689c1Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2225994689c1Smrg# variable here. 2226994689c1Smrgfunc_enable_tag () 2227994689c1Smrg{ 22285ec34c4cSmrg # Global variable: 22295ec34c4cSmrg tagname=$1 22307a84e134Smrg 22315ec34c4cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 22325ec34c4cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 22335ec34c4cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2234775e7de9Smrg 22355ec34c4cSmrg # Validate tagname. 22365ec34c4cSmrg case $tagname in 22375ec34c4cSmrg *[!-_A-Za-z0-9,/]*) 22385ec34c4cSmrg func_fatal_error "invalid tag name: $tagname" 22395ec34c4cSmrg ;; 22405ec34c4cSmrg esac 22417a84e134Smrg 22425ec34c4cSmrg # Don't test for the "default" C tag, as we know it's 22435ec34c4cSmrg # there but not specially marked. 22445ec34c4cSmrg case $tagname in 22455ec34c4cSmrg CC) ;; 2246994689c1Smrg *) 22475ec34c4cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 22485ec34c4cSmrg taglist="$taglist $tagname" 22495ec34c4cSmrg 22505ec34c4cSmrg # Evaluate the configuration. Be careful to quote the path 22515ec34c4cSmrg # and the sed script, to avoid splitting on whitespace, but 22525ec34c4cSmrg # also don't use non-portable quotes within backquotes within 22535ec34c4cSmrg # quotes we have to do it in 2 steps: 22545ec34c4cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 22555ec34c4cSmrg eval "$extractedcf" 22565ec34c4cSmrg else 22575ec34c4cSmrg func_error "ignoring unknown tag $tagname" 22585ec34c4cSmrg fi 22595ec34c4cSmrg ;; 22605ec34c4cSmrg esac 2261994689c1Smrg} 2262994689c1Smrg 22635ec34c4cSmrg 2264f353fbadSmrg# func_check_version_match 22655ec34c4cSmrg# ------------------------ 2266f353fbadSmrg# Ensure that we are using m4 macros, and libtool script from the same 2267f353fbadSmrg# release of libtool. 2268f353fbadSmrgfunc_check_version_match () 2269994689c1Smrg{ 22705ec34c4cSmrg if test "$package_revision" != "$macro_revision"; then 22715ec34c4cSmrg if test "$VERSION" != "$macro_version"; then 22725ec34c4cSmrg if test -z "$macro_version"; then 22735ec34c4cSmrg cat >&2 <<_LT_EOF 2274f353fbadSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2275f353fbadSmrg$progname: definition of this LT_INIT comes from an older release. 2276f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2277f353fbadSmrg$progname: and run autoconf again. 2278f353fbadSmrg_LT_EOF 22795ec34c4cSmrg else 22805ec34c4cSmrg cat >&2 <<_LT_EOF 2281f353fbadSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2282f353fbadSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2283f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2284f353fbadSmrg$progname: and run autoconf again. 2285f353fbadSmrg_LT_EOF 22865ec34c4cSmrg fi 22875ec34c4cSmrg else 22885ec34c4cSmrg cat >&2 <<_LT_EOF 2289f353fbadSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2290f353fbadSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2291f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2292f353fbadSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2293f353fbadSmrg_LT_EOF 22945ec34c4cSmrg fi 2295e1e1713cSmrg 22965ec34c4cSmrg exit $EXIT_MISMATCH 22975ec34c4cSmrg fi 2298f353fbadSmrg} 2299f353fbadSmrg 2300f353fbadSmrg 23015ec34c4cSmrg# libtool_options_prep [ARG]... 23025ec34c4cSmrg# ----------------------------- 23035ec34c4cSmrg# Preparation for options parsed by libtool. 23045ec34c4cSmrglibtool_options_prep () 23055ec34c4cSmrg{ 23065ec34c4cSmrg $debug_mode 23077a84e134Smrg 23085ec34c4cSmrg # Option defaults: 23095ec34c4cSmrg opt_config=false 23105ec34c4cSmrg opt_dlopen= 23115ec34c4cSmrg opt_dry_run=false 23125ec34c4cSmrg opt_help=false 23135ec34c4cSmrg opt_mode= 23145ec34c4cSmrg opt_preserve_dup_deps=false 23155ec34c4cSmrg opt_quiet=false 2316f353fbadSmrg 23175ec34c4cSmrg nonopt= 23185ec34c4cSmrg preserve_args= 2319f353fbadSmrg 23205ec34c4cSmrg # Shorthand for --mode=foo, only valid as the first argument 23215ec34c4cSmrg case $1 in 23225ec34c4cSmrg clean|clea|cle|cl) 23235ec34c4cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 23245ec34c4cSmrg ;; 23255ec34c4cSmrg compile|compil|compi|comp|com|co|c) 23265ec34c4cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 23275ec34c4cSmrg ;; 23285ec34c4cSmrg execute|execut|execu|exec|exe|ex|e) 23295ec34c4cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 23305ec34c4cSmrg ;; 23315ec34c4cSmrg finish|finis|fini|fin|fi|f) 23325ec34c4cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 23335ec34c4cSmrg ;; 23345ec34c4cSmrg install|instal|insta|inst|ins|in|i) 23355ec34c4cSmrg shift; set dummy --mode install ${1+"$@"}; shift 23365ec34c4cSmrg ;; 23375ec34c4cSmrg link|lin|li|l) 23385ec34c4cSmrg shift; set dummy --mode link ${1+"$@"}; shift 23395ec34c4cSmrg ;; 23405ec34c4cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 23415ec34c4cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 23425ec34c4cSmrg ;; 23435ec34c4cSmrg esac 23445ec34c4cSmrg 23455ec34c4cSmrg # Pass back the list of options. 23465ec34c4cSmrg func_quote_for_eval ${1+"$@"} 23475ec34c4cSmrg libtool_options_prep_result=$func_quote_for_eval_result 23485ec34c4cSmrg} 23495ec34c4cSmrgfunc_add_hook func_options_prep libtool_options_prep 2350f353fbadSmrg 2351f353fbadSmrg 23525ec34c4cSmrg# libtool_parse_options [ARG]... 23535ec34c4cSmrg# --------------------------------- 23545ec34c4cSmrg# Provide handling for libtool specific options. 23555ec34c4cSmrglibtool_parse_options () 2356f353fbadSmrg{ 23575ec34c4cSmrg $debug_cmd 2358994689c1Smrg 23595ec34c4cSmrg # Perform our own loop to consume as many options as possible in 23605ec34c4cSmrg # each iteration. 23615ec34c4cSmrg while test $# -gt 0; do 23625ec34c4cSmrg _G_opt=$1 23635ec34c4cSmrg shift 23645ec34c4cSmrg case $_G_opt in 23655ec34c4cSmrg --dry-run|--dryrun|-n) 23665ec34c4cSmrg opt_dry_run=: 23675ec34c4cSmrg ;; 23685ec34c4cSmrg 23695ec34c4cSmrg --config) func_config ;; 23705ec34c4cSmrg 23715ec34c4cSmrg --dlopen|-dlopen) 23725ec34c4cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 23735ec34c4cSmrg}$1" 23745ec34c4cSmrg shift 23755ec34c4cSmrg ;; 23765ec34c4cSmrg 23775ec34c4cSmrg --preserve-dup-deps) 23785ec34c4cSmrg opt_preserve_dup_deps=: ;; 23795ec34c4cSmrg 23805ec34c4cSmrg --features) func_features ;; 23815ec34c4cSmrg 23825ec34c4cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 23835ec34c4cSmrg 23845ec34c4cSmrg --help) opt_help=: ;; 23855ec34c4cSmrg 23865ec34c4cSmrg --help-all) opt_help=': help-all' ;; 23875ec34c4cSmrg 23885ec34c4cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 23895ec34c4cSmrg opt_mode=$1 23905ec34c4cSmrg case $1 in 23915ec34c4cSmrg # Valid mode arguments: 23925ec34c4cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 23935ec34c4cSmrg 23945ec34c4cSmrg # Catch anything else as an error 23955ec34c4cSmrg *) func_error "invalid argument for $_G_opt" 23965ec34c4cSmrg exit_cmd=exit 23975ec34c4cSmrg break 23985ec34c4cSmrg ;; 23995ec34c4cSmrg esac 24005ec34c4cSmrg shift 24015ec34c4cSmrg ;; 24025ec34c4cSmrg 24035ec34c4cSmrg --no-silent|--no-quiet) 24045ec34c4cSmrg opt_quiet=false 24055ec34c4cSmrg func_append preserve_args " $_G_opt" 24065ec34c4cSmrg ;; 24075ec34c4cSmrg 24085ec34c4cSmrg --no-warnings|--no-warning|--no-warn) 24095ec34c4cSmrg opt_warning=false 24105ec34c4cSmrg func_append preserve_args " $_G_opt" 24115ec34c4cSmrg ;; 24125ec34c4cSmrg 24135ec34c4cSmrg --no-verbose) 24145ec34c4cSmrg opt_verbose=false 24155ec34c4cSmrg func_append preserve_args " $_G_opt" 24165ec34c4cSmrg ;; 24175ec34c4cSmrg 24185ec34c4cSmrg --silent|--quiet) 24195ec34c4cSmrg opt_quiet=: 24205ec34c4cSmrg opt_verbose=false 24215ec34c4cSmrg func_append preserve_args " $_G_opt" 24225ec34c4cSmrg ;; 24235ec34c4cSmrg 24245ec34c4cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 24255ec34c4cSmrg opt_tag=$1 24265ec34c4cSmrg func_append preserve_args " $_G_opt $1" 24275ec34c4cSmrg func_enable_tag "$1" 24285ec34c4cSmrg shift 24295ec34c4cSmrg ;; 24305ec34c4cSmrg 24315ec34c4cSmrg --verbose|-v) opt_quiet=false 24325ec34c4cSmrg opt_verbose=: 24335ec34c4cSmrg func_append preserve_args " $_G_opt" 24345ec34c4cSmrg ;; 24355ec34c4cSmrg 24365ec34c4cSmrg # An option not handled by this hook function: 24375ec34c4cSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 24385ec34c4cSmrg esac 24395ec34c4cSmrg done 2440f353fbadSmrg 2441f353fbadSmrg 24425ec34c4cSmrg # save modified positional parameters for caller 24435ec34c4cSmrg func_quote_for_eval ${1+"$@"} 24445ec34c4cSmrg libtool_parse_options_result=$func_quote_for_eval_result 24455ec34c4cSmrg} 24465ec34c4cSmrgfunc_add_hook func_parse_options libtool_parse_options 2447994689c1Smrg 2448775e7de9Smrg 2449994689c1Smrg 24505ec34c4cSmrg# libtool_validate_options [ARG]... 24515ec34c4cSmrg# --------------------------------- 24525ec34c4cSmrg# Perform any sanity checks on option settings and/or unconsumed 24535ec34c4cSmrg# arguments. 24545ec34c4cSmrglibtool_validate_options () 24555ec34c4cSmrg{ 24565ec34c4cSmrg # save first non-option argument 24575ec34c4cSmrg if test 0 -lt $#; then 24585ec34c4cSmrg nonopt=$1 24595ec34c4cSmrg shift 2460994689c1Smrg fi 2461994689c1Smrg 24625ec34c4cSmrg # preserve --debug 24635ec34c4cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2464994689c1Smrg 24655ec34c4cSmrg case $host in 24665ec34c4cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 24675ec34c4cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 24685ec34c4cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 24695ec34c4cSmrg # don't eliminate duplications in $postdeps and $predeps 24705ec34c4cSmrg opt_duplicate_compiler_generated_deps=: 24715ec34c4cSmrg ;; 24725ec34c4cSmrg *) 24735ec34c4cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 24745ec34c4cSmrg ;; 24755ec34c4cSmrg esac 2476994689c1Smrg 24775ec34c4cSmrg $opt_help || { 24785ec34c4cSmrg # Sanity checks first: 24795ec34c4cSmrg func_check_version_match 24805ec34c4cSmrg 24815ec34c4cSmrg test yes != "$build_libtool_libs" \ 24825ec34c4cSmrg && test yes != "$build_old_libs" \ 24835ec34c4cSmrg && func_fatal_configuration "not configured to build any kind of library" 24845ec34c4cSmrg 24855ec34c4cSmrg # Darwin sucks 24865ec34c4cSmrg eval std_shrext=\"$shrext_cmds\" 24875ec34c4cSmrg 24885ec34c4cSmrg # Only execute mode is allowed to have -dlopen flags. 24895ec34c4cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 24905ec34c4cSmrg func_error "unrecognized option '-dlopen'" 24915ec34c4cSmrg $ECHO "$help" 1>&2 24925ec34c4cSmrg exit $EXIT_FAILURE 24935ec34c4cSmrg fi 2494994689c1Smrg 24955ec34c4cSmrg # Change the help message to a mode-specific one. 24965ec34c4cSmrg generic_help=$help 24975ec34c4cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 24985ec34c4cSmrg } 2499994689c1Smrg 25005ec34c4cSmrg # Pass back the unparsed argument list 25015ec34c4cSmrg func_quote_for_eval ${1+"$@"} 25025ec34c4cSmrg libtool_validate_options_result=$func_quote_for_eval_result 2503f353fbadSmrg} 25045ec34c4cSmrgfunc_add_hook func_validate_options libtool_validate_options 2505994689c1Smrg 2506994689c1Smrg 25075ec34c4cSmrg# Process options as early as possible so that --help and --version 25085ec34c4cSmrg# can return quickly. 25095ec34c4cSmrgfunc_options ${1+"$@"} 25105ec34c4cSmrgeval set dummy "$func_options_result"; shift 25115ec34c4cSmrg 25127a84e134Smrg 25137a84e134Smrg 2514f353fbadSmrg## ----------- ## 2515f353fbadSmrg## Main. ## 2516f353fbadSmrg## ----------- ## 25177a84e134Smrg 25185ec34c4cSmrgmagic='%%%MAGIC variable%%%' 25195ec34c4cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 25205ec34c4cSmrg 25215ec34c4cSmrg# Global variables. 25225ec34c4cSmrgextracted_archives= 25235ec34c4cSmrgextracted_serial=0 25245ec34c4cSmrg 25255ec34c4cSmrg# If this variable is set in any of the actions, the command in it 25265ec34c4cSmrg# will be execed at the end. This prevents here-documents from being 25275ec34c4cSmrg# left over by shells. 25285ec34c4cSmrgexec_cmd= 25295ec34c4cSmrg 25305ec34c4cSmrg 25315ec34c4cSmrg# A function that is used when there is no print builtin or printf. 25325ec34c4cSmrgfunc_fallback_echo () 25335ec34c4cSmrg{ 25345ec34c4cSmrg eval 'cat <<_LTECHO_EOF 25355ec34c4cSmrg$1 25365ec34c4cSmrg_LTECHO_EOF' 25375ec34c4cSmrg} 25385ec34c4cSmrg 25395ec34c4cSmrg# func_generated_by_libtool 25405ec34c4cSmrg# True iff stdin has been generated by Libtool. This function is only 25415ec34c4cSmrg# a basic sanity check; it will hardly flush out determined imposters. 25425ec34c4cSmrgfunc_generated_by_libtool_p () 25435ec34c4cSmrg{ 25445ec34c4cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 25455ec34c4cSmrg} 25465ec34c4cSmrg 2547994689c1Smrg# func_lalib_p file 25485ec34c4cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2549994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2550994689c1Smrg# determined imposters. 2551994689c1Smrgfunc_lalib_p () 2552994689c1Smrg{ 2553994689c1Smrg test -f "$1" && 25545ec34c4cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2555994689c1Smrg} 25567a84e134Smrg 2557994689c1Smrg# func_lalib_unsafe_p file 25585ec34c4cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2559994689c1Smrg# This function implements the same check as func_lalib_p without 2560994689c1Smrg# resorting to external programs. To this end, it redirects stdin and 2561994689c1Smrg# closes it afterwards, without saving the original file descriptor. 2562994689c1Smrg# As a safety measure, use it only where a negative result would be 25635ec34c4cSmrg# fatal anyway. Works if 'file' does not exist. 2564994689c1Smrgfunc_lalib_unsafe_p () 2565994689c1Smrg{ 2566994689c1Smrg lalib_p=no 2567994689c1Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2568994689c1Smrg for lalib_p_l in 1 2 3 4 2569994689c1Smrg do 2570994689c1Smrg read lalib_p_line 25715ec34c4cSmrg case $lalib_p_line in 2572994689c1Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2573994689c1Smrg esac 2574994689c1Smrg done 2575994689c1Smrg exec 0<&5 5<&- 2576994689c1Smrg fi 25775ec34c4cSmrg test yes = "$lalib_p" 2578994689c1Smrg} 25797a84e134Smrg 2580994689c1Smrg# func_ltwrapper_script_p file 2581994689c1Smrg# True iff FILE is a libtool wrapper script 2582994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2583994689c1Smrg# determined imposters. 2584994689c1Smrgfunc_ltwrapper_script_p () 2585994689c1Smrg{ 25865ec34c4cSmrg test -f "$1" && 25875ec34c4cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2588994689c1Smrg} 25897a84e134Smrg 2590994689c1Smrg# func_ltwrapper_executable_p file 2591994689c1Smrg# True iff FILE is a libtool wrapper executable 2592994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2593994689c1Smrg# determined imposters. 2594994689c1Smrgfunc_ltwrapper_executable_p () 2595994689c1Smrg{ 2596994689c1Smrg func_ltwrapper_exec_suffix= 2597994689c1Smrg case $1 in 2598994689c1Smrg *.exe) ;; 2599994689c1Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2600994689c1Smrg esac 2601994689c1Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2602994689c1Smrg} 2603994689c1Smrg 2604994689c1Smrg# func_ltwrapper_scriptname file 2605994689c1Smrg# Assumes file is an ltwrapper_executable 2606994689c1Smrg# uses $file to determine the appropriate filename for a 2607994689c1Smrg# temporary ltwrapper_script. 2608994689c1Smrgfunc_ltwrapper_scriptname () 2609994689c1Smrg{ 2610f353fbadSmrg func_dirname_and_basename "$1" "" "." 2611f353fbadSmrg func_stripname '' '.exe' "$func_basename_result" 26125ec34c4cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2613994689c1Smrg} 2614994689c1Smrg 2615994689c1Smrg# func_ltwrapper_p file 2616994689c1Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2617994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2618994689c1Smrg# determined imposters. 2619994689c1Smrgfunc_ltwrapper_p () 2620994689c1Smrg{ 2621994689c1Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2622994689c1Smrg} 2623994689c1Smrg 2624994689c1Smrg 2625994689c1Smrg# func_execute_cmds commands fail_cmd 2626994689c1Smrg# Execute tilde-delimited COMMANDS. 2627994689c1Smrg# If FAIL_CMD is given, eval that upon failure. 2628994689c1Smrg# FAIL_CMD may read-access the current command in variable CMD! 2629994689c1Smrgfunc_execute_cmds () 2630994689c1Smrg{ 26315ec34c4cSmrg $debug_cmd 26325ec34c4cSmrg 2633994689c1Smrg save_ifs=$IFS; IFS='~' 2634994689c1Smrg for cmd in $1; do 26355ec34c4cSmrg IFS=$sp$nl 2636994689c1Smrg eval cmd=\"$cmd\" 26375ec34c4cSmrg IFS=$save_ifs 2638994689c1Smrg func_show_eval "$cmd" "${2-:}" 2639994689c1Smrg done 2640994689c1Smrg IFS=$save_ifs 2641994689c1Smrg} 2642994689c1Smrg 2643994689c1Smrg 2644994689c1Smrg# func_source file 2645994689c1Smrg# Source FILE, adding directory component if necessary. 2646994689c1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2647994689c1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2648994689c1Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 26495ec34c4cSmrg# 'FILE.' does not work on cygwin managed mounts. 2650994689c1Smrgfunc_source () 2651994689c1Smrg{ 26525ec34c4cSmrg $debug_cmd 26535ec34c4cSmrg 2654994689c1Smrg case $1 in 2655994689c1Smrg */* | *\\*) . "$1" ;; 2656994689c1Smrg *) . "./$1" ;; 2657994689c1Smrg esac 2658994689c1Smrg} 2659994689c1Smrg 2660994689c1Smrg 2661f353fbadSmrg# func_resolve_sysroot PATH 2662f353fbadSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2663f353fbadSmrg# func_resolve_sysroot_result 2664f353fbadSmrgfunc_resolve_sysroot () 2665f353fbadSmrg{ 2666f353fbadSmrg func_resolve_sysroot_result=$1 2667f353fbadSmrg case $func_resolve_sysroot_result in 2668f353fbadSmrg =*) 2669f353fbadSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2670f353fbadSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2671f353fbadSmrg ;; 2672f353fbadSmrg esac 2673f353fbadSmrg} 2674f353fbadSmrg 2675f353fbadSmrg# func_replace_sysroot PATH 2676f353fbadSmrg# If PATH begins with the sysroot, replace it with = and 2677f353fbadSmrg# store the result into func_replace_sysroot_result. 2678f353fbadSmrgfunc_replace_sysroot () 2679f353fbadSmrg{ 26805ec34c4cSmrg case $lt_sysroot:$1 in 2681f353fbadSmrg ?*:"$lt_sysroot"*) 2682f353fbadSmrg func_stripname "$lt_sysroot" '' "$1" 26835ec34c4cSmrg func_replace_sysroot_result='='$func_stripname_result 2684f353fbadSmrg ;; 2685f353fbadSmrg *) 2686f353fbadSmrg # Including no sysroot. 2687f353fbadSmrg func_replace_sysroot_result=$1 2688f353fbadSmrg ;; 2689f353fbadSmrg esac 2690f353fbadSmrg} 2691f353fbadSmrg 2692994689c1Smrg# func_infer_tag arg 2693994689c1Smrg# Infer tagged configuration to use if any are available and 2694994689c1Smrg# if one wasn't chosen via the "--tag" command line option. 2695994689c1Smrg# Only attempt this if the compiler in the base compile 2696994689c1Smrg# command doesn't match the default compiler. 2697994689c1Smrg# arg is usually of the form 'gcc ...' 2698994689c1Smrgfunc_infer_tag () 2699994689c1Smrg{ 27005ec34c4cSmrg $debug_cmd 27015ec34c4cSmrg 2702994689c1Smrg if test -n "$available_tags" && test -z "$tagname"; then 2703994689c1Smrg CC_quoted= 2704994689c1Smrg for arg in $CC; do 2705f353fbadSmrg func_append_quoted CC_quoted "$arg" 2706994689c1Smrg done 2707994689c1Smrg CC_expanded=`func_echo_all $CC` 2708994689c1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2709994689c1Smrg case $@ in 2710994689c1Smrg # Blanks in the command may have been stripped by the calling shell, 2711994689c1Smrg # but not from the CC environment variable when configure was run. 2712994689c1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2713994689c1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2714994689c1Smrg # Blanks at the start of $base_compile will cause this to fail 2715994689c1Smrg # if we don't check for them as well. 2716994689c1Smrg *) 2717994689c1Smrg for z in $available_tags; do 2718994689c1Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2719994689c1Smrg # Evaluate the configuration. 27205ec34c4cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2721994689c1Smrg CC_quoted= 2722994689c1Smrg for arg in $CC; do 2723994689c1Smrg # Double-quote args containing other shell metacharacters. 2724f353fbadSmrg func_append_quoted CC_quoted "$arg" 2725994689c1Smrg done 2726994689c1Smrg CC_expanded=`func_echo_all $CC` 2727994689c1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2728994689c1Smrg case "$@ " in 2729994689c1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2730994689c1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2731994689c1Smrg # The compiler in the base compile command matches 2732994689c1Smrg # the one in the tagged configuration. 2733994689c1Smrg # Assume this is the tagged configuration we want. 2734994689c1Smrg tagname=$z 2735994689c1Smrg break 2736994689c1Smrg ;; 2737994689c1Smrg esac 2738994689c1Smrg fi 2739994689c1Smrg done 2740994689c1Smrg # If $tagname still isn't set, then no tagged configuration 2741994689c1Smrg # was found and let the user know that the "--tag" command 2742994689c1Smrg # line option must be used. 2743994689c1Smrg if test -z "$tagname"; then 2744994689c1Smrg func_echo "unable to infer tagged configuration" 27455ec34c4cSmrg func_fatal_error "specify a tag with '--tag'" 2746994689c1Smrg# else 2747994689c1Smrg# func_verbose "using $tagname tagged configuration" 2748994689c1Smrg fi 2749994689c1Smrg ;; 2750994689c1Smrg esac 2751994689c1Smrg fi 2752994689c1Smrg} 2753994689c1Smrg 2754994689c1Smrg 2755994689c1Smrg 2756f353fbadSmrg# func_write_libtool_object output_name pic_name nonpic_name 2757f353fbadSmrg# Create a libtool object file (analogous to a ".la" file), 2758f353fbadSmrg# but don't create it if we're doing a dry run. 2759f353fbadSmrgfunc_write_libtool_object () 2760f353fbadSmrg{ 27615ec34c4cSmrg write_libobj=$1 27625ec34c4cSmrg if test yes = "$build_libtool_libs"; then 27635ec34c4cSmrg write_lobj=\'$2\' 2764f353fbadSmrg else 2765f353fbadSmrg write_lobj=none 2766f353fbadSmrg fi 2767f353fbadSmrg 27685ec34c4cSmrg if test yes = "$build_old_libs"; then 27695ec34c4cSmrg write_oldobj=\'$3\' 2770f353fbadSmrg else 2771f353fbadSmrg write_oldobj=none 2772f353fbadSmrg fi 2773f353fbadSmrg 2774f353fbadSmrg $opt_dry_run || { 2775f353fbadSmrg cat >${write_libobj}T <<EOF 2776f353fbadSmrg# $write_libobj - a libtool object file 27775ec34c4cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2778f353fbadSmrg# 2779f353fbadSmrg# Please DO NOT delete this file! 2780f353fbadSmrg# It is necessary for linking the library. 2781f353fbadSmrg 2782f353fbadSmrg# Name of the PIC object. 2783f353fbadSmrgpic_object=$write_lobj 2784f353fbadSmrg 2785f353fbadSmrg# Name of the non-PIC object 2786f353fbadSmrgnon_pic_object=$write_oldobj 2787f353fbadSmrg 2788f353fbadSmrgEOF 27895ec34c4cSmrg $MV "${write_libobj}T" "$write_libobj" 2790f353fbadSmrg } 2791f353fbadSmrg} 2792f353fbadSmrg 2793f353fbadSmrg 2794f353fbadSmrg################################################## 2795f353fbadSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2796f353fbadSmrg################################################## 2797f353fbadSmrg 2798f353fbadSmrg# func_convert_core_file_wine_to_w32 ARG 2799f353fbadSmrg# Helper function used by file name conversion functions when $build is *nix, 2800f353fbadSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2801f353fbadSmrg# correctly configured wine environment available, with the winepath program 2802f353fbadSmrg# in $build's $PATH. 2803f353fbadSmrg# 2804f353fbadSmrg# ARG is the $build file name to be converted to w32 format. 2805f353fbadSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2806f353fbadSmrg# be empty on error (or when ARG is empty) 2807f353fbadSmrgfunc_convert_core_file_wine_to_w32 () 2808f353fbadSmrg{ 28095ec34c4cSmrg $debug_cmd 28105ec34c4cSmrg 28115ec34c4cSmrg func_convert_core_file_wine_to_w32_result=$1 2812f353fbadSmrg if test -n "$1"; then 2813f353fbadSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2814f353fbadSmrg # are forced to check the contents of stdout. On the other hand, if the 2815f353fbadSmrg # command is not found, the shell will set an exit code of 127 and print 2816f353fbadSmrg # *an error message* to stdout. So we must check for both error code of 2817f353fbadSmrg # zero AND non-empty stdout, which explains the odd construction: 2818f353fbadSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 28195ec34c4cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2820f353fbadSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 28215ec34c4cSmrg $SED -e "$sed_naive_backslashify"` 2822f353fbadSmrg else 2823f353fbadSmrg func_convert_core_file_wine_to_w32_result= 2824f353fbadSmrg fi 2825f353fbadSmrg fi 2826f353fbadSmrg} 2827f353fbadSmrg# end: func_convert_core_file_wine_to_w32 2828f353fbadSmrg 2829f353fbadSmrg 2830f353fbadSmrg# func_convert_core_path_wine_to_w32 ARG 2831f353fbadSmrg# Helper function used by path conversion functions when $build is *nix, and 2832f353fbadSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2833f353fbadSmrg# configured wine environment available, with the winepath program in $build's 2834f353fbadSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2835f353fbadSmrg# 2836f353fbadSmrg# ARG is path to be converted from $build format to win32. 2837f353fbadSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2838f353fbadSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2839f353fbadSmrg# are convertible, then the result may be empty. 2840f353fbadSmrgfunc_convert_core_path_wine_to_w32 () 2841f353fbadSmrg{ 28425ec34c4cSmrg $debug_cmd 28435ec34c4cSmrg 2844f353fbadSmrg # unfortunately, winepath doesn't convert paths, only file names 28455ec34c4cSmrg func_convert_core_path_wine_to_w32_result= 2846f353fbadSmrg if test -n "$1"; then 2847f353fbadSmrg oldIFS=$IFS 2848f353fbadSmrg IFS=: 2849f353fbadSmrg for func_convert_core_path_wine_to_w32_f in $1; do 2850f353fbadSmrg IFS=$oldIFS 2851f353fbadSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 28525ec34c4cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2853f353fbadSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 28545ec34c4cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2855f353fbadSmrg else 2856f353fbadSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2857f353fbadSmrg fi 2858f353fbadSmrg fi 2859f353fbadSmrg done 2860f353fbadSmrg IFS=$oldIFS 2861f353fbadSmrg fi 2862f353fbadSmrg} 2863f353fbadSmrg# end: func_convert_core_path_wine_to_w32 2864f353fbadSmrg 2865f353fbadSmrg 2866f353fbadSmrg# func_cygpath ARGS... 2867f353fbadSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2868f353fbadSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2869f353fbadSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2870f353fbadSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2871f353fbadSmrg# file name or path is assumed to be in w32 format, as previously converted 2872f353fbadSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2873f353fbadSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 2874f353fbadSmrg# Cygwin format). Returns an empty string on error. 2875f353fbadSmrg# 2876f353fbadSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 2877f353fbadSmrg# be converted. 2878f353fbadSmrg# 2879f353fbadSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2880f353fbadSmrg# environment variable; do not put it in $PATH. 2881f353fbadSmrgfunc_cygpath () 2882f353fbadSmrg{ 28835ec34c4cSmrg $debug_cmd 28845ec34c4cSmrg 2885f353fbadSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2886f353fbadSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2887f353fbadSmrg if test "$?" -ne 0; then 2888f353fbadSmrg # on failure, ensure result is empty 2889f353fbadSmrg func_cygpath_result= 2890f353fbadSmrg fi 2891f353fbadSmrg else 2892f353fbadSmrg func_cygpath_result= 28935ec34c4cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2894f353fbadSmrg fi 2895f353fbadSmrg} 2896f353fbadSmrg#end: func_cygpath 2897f353fbadSmrg 2898f353fbadSmrg 2899f353fbadSmrg# func_convert_core_msys_to_w32 ARG 2900f353fbadSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 2901f353fbadSmrg# result in func_convert_core_msys_to_w32_result. 2902f353fbadSmrgfunc_convert_core_msys_to_w32 () 2903f353fbadSmrg{ 29045ec34c4cSmrg $debug_cmd 29055ec34c4cSmrg 2906f353fbadSmrg # awkward: cmd appends spaces to result 2907f353fbadSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 29085ec34c4cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2909f353fbadSmrg} 2910f353fbadSmrg#end: func_convert_core_msys_to_w32 2911f353fbadSmrg 2912f353fbadSmrg 2913f353fbadSmrg# func_convert_file_check ARG1 ARG2 2914f353fbadSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 2915f353fbadSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2916f353fbadSmrg# func_to_host_file_result to ARG1). 2917f353fbadSmrgfunc_convert_file_check () 2918f353fbadSmrg{ 29195ec34c4cSmrg $debug_cmd 29205ec34c4cSmrg 29215ec34c4cSmrg if test -z "$2" && test -n "$1"; then 2922f353fbadSmrg func_error "Could not determine host file name corresponding to" 29235ec34c4cSmrg func_error " '$1'" 2924f353fbadSmrg func_error "Continuing, but uninstalled executables may not work." 2925f353fbadSmrg # Fallback: 29265ec34c4cSmrg func_to_host_file_result=$1 2927f353fbadSmrg fi 2928f353fbadSmrg} 2929f353fbadSmrg# end func_convert_file_check 2930f353fbadSmrg 2931f353fbadSmrg 2932f353fbadSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2933f353fbadSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2934f353fbadSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2935f353fbadSmrg# func_to_host_file_result to a simplistic fallback value (see below). 2936f353fbadSmrgfunc_convert_path_check () 2937f353fbadSmrg{ 29385ec34c4cSmrg $debug_cmd 29395ec34c4cSmrg 2940f353fbadSmrg if test -z "$4" && test -n "$3"; then 2941f353fbadSmrg func_error "Could not determine the host path corresponding to" 29425ec34c4cSmrg func_error " '$3'" 2943f353fbadSmrg func_error "Continuing, but uninstalled executables may not work." 2944f353fbadSmrg # Fallback. This is a deliberately simplistic "conversion" and 2945f353fbadSmrg # should not be "improved". See libtool.info. 2946f353fbadSmrg if test "x$1" != "x$2"; then 2947f353fbadSmrg lt_replace_pathsep_chars="s|$1|$2|g" 2948f353fbadSmrg func_to_host_path_result=`echo "$3" | 2949f353fbadSmrg $SED -e "$lt_replace_pathsep_chars"` 2950f353fbadSmrg else 29515ec34c4cSmrg func_to_host_path_result=$3 2952f353fbadSmrg fi 2953f353fbadSmrg fi 2954f353fbadSmrg} 2955f353fbadSmrg# end func_convert_path_check 2956f353fbadSmrg 2957f353fbadSmrg 2958f353fbadSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2959f353fbadSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2960f353fbadSmrg# and appending REPL if ORIG matches BACKPAT. 2961f353fbadSmrgfunc_convert_path_front_back_pathsep () 2962f353fbadSmrg{ 29635ec34c4cSmrg $debug_cmd 29645ec34c4cSmrg 2965f353fbadSmrg case $4 in 29665ec34c4cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2967f353fbadSmrg ;; 2968f353fbadSmrg esac 2969f353fbadSmrg case $4 in 2970f353fbadSmrg $2 ) func_append func_to_host_path_result "$3" 2971f353fbadSmrg ;; 2972f353fbadSmrg esac 2973f353fbadSmrg} 2974f353fbadSmrg# end func_convert_path_front_back_pathsep 2975f353fbadSmrg 2976f353fbadSmrg 2977f353fbadSmrg################################################## 2978f353fbadSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2979f353fbadSmrg################################################## 29805ec34c4cSmrg# invoked via '$to_host_file_cmd ARG' 2981f353fbadSmrg# 2982f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format. 2983f353fbadSmrg# Result will be available in $func_to_host_file_result. 2984f353fbadSmrg 2985f353fbadSmrg 2986f353fbadSmrg# func_to_host_file ARG 2987f353fbadSmrg# Converts the file name ARG from $build format to $host format. Return result 2988f353fbadSmrg# in func_to_host_file_result. 2989f353fbadSmrgfunc_to_host_file () 2990f353fbadSmrg{ 29915ec34c4cSmrg $debug_cmd 29925ec34c4cSmrg 2993f353fbadSmrg $to_host_file_cmd "$1" 2994f353fbadSmrg} 2995f353fbadSmrg# end func_to_host_file 2996f353fbadSmrg 2997f353fbadSmrg 2998f353fbadSmrg# func_to_tool_file ARG LAZY 2999f353fbadSmrg# converts the file name ARG from $build format to toolchain format. Return 3000f353fbadSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3001f353fbadSmrg# in (the comma separated) LAZY, no conversion takes place. 3002f353fbadSmrgfunc_to_tool_file () 3003f353fbadSmrg{ 30045ec34c4cSmrg $debug_cmd 30055ec34c4cSmrg 3006f353fbadSmrg case ,$2, in 3007f353fbadSmrg *,"$to_tool_file_cmd",*) 3008f353fbadSmrg func_to_tool_file_result=$1 3009f353fbadSmrg ;; 3010f353fbadSmrg *) 3011f353fbadSmrg $to_tool_file_cmd "$1" 3012f353fbadSmrg func_to_tool_file_result=$func_to_host_file_result 3013f353fbadSmrg ;; 3014f353fbadSmrg esac 3015f353fbadSmrg} 3016f353fbadSmrg# end func_to_tool_file 3017f353fbadSmrg 3018f353fbadSmrg 3019f353fbadSmrg# func_convert_file_noop ARG 3020f353fbadSmrg# Copy ARG to func_to_host_file_result. 3021f353fbadSmrgfunc_convert_file_noop () 3022f353fbadSmrg{ 30235ec34c4cSmrg func_to_host_file_result=$1 3024f353fbadSmrg} 3025f353fbadSmrg# end func_convert_file_noop 3026f353fbadSmrg 3027f353fbadSmrg 3028f353fbadSmrg# func_convert_file_msys_to_w32 ARG 3029f353fbadSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3030f353fbadSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3031f353fbadSmrg# func_to_host_file_result. 3032f353fbadSmrgfunc_convert_file_msys_to_w32 () 3033f353fbadSmrg{ 30345ec34c4cSmrg $debug_cmd 30355ec34c4cSmrg 30365ec34c4cSmrg func_to_host_file_result=$1 3037f353fbadSmrg if test -n "$1"; then 3038f353fbadSmrg func_convert_core_msys_to_w32 "$1" 30395ec34c4cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3040f353fbadSmrg fi 3041f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3042f353fbadSmrg} 3043f353fbadSmrg# end func_convert_file_msys_to_w32 3044f353fbadSmrg 3045f353fbadSmrg 3046f353fbadSmrg# func_convert_file_cygwin_to_w32 ARG 3047f353fbadSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3048f353fbadSmrg# func_to_host_file_result. 3049f353fbadSmrgfunc_convert_file_cygwin_to_w32 () 3050f353fbadSmrg{ 30515ec34c4cSmrg $debug_cmd 30525ec34c4cSmrg 30535ec34c4cSmrg func_to_host_file_result=$1 3054f353fbadSmrg if test -n "$1"; then 3055f353fbadSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3056f353fbadSmrg # LT_CYGPATH in this case. 3057f353fbadSmrg func_to_host_file_result=`cygpath -m "$1"` 3058f353fbadSmrg fi 3059f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3060f353fbadSmrg} 3061f353fbadSmrg# end func_convert_file_cygwin_to_w32 3062f353fbadSmrg 3063f353fbadSmrg 3064f353fbadSmrg# func_convert_file_nix_to_w32 ARG 3065f353fbadSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3066f353fbadSmrg# and a working winepath. Returns result in func_to_host_file_result. 3067f353fbadSmrgfunc_convert_file_nix_to_w32 () 3068f353fbadSmrg{ 30695ec34c4cSmrg $debug_cmd 30705ec34c4cSmrg 30715ec34c4cSmrg func_to_host_file_result=$1 3072f353fbadSmrg if test -n "$1"; then 3073f353fbadSmrg func_convert_core_file_wine_to_w32 "$1" 30745ec34c4cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3075f353fbadSmrg fi 3076f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3077f353fbadSmrg} 3078f353fbadSmrg# end func_convert_file_nix_to_w32 3079f353fbadSmrg 3080f353fbadSmrg 3081f353fbadSmrg# func_convert_file_msys_to_cygwin ARG 3082f353fbadSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3083f353fbadSmrg# Returns result in func_to_host_file_result. 3084f353fbadSmrgfunc_convert_file_msys_to_cygwin () 3085f353fbadSmrg{ 30865ec34c4cSmrg $debug_cmd 30875ec34c4cSmrg 30885ec34c4cSmrg func_to_host_file_result=$1 3089f353fbadSmrg if test -n "$1"; then 3090f353fbadSmrg func_convert_core_msys_to_w32 "$1" 3091f353fbadSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 30925ec34c4cSmrg func_to_host_file_result=$func_cygpath_result 3093f353fbadSmrg fi 3094f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3095f353fbadSmrg} 3096f353fbadSmrg# end func_convert_file_msys_to_cygwin 3097f353fbadSmrg 3098f353fbadSmrg 3099f353fbadSmrg# func_convert_file_nix_to_cygwin ARG 3100f353fbadSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3101f353fbadSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3102f353fbadSmrg# in func_to_host_file_result. 3103f353fbadSmrgfunc_convert_file_nix_to_cygwin () 3104f353fbadSmrg{ 31055ec34c4cSmrg $debug_cmd 31065ec34c4cSmrg 31075ec34c4cSmrg func_to_host_file_result=$1 3108f353fbadSmrg if test -n "$1"; then 3109f353fbadSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3110f353fbadSmrg func_convert_core_file_wine_to_w32 "$1" 3111f353fbadSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 31125ec34c4cSmrg func_to_host_file_result=$func_cygpath_result 3113f353fbadSmrg fi 3114f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3115f353fbadSmrg} 3116f353fbadSmrg# end func_convert_file_nix_to_cygwin 3117f353fbadSmrg 3118f353fbadSmrg 3119f353fbadSmrg############################################# 3120f353fbadSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3121f353fbadSmrg############################################# 31225ec34c4cSmrg# invoked via '$to_host_path_cmd ARG' 3123f353fbadSmrg# 3124f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format. 3125f353fbadSmrg# The result will be available in $func_to_host_path_result. 3126f353fbadSmrg# 3127f353fbadSmrg# Path separators are also converted from $build format to $host format. If 3128f353fbadSmrg# ARG begins or ends with a path separator character, it is preserved (but 3129f353fbadSmrg# converted to $host format) on output. 3130f353fbadSmrg# 3131f353fbadSmrg# All path conversion functions are named using the following convention: 3132f353fbadSmrg# file name conversion function : func_convert_file_X_to_Y () 3133f353fbadSmrg# path conversion function : func_convert_path_X_to_Y () 3134f353fbadSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3135f353fbadSmrg# same. If conversion functions are added for new $build/$host combinations, 3136f353fbadSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3137f353fbadSmrg# will break. 3138f353fbadSmrg 3139f353fbadSmrg 3140f353fbadSmrg# func_init_to_host_path_cmd 3141f353fbadSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3142f353fbadSmrg# appropriate value, based on the value of $to_host_file_cmd. 3143f353fbadSmrgto_host_path_cmd= 3144f353fbadSmrgfunc_init_to_host_path_cmd () 3145f353fbadSmrg{ 31465ec34c4cSmrg $debug_cmd 31475ec34c4cSmrg 3148f353fbadSmrg if test -z "$to_host_path_cmd"; then 3149f353fbadSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 31505ec34c4cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3151f353fbadSmrg fi 3152f353fbadSmrg} 3153f353fbadSmrg 3154f353fbadSmrg 3155f353fbadSmrg# func_to_host_path ARG 3156f353fbadSmrg# Converts the path ARG from $build format to $host format. Return result 3157f353fbadSmrg# in func_to_host_path_result. 3158f353fbadSmrgfunc_to_host_path () 3159f353fbadSmrg{ 31605ec34c4cSmrg $debug_cmd 31615ec34c4cSmrg 3162f353fbadSmrg func_init_to_host_path_cmd 3163f353fbadSmrg $to_host_path_cmd "$1" 3164f353fbadSmrg} 3165f353fbadSmrg# end func_to_host_path 3166f353fbadSmrg 3167f353fbadSmrg 3168f353fbadSmrg# func_convert_path_noop ARG 3169f353fbadSmrg# Copy ARG to func_to_host_path_result. 3170f353fbadSmrgfunc_convert_path_noop () 3171f353fbadSmrg{ 31725ec34c4cSmrg func_to_host_path_result=$1 3173f353fbadSmrg} 3174f353fbadSmrg# end func_convert_path_noop 3175f353fbadSmrg 3176f353fbadSmrg 3177f353fbadSmrg# func_convert_path_msys_to_w32 ARG 3178f353fbadSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3179f353fbadSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3180f353fbadSmrg# func_to_host_path_result. 3181f353fbadSmrgfunc_convert_path_msys_to_w32 () 3182994689c1Smrg{ 31835ec34c4cSmrg $debug_cmd 31845ec34c4cSmrg 31855ec34c4cSmrg func_to_host_path_result=$1 3186f353fbadSmrg if test -n "$1"; then 3187f353fbadSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3188f353fbadSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3189f353fbadSmrg # and winepath ignores them completely. 3190f353fbadSmrg func_stripname : : "$1" 3191f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3192f353fbadSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 31935ec34c4cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3194f353fbadSmrg func_convert_path_check : ";" \ 3195f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3196f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3197f353fbadSmrg fi 3198f353fbadSmrg} 3199f353fbadSmrg# end func_convert_path_msys_to_w32 3200994689c1Smrg 3201994689c1Smrg 3202f353fbadSmrg# func_convert_path_cygwin_to_w32 ARG 3203f353fbadSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3204f353fbadSmrg# func_to_host_file_result. 3205f353fbadSmrgfunc_convert_path_cygwin_to_w32 () 3206f353fbadSmrg{ 32075ec34c4cSmrg $debug_cmd 32085ec34c4cSmrg 32095ec34c4cSmrg func_to_host_path_result=$1 3210f353fbadSmrg if test -n "$1"; then 3211f353fbadSmrg # See func_convert_path_msys_to_w32: 3212f353fbadSmrg func_stripname : : "$1" 3213f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3214f353fbadSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3215f353fbadSmrg func_convert_path_check : ";" \ 3216f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3217f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3218f353fbadSmrg fi 3219f353fbadSmrg} 3220f353fbadSmrg# end func_convert_path_cygwin_to_w32 3221994689c1Smrg 3222994689c1Smrg 3223f353fbadSmrg# func_convert_path_nix_to_w32 ARG 3224f353fbadSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3225f353fbadSmrg# a working winepath. Returns result in func_to_host_file_result. 3226f353fbadSmrgfunc_convert_path_nix_to_w32 () 3227f353fbadSmrg{ 32285ec34c4cSmrg $debug_cmd 32295ec34c4cSmrg 32305ec34c4cSmrg func_to_host_path_result=$1 3231f353fbadSmrg if test -n "$1"; then 3232f353fbadSmrg # See func_convert_path_msys_to_w32: 3233f353fbadSmrg func_stripname : : "$1" 3234f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3235f353fbadSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 32365ec34c4cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3237f353fbadSmrg func_convert_path_check : ";" \ 3238f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3239f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3240f353fbadSmrg fi 3241f353fbadSmrg} 3242f353fbadSmrg# end func_convert_path_nix_to_w32 3243994689c1Smrg 3244f353fbadSmrg 3245f353fbadSmrg# func_convert_path_msys_to_cygwin ARG 3246f353fbadSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3247f353fbadSmrg# Returns result in func_to_host_file_result. 3248f353fbadSmrgfunc_convert_path_msys_to_cygwin () 3249f353fbadSmrg{ 32505ec34c4cSmrg $debug_cmd 32515ec34c4cSmrg 32525ec34c4cSmrg func_to_host_path_result=$1 3253f353fbadSmrg if test -n "$1"; then 3254f353fbadSmrg # See func_convert_path_msys_to_w32: 3255f353fbadSmrg func_stripname : : "$1" 3256f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3257f353fbadSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3258f353fbadSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 32595ec34c4cSmrg func_to_host_path_result=$func_cygpath_result 3260f353fbadSmrg func_convert_path_check : : \ 3261f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3262f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3263f353fbadSmrg fi 3264f353fbadSmrg} 3265f353fbadSmrg# end func_convert_path_msys_to_cygwin 3266f353fbadSmrg 3267f353fbadSmrg 3268f353fbadSmrg# func_convert_path_nix_to_cygwin ARG 3269f353fbadSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3270f353fbadSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3271f353fbadSmrg# func_to_host_file_result. 3272f353fbadSmrgfunc_convert_path_nix_to_cygwin () 3273f353fbadSmrg{ 32745ec34c4cSmrg $debug_cmd 32755ec34c4cSmrg 32765ec34c4cSmrg func_to_host_path_result=$1 3277f353fbadSmrg if test -n "$1"; then 3278f353fbadSmrg # Remove leading and trailing path separator characters from 3279f353fbadSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3280f353fbadSmrg # into '.;' and ';.', and winepath ignores them completely. 3281f353fbadSmrg func_stripname : : "$1" 3282f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3283f353fbadSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3284f353fbadSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 32855ec34c4cSmrg func_to_host_path_result=$func_cygpath_result 3286f353fbadSmrg func_convert_path_check : : \ 3287f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3288f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3289f353fbadSmrg fi 3290994689c1Smrg} 3291f353fbadSmrg# end func_convert_path_nix_to_cygwin 3292f353fbadSmrg 3293994689c1Smrg 32945ec34c4cSmrg# func_dll_def_p FILE 32955ec34c4cSmrg# True iff FILE is a Windows DLL '.def' file. 32965ec34c4cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 32975ec34c4cSmrgfunc_dll_def_p () 32985ec34c4cSmrg{ 32995ec34c4cSmrg $debug_cmd 33005ec34c4cSmrg 33015ec34c4cSmrg func_dll_def_p_tmp=`$SED -n \ 33025ec34c4cSmrg -e 's/^[ ]*//' \ 33035ec34c4cSmrg -e '/^\(;.*\)*$/d' \ 33045ec34c4cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 33055ec34c4cSmrg -e q \ 33065ec34c4cSmrg "$1"` 33075ec34c4cSmrg test DEF = "$func_dll_def_p_tmp" 33085ec34c4cSmrg} 33095ec34c4cSmrg 33105ec34c4cSmrg 3311994689c1Smrg# func_mode_compile arg... 3312994689c1Smrgfunc_mode_compile () 3313994689c1Smrg{ 33145ec34c4cSmrg $debug_cmd 33155ec34c4cSmrg 3316994689c1Smrg # Get the compilation command and the source file. 3317994689c1Smrg base_compile= 33185ec34c4cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3319994689c1Smrg suppress_opt=yes 3320994689c1Smrg suppress_output= 3321994689c1Smrg arg_mode=normal 3322994689c1Smrg libobj= 3323994689c1Smrg later= 3324994689c1Smrg pie_flag= 3325994689c1Smrg 3326994689c1Smrg for arg 3327994689c1Smrg do 3328994689c1Smrg case $arg_mode in 3329994689c1Smrg arg ) 3330994689c1Smrg # do not "continue". Instead, add this to base_compile 33315ec34c4cSmrg lastarg=$arg 3332994689c1Smrg arg_mode=normal 3333994689c1Smrg ;; 3334994689c1Smrg 3335994689c1Smrg target ) 33365ec34c4cSmrg libobj=$arg 3337994689c1Smrg arg_mode=normal 3338994689c1Smrg continue 3339994689c1Smrg ;; 3340994689c1Smrg 3341994689c1Smrg normal ) 3342994689c1Smrg # Accept any command-line options. 3343994689c1Smrg case $arg in 3344994689c1Smrg -o) 3345994689c1Smrg test -n "$libobj" && \ 33465ec34c4cSmrg func_fatal_error "you cannot specify '-o' more than once" 3347994689c1Smrg arg_mode=target 3348994689c1Smrg continue 3349994689c1Smrg ;; 3350994689c1Smrg 3351994689c1Smrg -pie | -fpie | -fPIE) 3352f353fbadSmrg func_append pie_flag " $arg" 3353994689c1Smrg continue 3354994689c1Smrg ;; 3355994689c1Smrg 3356994689c1Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3357f353fbadSmrg func_append later " $arg" 3358994689c1Smrg continue 3359994689c1Smrg ;; 33607a84e134Smrg 33617a84e134Smrg -no-suppress) 33627a84e134Smrg suppress_opt=no 33637a84e134Smrg continue 33647a84e134Smrg ;; 33657a84e134Smrg 33667a84e134Smrg -Xcompiler) 33677a84e134Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 33687a84e134Smrg continue # The current "srcfile" will either be retained or 33697a84e134Smrg ;; # replaced later. I would guess that would be a bug. 33707a84e134Smrg 33717a84e134Smrg -Wc,*) 3372994689c1Smrg func_stripname '-Wc,' '' "$arg" 3373994689c1Smrg args=$func_stripname_result 33747a84e134Smrg lastarg= 33755ec34c4cSmrg save_ifs=$IFS; IFS=, 3376994689c1Smrg for arg in $args; do 33775ec34c4cSmrg IFS=$save_ifs 3378f353fbadSmrg func_append_quoted lastarg "$arg" 33797a84e134Smrg done 33805ec34c4cSmrg IFS=$save_ifs 3381994689c1Smrg func_stripname ' ' '' "$lastarg" 3382994689c1Smrg lastarg=$func_stripname_result 33837a84e134Smrg 33847a84e134Smrg # Add the arguments to base_compile. 3385f353fbadSmrg func_append base_compile " $lastarg" 33867a84e134Smrg continue 33877a84e134Smrg ;; 33887a84e134Smrg 3389994689c1Smrg *) 33907a84e134Smrg # Accept the current argument as the source file. 33917a84e134Smrg # The previous "srcfile" becomes the current argument. 33927a84e134Smrg # 33935ec34c4cSmrg lastarg=$srcfile 33945ec34c4cSmrg srcfile=$arg 33957a84e134Smrg ;; 33967a84e134Smrg esac # case $arg 33977a84e134Smrg ;; 33987a84e134Smrg esac # case $arg_mode 33997a84e134Smrg 34007a84e134Smrg # Aesthetically quote the previous argument. 3401f353fbadSmrg func_append_quoted base_compile "$lastarg" 34027a84e134Smrg done # for arg 34037a84e134Smrg 34047a84e134Smrg case $arg_mode in 34057a84e134Smrg arg) 3406994689c1Smrg func_fatal_error "you must specify an argument for -Xcompile" 34077a84e134Smrg ;; 34087a84e134Smrg target) 34095ec34c4cSmrg func_fatal_error "you must specify a target with '-o'" 34107a84e134Smrg ;; 34117a84e134Smrg *) 34127a84e134Smrg # Get the name of the library object. 3413994689c1Smrg test -z "$libobj" && { 3414994689c1Smrg func_basename "$srcfile" 34155ec34c4cSmrg libobj=$func_basename_result 3416994689c1Smrg } 34177a84e134Smrg ;; 34187a84e134Smrg esac 34197a84e134Smrg 34207a84e134Smrg # Recognize several different file suffixes. 34217a84e134Smrg # If the user specifies -o file.o, it is replaced with file.lo 34227a84e134Smrg case $libobj in 3423994689c1Smrg *.[cCFSifmso] | \ 3424994689c1Smrg *.ada | *.adb | *.ads | *.asm | \ 3425994689c1Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3426421c997bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3427994689c1Smrg func_xform "$libobj" 3428994689c1Smrg libobj=$func_xform_result 3429994689c1Smrg ;; 34307a84e134Smrg esac 34317a84e134Smrg 34327a84e134Smrg case $libobj in 3433994689c1Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 34347a84e134Smrg *) 34355ec34c4cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 34367a84e134Smrg ;; 34377a84e134Smrg esac 34387a84e134Smrg 34397a84e134Smrg func_infer_tag $base_compile 34407a84e134Smrg 34417a84e134Smrg for arg in $later; do 34427a84e134Smrg case $arg in 3443994689c1Smrg -shared) 34445ec34c4cSmrg test yes = "$build_libtool_libs" \ 34455ec34c4cSmrg || func_fatal_configuration "cannot build a shared library" 3446994689c1Smrg build_old_libs=no 3447994689c1Smrg continue 3448994689c1Smrg ;; 3449994689c1Smrg 34507a84e134Smrg -static) 3451994689c1Smrg build_libtool_libs=no 34527a84e134Smrg build_old_libs=yes 34537a84e134Smrg continue 34547a84e134Smrg ;; 34557a84e134Smrg 34567a84e134Smrg -prefer-pic) 34577a84e134Smrg pic_mode=yes 34587a84e134Smrg continue 34597a84e134Smrg ;; 34607a84e134Smrg 34617a84e134Smrg -prefer-non-pic) 34627a84e134Smrg pic_mode=no 34637a84e134Smrg continue 34647a84e134Smrg ;; 34657a84e134Smrg esac 34667a84e134Smrg done 34677a84e134Smrg 3468994689c1Smrg func_quote_for_eval "$libobj" 3469994689c1Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3470994689c1Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 34715ec34c4cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3472994689c1Smrg func_dirname_and_basename "$obj" "/" "" 34735ec34c4cSmrg objname=$func_basename_result 34745ec34c4cSmrg xdir=$func_dirname_result 34755ec34c4cSmrg lobj=$xdir$objdir/$objname 34767a84e134Smrg 3477994689c1Smrg test -z "$base_compile" && \ 3478994689c1Smrg func_fatal_help "you must specify a compilation command" 34797a84e134Smrg 34807a84e134Smrg # Delete any leftover library objects. 34815ec34c4cSmrg if test yes = "$build_old_libs"; then 34827a84e134Smrg removelist="$obj $lobj $libobj ${libobj}T" 34837a84e134Smrg else 34847a84e134Smrg removelist="$lobj $libobj ${libobj}T" 34857a84e134Smrg fi 34867a84e134Smrg 34877a84e134Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 34887a84e134Smrg case $host_os in 3489994689c1Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 34907a84e134Smrg pic_mode=default 34917a84e134Smrg ;; 34927a84e134Smrg esac 34935ec34c4cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 34947a84e134Smrg # non-PIC code in shared libraries is not supported 34957a84e134Smrg pic_mode=default 34967a84e134Smrg fi 34977a84e134Smrg 34987a84e134Smrg # Calculate the filename of the output object if compiler does 34997a84e134Smrg # not support -o with -c 35005ec34c4cSmrg if test no = "$compiler_c_o"; then 35015ec34c4cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 35025ec34c4cSmrg lockfile=$output_obj.lock 35037a84e134Smrg else 35047a84e134Smrg output_obj= 35057a84e134Smrg need_locks=no 35067a84e134Smrg lockfile= 35077a84e134Smrg fi 35087a84e134Smrg 35097a84e134Smrg # Lock this critical section if it is needed 35107a84e134Smrg # We use this script file to make the link, it avoids creating a new file 35115ec34c4cSmrg if test yes = "$need_locks"; then 3512994689c1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3513994689c1Smrg func_echo "Waiting for $lockfile to be removed" 35147a84e134Smrg sleep 2 35157a84e134Smrg done 35165ec34c4cSmrg elif test warn = "$need_locks"; then 35177a84e134Smrg if test -f "$lockfile"; then 3518994689c1Smrg $ECHO "\ 35197a84e134Smrg*** ERROR, $lockfile exists and contains: 35207a84e134Smrg`cat $lockfile 2>/dev/null` 35217a84e134Smrg 35227a84e134SmrgThis indicates that another process is trying to use the same 35237a84e134Smrgtemporary object file, and libtool could not work around it because 35245ec34c4cSmrgyour compiler does not support '-c' and '-o' together. If you 35257a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better 35267a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better 35277a84e134Smrgcompiler." 35287a84e134Smrg 3529994689c1Smrg $opt_dry_run || $RM $removelist 35307a84e134Smrg exit $EXIT_FAILURE 35317a84e134Smrg fi 3532f353fbadSmrg func_append removelist " $output_obj" 3533994689c1Smrg $ECHO "$srcfile" > "$lockfile" 35347a84e134Smrg fi 35357a84e134Smrg 3536994689c1Smrg $opt_dry_run || $RM $removelist 3537f353fbadSmrg func_append removelist " $lockfile" 3538994689c1Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3539994689c1Smrg 3540f353fbadSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3541f353fbadSmrg srcfile=$func_to_tool_file_result 3542994689c1Smrg func_quote_for_eval "$srcfile" 3543994689c1Smrg qsrcfile=$func_quote_for_eval_result 35447a84e134Smrg 35457a84e134Smrg # Only build a PIC object if we are building libtool libraries. 35465ec34c4cSmrg if test yes = "$build_libtool_libs"; then 35477a84e134Smrg # Without this assignment, base_compile gets emptied. 35487a84e134Smrg fbsd_hideous_sh_bug=$base_compile 35497a84e134Smrg 35505ec34c4cSmrg if test no != "$pic_mode"; then 35517a84e134Smrg command="$base_compile $qsrcfile $pic_flag" 35527a84e134Smrg else 35537a84e134Smrg # Don't build PIC code 35547a84e134Smrg command="$base_compile $qsrcfile" 35557a84e134Smrg fi 35567a84e134Smrg 3557994689c1Smrg func_mkdir_p "$xdir$objdir" 35587a84e134Smrg 35597a84e134Smrg if test -z "$output_obj"; then 35607a84e134Smrg # Place PIC objects in $objdir 3561f353fbadSmrg func_append command " -o $lobj" 35627a84e134Smrg fi 35637a84e134Smrg 3564994689c1Smrg func_show_eval_locale "$command" \ 3565994689c1Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 35667a84e134Smrg 35675ec34c4cSmrg if test warn = "$need_locks" && 35687a84e134Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3569994689c1Smrg $ECHO "\ 35707a84e134Smrg*** ERROR, $lockfile contains: 35717a84e134Smrg`cat $lockfile 2>/dev/null` 35727a84e134Smrg 35737a84e134Smrgbut it should contain: 35747a84e134Smrg$srcfile 35757a84e134Smrg 35767a84e134SmrgThis indicates that another process is trying to use the same 35777a84e134Smrgtemporary object file, and libtool could not work around it because 35785ec34c4cSmrgyour compiler does not support '-c' and '-o' together. If you 35797a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better 35807a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better 35817a84e134Smrgcompiler." 35827a84e134Smrg 3583994689c1Smrg $opt_dry_run || $RM $removelist 35847a84e134Smrg exit $EXIT_FAILURE 35857a84e134Smrg fi 35867a84e134Smrg 35877a84e134Smrg # Just move the object if needed, then go on to compile the next one 35887a84e134Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3589994689c1Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3590994689c1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35917a84e134Smrg fi 35927a84e134Smrg 35937a84e134Smrg # Allow error messages only from the first compilation. 35945ec34c4cSmrg if test yes = "$suppress_opt"; then 3595994689c1Smrg suppress_output=' >/dev/null 2>&1' 35967a84e134Smrg fi 35977a84e134Smrg fi 35987a84e134Smrg 35997a84e134Smrg # Only build a position-dependent object if we build old libraries. 36005ec34c4cSmrg if test yes = "$build_old_libs"; then 36015ec34c4cSmrg if test yes != "$pic_mode"; then 36027a84e134Smrg # Don't build PIC code 3603994689c1Smrg command="$base_compile $qsrcfile$pie_flag" 36047a84e134Smrg else 36057a84e134Smrg command="$base_compile $qsrcfile $pic_flag" 36067a84e134Smrg fi 36075ec34c4cSmrg if test yes = "$compiler_c_o"; then 3608f353fbadSmrg func_append command " -o $obj" 36097a84e134Smrg fi 36107a84e134Smrg 36117a84e134Smrg # Suppress compiler output if we already did a PIC compilation. 3612f353fbadSmrg func_append command "$suppress_output" 3613994689c1Smrg func_show_eval_locale "$command" \ 3614994689c1Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 36157a84e134Smrg 36165ec34c4cSmrg if test warn = "$need_locks" && 36177a84e134Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3618994689c1Smrg $ECHO "\ 36197a84e134Smrg*** ERROR, $lockfile contains: 36207a84e134Smrg`cat $lockfile 2>/dev/null` 36217a84e134Smrg 36227a84e134Smrgbut it should contain: 36237a84e134Smrg$srcfile 36247a84e134Smrg 36257a84e134SmrgThis indicates that another process is trying to use the same 36267a84e134Smrgtemporary object file, and libtool could not work around it because 36275ec34c4cSmrgyour compiler does not support '-c' and '-o' together. If you 36287a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better 36297a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better 36307a84e134Smrgcompiler." 36317a84e134Smrg 3632994689c1Smrg $opt_dry_run || $RM $removelist 36337a84e134Smrg exit $EXIT_FAILURE 36347a84e134Smrg fi 36357a84e134Smrg 36367a84e134Smrg # Just move the object if needed 36377a84e134Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3638994689c1Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3639994689c1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 36407a84e134Smrg fi 36417a84e134Smrg fi 36427a84e134Smrg 3643994689c1Smrg $opt_dry_run || { 3644994689c1Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 36457a84e134Smrg 3646994689c1Smrg # Unlock the critical section if it was locked 36475ec34c4cSmrg if test no != "$need_locks"; then 3648994689c1Smrg removelist=$lockfile 3649994689c1Smrg $RM "$lockfile" 3650994689c1Smrg fi 3651994689c1Smrg } 36527a84e134Smrg 36537a84e134Smrg exit $EXIT_SUCCESS 3654994689c1Smrg} 36557a84e134Smrg 3656994689c1Smrg$opt_help || { 36575ec34c4cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3658994689c1Smrg} 36597a84e134Smrg 3660994689c1Smrgfunc_mode_help () 3661994689c1Smrg{ 3662994689c1Smrg # We need to display help for each of the modes. 3663f353fbadSmrg case $opt_mode in 3664994689c1Smrg "") 3665994689c1Smrg # Generic help is extracted from the usage comments 3666994689c1Smrg # at the start of this file. 3667994689c1Smrg func_help 3668994689c1Smrg ;; 36697a84e134Smrg 3670994689c1Smrg clean) 3671994689c1Smrg $ECHO \ 3672994689c1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 36737a84e134Smrg 3674994689c1SmrgRemove files from the build directory. 36757a84e134Smrg 3676994689c1SmrgRM is the name of the program to use to delete files associated with each FILE 36775ec34c4cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3678994689c1Smrgto RM. 36797a84e134Smrg 3680994689c1SmrgIf FILE is a libtool library, object or program, all the files associated 3681994689c1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3682994689c1Smrg ;; 36837a84e134Smrg 3684994689c1Smrg compile) 3685994689c1Smrg $ECHO \ 3686994689c1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 36877a84e134Smrg 3688994689c1SmrgCompile a source file into a libtool library object. 36897a84e134Smrg 3690994689c1SmrgThis mode accepts the following additional options: 36917a84e134Smrg 3692994689c1Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3693994689c1Smrg -no-suppress do not suppress compiler output for multiple passes 3694994689c1Smrg -prefer-pic try to build PIC objects only 3695994689c1Smrg -prefer-non-pic try to build non-PIC objects only 36965ec34c4cSmrg -shared do not build a '.o' file suitable for static linking 36975ec34c4cSmrg -static only build a '.o' file suitable for static linking 3698994689c1Smrg -Wc,FLAG pass FLAG directly to the compiler 36997a84e134Smrg 37005ec34c4cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3701994689c1Smrgfrom the given SOURCEFILE. 37027a84e134Smrg 3703994689c1SmrgThe output file name is determined by removing the directory component from 37045ec34c4cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 37055ec34c4cSmrglibrary object suffix, '.lo'." 3706994689c1Smrg ;; 37077a84e134Smrg 3708994689c1Smrg execute) 3709994689c1Smrg $ECHO \ 3710994689c1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 37117a84e134Smrg 3712994689c1SmrgAutomatically set library path, then run a program. 37137a84e134Smrg 3714994689c1SmrgThis mode accepts the following additional options: 37157a84e134Smrg 3716994689c1Smrg -dlopen FILE add the directory containing FILE to the library path 37177a84e134Smrg 37185ec34c4cSmrgThis mode sets the library path environment variable according to '-dlopen' 3719994689c1Smrgflags. 37207a84e134Smrg 3721994689c1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3722994689c1Smrginto their corresponding uninstalled binary, and any of their required library 3723994689c1Smrgdirectories are added to the library path. 37247a84e134Smrg 3725994689c1SmrgThen, COMMAND is executed, with ARGS as arguments." 3726994689c1Smrg ;; 37277a84e134Smrg 3728994689c1Smrg finish) 3729994689c1Smrg $ECHO \ 3730994689c1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 37317a84e134Smrg 3732994689c1SmrgComplete the installation of libtool libraries. 37337a84e134Smrg 3734994689c1SmrgEach LIBDIR is a directory that contains libtool libraries. 37357a84e134Smrg 3736994689c1SmrgThe commands that this mode executes may require superuser privileges. Use 37375ec34c4cSmrgthe '--dry-run' option if you just want to see what would be executed." 3738994689c1Smrg ;; 37397a84e134Smrg 3740994689c1Smrg install) 3741994689c1Smrg $ECHO \ 3742994689c1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 37437a84e134Smrg 3744994689c1SmrgInstall executables or libraries. 37457a84e134Smrg 3746994689c1SmrgINSTALL-COMMAND is the installation command. The first component should be 37475ec34c4cSmrgeither the 'install' or 'cp' program. 37487a84e134Smrg 3749994689c1SmrgThe following components of INSTALL-COMMAND are treated specially: 37507a84e134Smrg 3751994689c1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 37527a84e134Smrg 3753994689c1SmrgThe rest of the components are interpreted as arguments to that command (only 3754994689c1SmrgBSD-compatible install options are recognized)." 3755994689c1Smrg ;; 37567a84e134Smrg 3757994689c1Smrg link) 3758994689c1Smrg $ECHO \ 3759994689c1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 37607a84e134Smrg 3761994689c1SmrgLink object files or libraries together to form another library, or to 3762994689c1Smrgcreate an executable program. 37637a84e134Smrg 3764994689c1SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3765994689c1Smrga program from several object files. 37667a84e134Smrg 3767994689c1SmrgThe following components of LINK-COMMAND are treated specially: 37687a84e134Smrg 3769994689c1Smrg -all-static do not do any dynamic linking at all 3770994689c1Smrg -avoid-version do not add a version suffix if possible 3771994689c1Smrg -bindir BINDIR specify path to binaries directory (for systems where 3772994689c1Smrg libraries must be found in the PATH setting at runtime) 37735ec34c4cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3774994689c1Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3775994689c1Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3776994689c1Smrg -export-symbols SYMFILE 3777994689c1Smrg try to export only the symbols listed in SYMFILE 3778994689c1Smrg -export-symbols-regex REGEX 3779994689c1Smrg try to export only the symbols matching REGEX 3780994689c1Smrg -LLIBDIR search LIBDIR for required installed libraries 3781994689c1Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3782994689c1Smrg -module build a library that can dlopened 3783994689c1Smrg -no-fast-install disable the fast-install mode 3784994689c1Smrg -no-install link a not-installable executable 3785994689c1Smrg -no-undefined declare that a library does not refer to external symbols 3786994689c1Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 37875ec34c4cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 37885ec34c4cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3789994689c1Smrg -precious-files-regex REGEX 3790994689c1Smrg don't remove output files matching REGEX 3791994689c1Smrg -release RELEASE specify package release information 3792994689c1Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3793994689c1Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3794994689c1Smrg -shared only do dynamic linking of libtool libraries 3795994689c1Smrg -shrext SUFFIX override the standard shared library file extension 3796994689c1Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3797994689c1Smrg -static-libtool-libs 3798994689c1Smrg do not do any dynamic linking of libtool libraries 3799994689c1Smrg -version-info CURRENT[:REVISION[:AGE]] 3800994689c1Smrg specify library version info [each variable defaults to 0] 3801994689c1Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 3802994689c1Smrg -Wc,FLAG 3803994689c1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3804994689c1Smrg -Wl,FLAG 3805994689c1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3806994689c1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 38077a84e134Smrg 38085ec34c4cSmrgAll other options (arguments beginning with '-') are ignored. 38097a84e134Smrg 38105ec34c4cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3811994689c1Smrgtreated as uninstalled libtool libraries, other files are standard or library 3812994689c1Smrgobject files. 38137a84e134Smrg 38145ec34c4cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 38155ec34c4cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3816994689c1Smrgrequired, except when creating a convenience library. 38177a84e134Smrg 38185ec34c4cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 38195ec34c4cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 38207a84e134Smrg 38215ec34c4cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3822994689c1Smrgis created, otherwise an executable program is created." 3823994689c1Smrg ;; 38247a84e134Smrg 3825994689c1Smrg uninstall) 3826994689c1Smrg $ECHO \ 3827994689c1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 38287a84e134Smrg 3829994689c1SmrgRemove libraries from an installation directory. 38307a84e134Smrg 3831994689c1SmrgRM is the name of the program to use to delete files associated with each FILE 38325ec34c4cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3833994689c1Smrgto RM. 38347a84e134Smrg 3835994689c1SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3836994689c1SmrgOtherwise, only FILE itself is deleted using RM." 3837994689c1Smrg ;; 38387a84e134Smrg 3839994689c1Smrg *) 38405ec34c4cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3841994689c1Smrg ;; 3842994689c1Smrg esac 38437a84e134Smrg 3844994689c1Smrg echo 38455ec34c4cSmrg $ECHO "Try '$progname --help' for more information about other modes." 3846994689c1Smrg} 3847775e7de9Smrg 3848994689c1Smrg# Now that we've collected a possible --mode arg, show help if necessary 3849994689c1Smrgif $opt_help; then 38505ec34c4cSmrg if test : = "$opt_help"; then 3851994689c1Smrg func_mode_help 3852994689c1Smrg else 3853994689c1Smrg { 3854994689c1Smrg func_help noexit 3855f353fbadSmrg for opt_mode in compile link execute install finish uninstall clean; do 3856994689c1Smrg func_mode_help 3857994689c1Smrg done 38585ec34c4cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3859994689c1Smrg { 3860994689c1Smrg func_help noexit 3861f353fbadSmrg for opt_mode in compile link execute install finish uninstall clean; do 3862994689c1Smrg echo 3863994689c1Smrg func_mode_help 3864994689c1Smrg done 3865994689c1Smrg } | 38665ec34c4cSmrg $SED '1d 3867994689c1Smrg /^When reporting/,/^Report/{ 3868994689c1Smrg H 3869994689c1Smrg d 3870994689c1Smrg } 3871994689c1Smrg $x 3872994689c1Smrg /information about other modes/d 3873994689c1Smrg /more detailed .*MODE/d 3874994689c1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3875994689c1Smrg fi 3876994689c1Smrg exit $? 3877994689c1Smrgfi 38787a84e134Smrg 38797a84e134Smrg 3880994689c1Smrg# func_mode_execute arg... 3881994689c1Smrgfunc_mode_execute () 3882994689c1Smrg{ 38835ec34c4cSmrg $debug_cmd 38845ec34c4cSmrg 3885994689c1Smrg # The first argument is the command name. 38865ec34c4cSmrg cmd=$nonopt 3887994689c1Smrg test -z "$cmd" && \ 3888994689c1Smrg func_fatal_help "you must specify a COMMAND" 3889ab902922Smrg 3890994689c1Smrg # Handle -dlopen flags immediately. 3891f353fbadSmrg for file in $opt_dlopen; do 3892994689c1Smrg test -f "$file" \ 38935ec34c4cSmrg || func_fatal_help "'$file' is not a file" 38947a84e134Smrg 3895994689c1Smrg dir= 3896994689c1Smrg case $file in 3897994689c1Smrg *.la) 3898f353fbadSmrg func_resolve_sysroot "$file" 3899f353fbadSmrg file=$func_resolve_sysroot_result 3900f353fbadSmrg 3901994689c1Smrg # Check to see that this really is a libtool archive. 3902994689c1Smrg func_lalib_unsafe_p "$file" \ 39035ec34c4cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 39047a84e134Smrg 3905994689c1Smrg # Read the libtool library. 3906994689c1Smrg dlname= 3907994689c1Smrg library_names= 3908994689c1Smrg func_source "$file" 39097a84e134Smrg 3910994689c1Smrg # Skip this library if it cannot be dlopened. 3911994689c1Smrg if test -z "$dlname"; then 3912994689c1Smrg # Warn if it was a shared library. 3913994689c1Smrg test -n "$library_names" && \ 39145ec34c4cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3915994689c1Smrg continue 3916994689c1Smrg fi 3917e1e1713cSmrg 3918994689c1Smrg func_dirname "$file" "" "." 39195ec34c4cSmrg dir=$func_dirname_result 3920e1e1713cSmrg 3921994689c1Smrg if test -f "$dir/$objdir/$dlname"; then 3922f353fbadSmrg func_append dir "/$objdir" 3923994689c1Smrg else 3924994689c1Smrg if test ! -f "$dir/$dlname"; then 39255ec34c4cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3926994689c1Smrg fi 3927994689c1Smrg fi 3928775e7de9Smrg ;; 3929e1e1713cSmrg 3930994689c1Smrg *.lo) 3931994689c1Smrg # Just add the directory containing the .lo file. 3932994689c1Smrg func_dirname "$file" "" "." 39335ec34c4cSmrg dir=$func_dirname_result 3934775e7de9Smrg ;; 3935994689c1Smrg 3936994689c1Smrg *) 39375ec34c4cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3938e1e1713cSmrg continue 3939775e7de9Smrg ;; 3940994689c1Smrg esac 3941775e7de9Smrg 3942994689c1Smrg # Get the absolute pathname. 3943994689c1Smrg absdir=`cd "$dir" && pwd` 39445ec34c4cSmrg test -n "$absdir" && dir=$absdir 3945775e7de9Smrg 3946994689c1Smrg # Now add the directory to shlibpath_var. 3947994689c1Smrg if eval "test -z \"\$$shlibpath_var\""; then 3948994689c1Smrg eval "$shlibpath_var=\"\$dir\"" 3949994689c1Smrg else 3950994689c1Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3951994689c1Smrg fi 3952994689c1Smrg done 3953775e7de9Smrg 3954994689c1Smrg # This variable tells wrapper scripts just to set shlibpath_var 3955994689c1Smrg # rather than running their programs. 39565ec34c4cSmrg libtool_execute_magic=$magic 39577a84e134Smrg 3958994689c1Smrg # Check if any of the arguments is a wrapper script. 3959994689c1Smrg args= 3960994689c1Smrg for file 3961994689c1Smrg do 3962994689c1Smrg case $file in 3963994689c1Smrg -* | *.la | *.lo ) ;; 3964994689c1Smrg *) 3965994689c1Smrg # Do a test to see if this is really a libtool program. 3966994689c1Smrg if func_ltwrapper_script_p "$file"; then 3967994689c1Smrg func_source "$file" 3968994689c1Smrg # Transform arg to wrapped name. 39695ec34c4cSmrg file=$progdir/$program 3970994689c1Smrg elif func_ltwrapper_executable_p "$file"; then 3971994689c1Smrg func_ltwrapper_scriptname "$file" 3972994689c1Smrg func_source "$func_ltwrapper_scriptname_result" 3973994689c1Smrg # Transform arg to wrapped name. 39745ec34c4cSmrg file=$progdir/$program 3975994689c1Smrg fi 3976e1e1713cSmrg ;; 3977994689c1Smrg esac 3978994689c1Smrg # Quote arguments (to preserve shell metacharacters). 3979f353fbadSmrg func_append_quoted args "$file" 3980994689c1Smrg done 39817a84e134Smrg 39825ec34c4cSmrg if $opt_dry_run; then 39835ec34c4cSmrg # Display what would be done. 39845ec34c4cSmrg if test -n "$shlibpath_var"; then 39855ec34c4cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 39865ec34c4cSmrg echo "export $shlibpath_var" 39875ec34c4cSmrg fi 39885ec34c4cSmrg $ECHO "$cmd$args" 39895ec34c4cSmrg exit $EXIT_SUCCESS 39905ec34c4cSmrg else 3991994689c1Smrg if test -n "$shlibpath_var"; then 3992994689c1Smrg # Export the shlibpath_var. 3993994689c1Smrg eval "export $shlibpath_var" 3994994689c1Smrg fi 3995775e7de9Smrg 3996994689c1Smrg # Restore saved environment variables 3997994689c1Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3998994689c1Smrg do 3999994689c1Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4000994689c1Smrg $lt_var=\$save_$lt_var; export $lt_var 4001994689c1Smrg else 4002994689c1Smrg $lt_unset $lt_var 4003994689c1Smrg fi" 4004994689c1Smrg done 40057a84e134Smrg 4006994689c1Smrg # Now prepare to actually exec the command. 40075ec34c4cSmrg exec_cmd=\$cmd$args 4008994689c1Smrg fi 4009994689c1Smrg} 4010775e7de9Smrg 40115ec34c4cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4012775e7de9Smrg 4013775e7de9Smrg 4014994689c1Smrg# func_mode_finish arg... 4015994689c1Smrgfunc_mode_finish () 4016994689c1Smrg{ 40175ec34c4cSmrg $debug_cmd 40185ec34c4cSmrg 4019f353fbadSmrg libs= 4020f353fbadSmrg libdirs= 4021994689c1Smrg admincmds= 4022775e7de9Smrg 4023f353fbadSmrg for opt in "$nonopt" ${1+"$@"} 4024f353fbadSmrg do 4025f353fbadSmrg if test -d "$opt"; then 4026f353fbadSmrg func_append libdirs " $opt" 4027f353fbadSmrg 4028f353fbadSmrg elif test -f "$opt"; then 4029f353fbadSmrg if func_lalib_unsafe_p "$opt"; then 4030f353fbadSmrg func_append libs " $opt" 4031f353fbadSmrg else 40325ec34c4cSmrg func_warning "'$opt' is not a valid libtool archive" 4033f353fbadSmrg fi 4034f353fbadSmrg 4035f353fbadSmrg else 40365ec34c4cSmrg func_fatal_error "invalid argument '$opt'" 4037f353fbadSmrg fi 4038f353fbadSmrg done 4039f353fbadSmrg 4040f353fbadSmrg if test -n "$libs"; then 4041f353fbadSmrg if test -n "$lt_sysroot"; then 4042f353fbadSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4043f353fbadSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4044f353fbadSmrg else 4045f353fbadSmrg sysroot_cmd= 4046f353fbadSmrg fi 4047f353fbadSmrg 4048f353fbadSmrg # Remove sysroot references 4049f353fbadSmrg if $opt_dry_run; then 4050f353fbadSmrg for lib in $libs; do 40515ec34c4cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4052f353fbadSmrg done 4053f353fbadSmrg else 4054f353fbadSmrg tmpdir=`func_mktempdir` 4055f353fbadSmrg for lib in $libs; do 40565ec34c4cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4057f353fbadSmrg > $tmpdir/tmp-la 4058f353fbadSmrg mv -f $tmpdir/tmp-la $lib 4059f353fbadSmrg done 4060f353fbadSmrg ${RM}r "$tmpdir" 4061f353fbadSmrg fi 4062f353fbadSmrg fi 4063775e7de9Smrg 4064f353fbadSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4065994689c1Smrg for libdir in $libdirs; do 4066994689c1Smrg if test -n "$finish_cmds"; then 4067994689c1Smrg # Do each command in the finish commands. 4068994689c1Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4069994689c1Smrg'"$cmd"'"' 4070994689c1Smrg fi 4071994689c1Smrg if test -n "$finish_eval"; then 4072994689c1Smrg # Do the single finish_eval. 4073994689c1Smrg eval cmds=\"$finish_eval\" 4074f353fbadSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4075994689c1Smrg $cmds" 4076994689c1Smrg fi 4077994689c1Smrg done 4078994689c1Smrg fi 4079775e7de9Smrg 4080994689c1Smrg # Exit here if they wanted silent mode. 40815ec34c4cSmrg $opt_quiet && exit $EXIT_SUCCESS 4082775e7de9Smrg 4083f353fbadSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4084f353fbadSmrg echo "----------------------------------------------------------------------" 4085f353fbadSmrg echo "Libraries have been installed in:" 4086f353fbadSmrg for libdir in $libdirs; do 4087f353fbadSmrg $ECHO " $libdir" 4088f353fbadSmrg done 4089f353fbadSmrg echo 4090f353fbadSmrg echo "If you ever happen to want to link against installed libraries" 4091f353fbadSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 40925ec34c4cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4093f353fbadSmrg echo "flag during linking and do at least one of the following:" 4094f353fbadSmrg if test -n "$shlibpath_var"; then 40955ec34c4cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4096f353fbadSmrg echo " during execution" 4097f353fbadSmrg fi 4098f353fbadSmrg if test -n "$runpath_var"; then 40995ec34c4cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4100f353fbadSmrg echo " during linking" 4101f353fbadSmrg fi 4102f353fbadSmrg if test -n "$hardcode_libdir_flag_spec"; then 4103f353fbadSmrg libdir=LIBDIR 4104f353fbadSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4105775e7de9Smrg 41065ec34c4cSmrg $ECHO " - use the '$flag' linker flag" 4107f353fbadSmrg fi 4108f353fbadSmrg if test -n "$admincmds"; then 4109f353fbadSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4110f353fbadSmrg fi 4111f353fbadSmrg if test -f /etc/ld.so.conf; then 41125ec34c4cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4113f353fbadSmrg fi 4114f353fbadSmrg echo 4115775e7de9Smrg 4116f353fbadSmrg echo "See any operating system documentation about shared libraries for" 4117f353fbadSmrg case $host in 4118f353fbadSmrg solaris2.[6789]|solaris2.1[0-9]) 4119f353fbadSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4120f353fbadSmrg echo "pages." 4121f353fbadSmrg ;; 4122f353fbadSmrg *) 4123f353fbadSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4124f353fbadSmrg ;; 4125f353fbadSmrg esac 4126f353fbadSmrg echo "----------------------------------------------------------------------" 4127f353fbadSmrg fi 4128994689c1Smrg exit $EXIT_SUCCESS 4129994689c1Smrg} 4130775e7de9Smrg 41315ec34c4cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4132e1e1713cSmrg 41337a84e134Smrg 4134994689c1Smrg# func_mode_install arg... 4135994689c1Smrgfunc_mode_install () 4136994689c1Smrg{ 41375ec34c4cSmrg $debug_cmd 41385ec34c4cSmrg 4139994689c1Smrg # There may be an optional sh(1) argument at the beginning of 4140994689c1Smrg # install_prog (especially on Windows NT). 41415ec34c4cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4142994689c1Smrg # Allow the use of GNU shtool's install command. 41435ec34c4cSmrg case $nonopt in *shtool*) :;; *) false;; esac 41445ec34c4cSmrg then 4145994689c1Smrg # Aesthetically quote it. 4146994689c1Smrg func_quote_for_eval "$nonopt" 4147994689c1Smrg install_prog="$func_quote_for_eval_result " 4148994689c1Smrg arg=$1 4149994689c1Smrg shift 4150994689c1Smrg else 4151994689c1Smrg install_prog= 4152994689c1Smrg arg=$nonopt 4153994689c1Smrg fi 41547a84e134Smrg 4155994689c1Smrg # The real first argument should be the name of the installation program. 4156994689c1Smrg # Aesthetically quote it. 4157994689c1Smrg func_quote_for_eval "$arg" 4158f353fbadSmrg func_append install_prog "$func_quote_for_eval_result" 4159994689c1Smrg install_shared_prog=$install_prog 4160994689c1Smrg case " $install_prog " in 4161994689c1Smrg *[\\\ /]cp\ *) install_cp=: ;; 4162994689c1Smrg *) install_cp=false ;; 4163994689c1Smrg esac 41647a84e134Smrg 4165994689c1Smrg # We need to accept at least all the BSD install flags. 4166994689c1Smrg dest= 4167994689c1Smrg files= 4168994689c1Smrg opts= 4169994689c1Smrg prev= 4170994689c1Smrg install_type= 41715ec34c4cSmrg isdir=false 4172994689c1Smrg stripme= 4173994689c1Smrg no_mode=: 4174994689c1Smrg for arg 4175994689c1Smrg do 4176994689c1Smrg arg2= 4177994689c1Smrg if test -n "$dest"; then 4178f353fbadSmrg func_append files " $dest" 4179994689c1Smrg dest=$arg 4180e1e1713cSmrg continue 4181994689c1Smrg fi 41827a84e134Smrg 4183994689c1Smrg case $arg in 41845ec34c4cSmrg -d) isdir=: ;; 4185994689c1Smrg -f) 4186994689c1Smrg if $install_cp; then :; else 4187994689c1Smrg prev=$arg 4188775e7de9Smrg fi 4189994689c1Smrg ;; 4190994689c1Smrg -g | -m | -o) 4191994689c1Smrg prev=$arg 4192994689c1Smrg ;; 4193994689c1Smrg -s) 4194994689c1Smrg stripme=" -s" 4195e1e1713cSmrg continue 4196e1e1713cSmrg ;; 4197994689c1Smrg -*) 4198994689c1Smrg ;; 4199e1e1713cSmrg *) 4200994689c1Smrg # If the previous option needed an argument, then skip it. 4201994689c1Smrg if test -n "$prev"; then 42025ec34c4cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4203994689c1Smrg arg2=$install_override_mode 4204994689c1Smrg no_mode=false 4205994689c1Smrg fi 4206994689c1Smrg prev= 4207994689c1Smrg else 4208994689c1Smrg dest=$arg 4209994689c1Smrg continue 4210994689c1Smrg fi 4211775e7de9Smrg ;; 4212994689c1Smrg esac 42137a84e134Smrg 4214994689c1Smrg # Aesthetically quote the argument. 4215994689c1Smrg func_quote_for_eval "$arg" 4216f353fbadSmrg func_append install_prog " $func_quote_for_eval_result" 4217994689c1Smrg if test -n "$arg2"; then 4218994689c1Smrg func_quote_for_eval "$arg2" 4219e1e1713cSmrg fi 4220f353fbadSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4221994689c1Smrg done 42227a84e134Smrg 4223994689c1Smrg test -z "$install_prog" && \ 4224994689c1Smrg func_fatal_help "you must specify an install program" 42257a84e134Smrg 4226994689c1Smrg test -n "$prev" && \ 42275ec34c4cSmrg func_fatal_help "the '$prev' option requires an argument" 4228775e7de9Smrg 4229994689c1Smrg if test -n "$install_override_mode" && $no_mode; then 4230994689c1Smrg if $install_cp; then :; else 4231994689c1Smrg func_quote_for_eval "$install_override_mode" 4232f353fbadSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4233994689c1Smrg fi 4234e1e1713cSmrg fi 4235775e7de9Smrg 4236994689c1Smrg if test -z "$files"; then 4237994689c1Smrg if test -z "$dest"; then 4238994689c1Smrg func_fatal_help "no file or destination specified" 4239994689c1Smrg else 4240994689c1Smrg func_fatal_help "you must specify a destination" 4241775e7de9Smrg fi 4242775e7de9Smrg fi 4243775e7de9Smrg 4244994689c1Smrg # Strip any trailing slash from the destination. 4245994689c1Smrg func_stripname '' '/' "$dest" 4246994689c1Smrg dest=$func_stripname_result 42477a84e134Smrg 4248994689c1Smrg # Check to see that the destination is a directory. 42495ec34c4cSmrg test -d "$dest" && isdir=: 42505ec34c4cSmrg if $isdir; then 42515ec34c4cSmrg destdir=$dest 4252994689c1Smrg destname= 4253994689c1Smrg else 4254994689c1Smrg func_dirname_and_basename "$dest" "" "." 42555ec34c4cSmrg destdir=$func_dirname_result 42565ec34c4cSmrg destname=$func_basename_result 4257994689c1Smrg 4258994689c1Smrg # Not a directory, so check to see that there is only one file specified. 4259994689c1Smrg set dummy $files; shift 4260994689c1Smrg test "$#" -gt 1 && \ 42615ec34c4cSmrg func_fatal_help "'$dest' is not a directory" 4262994689c1Smrg fi 4263994689c1Smrg case $destdir in 4264994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4265e1e1713cSmrg *) 4266994689c1Smrg for file in $files; do 4267994689c1Smrg case $file in 4268994689c1Smrg *.lo) ;; 4269994689c1Smrg *) 42705ec34c4cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4271994689c1Smrg ;; 4272994689c1Smrg esac 4273994689c1Smrg done 4274e1e1713cSmrg ;; 4275e1e1713cSmrg esac 42767a84e134Smrg 4277994689c1Smrg # This variable tells wrapper scripts just to set variables rather 4278994689c1Smrg # than running their programs. 42795ec34c4cSmrg libtool_install_magic=$magic 42807a84e134Smrg 4281994689c1Smrg staticlibs= 4282994689c1Smrg future_libdirs= 4283994689c1Smrg current_libdirs= 4284994689c1Smrg for file in $files; do 42857a84e134Smrg 4286994689c1Smrg # Do each installation. 4287994689c1Smrg case $file in 4288994689c1Smrg *.$libext) 4289994689c1Smrg # Do the static libraries later. 4290f353fbadSmrg func_append staticlibs " $file" 4291994689c1Smrg ;; 4292994689c1Smrg 4293994689c1Smrg *.la) 4294f353fbadSmrg func_resolve_sysroot "$file" 4295f353fbadSmrg file=$func_resolve_sysroot_result 4296f353fbadSmrg 4297994689c1Smrg # Check to see that this really is a libtool archive. 4298994689c1Smrg func_lalib_unsafe_p "$file" \ 42995ec34c4cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4300994689c1Smrg 4301994689c1Smrg library_names= 4302994689c1Smrg old_library= 4303994689c1Smrg relink_command= 4304994689c1Smrg func_source "$file" 4305994689c1Smrg 4306994689c1Smrg # Add the libdir to current_libdirs if it is the destination. 4307994689c1Smrg if test "X$destdir" = "X$libdir"; then 4308994689c1Smrg case "$current_libdirs " in 4309994689c1Smrg *" $libdir "*) ;; 4310f353fbadSmrg *) func_append current_libdirs " $libdir" ;; 4311775e7de9Smrg esac 4312994689c1Smrg else 4313994689c1Smrg # Note the libdir as a future libdir. 4314994689c1Smrg case "$future_libdirs " in 4315994689c1Smrg *" $libdir "*) ;; 4316f353fbadSmrg *) func_append future_libdirs " $libdir" ;; 4317994689c1Smrg esac 4318994689c1Smrg fi 4319775e7de9Smrg 4320994689c1Smrg func_dirname "$file" "/" "" 43215ec34c4cSmrg dir=$func_dirname_result 4322f353fbadSmrg func_append dir "$objdir" 4323994689c1Smrg 4324994689c1Smrg if test -n "$relink_command"; then 4325994689c1Smrg # Determine the prefix the user has applied to our future dir. 4326994689c1Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4327994689c1Smrg 4328994689c1Smrg # Don't allow the user to place us outside of our expected 4329994689c1Smrg # location b/c this prevents finding dependent libraries that 4330994689c1Smrg # are installed to the same prefix. 4331994689c1Smrg # At present, this check doesn't affect windows .dll's that 4332994689c1Smrg # are installed into $libdir/../bin (currently, that works fine) 4333994689c1Smrg # but it's something to keep an eye on. 4334994689c1Smrg test "$inst_prefix_dir" = "$destdir" && \ 43355ec34c4cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4336994689c1Smrg 4337994689c1Smrg if test -n "$inst_prefix_dir"; then 4338994689c1Smrg # Stick the inst_prefix_dir data into the link command. 4339994689c1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4340994689c1Smrg else 4341994689c1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4342994689c1Smrg fi 4343994689c1Smrg 43445ec34c4cSmrg func_warning "relinking '$file'" 4345994689c1Smrg func_show_eval "$relink_command" \ 43465ec34c4cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4347994689c1Smrg fi 4348994689c1Smrg 4349994689c1Smrg # See the names of the shared library. 4350994689c1Smrg set dummy $library_names; shift 4351994689c1Smrg if test -n "$1"; then 43525ec34c4cSmrg realname=$1 4353994689c1Smrg shift 4354994689c1Smrg 43555ec34c4cSmrg srcname=$realname 43565ec34c4cSmrg test -n "$relink_command" && srcname=${realname}T 4357994689c1Smrg 4358994689c1Smrg # Install the shared library and build the symlinks. 4359994689c1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4360994689c1Smrg 'exit $?' 43615ec34c4cSmrg tstripme=$stripme 4362994689c1Smrg case $host_os in 4363994689c1Smrg cygwin* | mingw* | pw32* | cegcc*) 4364994689c1Smrg case $realname in 4365994689c1Smrg *.dll.a) 43665ec34c4cSmrg tstripme= 43675ec34c4cSmrg ;; 43685ec34c4cSmrg esac 43695ec34c4cSmrg ;; 43705ec34c4cSmrg os2*) 43715ec34c4cSmrg case $realname in 43725ec34c4cSmrg *_dll.a) 43735ec34c4cSmrg tstripme= 4374994689c1Smrg ;; 4375994689c1Smrg esac 4376775e7de9Smrg ;; 4377775e7de9Smrg esac 4378994689c1Smrg if test -n "$tstripme" && test -n "$striplib"; then 4379994689c1Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4380994689c1Smrg fi 4381994689c1Smrg 4382994689c1Smrg if test "$#" -gt 0; then 4383994689c1Smrg # Delete the old symlinks, and create new ones. 43845ec34c4cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4385994689c1Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4386994689c1Smrg # so we also need to try rm && ln -s. 4387994689c1Smrg for linkname 4388994689c1Smrg do 4389994689c1Smrg test "$linkname" != "$realname" \ 4390994689c1Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4391994689c1Smrg done 4392994689c1Smrg fi 4393994689c1Smrg 4394994689c1Smrg # Do each command in the postinstall commands. 43955ec34c4cSmrg lib=$destdir/$realname 4396994689c1Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4397994689c1Smrg fi 4398994689c1Smrg 4399994689c1Smrg # Install the pseudo-library for information purposes. 4400994689c1Smrg func_basename "$file" 44015ec34c4cSmrg name=$func_basename_result 44025ec34c4cSmrg instname=$dir/${name}i 4403994689c1Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4404994689c1Smrg 4405994689c1Smrg # Maybe install the static library, too. 4406f353fbadSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4407775e7de9Smrg ;; 4408994689c1Smrg 4409994689c1Smrg *.lo) 4410994689c1Smrg # Install (i.e. copy) a libtool object. 4411994689c1Smrg 4412994689c1Smrg # Figure out destination file name, if it wasn't already specified. 4413994689c1Smrg if test -n "$destname"; then 44145ec34c4cSmrg destfile=$destdir/$destname 4415994689c1Smrg else 4416994689c1Smrg func_basename "$file" 44175ec34c4cSmrg destfile=$func_basename_result 44185ec34c4cSmrg destfile=$destdir/$destfile 4419994689c1Smrg fi 4420994689c1Smrg 4421994689c1Smrg # Deduce the name of the destination old-style object file. 4422994689c1Smrg case $destfile in 4423994689c1Smrg *.lo) 4424994689c1Smrg func_lo2o "$destfile" 4425994689c1Smrg staticdest=$func_lo2o_result 4426e1e1713cSmrg ;; 4427994689c1Smrg *.$objext) 44285ec34c4cSmrg staticdest=$destfile 4429994689c1Smrg destfile= 4430e1e1713cSmrg ;; 4431994689c1Smrg *) 44325ec34c4cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4433e1e1713cSmrg ;; 4434994689c1Smrg esac 4435994689c1Smrg 4436994689c1Smrg # Install the libtool object if requested. 4437994689c1Smrg test -n "$destfile" && \ 4438994689c1Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4439994689c1Smrg 4440994689c1Smrg # Install the old object if enabled. 44415ec34c4cSmrg if test yes = "$build_old_libs"; then 4442994689c1Smrg # Deduce the name of the old-style object file. 4443994689c1Smrg func_lo2o "$file" 4444994689c1Smrg staticobj=$func_lo2o_result 4445994689c1Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4446e1e1713cSmrg fi 4447994689c1Smrg exit $EXIT_SUCCESS 4448994689c1Smrg ;; 44497a84e134Smrg 4450994689c1Smrg *) 4451994689c1Smrg # Figure out destination file name, if it wasn't already specified. 4452994689c1Smrg if test -n "$destname"; then 44535ec34c4cSmrg destfile=$destdir/$destname 4454e1e1713cSmrg else 4455994689c1Smrg func_basename "$file" 44565ec34c4cSmrg destfile=$func_basename_result 44575ec34c4cSmrg destfile=$destdir/$destfile 4458e1e1713cSmrg fi 44597a84e134Smrg 4460994689c1Smrg # If the file is missing, and there is a .exe on the end, strip it 4461994689c1Smrg # because it is most likely a libtool script we actually want to 4462994689c1Smrg # install 44635ec34c4cSmrg stripped_ext= 4464994689c1Smrg case $file in 4465994689c1Smrg *.exe) 4466994689c1Smrg if test ! -f "$file"; then 4467994689c1Smrg func_stripname '' '.exe' "$file" 4468994689c1Smrg file=$func_stripname_result 44695ec34c4cSmrg stripped_ext=.exe 4470994689c1Smrg fi 4471994689c1Smrg ;; 4472994689c1Smrg esac 44737a84e134Smrg 4474994689c1Smrg # Do a test to see if this is really a libtool program. 4475994689c1Smrg case $host in 4476994689c1Smrg *cygwin* | *mingw*) 4477994689c1Smrg if func_ltwrapper_executable_p "$file"; then 4478994689c1Smrg func_ltwrapper_scriptname "$file" 4479994689c1Smrg wrapper=$func_ltwrapper_scriptname_result 4480994689c1Smrg else 4481994689c1Smrg func_stripname '' '.exe' "$file" 4482994689c1Smrg wrapper=$func_stripname_result 4483994689c1Smrg fi 4484994689c1Smrg ;; 4485994689c1Smrg *) 4486994689c1Smrg wrapper=$file 4487994689c1Smrg ;; 4488994689c1Smrg esac 4489994689c1Smrg if func_ltwrapper_script_p "$wrapper"; then 4490994689c1Smrg notinst_deplibs= 4491994689c1Smrg relink_command= 44927a84e134Smrg 4493994689c1Smrg func_source "$wrapper" 44947a84e134Smrg 4495994689c1Smrg # Check the variables that should have been set. 4496994689c1Smrg test -z "$generated_by_libtool_version" && \ 44975ec34c4cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 44987a84e134Smrg 44995ec34c4cSmrg finalize=: 4500994689c1Smrg for lib in $notinst_deplibs; do 4501994689c1Smrg # Check to see that each library is installed. 4502994689c1Smrg libdir= 4503994689c1Smrg if test -f "$lib"; then 4504994689c1Smrg func_source "$lib" 4505e1e1713cSmrg fi 45065ec34c4cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4507994689c1Smrg if test -n "$libdir" && test ! -f "$libfile"; then 45085ec34c4cSmrg func_warning "'$lib' has not been installed in '$libdir'" 45095ec34c4cSmrg finalize=false 4510994689c1Smrg fi 4511994689c1Smrg done 45127a84e134Smrg 4513994689c1Smrg relink_command= 4514994689c1Smrg func_source "$wrapper" 45157a84e134Smrg 4516994689c1Smrg outputname= 45175ec34c4cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4518994689c1Smrg $opt_dry_run || { 45195ec34c4cSmrg if $finalize; then 4520994689c1Smrg tmpdir=`func_mktempdir` 4521994689c1Smrg func_basename "$file$stripped_ext" 45225ec34c4cSmrg file=$func_basename_result 45235ec34c4cSmrg outputname=$tmpdir/$file 4524994689c1Smrg # Replace the output file specification. 4525994689c1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4526994689c1Smrg 45275ec34c4cSmrg $opt_quiet || { 4528994689c1Smrg func_quote_for_expand "$relink_command" 4529994689c1Smrg eval "func_echo $func_quote_for_expand_result" 4530994689c1Smrg } 4531994689c1Smrg if eval "$relink_command"; then : 4532994689c1Smrg else 45335ec34c4cSmrg func_error "error: relink '$file' with the above command before installing it" 4534994689c1Smrg $opt_dry_run || ${RM}r "$tmpdir" 4535994689c1Smrg continue 4536994689c1Smrg fi 45375ec34c4cSmrg file=$outputname 4538994689c1Smrg else 45395ec34c4cSmrg func_warning "cannot relink '$file'" 4540994689c1Smrg fi 4541994689c1Smrg } 4542e1e1713cSmrg else 4543994689c1Smrg # Install the binary that we compiled earlier. 4544994689c1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4545e1e1713cSmrg fi 4546994689c1Smrg fi 45477a84e134Smrg 4548994689c1Smrg # remove .exe since cygwin /usr/bin/install will append another 4549994689c1Smrg # one anyway 4550994689c1Smrg case $install_prog,$host in 4551994689c1Smrg */usr/bin/install*,*cygwin*) 4552994689c1Smrg case $file:$destfile in 4553994689c1Smrg *.exe:*.exe) 4554994689c1Smrg # this is ok 4555994689c1Smrg ;; 4556994689c1Smrg *.exe:*) 4557994689c1Smrg destfile=$destfile.exe 4558994689c1Smrg ;; 4559994689c1Smrg *:*.exe) 4560994689c1Smrg func_stripname '' '.exe' "$destfile" 4561994689c1Smrg destfile=$func_stripname_result 4562994689c1Smrg ;; 4563994689c1Smrg esac 4564e1e1713cSmrg ;; 4565e1e1713cSmrg esac 4566994689c1Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4567994689c1Smrg $opt_dry_run || if test -n "$outputname"; then 4568994689c1Smrg ${RM}r "$tmpdir" 4569994689c1Smrg fi 4570994689c1Smrg ;; 4571994689c1Smrg esac 4572994689c1Smrg done 45737a84e134Smrg 4574994689c1Smrg for file in $staticlibs; do 4575994689c1Smrg func_basename "$file" 45765ec34c4cSmrg name=$func_basename_result 4577994689c1Smrg 4578994689c1Smrg # Set up the ranlib parameters. 45795ec34c4cSmrg oldlib=$destdir/$name 4580421c997bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4581421c997bSmrg tool_oldlib=$func_to_tool_file_result 4582994689c1Smrg 4583994689c1Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4584994689c1Smrg 4585994689c1Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4586421c997bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4587994689c1Smrg fi 4588994689c1Smrg 4589994689c1Smrg # Do each command in the postinstall commands. 4590994689c1Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4591994689c1Smrg done 4592994689c1Smrg 4593994689c1Smrg test -n "$future_libdirs" && \ 45945ec34c4cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4595994689c1Smrg 4596994689c1Smrg if test -n "$current_libdirs"; then 4597994689c1Smrg # Maybe just do a dry run. 4598994689c1Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 45995ec34c4cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4600994689c1Smrg else 4601994689c1Smrg exit $EXIT_SUCCESS 4602994689c1Smrg fi 4603994689c1Smrg} 4604994689c1Smrg 46055ec34c4cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4606994689c1Smrg 4607994689c1Smrg 4608994689c1Smrg# func_generate_dlsyms outputname originator pic_p 4609994689c1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4610994689c1Smrg# a dlpreopen symbol table. 4611994689c1Smrgfunc_generate_dlsyms () 4612994689c1Smrg{ 46135ec34c4cSmrg $debug_cmd 46145ec34c4cSmrg 46155ec34c4cSmrg my_outputname=$1 46165ec34c4cSmrg my_originator=$2 46175ec34c4cSmrg my_pic_p=${3-false} 46185ec34c4cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4619994689c1Smrg my_dlsyms= 4620994689c1Smrg 46215ec34c4cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4622994689c1Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 46235ec34c4cSmrg my_dlsyms=${my_outputname}S.c 4624994689c1Smrg else 4625994689c1Smrg func_error "not configured to extract global symbols from dlpreopened files" 4626994689c1Smrg fi 4627994689c1Smrg fi 4628994689c1Smrg 4629994689c1Smrg if test -n "$my_dlsyms"; then 4630994689c1Smrg case $my_dlsyms in 4631994689c1Smrg "") ;; 4632994689c1Smrg *.c) 4633994689c1Smrg # Discover the nlist of each of the dlfiles. 46345ec34c4cSmrg nlist=$output_objdir/$my_outputname.nm 4635994689c1Smrg 4636994689c1Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4637994689c1Smrg 4638994689c1Smrg # Parse the name list into a source file. 4639994689c1Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4640994689c1Smrg 4641994689c1Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 46425ec34c4cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 46435ec34c4cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4644994689c1Smrg 4645994689c1Smrg#ifdef __cplusplus 4646994689c1Smrgextern \"C\" { 4647994689c1Smrg#endif 4648994689c1Smrg 46495ec34c4cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4650994689c1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4651994689c1Smrg#endif 4652994689c1Smrg 4653f353fbadSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 46545ec34c4cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 46555ec34c4cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4656f353fbadSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4657f353fbadSmrg# define LT_DLSYM_CONST 46585ec34c4cSmrg#elif defined __osf__ 4659f353fbadSmrg/* This system does not cope well with relocations in const data. */ 4660f353fbadSmrg# define LT_DLSYM_CONST 4661f353fbadSmrg#else 4662f353fbadSmrg# define LT_DLSYM_CONST const 4663f353fbadSmrg#endif 4664f353fbadSmrg 46655ec34c4cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 46665ec34c4cSmrg 4667994689c1Smrg/* External symbol declarations for the compiler. */\ 4668994689c1Smrg" 4669994689c1Smrg 46705ec34c4cSmrg if test yes = "$dlself"; then 46715ec34c4cSmrg func_verbose "generating symbol list for '$output'" 4672994689c1Smrg 4673994689c1Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4674994689c1Smrg 4675994689c1Smrg # Add our own program objects to the symbol list. 4676994689c1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4677994689c1Smrg for progfile in $progfiles; do 4678f353fbadSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 46795ec34c4cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4680f353fbadSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4681994689c1Smrg done 4682994689c1Smrg 4683994689c1Smrg if test -n "$exclude_expsyms"; then 4684994689c1Smrg $opt_dry_run || { 4685994689c1Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4686994689c1Smrg eval '$MV "$nlist"T "$nlist"' 4687994689c1Smrg } 4688e1e1713cSmrg fi 4689994689c1Smrg 4690994689c1Smrg if test -n "$export_symbols_regex"; then 4691994689c1Smrg $opt_dry_run || { 4692994689c1Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4693994689c1Smrg eval '$MV "$nlist"T "$nlist"' 4694994689c1Smrg } 4695994689c1Smrg fi 4696994689c1Smrg 4697994689c1Smrg # Prepare the list of exported symbols 4698994689c1Smrg if test -z "$export_symbols"; then 46995ec34c4cSmrg export_symbols=$output_objdir/$outputname.exp 4700994689c1Smrg $opt_dry_run || { 4701994689c1Smrg $RM $export_symbols 47025ec34c4cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4703994689c1Smrg case $host in 4704994689c1Smrg *cygwin* | *mingw* | *cegcc* ) 4705994689c1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4706994689c1Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4707994689c1Smrg ;; 4708994689c1Smrg esac 4709994689c1Smrg } 4710e1e1713cSmrg else 4711994689c1Smrg $opt_dry_run || { 47125ec34c4cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4713994689c1Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4714994689c1Smrg eval '$MV "$nlist"T "$nlist"' 4715994689c1Smrg case $host in 4716994689c1Smrg *cygwin* | *mingw* | *cegcc* ) 4717994689c1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4718994689c1Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4719994689c1Smrg ;; 4720994689c1Smrg esac 4721994689c1Smrg } 4722e1e1713cSmrg fi 4723994689c1Smrg fi 47247a84e134Smrg 4725994689c1Smrg for dlprefile in $dlprefiles; do 47265ec34c4cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4727994689c1Smrg func_basename "$dlprefile" 47285ec34c4cSmrg name=$func_basename_result 4729f353fbadSmrg case $host in 4730f353fbadSmrg *cygwin* | *mingw* | *cegcc* ) 4731f353fbadSmrg # if an import library, we need to obtain dlname 4732f353fbadSmrg if func_win32_import_lib_p "$dlprefile"; then 4733f353fbadSmrg func_tr_sh "$dlprefile" 4734f353fbadSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 47355ec34c4cSmrg dlprefile_dlbasename= 4736f353fbadSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4737f353fbadSmrg # Use subshell, to avoid clobbering current variable values 4738f353fbadSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 47395ec34c4cSmrg if test -n "$dlprefile_dlname"; then 4740f353fbadSmrg func_basename "$dlprefile_dlname" 47415ec34c4cSmrg dlprefile_dlbasename=$func_basename_result 4742f353fbadSmrg else 4743f353fbadSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4744f353fbadSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4745f353fbadSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4746f353fbadSmrg fi 4747f353fbadSmrg fi 4748f353fbadSmrg $opt_dry_run || { 47495ec34c4cSmrg if test -n "$dlprefile_dlbasename"; then 4750f353fbadSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4751f353fbadSmrg else 4752f353fbadSmrg func_warning "Could not compute DLL name from $name" 4753f353fbadSmrg eval '$ECHO ": $name " >> "$nlist"' 4754f353fbadSmrg fi 4755f353fbadSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4756f353fbadSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4757f353fbadSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4758f353fbadSmrg } 4759f353fbadSmrg else # not an import lib 4760f353fbadSmrg $opt_dry_run || { 4761f353fbadSmrg eval '$ECHO ": $name " >> "$nlist"' 4762f353fbadSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4763f353fbadSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4764f353fbadSmrg } 4765f353fbadSmrg fi 4766f353fbadSmrg ;; 4767f353fbadSmrg *) 4768f353fbadSmrg $opt_dry_run || { 4769f353fbadSmrg eval '$ECHO ": $name " >> "$nlist"' 4770f353fbadSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4771f353fbadSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4772f353fbadSmrg } 4773f353fbadSmrg ;; 4774f353fbadSmrg esac 4775994689c1Smrg done 4776994689c1Smrg 4777994689c1Smrg $opt_dry_run || { 4778994689c1Smrg # Make sure we have at least an empty file. 4779994689c1Smrg test -f "$nlist" || : > "$nlist" 4780994689c1Smrg 4781994689c1Smrg if test -n "$exclude_expsyms"; then 4782994689c1Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4783994689c1Smrg $MV "$nlist"T "$nlist" 4784e1e1713cSmrg fi 4785994689c1Smrg 4786994689c1Smrg # Try sorting and uniquifying the output. 4787994689c1Smrg if $GREP -v "^: " < "$nlist" | 4788994689c1Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4789994689c1Smrg sort -k 3 4790994689c1Smrg else 4791994689c1Smrg sort +2 4792994689c1Smrg fi | 4793994689c1Smrg uniq > "$nlist"S; then 4794994689c1Smrg : 4795e1e1713cSmrg else 4796994689c1Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4797e1e1713cSmrg fi 47987a84e134Smrg 4799994689c1Smrg if test -f "$nlist"S; then 4800994689c1Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4801e1e1713cSmrg else 4802994689c1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4803e1e1713cSmrg fi 48047a84e134Smrg 48055ec34c4cSmrg func_show_eval '$RM "${nlist}I"' 48065ec34c4cSmrg if test -n "$global_symbol_to_import"; then 48075ec34c4cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 48085ec34c4cSmrg fi 48095ec34c4cSmrg 4810994689c1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48117a84e134Smrg 4812994689c1Smrg/* The mapping between symbol names and symbols. */ 4813994689c1Smrgtypedef struct { 4814994689c1Smrg const char *name; 4815994689c1Smrg void *address; 4816994689c1Smrg} lt_dlsymlist; 4817f353fbadSmrgextern LT_DLSYM_CONST lt_dlsymlist 48185ec34c4cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 48195ec34c4cSmrg" 48205ec34c4cSmrg 48215ec34c4cSmrg if test -s "$nlist"I; then 48225ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48235ec34c4cSmrgstatic void lt_syminit(void) 48245ec34c4cSmrg{ 48255ec34c4cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 48265ec34c4cSmrg for (; symbol->name; ++symbol) 48275ec34c4cSmrg {" 48285ec34c4cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 48295ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48305ec34c4cSmrg } 48315ec34c4cSmrg}" 48325ec34c4cSmrg fi 48335ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4834f353fbadSmrgLT_DLSYM_CONST lt_dlsymlist 4835994689c1Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 48365ec34c4cSmrg{ {\"$my_originator\", (void *) 0}," 48375ec34c4cSmrg 48385ec34c4cSmrg if test -s "$nlist"I; then 48395ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 48405ec34c4cSmrg {\"@INIT@\", (void *) <_syminit}," 48415ec34c4cSmrg fi 48427a84e134Smrg 4843994689c1Smrg case $need_lib_prefix in 4844994689c1Smrg no) 4845994689c1Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4846994689c1Smrg ;; 4847994689c1Smrg *) 4848994689c1Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4849994689c1Smrg ;; 4850994689c1Smrg esac 4851994689c1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4852994689c1Smrg {0, (void *) 0} 4853994689c1Smrg}; 48547a84e134Smrg 4855994689c1Smrg/* This works around a problem in FreeBSD linker */ 4856994689c1Smrg#ifdef FREEBSD_WORKAROUND 4857994689c1Smrgstatic const void *lt_preloaded_setup() { 4858994689c1Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4859994689c1Smrg} 4860994689c1Smrg#endif 48617a84e134Smrg 4862994689c1Smrg#ifdef __cplusplus 4863994689c1Smrg} 4864994689c1Smrg#endif\ 4865994689c1Smrg" 4866994689c1Smrg } # !$opt_dry_run 4867775e7de9Smrg 4868994689c1Smrg pic_flag_for_symtable= 4869994689c1Smrg case "$compile_command " in 4870994689c1Smrg *" -static "*) ;; 4871994689c1Smrg *) 4872994689c1Smrg case $host in 4873994689c1Smrg # compiling the symbol table file with pic_flag works around 4874994689c1Smrg # a FreeBSD bug that causes programs to crash when -lm is 4875994689c1Smrg # linked before any other PIC object. But we must not use 4876994689c1Smrg # pic_flag when linking with -static. The problem exists in 4877994689c1Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4878421c997bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4879994689c1Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4880994689c1Smrg *-*-hpux*) 4881994689c1Smrg pic_flag_for_symtable=" $pic_flag" ;; 4882994689c1Smrg *) 48835ec34c4cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4884994689c1Smrg ;; 4885994689c1Smrg esac 4886994689c1Smrg ;; 4887994689c1Smrg esac 4888994689c1Smrg symtab_cflags= 4889994689c1Smrg for arg in $LTCFLAGS; do 4890994689c1Smrg case $arg in 4891994689c1Smrg -pie | -fpie | -fPIE) ;; 4892f353fbadSmrg *) func_append symtab_cflags " $arg" ;; 4893994689c1Smrg esac 4894994689c1Smrg done 48957a84e134Smrg 4896994689c1Smrg # Now compile the dynamic symbol file. 4897994689c1Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 48987a84e134Smrg 4899994689c1Smrg # Clean up the generated files. 49005ec34c4cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4901775e7de9Smrg 4902994689c1Smrg # Transform the symbol file into the correct name. 49035ec34c4cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4904994689c1Smrg case $host in 4905994689c1Smrg *cygwin* | *mingw* | *cegcc* ) 4906994689c1Smrg if test -f "$output_objdir/$my_outputname.def"; then 4907994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4908994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4909994689c1Smrg else 4910994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4911994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4912994689c1Smrg fi 4913994689c1Smrg ;; 4914994689c1Smrg *) 4915994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4916994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4917994689c1Smrg ;; 4918994689c1Smrg esac 4919994689c1Smrg ;; 4920994689c1Smrg *) 49215ec34c4cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4922994689c1Smrg ;; 4923994689c1Smrg esac 4924994689c1Smrg else 4925994689c1Smrg # We keep going just in case the user didn't refer to 4926994689c1Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4927994689c1Smrg # really was required. 4928775e7de9Smrg 4929994689c1Smrg # Nullify the symbol file. 4930994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4931994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4932994689c1Smrg fi 4933994689c1Smrg} 4934775e7de9Smrg 49355ec34c4cSmrg# func_cygming_gnu_implib_p ARG 49365ec34c4cSmrg# This predicate returns with zero status (TRUE) if 49375ec34c4cSmrg# ARG is a GNU/binutils-style import library. Returns 49385ec34c4cSmrg# with nonzero status (FALSE) otherwise. 49395ec34c4cSmrgfunc_cygming_gnu_implib_p () 49405ec34c4cSmrg{ 49415ec34c4cSmrg $debug_cmd 49425ec34c4cSmrg 49435ec34c4cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49445ec34c4cSmrg 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)$'` 49455ec34c4cSmrg test -n "$func_cygming_gnu_implib_tmp" 49465ec34c4cSmrg} 49475ec34c4cSmrg 49485ec34c4cSmrg# func_cygming_ms_implib_p ARG 49495ec34c4cSmrg# This predicate returns with zero status (TRUE) if 49505ec34c4cSmrg# ARG is an MS-style import library. Returns 49515ec34c4cSmrg# with nonzero status (FALSE) otherwise. 49525ec34c4cSmrgfunc_cygming_ms_implib_p () 49535ec34c4cSmrg{ 49545ec34c4cSmrg $debug_cmd 49555ec34c4cSmrg 49565ec34c4cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49575ec34c4cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 49585ec34c4cSmrg test -n "$func_cygming_ms_implib_tmp" 49595ec34c4cSmrg} 49605ec34c4cSmrg 4961994689c1Smrg# func_win32_libid arg 4962994689c1Smrg# return the library type of file 'arg' 4963994689c1Smrg# 4964994689c1Smrg# Need a lot of goo to handle *both* DLLs and import libs 4965994689c1Smrg# Has to be a shell function in order to 'eat' the argument 4966994689c1Smrg# that is supplied when $file_magic_command is called. 4967994689c1Smrg# Despite the name, also deal with 64 bit binaries. 4968994689c1Smrgfunc_win32_libid () 4969994689c1Smrg{ 49705ec34c4cSmrg $debug_cmd 49715ec34c4cSmrg 49725ec34c4cSmrg win32_libid_type=unknown 4973994689c1Smrg win32_fileres=`file -L $1 2>/dev/null` 4974994689c1Smrg case $win32_fileres in 4975994689c1Smrg *ar\ archive\ import\ library*) # definitely import 4976994689c1Smrg win32_libid_type="x86 archive import" 4977994689c1Smrg ;; 4978994689c1Smrg *ar\ archive*) # could be an import, or static 4979994689c1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4980994689c1Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4981994689c1Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 49825ec34c4cSmrg case $nm_interface in 49835ec34c4cSmrg "MS dumpbin") 49845ec34c4cSmrg if func_cygming_ms_implib_p "$1" || 49855ec34c4cSmrg func_cygming_gnu_implib_p "$1" 49865ec34c4cSmrg then 49875ec34c4cSmrg win32_nmres=import 49885ec34c4cSmrg else 49895ec34c4cSmrg win32_nmres= 49905ec34c4cSmrg fi 49915ec34c4cSmrg ;; 49925ec34c4cSmrg *) 49935ec34c4cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 49945ec34c4cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 49955ec34c4cSmrg $SED -n -e ' 4996994689c1Smrg 1,100{ 4997994689c1Smrg / I /{ 49985ec34c4cSmrg s|.*|import| 4999994689c1Smrg p 5000994689c1Smrg q 5001994689c1Smrg } 5002994689c1Smrg }'` 50035ec34c4cSmrg ;; 50045ec34c4cSmrg esac 5005994689c1Smrg case $win32_nmres in 5006994689c1Smrg import*) win32_libid_type="x86 archive import";; 5007994689c1Smrg *) win32_libid_type="x86 archive static";; 5008994689c1Smrg esac 5009994689c1Smrg fi 5010994689c1Smrg ;; 5011994689c1Smrg *DLL*) 5012994689c1Smrg win32_libid_type="x86 DLL" 5013994689c1Smrg ;; 5014994689c1Smrg *executable*) # but shell scripts are "executable" too... 5015994689c1Smrg case $win32_fileres in 5016994689c1Smrg *MS\ Windows\ PE\ Intel*) 5017994689c1Smrg win32_libid_type="x86 DLL" 5018994689c1Smrg ;; 5019994689c1Smrg esac 5020994689c1Smrg ;; 5021994689c1Smrg esac 5022994689c1Smrg $ECHO "$win32_libid_type" 5023994689c1Smrg} 5024775e7de9Smrg 5025f353fbadSmrg# func_cygming_dll_for_implib ARG 5026f353fbadSmrg# 5027f353fbadSmrg# Platform-specific function to extract the 5028f353fbadSmrg# name of the DLL associated with the specified 5029f353fbadSmrg# import library ARG. 5030f353fbadSmrg# Invoked by eval'ing the libtool variable 5031f353fbadSmrg# $sharedlib_from_linklib_cmd 5032f353fbadSmrg# Result is available in the variable 5033f353fbadSmrg# $sharedlib_from_linklib_result 5034f353fbadSmrgfunc_cygming_dll_for_implib () 5035f353fbadSmrg{ 50365ec34c4cSmrg $debug_cmd 50375ec34c4cSmrg 5038f353fbadSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5039f353fbadSmrg} 5040f353fbadSmrg 5041f353fbadSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5042f353fbadSmrg# 5043f353fbadSmrg# The is the core of a fallback implementation of a 5044f353fbadSmrg# platform-specific function to extract the name of the 5045f353fbadSmrg# DLL associated with the specified import library LIBNAME. 5046f353fbadSmrg# 5047f353fbadSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5048f353fbadSmrg# on the platform and compiler that created the implib. 5049f353fbadSmrg# 5050f353fbadSmrg# Echos the name of the DLL associated with the 5051f353fbadSmrg# specified import library. 5052f353fbadSmrgfunc_cygming_dll_for_implib_fallback_core () 5053f353fbadSmrg{ 50545ec34c4cSmrg $debug_cmd 50555ec34c4cSmrg 5056f353fbadSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5057f353fbadSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5058f353fbadSmrg $SED '/^Contents of section '"$match_literal"':/{ 5059f353fbadSmrg # Place marker at beginning of archive member dllname section 5060f353fbadSmrg s/.*/====MARK====/ 5061f353fbadSmrg p 5062f353fbadSmrg d 5063f353fbadSmrg } 5064f353fbadSmrg # These lines can sometimes be longer than 43 characters, but 5065f353fbadSmrg # are always uninteresting 5066f353fbadSmrg /:[ ]*file format pe[i]\{,1\}-/d 5067f353fbadSmrg /^In archive [^:]*:/d 5068f353fbadSmrg # Ensure marker is printed 5069f353fbadSmrg /^====MARK====/p 5070f353fbadSmrg # Remove all lines with less than 43 characters 5071f353fbadSmrg /^.\{43\}/!d 5072f353fbadSmrg # From remaining lines, remove first 43 characters 5073f353fbadSmrg s/^.\{43\}//' | 5074f353fbadSmrg $SED -n ' 5075f353fbadSmrg # Join marker and all lines until next marker into a single line 5076f353fbadSmrg /^====MARK====/ b para 5077f353fbadSmrg H 5078f353fbadSmrg $ b para 5079f353fbadSmrg b 5080f353fbadSmrg :para 5081f353fbadSmrg x 5082f353fbadSmrg s/\n//g 5083f353fbadSmrg # Remove the marker 5084f353fbadSmrg s/^====MARK====// 5085f353fbadSmrg # Remove trailing dots and whitespace 5086f353fbadSmrg s/[\. \t]*$// 5087f353fbadSmrg # Print 5088f353fbadSmrg /./p' | 5089f353fbadSmrg # we now have a list, one entry per line, of the stringified 5090f353fbadSmrg # contents of the appropriate section of all members of the 50915ec34c4cSmrg # archive that possess that section. Heuristic: eliminate 50925ec34c4cSmrg # all those that have a first or second character that is 5093f353fbadSmrg # a '.' (that is, objdump's representation of an unprintable 5094f353fbadSmrg # character.) This should work for all archives with less than 5095f353fbadSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5096f353fbadSmrg # begins with a literal '.' or a single character followed by 5097f353fbadSmrg # a '.'. 5098f353fbadSmrg # 5099f353fbadSmrg # Of those that remain, print the first one. 5100f353fbadSmrg $SED -e '/^\./d;/^.\./d;q' 5101f353fbadSmrg} 5102f353fbadSmrg 5103f353fbadSmrg# func_cygming_dll_for_implib_fallback ARG 5104f353fbadSmrg# Platform-specific function to extract the 5105f353fbadSmrg# name of the DLL associated with the specified 5106f353fbadSmrg# import library ARG. 5107f353fbadSmrg# 5108f353fbadSmrg# This fallback implementation is for use when $DLLTOOL 5109f353fbadSmrg# does not support the --identify-strict option. 5110f353fbadSmrg# Invoked by eval'ing the libtool variable 5111f353fbadSmrg# $sharedlib_from_linklib_cmd 5112f353fbadSmrg# Result is available in the variable 5113f353fbadSmrg# $sharedlib_from_linklib_result 5114f353fbadSmrgfunc_cygming_dll_for_implib_fallback () 5115f353fbadSmrg{ 51165ec34c4cSmrg $debug_cmd 51175ec34c4cSmrg 51185ec34c4cSmrg if func_cygming_gnu_implib_p "$1"; then 5119f353fbadSmrg # binutils import library 5120f353fbadSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 51215ec34c4cSmrg elif func_cygming_ms_implib_p "$1"; then 5122f353fbadSmrg # ms-generated import library 5123f353fbadSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5124f353fbadSmrg else 5125f353fbadSmrg # unknown 51265ec34c4cSmrg sharedlib_from_linklib_result= 5127f353fbadSmrg fi 5128f353fbadSmrg} 51297a84e134Smrg 51307a84e134Smrg 5131994689c1Smrg# func_extract_an_archive dir oldlib 5132994689c1Smrgfunc_extract_an_archive () 5133994689c1Smrg{ 51345ec34c4cSmrg $debug_cmd 51355ec34c4cSmrg 51365ec34c4cSmrg f_ex_an_ar_dir=$1; shift 51375ec34c4cSmrg f_ex_an_ar_oldlib=$1 51385ec34c4cSmrg if test yes = "$lock_old_archive_extraction"; then 5139994689c1Smrg lockfile=$f_ex_an_ar_oldlib.lock 5140994689c1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5141994689c1Smrg func_echo "Waiting for $lockfile to be removed" 5142994689c1Smrg sleep 2 5143994689c1Smrg done 5144994689c1Smrg fi 5145994689c1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5146994689c1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 51475ec34c4cSmrg if test yes = "$lock_old_archive_extraction"; then 5148994689c1Smrg $opt_dry_run || rm -f "$lockfile" 5149994689c1Smrg fi 5150994689c1Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5151994689c1Smrg : 5152994689c1Smrg else 5153994689c1Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5154994689c1Smrg fi 5155994689c1Smrg} 51567a84e134Smrg 51577a84e134Smrg 5158994689c1Smrg# func_extract_archives gentop oldlib ... 5159994689c1Smrgfunc_extract_archives () 5160994689c1Smrg{ 51615ec34c4cSmrg $debug_cmd 51625ec34c4cSmrg 51635ec34c4cSmrg my_gentop=$1; shift 5164994689c1Smrg my_oldlibs=${1+"$@"} 51655ec34c4cSmrg my_oldobjs= 51665ec34c4cSmrg my_xlib= 51675ec34c4cSmrg my_xabs= 51685ec34c4cSmrg my_xdir= 51697a84e134Smrg 5170994689c1Smrg for my_xlib in $my_oldlibs; do 5171994689c1Smrg # Extract the objects. 5172994689c1Smrg case $my_xlib in 51735ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5174994689c1Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5175994689c1Smrg esac 5176994689c1Smrg func_basename "$my_xlib" 51775ec34c4cSmrg my_xlib=$func_basename_result 5178994689c1Smrg my_xlib_u=$my_xlib 5179994689c1Smrg while :; do 5180994689c1Smrg case " $extracted_archives " in 5181994689c1Smrg *" $my_xlib_u "*) 5182994689c1Smrg func_arith $extracted_serial + 1 5183994689c1Smrg extracted_serial=$func_arith_result 5184994689c1Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5185994689c1Smrg *) break ;; 5186994689c1Smrg esac 5187994689c1Smrg done 5188994689c1Smrg extracted_archives="$extracted_archives $my_xlib_u" 51895ec34c4cSmrg my_xdir=$my_gentop/$my_xlib_u 5190775e7de9Smrg 5191994689c1Smrg func_mkdir_p "$my_xdir" 5192994689c1Smrg 5193994689c1Smrg case $host in 5194994689c1Smrg *-darwin*) 5195994689c1Smrg func_verbose "Extracting $my_xabs" 5196994689c1Smrg # Do not bother doing anything if just a dry run 5197994689c1Smrg $opt_dry_run || { 5198994689c1Smrg darwin_orig_dir=`pwd` 5199994689c1Smrg cd $my_xdir || exit $? 5200994689c1Smrg darwin_archive=$my_xabs 5201994689c1Smrg darwin_curdir=`pwd` 52025ec34c4cSmrg func_basename "$darwin_archive" 52035ec34c4cSmrg darwin_base_archive=$func_basename_result 5204994689c1Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5205994689c1Smrg if test -n "$darwin_arches"; then 5206994689c1Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5207994689c1Smrg darwin_arch= 5208994689c1Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 52095ec34c4cSmrg for darwin_arch in $darwin_arches; do 52105ec34c4cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 52115ec34c4cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 52125ec34c4cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 52135ec34c4cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5214994689c1Smrg cd "$darwin_curdir" 52155ec34c4cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5216994689c1Smrg done # $darwin_arches 5217994689c1Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 52185ec34c4cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5219994689c1Smrg darwin_file= 5220994689c1Smrg darwin_files= 5221994689c1Smrg for darwin_file in $darwin_filelist; do 5222994689c1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5223994689c1Smrg $LIPO -create -output "$darwin_file" $darwin_files 5224994689c1Smrg done # $darwin_filelist 5225994689c1Smrg $RM -rf unfat-$$ 5226994689c1Smrg cd "$darwin_orig_dir" 5227e1e1713cSmrg else 5228994689c1Smrg cd $darwin_orig_dir 5229994689c1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5230994689c1Smrg fi # $darwin_arches 5231994689c1Smrg } # !$opt_dry_run 5232994689c1Smrg ;; 5233994689c1Smrg *) 5234994689c1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5235994689c1Smrg ;; 5236994689c1Smrg esac 5237994689c1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5238994689c1Smrg done 52397a84e134Smrg 52405ec34c4cSmrg func_extract_archives_result=$my_oldobjs 5241994689c1Smrg} 52427a84e134Smrg 52437a84e134Smrg 5244994689c1Smrg# func_emit_wrapper [arg=no] 5245994689c1Smrg# 5246994689c1Smrg# Emit a libtool wrapper script on stdout. 5247994689c1Smrg# Don't directly open a file because we may want to 5248994689c1Smrg# incorporate the script contents within a cygwin/mingw 5249994689c1Smrg# wrapper executable. Must ONLY be called from within 5250994689c1Smrg# func_mode_link because it depends on a number of variables 5251994689c1Smrg# set therein. 5252994689c1Smrg# 5253994689c1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5254994689c1Smrg# variable will take. If 'yes', then the emitted script 52555ec34c4cSmrg# will assume that the directory where it is stored is 5256994689c1Smrg# the $objdir directory. This is a cygwin/mingw-specific 5257994689c1Smrg# behavior. 5258994689c1Smrgfunc_emit_wrapper () 5259994689c1Smrg{ 5260994689c1Smrg func_emit_wrapper_arg1=${1-no} 5261e1e1713cSmrg 5262994689c1Smrg $ECHO "\ 5263994689c1Smrg#! $SHELL 52647a84e134Smrg 5265994689c1Smrg# $output - temporary wrapper script for $objdir/$outputname 52665ec34c4cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5267994689c1Smrg# 5268994689c1Smrg# The $output program cannot be directly executed until all the libtool 5269994689c1Smrg# libraries that it depends on are installed. 5270994689c1Smrg# 5271994689c1Smrg# This wrapper script should never be moved out of the build directory. 5272994689c1Smrg# If it is, it will not operate correctly. 52737a84e134Smrg 5274994689c1Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5275994689c1Smrg# metacharacters that are still active within double-quoted strings. 5276994689c1Smrgsed_quote_subst='$sed_quote_subst' 52777a84e134Smrg 5278994689c1Smrg# Be Bourne compatible 5279994689c1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5280994689c1Smrg emulate sh 5281994689c1Smrg NULLCMD=: 5282994689c1Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5283994689c1Smrg # is contrary to our usage. Disable this feature. 5284994689c1Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5285994689c1Smrg setopt NO_GLOB_SUBST 5286994689c1Smrgelse 5287994689c1Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5288994689c1Smrgfi 5289994689c1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5290994689c1SmrgDUALCASE=1; export DUALCASE # for MKS sh 52917a84e134Smrg 5292994689c1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5293994689c1Smrg# if CDPATH is set. 5294994689c1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 52957a84e134Smrg 5296994689c1Smrgrelink_command=\"$relink_command\" 52977a84e134Smrg 5298994689c1Smrg# This environment variable determines our operation mode. 5299994689c1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5300994689c1Smrg # install mode needs the following variables: 5301994689c1Smrg generated_by_libtool_version='$macro_version' 5302994689c1Smrg notinst_deplibs='$notinst_deplibs' 5303994689c1Smrgelse 5304994689c1Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5305994689c1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5306994689c1Smrg file=\"\$0\"" 53077a84e134Smrg 53085ec34c4cSmrg func_quote "$ECHO" 53095ec34c4cSmrg qECHO=$func_quote_result 5310994689c1Smrg $ECHO "\ 53117a84e134Smrg 5312994689c1Smrg# A function that is used when there is no print builtin or printf. 5313994689c1Smrgfunc_fallback_echo () 5314994689c1Smrg{ 5315994689c1Smrg eval 'cat <<_LTECHO_EOF 5316994689c1Smrg\$1 5317994689c1Smrg_LTECHO_EOF' 5318994689c1Smrg} 5319994689c1Smrg ECHO=\"$qECHO\" 5320994689c1Smrg fi 5321994689c1Smrg 5322994689c1Smrg# Very basic option parsing. These options are (a) specific to 5323994689c1Smrg# the libtool wrapper, (b) are identical between the wrapper 53245ec34c4cSmrg# /script/ and the wrapper /executable/ that is used only on 5325994689c1Smrg# windows platforms, and (c) all begin with the string "--lt-" 53265ec34c4cSmrg# (application programs are unlikely to have options that match 5327994689c1Smrg# this pattern). 5328994689c1Smrg# 5329994689c1Smrg# There are only two supported options: --lt-debug and 5330994689c1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5331994689c1Smrg# 5332994689c1Smrg# The first argument to this parsing function should be the 5333994689c1Smrg# script's $0 value, followed by "$@". 5334994689c1Smrglt_option_debug= 5335994689c1Smrgfunc_parse_lt_options () 5336994689c1Smrg{ 5337994689c1Smrg lt_script_arg0=\$0 5338994689c1Smrg shift 5339994689c1Smrg for lt_opt 5340994689c1Smrg do 5341994689c1Smrg case \"\$lt_opt\" in 5342994689c1Smrg --lt-debug) lt_option_debug=1 ;; 5343994689c1Smrg --lt-dump-script) 5344994689c1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5345994689c1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5346994689c1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5347994689c1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5348994689c1Smrg exit 0 5349994689c1Smrg ;; 5350994689c1Smrg --lt-*) 5351994689c1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5352994689c1Smrg exit 1 5353e1e1713cSmrg ;; 5354994689c1Smrg esac 5355994689c1Smrg done 53567a84e134Smrg 5357994689c1Smrg # Print the debug banner immediately: 5358994689c1Smrg if test -n \"\$lt_option_debug\"; then 53595ec34c4cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5360994689c1Smrg fi 5361994689c1Smrg} 53627a84e134Smrg 5363994689c1Smrg# Used when --lt-debug. Prints its arguments to stdout 5364994689c1Smrg# (redirection is the responsibility of the caller) 5365994689c1Smrgfunc_lt_dump_args () 5366994689c1Smrg{ 5367994689c1Smrg lt_dump_args_N=1; 5368994689c1Smrg for lt_arg 5369994689c1Smrg do 53705ec34c4cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5371994689c1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5372994689c1Smrg done 5373994689c1Smrg} 53747a84e134Smrg 5375994689c1Smrg# Core function for launching the target application 5376994689c1Smrgfunc_exec_program_core () 5377994689c1Smrg{ 5378994689c1Smrg" 5379994689c1Smrg case $host in 5380994689c1Smrg # Backslashes separate directories on plain windows 5381994689c1Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5382994689c1Smrg $ECHO "\ 5383994689c1Smrg if test -n \"\$lt_option_debug\"; then 53845ec34c4cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5385994689c1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5386e1e1713cSmrg fi 5387994689c1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5388994689c1Smrg" 5389994689c1Smrg ;; 53907a84e134Smrg 5391994689c1Smrg *) 5392994689c1Smrg $ECHO "\ 5393994689c1Smrg if test -n \"\$lt_option_debug\"; then 53945ec34c4cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5395994689c1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5396e1e1713cSmrg fi 5397994689c1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5398994689c1Smrg" 5399994689c1Smrg ;; 5400994689c1Smrg esac 5401994689c1Smrg $ECHO "\ 5402994689c1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5403994689c1Smrg exit 1 5404994689c1Smrg} 54057a84e134Smrg 5406994689c1Smrg# A function to encapsulate launching the target application 5407994689c1Smrg# Strips options in the --lt-* namespace from \$@ and 5408994689c1Smrg# launches target application with the remaining arguments. 5409994689c1Smrgfunc_exec_program () 5410994689c1Smrg{ 5411421c997bSmrg case \" \$* \" in 5412421c997bSmrg *\\ --lt-*) 5413421c997bSmrg for lt_wr_arg 5414421c997bSmrg do 5415421c997bSmrg case \$lt_wr_arg in 5416421c997bSmrg --lt-*) ;; 5417421c997bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5418421c997bSmrg esac 5419421c997bSmrg shift 5420421c997bSmrg done ;; 5421421c997bSmrg esac 5422994689c1Smrg func_exec_program_core \${1+\"\$@\"} 5423994689c1Smrg} 54247a84e134Smrg 5425994689c1Smrg # Parse options 5426994689c1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 54277a84e134Smrg 5428994689c1Smrg # Find the directory that this script lives in. 5429994689c1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5430994689c1Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 54317a84e134Smrg 5432994689c1Smrg # Follow symbolic links until we get to the real thisdir. 5433994689c1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5434994689c1Smrg while test -n \"\$file\"; do 5435994689c1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 54367a84e134Smrg 5437994689c1Smrg # If there was a directory component, then change thisdir. 5438994689c1Smrg if test \"x\$destdir\" != \"x\$file\"; then 5439994689c1Smrg case \"\$destdir\" in 5440994689c1Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5441994689c1Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5442994689c1Smrg esac 5443994689c1Smrg fi 54447a84e134Smrg 5445994689c1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5446994689c1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5447994689c1Smrg done 54487a84e134Smrg 5449994689c1Smrg # Usually 'no', except on cygwin/mingw when embedded into 5450994689c1Smrg # the cwrapper. 5451994689c1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5452994689c1Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5453994689c1Smrg # special case for '.' 5454994689c1Smrg if test \"\$thisdir\" = \".\"; then 5455994689c1Smrg thisdir=\`pwd\` 5456994689c1Smrg fi 5457994689c1Smrg # remove .libs from thisdir 5458994689c1Smrg case \"\$thisdir\" in 5459994689c1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5460994689c1Smrg $objdir ) thisdir=. ;; 5461994689c1Smrg esac 5462994689c1Smrg fi 54637a84e134Smrg 5464994689c1Smrg # Try to get the absolute directory name. 5465994689c1Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5466994689c1Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5467994689c1Smrg" 54687a84e134Smrg 54695ec34c4cSmrg if test yes = "$fast_install"; then 5470994689c1Smrg $ECHO "\ 5471994689c1Smrg program=lt-'$outputname'$exeext 5472994689c1Smrg progdir=\"\$thisdir/$objdir\" 54737a84e134Smrg 5474994689c1Smrg if test ! -f \"\$progdir/\$program\" || 54755ec34c4cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5476994689c1Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 54777a84e134Smrg 5478994689c1Smrg file=\"\$\$-\$program\" 54797a84e134Smrg 5480994689c1Smrg if test ! -d \"\$progdir\"; then 5481994689c1Smrg $MKDIR \"\$progdir\" 5482994689c1Smrg else 5483994689c1Smrg $RM \"\$progdir/\$file\" 5484994689c1Smrg fi" 54857a84e134Smrg 5486994689c1Smrg $ECHO "\ 54877a84e134Smrg 5488994689c1Smrg # relink executable if necessary 5489994689c1Smrg if test -n \"\$relink_command\"; then 5490994689c1Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5491994689c1Smrg else 54925ec34c4cSmrg \$ECHO \"\$relink_command_output\" >&2 5493994689c1Smrg $RM \"\$progdir/\$file\" 5494994689c1Smrg exit 1 5495994689c1Smrg fi 5496994689c1Smrg fi 54977a84e134Smrg 5498994689c1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5499994689c1Smrg { $RM \"\$progdir/\$program\"; 5500994689c1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5501994689c1Smrg $RM \"\$progdir/\$file\" 5502994689c1Smrg fi" 5503994689c1Smrg else 5504994689c1Smrg $ECHO "\ 5505994689c1Smrg program='$outputname' 5506994689c1Smrg progdir=\"\$thisdir/$objdir\" 5507994689c1Smrg" 5508994689c1Smrg fi 5509775e7de9Smrg 5510994689c1Smrg $ECHO "\ 55117a84e134Smrg 5512994689c1Smrg if test -f \"\$progdir/\$program\"; then" 55137a84e134Smrg 5514f353fbadSmrg # fixup the dll searchpath if we need to. 5515f353fbadSmrg # 5516f353fbadSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5517f353fbadSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5518f353fbadSmrg # libraries must come first. 5519f353fbadSmrg if test -n "$dllsearchpath"; then 5520f353fbadSmrg $ECHO "\ 5521f353fbadSmrg # Add the dll search path components to the executable PATH 5522f353fbadSmrg PATH=$dllsearchpath:\$PATH 5523f353fbadSmrg" 5524f353fbadSmrg fi 5525f353fbadSmrg 5526994689c1Smrg # Export our shlibpath_var if we have one. 55275ec34c4cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5528994689c1Smrg $ECHO "\ 5529994689c1Smrg # Add our own library path to $shlibpath_var 5530994689c1Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 55317a84e134Smrg 5532994689c1Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5533994689c1Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5534994689c1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 55357a84e134Smrg 5536994689c1Smrg export $shlibpath_var 5537994689c1Smrg" 5538994689c1Smrg fi 55397a84e134Smrg 5540994689c1Smrg $ECHO "\ 5541994689c1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5542994689c1Smrg # Run the actual program with our arguments. 5543994689c1Smrg func_exec_program \${1+\"\$@\"} 5544994689c1Smrg fi 5545994689c1Smrg else 5546994689c1Smrg # The program doesn't exist. 55475ec34c4cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5548994689c1Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5549994689c1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5550994689c1Smrg exit 1 5551994689c1Smrg fi 5552994689c1Smrgfi\ 5553994689c1Smrg" 5554994689c1Smrg} 55557a84e134Smrg 55567a84e134Smrg 5557994689c1Smrg# func_emit_cwrapperexe_src 5558994689c1Smrg# emit the source code for a wrapper executable on stdout 5559994689c1Smrg# Must ONLY be called from within func_mode_link because 5560994689c1Smrg# it depends on a number of variable set therein. 5561994689c1Smrgfunc_emit_cwrapperexe_src () 5562994689c1Smrg{ 5563994689c1Smrg cat <<EOF 55647a84e134Smrg 5565994689c1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 55665ec34c4cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 55677a84e134Smrg 5568994689c1Smrg The $output program cannot be directly executed until all the libtool 5569994689c1Smrg libraries that it depends on are installed. 55707a84e134Smrg 5571994689c1Smrg This wrapper executable should never be moved out of the build directory. 5572994689c1Smrg If it is, it will not operate correctly. 5573994689c1Smrg*/ 5574994689c1SmrgEOF 5575994689c1Smrg cat <<"EOF" 5576994689c1Smrg#ifdef _MSC_VER 5577994689c1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5578994689c1Smrg#endif 5579994689c1Smrg#include <stdio.h> 5580994689c1Smrg#include <stdlib.h> 5581994689c1Smrg#ifdef _MSC_VER 5582994689c1Smrg# include <direct.h> 5583994689c1Smrg# include <process.h> 5584994689c1Smrg# include <io.h> 5585994689c1Smrg#else 5586994689c1Smrg# include <unistd.h> 5587994689c1Smrg# include <stdint.h> 5588994689c1Smrg# ifdef __CYGWIN__ 5589994689c1Smrg# include <io.h> 5590994689c1Smrg# endif 5591994689c1Smrg#endif 5592994689c1Smrg#include <malloc.h> 5593994689c1Smrg#include <stdarg.h> 5594994689c1Smrg#include <assert.h> 5595994689c1Smrg#include <string.h> 5596994689c1Smrg#include <ctype.h> 5597994689c1Smrg#include <errno.h> 5598994689c1Smrg#include <fcntl.h> 5599994689c1Smrg#include <sys/stat.h> 56007a84e134Smrg 56015ec34c4cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 56025ec34c4cSmrg 5603994689c1Smrg/* declarations of non-ANSI functions */ 56045ec34c4cSmrg#if defined __MINGW32__ 5605994689c1Smrg# ifdef __STRICT_ANSI__ 5606994689c1Smrgint _putenv (const char *); 5607994689c1Smrg# endif 56085ec34c4cSmrg#elif defined __CYGWIN__ 5609994689c1Smrg# ifdef __STRICT_ANSI__ 5610994689c1Smrgchar *realpath (const char *, char *); 5611994689c1Smrgint putenv (char *); 5612994689c1Smrgint setenv (const char *, const char *, int); 5613994689c1Smrg# endif 56145ec34c4cSmrg/* #elif defined other_platform || defined ... */ 5615994689c1Smrg#endif 56167a84e134Smrg 5617994689c1Smrg/* portability defines, excluding path handling macros */ 56185ec34c4cSmrg#if defined _MSC_VER 5619994689c1Smrg# define setmode _setmode 5620994689c1Smrg# define stat _stat 5621994689c1Smrg# define chmod _chmod 5622994689c1Smrg# define getcwd _getcwd 5623994689c1Smrg# define putenv _putenv 5624994689c1Smrg# define S_IXUSR _S_IEXEC 56255ec34c4cSmrg#elif defined __MINGW32__ 5626994689c1Smrg# define setmode _setmode 5627994689c1Smrg# define stat _stat 5628994689c1Smrg# define chmod _chmod 5629994689c1Smrg# define getcwd _getcwd 5630994689c1Smrg# define putenv _putenv 56315ec34c4cSmrg#elif defined __CYGWIN__ 5632994689c1Smrg# define HAVE_SETENV 5633994689c1Smrg# define FOPEN_WB "wb" 56345ec34c4cSmrg/* #elif defined other platforms ... */ 5635994689c1Smrg#endif 56367a84e134Smrg 56375ec34c4cSmrg#if defined PATH_MAX 5638994689c1Smrg# define LT_PATHMAX PATH_MAX 56395ec34c4cSmrg#elif defined MAXPATHLEN 5640994689c1Smrg# define LT_PATHMAX MAXPATHLEN 5641994689c1Smrg#else 5642994689c1Smrg# define LT_PATHMAX 1024 5643994689c1Smrg#endif 56447a84e134Smrg 5645994689c1Smrg#ifndef S_IXOTH 5646994689c1Smrg# define S_IXOTH 0 5647994689c1Smrg#endif 5648994689c1Smrg#ifndef S_IXGRP 5649994689c1Smrg# define S_IXGRP 0 5650994689c1Smrg#endif 56517a84e134Smrg 5652994689c1Smrg/* path handling portability macros */ 5653994689c1Smrg#ifndef DIR_SEPARATOR 5654994689c1Smrg# define DIR_SEPARATOR '/' 5655994689c1Smrg# define PATH_SEPARATOR ':' 5656994689c1Smrg#endif 56577a84e134Smrg 56585ec34c4cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 56595ec34c4cSmrg defined __OS2__ 5660994689c1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5661994689c1Smrg# define FOPEN_WB "wb" 5662994689c1Smrg# ifndef DIR_SEPARATOR_2 5663994689c1Smrg# define DIR_SEPARATOR_2 '\\' 5664994689c1Smrg# endif 5665994689c1Smrg# ifndef PATH_SEPARATOR_2 5666994689c1Smrg# define PATH_SEPARATOR_2 ';' 5667994689c1Smrg# endif 5668994689c1Smrg#endif 56697a84e134Smrg 5670994689c1Smrg#ifndef DIR_SEPARATOR_2 5671994689c1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5672994689c1Smrg#else /* DIR_SEPARATOR_2 */ 5673994689c1Smrg# define IS_DIR_SEPARATOR(ch) \ 5674994689c1Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5675994689c1Smrg#endif /* DIR_SEPARATOR_2 */ 56767a84e134Smrg 5677994689c1Smrg#ifndef PATH_SEPARATOR_2 5678994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5679994689c1Smrg#else /* PATH_SEPARATOR_2 */ 5680994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5681994689c1Smrg#endif /* PATH_SEPARATOR_2 */ 5682994689c1Smrg 5683994689c1Smrg#ifndef FOPEN_WB 5684994689c1Smrg# define FOPEN_WB "w" 5685994689c1Smrg#endif 5686994689c1Smrg#ifndef _O_BINARY 5687994689c1Smrg# define _O_BINARY 0 5688994689c1Smrg#endif 5689994689c1Smrg 5690994689c1Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5691994689c1Smrg#define XFREE(stale) do { \ 56925ec34c4cSmrg if (stale) { free (stale); stale = 0; } \ 5693994689c1Smrg} while (0) 5694994689c1Smrg 56955ec34c4cSmrg#if defined LT_DEBUGWRAPPER 5696994689c1Smrgstatic int lt_debug = 1; 5697994689c1Smrg#else 5698994689c1Smrgstatic int lt_debug = 0; 5699994689c1Smrg#endif 5700994689c1Smrg 5701994689c1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5702994689c1Smrg 5703994689c1Smrgvoid *xmalloc (size_t num); 5704994689c1Smrgchar *xstrdup (const char *string); 5705994689c1Smrgconst char *base_name (const char *name); 5706994689c1Smrgchar *find_executable (const char *wrapper); 5707994689c1Smrgchar *chase_symlinks (const char *pathspec); 5708994689c1Smrgint make_executable (const char *path); 5709994689c1Smrgint check_executable (const char *path); 5710994689c1Smrgchar *strendzap (char *str, const char *pat); 5711994689c1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5712994689c1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5713994689c1Smrgstatic const char *nonnull (const char *s); 5714994689c1Smrgstatic const char *nonempty (const char *s); 5715994689c1Smrgvoid lt_setenv (const char *name, const char *value); 5716994689c1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5717994689c1Smrgvoid lt_update_exe_path (const char *name, const char *value); 5718994689c1Smrgvoid lt_update_lib_path (const char *name, const char *value); 5719994689c1Smrgchar **prepare_spawn (char **argv); 5720994689c1Smrgvoid lt_dump_script (FILE *f); 5721994689c1SmrgEOF 5722994689c1Smrg 5723994689c1Smrg cat <<EOF 57245ec34c4cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 57255ec34c4cSmrg# define externally_visible volatile 57265ec34c4cSmrg#else 57275ec34c4cSmrg# define externally_visible __attribute__((externally_visible)) volatile 57285ec34c4cSmrg#endif 57295ec34c4cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5730994689c1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5731994689c1SmrgEOF 5732994689c1Smrg 57335ec34c4cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5734f353fbadSmrg func_to_host_path "$temp_rpath" 5735994689c1Smrg cat <<EOF 5736f353fbadSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5737e1e1713cSmrgEOF 5738e1e1713cSmrg else 5739994689c1Smrg cat <<"EOF" 5740994689c1Smrgconst char * LIB_PATH_VALUE = ""; 5741994689c1SmrgEOF 5742e1e1713cSmrg fi 5743994689c1Smrg 5744994689c1Smrg if test -n "$dllsearchpath"; then 5745f353fbadSmrg func_to_host_path "$dllsearchpath:" 5746994689c1Smrg cat <<EOF 5747994689c1Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5748f353fbadSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5749994689c1SmrgEOF 5750e1e1713cSmrg else 5751994689c1Smrg cat <<"EOF" 5752994689c1Smrgconst char * EXE_PATH_VARNAME = ""; 5753994689c1Smrgconst char * EXE_PATH_VALUE = ""; 5754994689c1SmrgEOF 5755e1e1713cSmrg fi 5756994689c1Smrg 57575ec34c4cSmrg if test yes = "$fast_install"; then 5758994689c1Smrg cat <<EOF 5759994689c1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5760994689c1SmrgEOF 5761e1e1713cSmrg else 5762994689c1Smrg cat <<EOF 5763994689c1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5764994689c1SmrgEOF 5765e1e1713cSmrg fi 57667a84e134Smrg 57677a84e134Smrg 5768994689c1Smrg cat <<"EOF" 57697a84e134Smrg 5770994689c1Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 57717a84e134Smrg 5772994689c1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5773994689c1Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5774994689c1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 57757a84e134Smrg 5776994689c1Smrgint 5777994689c1Smrgmain (int argc, char *argv[]) 5778994689c1Smrg{ 5779994689c1Smrg char **newargz; 5780994689c1Smrg int newargc; 5781994689c1Smrg char *tmp_pathspec; 5782994689c1Smrg char *actual_cwrapper_path; 5783994689c1Smrg char *actual_cwrapper_name; 5784994689c1Smrg char *target_name; 5785994689c1Smrg char *lt_argv_zero; 57865ec34c4cSmrg int rval = 127; 57877a84e134Smrg 5788994689c1Smrg int i; 57897a84e134Smrg 5790994689c1Smrg program_name = (char *) xstrdup (base_name (argv[0])); 57915ec34c4cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 57927a84e134Smrg 5793994689c1Smrg /* very simple arg parsing; don't want to rely on getopt 5794994689c1Smrg * also, copy all non cwrapper options to newargz, except 5795994689c1Smrg * argz[0], which is handled differently 5796994689c1Smrg */ 5797994689c1Smrg newargc=0; 5798994689c1Smrg for (i = 1; i < argc; i++) 5799994689c1Smrg { 58005ec34c4cSmrg if (STREQ (argv[i], dumpscript_opt)) 5801994689c1Smrg { 5802994689c1SmrgEOF 58035ec34c4cSmrg case $host in 5804994689c1Smrg *mingw* | *cygwin* ) 5805994689c1Smrg # make stdout use "unix" line endings 5806994689c1Smrg echo " setmode(1,_O_BINARY);" 5807994689c1Smrg ;; 5808e1e1713cSmrg esac 58097a84e134Smrg 5810994689c1Smrg cat <<"EOF" 5811994689c1Smrg lt_dump_script (stdout); 5812994689c1Smrg return 0; 5813994689c1Smrg } 58145ec34c4cSmrg if (STREQ (argv[i], debug_opt)) 5815994689c1Smrg { 5816994689c1Smrg lt_debug = 1; 5817994689c1Smrg continue; 5818994689c1Smrg } 58195ec34c4cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5820994689c1Smrg { 5821994689c1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5822994689c1Smrg namespace, but it is not one of the ones we know about and 5823994689c1Smrg have already dealt with, above (inluding dump-script), then 5824994689c1Smrg report an error. Otherwise, targets might begin to believe 5825994689c1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5826994689c1Smrg namespace. The first time any user complains about this, we'll 5827994689c1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5828994689c1Smrg or a configure.ac-settable value. 5829994689c1Smrg */ 5830994689c1Smrg lt_fatal (__FILE__, __LINE__, 5831994689c1Smrg "unrecognized %s option: '%s'", 5832994689c1Smrg ltwrapper_option_prefix, argv[i]); 5833994689c1Smrg } 5834994689c1Smrg /* otherwise ... */ 5835994689c1Smrg newargz[++newargc] = xstrdup (argv[i]); 5836994689c1Smrg } 5837994689c1Smrg newargz[++newargc] = NULL; 58387a84e134Smrg 5839994689c1SmrgEOF 5840994689c1Smrg cat <<EOF 5841994689c1Smrg /* The GNU banner must be the first non-error debug message */ 58425ec34c4cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5843994689c1SmrgEOF 5844994689c1Smrg cat <<"EOF" 5845994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5846994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5847994689c1Smrg 5848994689c1Smrg tmp_pathspec = find_executable (argv[0]); 5849994689c1Smrg if (tmp_pathspec == NULL) 5850994689c1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5851994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 5852994689c1Smrg "(main) found exe (before symlink chase) at: %s\n", 5853994689c1Smrg tmp_pathspec); 5854994689c1Smrg 5855994689c1Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5856994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 5857994689c1Smrg "(main) found exe (after symlink chase) at: %s\n", 5858994689c1Smrg actual_cwrapper_path); 5859994689c1Smrg XFREE (tmp_pathspec); 5860994689c1Smrg 5861994689c1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5862994689c1Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5863994689c1Smrg 5864994689c1Smrg /* wrapper name transforms */ 5865994689c1Smrg strendzap (actual_cwrapper_name, ".exe"); 5866994689c1Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5867994689c1Smrg XFREE (actual_cwrapper_name); 5868994689c1Smrg actual_cwrapper_name = tmp_pathspec; 5869994689c1Smrg tmp_pathspec = 0; 5870994689c1Smrg 5871994689c1Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5872994689c1Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5873994689c1Smrg strendzap (target_name, ".exe"); 5874994689c1Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5875994689c1Smrg XFREE (target_name); 5876994689c1Smrg target_name = tmp_pathspec; 5877994689c1Smrg tmp_pathspec = 0; 5878994689c1Smrg 5879994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 5880994689c1Smrg "(main) libtool target name: %s\n", 5881994689c1Smrg target_name); 5882994689c1SmrgEOF 58837a84e134Smrg 5884994689c1Smrg cat <<EOF 5885994689c1Smrg newargz[0] = 5886994689c1Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5887994689c1Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5888994689c1Smrg strcpy (newargz[0], actual_cwrapper_path); 5889994689c1Smrg strcat (newargz[0], "$objdir"); 5890994689c1Smrg strcat (newargz[0], "/"); 5891994689c1SmrgEOF 58927a84e134Smrg 5893994689c1Smrg cat <<"EOF" 5894994689c1Smrg /* stop here, and copy so we don't have to do this twice */ 5895994689c1Smrg tmp_pathspec = xstrdup (newargz[0]); 58967a84e134Smrg 5897994689c1Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5898994689c1Smrg strcat (newargz[0], actual_cwrapper_name); 58997a84e134Smrg 5900994689c1Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5901994689c1Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5902994689c1Smrg XFREE (tmp_pathspec); 5903994689c1Smrg tmp_pathspec = NULL; 5904994689c1SmrgEOF 59057a84e134Smrg 5906994689c1Smrg case $host_os in 5907994689c1Smrg mingw*) 5908994689c1Smrg cat <<"EOF" 5909994689c1Smrg { 5910994689c1Smrg char* p; 5911994689c1Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5912994689c1Smrg { 5913994689c1Smrg *p = '/'; 5914994689c1Smrg } 5915994689c1Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5916994689c1Smrg { 5917994689c1Smrg *p = '/'; 5918994689c1Smrg } 5919994689c1Smrg } 5920994689c1SmrgEOF 5921994689c1Smrg ;; 5922994689c1Smrg esac 59237a84e134Smrg 5924994689c1Smrg cat <<"EOF" 5925994689c1Smrg XFREE (target_name); 5926994689c1Smrg XFREE (actual_cwrapper_path); 5927994689c1Smrg XFREE (actual_cwrapper_name); 59287a84e134Smrg 5929994689c1Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5930994689c1Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5931f353fbadSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5932f353fbadSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5933f353fbadSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5934f353fbadSmrg libraries must come first. */ 5935994689c1Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5936f353fbadSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 59377a84e134Smrg 5938994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5939994689c1Smrg nonnull (lt_argv_zero)); 5940994689c1Smrg for (i = 0; i < newargc; i++) 5941994689c1Smrg { 5942994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5943994689c1Smrg i, nonnull (newargz[i])); 5944994689c1Smrg } 59457a84e134Smrg 5946994689c1SmrgEOF 59477a84e134Smrg 5948994689c1Smrg case $host_os in 5949994689c1Smrg mingw*) 5950994689c1Smrg cat <<"EOF" 5951994689c1Smrg /* execv doesn't actually work on mingw as expected on unix */ 5952994689c1Smrg newargz = prepare_spawn (newargz); 59535ec34c4cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5954994689c1Smrg if (rval == -1) 5955994689c1Smrg { 5956994689c1Smrg /* failed to start process */ 5957994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 5958994689c1Smrg "(main) failed to launch target \"%s\": %s\n", 5959994689c1Smrg lt_argv_zero, nonnull (strerror (errno))); 5960994689c1Smrg return 127; 5961994689c1Smrg } 5962994689c1Smrg return rval; 5963994689c1SmrgEOF 5964994689c1Smrg ;; 5965994689c1Smrg *) 5966994689c1Smrg cat <<"EOF" 5967994689c1Smrg execv (lt_argv_zero, newargz); 5968994689c1Smrg return rval; /* =127, but avoids unused variable warning */ 5969994689c1SmrgEOF 5970994689c1Smrg ;; 5971994689c1Smrg esac 59727a84e134Smrg 5973994689c1Smrg cat <<"EOF" 5974994689c1Smrg} 59757a84e134Smrg 5976994689c1Smrgvoid * 5977994689c1Smrgxmalloc (size_t num) 5978994689c1Smrg{ 5979994689c1Smrg void *p = (void *) malloc (num); 5980994689c1Smrg if (!p) 5981994689c1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 59827a84e134Smrg 5983994689c1Smrg return p; 5984994689c1Smrg} 59857a84e134Smrg 5986994689c1Smrgchar * 5987994689c1Smrgxstrdup (const char *string) 5988994689c1Smrg{ 5989994689c1Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5990994689c1Smrg string) : NULL; 5991994689c1Smrg} 59927a84e134Smrg 5993994689c1Smrgconst char * 5994994689c1Smrgbase_name (const char *name) 5995994689c1Smrg{ 5996994689c1Smrg const char *base; 59977a84e134Smrg 59985ec34c4cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5999994689c1Smrg /* Skip over the disk name in MSDOS pathnames. */ 6000994689c1Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6001994689c1Smrg name += 2; 6002994689c1Smrg#endif 60037a84e134Smrg 6004994689c1Smrg for (base = name; *name; name++) 6005994689c1Smrg if (IS_DIR_SEPARATOR (*name)) 6006994689c1Smrg base = name + 1; 6007994689c1Smrg return base; 6008994689c1Smrg} 60097a84e134Smrg 6010994689c1Smrgint 6011994689c1Smrgcheck_executable (const char *path) 6012994689c1Smrg{ 6013994689c1Smrg struct stat st; 60147a84e134Smrg 6015994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6016994689c1Smrg nonempty (path)); 6017994689c1Smrg if ((!path) || (!*path)) 6018994689c1Smrg return 0; 60197a84e134Smrg 6020994689c1Smrg if ((stat (path, &st) >= 0) 6021994689c1Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6022994689c1Smrg return 1; 6023994689c1Smrg else 6024994689c1Smrg return 0; 6025994689c1Smrg} 60267a84e134Smrg 6027994689c1Smrgint 6028994689c1Smrgmake_executable (const char *path) 6029994689c1Smrg{ 6030994689c1Smrg int rval = 0; 6031994689c1Smrg struct stat st; 6032e1e1713cSmrg 6033994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6034994689c1Smrg nonempty (path)); 6035994689c1Smrg if ((!path) || (!*path)) 6036994689c1Smrg return 0; 6037e1e1713cSmrg 6038994689c1Smrg if (stat (path, &st) >= 0) 6039994689c1Smrg { 6040994689c1Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6041994689c1Smrg } 6042994689c1Smrg return rval; 6043994689c1Smrg} 6044e1e1713cSmrg 6045994689c1Smrg/* Searches for the full path of the wrapper. Returns 6046994689c1Smrg newly allocated full path name if found, NULL otherwise 6047994689c1Smrg Does not chase symlinks, even on platforms that support them. 6048994689c1Smrg*/ 6049994689c1Smrgchar * 6050994689c1Smrgfind_executable (const char *wrapper) 6051994689c1Smrg{ 6052994689c1Smrg int has_slash = 0; 6053994689c1Smrg const char *p; 6054994689c1Smrg const char *p_next; 6055994689c1Smrg /* static buffer for getcwd */ 6056994689c1Smrg char tmp[LT_PATHMAX + 1]; 60575ec34c4cSmrg size_t tmp_len; 6058994689c1Smrg char *concat_name; 6059e1e1713cSmrg 6060994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6061994689c1Smrg nonempty (wrapper)); 6062e1e1713cSmrg 6063994689c1Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6064994689c1Smrg return NULL; 60657a84e134Smrg 6066994689c1Smrg /* Absolute path? */ 60675ec34c4cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6068994689c1Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6069994689c1Smrg { 6070994689c1Smrg concat_name = xstrdup (wrapper); 6071994689c1Smrg if (check_executable (concat_name)) 6072994689c1Smrg return concat_name; 6073994689c1Smrg XFREE (concat_name); 6074994689c1Smrg } 6075994689c1Smrg else 6076994689c1Smrg { 6077994689c1Smrg#endif 6078994689c1Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6079994689c1Smrg { 6080994689c1Smrg concat_name = xstrdup (wrapper); 6081994689c1Smrg if (check_executable (concat_name)) 6082994689c1Smrg return concat_name; 6083994689c1Smrg XFREE (concat_name); 6084994689c1Smrg } 60855ec34c4cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6086994689c1Smrg } 6087994689c1Smrg#endif 60887a84e134Smrg 6089994689c1Smrg for (p = wrapper; *p; p++) 6090994689c1Smrg if (*p == '/') 6091994689c1Smrg { 6092994689c1Smrg has_slash = 1; 6093994689c1Smrg break; 6094994689c1Smrg } 6095994689c1Smrg if (!has_slash) 6096994689c1Smrg { 6097994689c1Smrg /* no slashes; search PATH */ 6098994689c1Smrg const char *path = getenv ("PATH"); 6099994689c1Smrg if (path != NULL) 6100994689c1Smrg { 6101994689c1Smrg for (p = path; *p; p = p_next) 6102994689c1Smrg { 6103994689c1Smrg const char *q; 6104994689c1Smrg size_t p_len; 6105994689c1Smrg for (q = p; *q; q++) 6106994689c1Smrg if (IS_PATH_SEPARATOR (*q)) 6107994689c1Smrg break; 61085ec34c4cSmrg p_len = (size_t) (q - p); 6109994689c1Smrg p_next = (*q == '\0' ? q : q + 1); 6110994689c1Smrg if (p_len == 0) 6111994689c1Smrg { 6112994689c1Smrg /* empty path: current directory */ 6113994689c1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6114994689c1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6115994689c1Smrg nonnull (strerror (errno))); 6116994689c1Smrg tmp_len = strlen (tmp); 6117994689c1Smrg concat_name = 6118994689c1Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6119994689c1Smrg memcpy (concat_name, tmp, tmp_len); 6120994689c1Smrg concat_name[tmp_len] = '/'; 6121994689c1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6122994689c1Smrg } 6123994689c1Smrg else 6124994689c1Smrg { 6125994689c1Smrg concat_name = 6126994689c1Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6127994689c1Smrg memcpy (concat_name, p, p_len); 6128994689c1Smrg concat_name[p_len] = '/'; 6129994689c1Smrg strcpy (concat_name + p_len + 1, wrapper); 6130994689c1Smrg } 6131994689c1Smrg if (check_executable (concat_name)) 6132994689c1Smrg return concat_name; 6133994689c1Smrg XFREE (concat_name); 6134994689c1Smrg } 6135994689c1Smrg } 6136994689c1Smrg /* not found in PATH; assume curdir */ 6137994689c1Smrg } 6138994689c1Smrg /* Relative path | not found in path: prepend cwd */ 6139994689c1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6140994689c1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6141994689c1Smrg nonnull (strerror (errno))); 6142994689c1Smrg tmp_len = strlen (tmp); 6143994689c1Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6144994689c1Smrg memcpy (concat_name, tmp, tmp_len); 6145994689c1Smrg concat_name[tmp_len] = '/'; 6146994689c1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 61477a84e134Smrg 6148994689c1Smrg if (check_executable (concat_name)) 6149994689c1Smrg return concat_name; 6150994689c1Smrg XFREE (concat_name); 6151994689c1Smrg return NULL; 6152994689c1Smrg} 6153e1e1713cSmrg 6154994689c1Smrgchar * 6155994689c1Smrgchase_symlinks (const char *pathspec) 6156994689c1Smrg{ 6157994689c1Smrg#ifndef S_ISLNK 6158994689c1Smrg return xstrdup (pathspec); 6159994689c1Smrg#else 6160994689c1Smrg char buf[LT_PATHMAX]; 6161994689c1Smrg struct stat s; 6162994689c1Smrg char *tmp_pathspec = xstrdup (pathspec); 6163994689c1Smrg char *p; 6164994689c1Smrg int has_symlinks = 0; 6165994689c1Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6166994689c1Smrg { 6167994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6168994689c1Smrg "checking path component for symlinks: %s\n", 6169994689c1Smrg tmp_pathspec); 6170994689c1Smrg if (lstat (tmp_pathspec, &s) == 0) 6171994689c1Smrg { 6172994689c1Smrg if (S_ISLNK (s.st_mode) != 0) 6173994689c1Smrg { 6174994689c1Smrg has_symlinks = 1; 6175994689c1Smrg break; 6176994689c1Smrg } 6177e1e1713cSmrg 6178994689c1Smrg /* search backwards for last DIR_SEPARATOR */ 6179994689c1Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6180994689c1Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6181994689c1Smrg p--; 6182994689c1Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6183994689c1Smrg { 6184994689c1Smrg /* no more DIR_SEPARATORS left */ 6185994689c1Smrg break; 6186994689c1Smrg } 6187994689c1Smrg *p = '\0'; 6188994689c1Smrg } 6189994689c1Smrg else 6190994689c1Smrg { 6191994689c1Smrg lt_fatal (__FILE__, __LINE__, 6192994689c1Smrg "error accessing file \"%s\": %s", 6193994689c1Smrg tmp_pathspec, nonnull (strerror (errno))); 6194994689c1Smrg } 6195994689c1Smrg } 6196994689c1Smrg XFREE (tmp_pathspec); 6197e1e1713cSmrg 6198994689c1Smrg if (!has_symlinks) 6199994689c1Smrg { 6200994689c1Smrg return xstrdup (pathspec); 6201994689c1Smrg } 6202e1e1713cSmrg 6203994689c1Smrg tmp_pathspec = realpath (pathspec, buf); 6204994689c1Smrg if (tmp_pathspec == 0) 6205994689c1Smrg { 6206994689c1Smrg lt_fatal (__FILE__, __LINE__, 6207994689c1Smrg "could not follow symlinks for %s", pathspec); 6208994689c1Smrg } 6209994689c1Smrg return xstrdup (tmp_pathspec); 6210994689c1Smrg#endif 6211994689c1Smrg} 62127a84e134Smrg 6213994689c1Smrgchar * 6214994689c1Smrgstrendzap (char *str, const char *pat) 6215994689c1Smrg{ 6216994689c1Smrg size_t len, patlen; 62177a84e134Smrg 6218994689c1Smrg assert (str != NULL); 6219994689c1Smrg assert (pat != NULL); 62207a84e134Smrg 6221994689c1Smrg len = strlen (str); 6222994689c1Smrg patlen = strlen (pat); 62237a84e134Smrg 6224994689c1Smrg if (patlen <= len) 6225994689c1Smrg { 6226994689c1Smrg str += len - patlen; 62275ec34c4cSmrg if (STREQ (str, pat)) 6228994689c1Smrg *str = '\0'; 6229994689c1Smrg } 6230994689c1Smrg return str; 6231994689c1Smrg} 62327a84e134Smrg 6233994689c1Smrgvoid 6234994689c1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6235994689c1Smrg{ 6236994689c1Smrg va_list args; 6237994689c1Smrg if (lt_debug) 6238994689c1Smrg { 6239994689c1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6240994689c1Smrg va_start (args, fmt); 6241994689c1Smrg (void) vfprintf (stderr, fmt, args); 6242994689c1Smrg va_end (args); 6243994689c1Smrg } 6244994689c1Smrg} 62457a84e134Smrg 6246994689c1Smrgstatic void 6247994689c1Smrglt_error_core (int exit_status, const char *file, 6248994689c1Smrg int line, const char *mode, 6249994689c1Smrg const char *message, va_list ap) 6250994689c1Smrg{ 6251994689c1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6252994689c1Smrg vfprintf (stderr, message, ap); 6253994689c1Smrg fprintf (stderr, ".\n"); 62547a84e134Smrg 6255994689c1Smrg if (exit_status >= 0) 6256994689c1Smrg exit (exit_status); 6257994689c1Smrg} 62587a84e134Smrg 6259994689c1Smrgvoid 6260994689c1Smrglt_fatal (const char *file, int line, const char *message, ...) 6261994689c1Smrg{ 6262994689c1Smrg va_list ap; 6263994689c1Smrg va_start (ap, message); 6264994689c1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6265994689c1Smrg va_end (ap); 6266994689c1Smrg} 62677a84e134Smrg 6268994689c1Smrgstatic const char * 6269994689c1Smrgnonnull (const char *s) 6270994689c1Smrg{ 6271994689c1Smrg return s ? s : "(null)"; 6272994689c1Smrg} 62737a84e134Smrg 6274994689c1Smrgstatic const char * 6275994689c1Smrgnonempty (const char *s) 6276994689c1Smrg{ 6277994689c1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6278994689c1Smrg} 6279775e7de9Smrg 6280994689c1Smrgvoid 6281994689c1Smrglt_setenv (const char *name, const char *value) 6282994689c1Smrg{ 6283994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6284994689c1Smrg "(lt_setenv) setting '%s' to '%s'\n", 6285994689c1Smrg nonnull (name), nonnull (value)); 6286994689c1Smrg { 6287994689c1Smrg#ifdef HAVE_SETENV 6288994689c1Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6289994689c1Smrg char *str = xstrdup (value); 6290994689c1Smrg setenv (name, str, 1); 6291994689c1Smrg#else 62925ec34c4cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6293994689c1Smrg char *str = XMALLOC (char, len); 6294994689c1Smrg sprintf (str, "%s=%s", name, value); 6295994689c1Smrg if (putenv (str) != EXIT_SUCCESS) 6296994689c1Smrg { 6297994689c1Smrg XFREE (str); 6298994689c1Smrg } 6299994689c1Smrg#endif 6300994689c1Smrg } 6301994689c1Smrg} 63027a84e134Smrg 6303994689c1Smrgchar * 6304994689c1Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6305994689c1Smrg{ 6306994689c1Smrg char *new_value; 6307994689c1Smrg if (orig_value && *orig_value) 6308994689c1Smrg { 63095ec34c4cSmrg size_t orig_value_len = strlen (orig_value); 63105ec34c4cSmrg size_t add_len = strlen (add); 6311994689c1Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6312994689c1Smrg if (to_end) 6313994689c1Smrg { 6314994689c1Smrg strcpy (new_value, orig_value); 6315994689c1Smrg strcpy (new_value + orig_value_len, add); 6316994689c1Smrg } 6317994689c1Smrg else 6318994689c1Smrg { 6319994689c1Smrg strcpy (new_value, add); 6320994689c1Smrg strcpy (new_value + add_len, orig_value); 6321994689c1Smrg } 6322994689c1Smrg } 6323994689c1Smrg else 6324994689c1Smrg { 6325994689c1Smrg new_value = xstrdup (add); 6326994689c1Smrg } 6327994689c1Smrg return new_value; 6328994689c1Smrg} 63297a84e134Smrg 6330994689c1Smrgvoid 6331994689c1Smrglt_update_exe_path (const char *name, const char *value) 6332994689c1Smrg{ 6333994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6334994689c1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6335994689c1Smrg nonnull (name), nonnull (value)); 63367a84e134Smrg 6337994689c1Smrg if (name && *name && value && *value) 6338994689c1Smrg { 6339994689c1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6340994689c1Smrg /* some systems can't cope with a ':'-terminated path #' */ 63415ec34c4cSmrg size_t len = strlen (new_value); 63425ec34c4cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6343994689c1Smrg { 63445ec34c4cSmrg new_value[--len] = '\0'; 6345994689c1Smrg } 6346994689c1Smrg lt_setenv (name, new_value); 6347994689c1Smrg XFREE (new_value); 6348994689c1Smrg } 6349994689c1Smrg} 63507a84e134Smrg 6351994689c1Smrgvoid 6352994689c1Smrglt_update_lib_path (const char *name, const char *value) 6353994689c1Smrg{ 6354994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6355994689c1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6356994689c1Smrg nonnull (name), nonnull (value)); 63577a84e134Smrg 6358994689c1Smrg if (name && *name && value && *value) 6359994689c1Smrg { 6360994689c1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6361994689c1Smrg lt_setenv (name, new_value); 6362994689c1Smrg XFREE (new_value); 6363994689c1Smrg } 6364994689c1Smrg} 63657a84e134Smrg 6366994689c1SmrgEOF 6367994689c1Smrg case $host_os in 6368994689c1Smrg mingw*) 6369994689c1Smrg cat <<"EOF" 6370994689c1Smrg 6371994689c1Smrg/* Prepares an argument vector before calling spawn(). 6372994689c1Smrg Note that spawn() does not by itself call the command interpreter 6373994689c1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6374994689c1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6375994689c1Smrg GetVersionEx(&v); 6376994689c1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6377994689c1Smrg }) ? "cmd.exe" : "command.com"). 6378994689c1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6379994689c1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6380994689c1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6381994689c1Smrg special way: 6382994689c1Smrg - Space and tab are interpreted as delimiters. They are not treated as 6383994689c1Smrg delimiters if they are surrounded by double quotes: "...". 6384994689c1Smrg - Unescaped double quotes are removed from the input. Their only effect is 6385994689c1Smrg that within double quotes, space and tab are treated like normal 6386994689c1Smrg characters. 6387994689c1Smrg - Backslashes not followed by double quotes are not special. 6388994689c1Smrg - But 2*n+1 backslashes followed by a double quote become 6389994689c1Smrg n backslashes followed by a double quote (n >= 0): 6390994689c1Smrg \" -> " 6391994689c1Smrg \\\" -> \" 6392994689c1Smrg \\\\\" -> \\" 6393994689c1Smrg */ 6394994689c1Smrg#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" 6395994689c1Smrg#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" 6396994689c1Smrgchar ** 6397994689c1Smrgprepare_spawn (char **argv) 6398994689c1Smrg{ 6399994689c1Smrg size_t argc; 6400994689c1Smrg char **new_argv; 6401994689c1Smrg size_t i; 64027a84e134Smrg 6403994689c1Smrg /* Count number of arguments. */ 6404994689c1Smrg for (argc = 0; argv[argc] != NULL; argc++) 6405994689c1Smrg ; 64067a84e134Smrg 6407994689c1Smrg /* Allocate new argument vector. */ 6408994689c1Smrg new_argv = XMALLOC (char *, argc + 1); 64097a84e134Smrg 6410994689c1Smrg /* Put quoted arguments into the new argument vector. */ 6411994689c1Smrg for (i = 0; i < argc; i++) 6412994689c1Smrg { 6413994689c1Smrg const char *string = argv[i]; 6414994689c1Smrg 6415994689c1Smrg if (string[0] == '\0') 6416994689c1Smrg new_argv[i] = xstrdup ("\"\""); 6417994689c1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6418994689c1Smrg { 6419994689c1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6420994689c1Smrg size_t length; 6421994689c1Smrg unsigned int backslashes; 6422994689c1Smrg const char *s; 6423994689c1Smrg char *quoted_string; 6424994689c1Smrg char *p; 6425994689c1Smrg 6426994689c1Smrg length = 0; 6427994689c1Smrg backslashes = 0; 6428994689c1Smrg if (quote_around) 6429994689c1Smrg length++; 6430994689c1Smrg for (s = string; *s != '\0'; s++) 6431994689c1Smrg { 6432994689c1Smrg char c = *s; 6433994689c1Smrg if (c == '"') 6434994689c1Smrg length += backslashes + 1; 6435994689c1Smrg length++; 6436994689c1Smrg if (c == '\\') 6437994689c1Smrg backslashes++; 6438994689c1Smrg else 6439994689c1Smrg backslashes = 0; 6440994689c1Smrg } 6441994689c1Smrg if (quote_around) 6442994689c1Smrg length += backslashes + 1; 6443994689c1Smrg 6444994689c1Smrg quoted_string = XMALLOC (char, length + 1); 6445994689c1Smrg 6446994689c1Smrg p = quoted_string; 6447994689c1Smrg backslashes = 0; 6448994689c1Smrg if (quote_around) 6449994689c1Smrg *p++ = '"'; 6450994689c1Smrg for (s = string; *s != '\0'; s++) 6451994689c1Smrg { 6452994689c1Smrg char c = *s; 6453994689c1Smrg if (c == '"') 6454994689c1Smrg { 6455994689c1Smrg unsigned int j; 6456994689c1Smrg for (j = backslashes + 1; j > 0; j--) 6457994689c1Smrg *p++ = '\\'; 6458994689c1Smrg } 6459994689c1Smrg *p++ = c; 6460994689c1Smrg if (c == '\\') 6461994689c1Smrg backslashes++; 6462994689c1Smrg else 6463994689c1Smrg backslashes = 0; 6464994689c1Smrg } 6465994689c1Smrg if (quote_around) 6466994689c1Smrg { 6467994689c1Smrg unsigned int j; 6468994689c1Smrg for (j = backslashes; j > 0; j--) 6469994689c1Smrg *p++ = '\\'; 6470994689c1Smrg *p++ = '"'; 6471994689c1Smrg } 6472994689c1Smrg *p = '\0'; 64737a84e134Smrg 6474994689c1Smrg new_argv[i] = quoted_string; 6475994689c1Smrg } 6476994689c1Smrg else 6477994689c1Smrg new_argv[i] = (char *) string; 6478994689c1Smrg } 6479994689c1Smrg new_argv[argc] = NULL; 64807a84e134Smrg 6481994689c1Smrg return new_argv; 6482994689c1Smrg} 6483994689c1SmrgEOF 6484e1e1713cSmrg ;; 6485994689c1Smrg esac 64867a84e134Smrg 6487994689c1Smrg cat <<"EOF" 6488994689c1Smrgvoid lt_dump_script (FILE* f) 6489994689c1Smrg{ 6490994689c1SmrgEOF 6491994689c1Smrg func_emit_wrapper yes | 6492421c997bSmrg $SED -n -e ' 6493421c997bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6494421c997bSmrg\2/ 6495421c997bSmrgh 6496421c997bSmrgs/\([\\"]\)/\\\1/g 6497421c997bSmrgs/$/\\n/ 6498421c997bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6499421c997bSmrgg 6500421c997bSmrgD' 6501994689c1Smrg cat <<"EOF" 6502994689c1Smrg} 6503994689c1SmrgEOF 6504994689c1Smrg} 6505994689c1Smrg# end: func_emit_cwrapperexe_src 65067a84e134Smrg 6507994689c1Smrg# func_win32_import_lib_p ARG 6508994689c1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6509994689c1Smrgfunc_win32_import_lib_p () 6510994689c1Smrg{ 65115ec34c4cSmrg $debug_cmd 65125ec34c4cSmrg 6513994689c1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6514994689c1Smrg *import*) : ;; 6515994689c1Smrg *) false ;; 6516994689c1Smrg esac 6517994689c1Smrg} 65187a84e134Smrg 65195ec34c4cSmrg# func_suncc_cstd_abi 65205ec34c4cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 65215ec34c4cSmrg# Several compiler flags select an ABI that is incompatible with the 65225ec34c4cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 65235ec34c4cSmrgfunc_suncc_cstd_abi () 65245ec34c4cSmrg{ 65255ec34c4cSmrg $debug_cmd 65265ec34c4cSmrg 65275ec34c4cSmrg case " $compile_command " in 65285ec34c4cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 65295ec34c4cSmrg suncc_use_cstd_abi=no 65305ec34c4cSmrg ;; 65315ec34c4cSmrg *) 65325ec34c4cSmrg suncc_use_cstd_abi=yes 65335ec34c4cSmrg ;; 65345ec34c4cSmrg esac 65355ec34c4cSmrg} 65365ec34c4cSmrg 6537994689c1Smrg# func_mode_link arg... 6538994689c1Smrgfunc_mode_link () 6539994689c1Smrg{ 65405ec34c4cSmrg $debug_cmd 65415ec34c4cSmrg 6542994689c1Smrg case $host in 6543994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6544994689c1Smrg # It is impossible to link a dll without this setting, and 6545994689c1Smrg # we shouldn't force the makefile maintainer to figure out 65465ec34c4cSmrg # what system we are compiling for in order to pass an extra 6547994689c1Smrg # flag for every libtool invocation. 6548994689c1Smrg # allow_undefined=no 65497a84e134Smrg 6550994689c1Smrg # FIXME: Unfortunately, there are problems with the above when trying 65515ec34c4cSmrg # to make a dll that has undefined symbols, in which case not 6552994689c1Smrg # even a static library is built. For now, we need to specify 6553994689c1Smrg # -no-undefined on the libtool link line when we can be certain 6554994689c1Smrg # that all symbols are satisfied, otherwise we get a static library. 6555994689c1Smrg allow_undefined=yes 6556994689c1Smrg ;; 6557994689c1Smrg *) 6558994689c1Smrg allow_undefined=yes 6559994689c1Smrg ;; 6560994689c1Smrg esac 6561994689c1Smrg libtool_args=$nonopt 6562994689c1Smrg base_compile="$nonopt $@" 6563994689c1Smrg compile_command=$nonopt 6564994689c1Smrg finalize_command=$nonopt 65657a84e134Smrg 6566994689c1Smrg compile_rpath= 6567994689c1Smrg finalize_rpath= 6568994689c1Smrg compile_shlibpath= 6569994689c1Smrg finalize_shlibpath= 6570994689c1Smrg convenience= 6571994689c1Smrg old_convenience= 6572994689c1Smrg deplibs= 6573994689c1Smrg old_deplibs= 6574994689c1Smrg compiler_flags= 6575994689c1Smrg linker_flags= 6576994689c1Smrg dllsearchpath= 6577994689c1Smrg lib_search_path=`pwd` 6578994689c1Smrg inst_prefix_dir= 6579994689c1Smrg new_inherited_linker_flags= 65807a84e134Smrg 6581994689c1Smrg avoid_version=no 6582994689c1Smrg bindir= 6583994689c1Smrg dlfiles= 6584994689c1Smrg dlprefiles= 6585994689c1Smrg dlself=no 6586994689c1Smrg export_dynamic=no 6587994689c1Smrg export_symbols= 6588994689c1Smrg export_symbols_regex= 6589994689c1Smrg generated= 6590994689c1Smrg libobjs= 6591994689c1Smrg ltlibs= 6592994689c1Smrg module=no 6593994689c1Smrg no_install=no 6594994689c1Smrg objs= 65955ec34c4cSmrg os2dllname= 6596994689c1Smrg non_pic_objects= 6597994689c1Smrg precious_files_regex= 6598994689c1Smrg prefer_static_libs=no 65995ec34c4cSmrg preload=false 6600994689c1Smrg prev= 6601994689c1Smrg prevarg= 6602994689c1Smrg release= 6603994689c1Smrg rpath= 6604994689c1Smrg xrpath= 6605994689c1Smrg perm_rpath= 6606994689c1Smrg temp_rpath= 6607994689c1Smrg thread_safe=no 6608994689c1Smrg vinfo= 6609994689c1Smrg vinfo_number=no 6610994689c1Smrg weak_libs= 66115ec34c4cSmrg single_module=$wl-single_module 6612994689c1Smrg func_infer_tag $base_compile 66137a84e134Smrg 6614994689c1Smrg # We need to know -static, to get the right output filenames. 6615994689c1Smrg for arg 6616994689c1Smrg do 6617994689c1Smrg case $arg in 6618994689c1Smrg -shared) 66195ec34c4cSmrg test yes != "$build_libtool_libs" \ 66205ec34c4cSmrg && func_fatal_configuration "cannot build a shared library" 6621994689c1Smrg build_old_libs=no 6622994689c1Smrg break 6623994689c1Smrg ;; 6624994689c1Smrg -all-static | -static | -static-libtool-libs) 6625994689c1Smrg case $arg in 6626994689c1Smrg -all-static) 66275ec34c4cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6628994689c1Smrg func_warning "complete static linking is impossible in this configuration" 6629994689c1Smrg fi 6630994689c1Smrg if test -n "$link_static_flag"; then 6631994689c1Smrg dlopen_self=$dlopen_self_static 6632994689c1Smrg fi 6633994689c1Smrg prefer_static_libs=yes 6634994689c1Smrg ;; 6635994689c1Smrg -static) 6636994689c1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6637994689c1Smrg dlopen_self=$dlopen_self_static 6638994689c1Smrg fi 6639994689c1Smrg prefer_static_libs=built 6640994689c1Smrg ;; 6641994689c1Smrg -static-libtool-libs) 6642994689c1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6643994689c1Smrg dlopen_self=$dlopen_self_static 6644994689c1Smrg fi 6645994689c1Smrg prefer_static_libs=yes 6646994689c1Smrg ;; 6647994689c1Smrg esac 6648994689c1Smrg build_libtool_libs=no 6649994689c1Smrg build_old_libs=yes 6650994689c1Smrg break 6651994689c1Smrg ;; 6652994689c1Smrg esac 6653994689c1Smrg done 66547a84e134Smrg 6655994689c1Smrg # See if our shared archives depend on static archives. 6656994689c1Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 66577a84e134Smrg 6658994689c1Smrg # Go through the arguments, transforming them on the way. 6659994689c1Smrg while test "$#" -gt 0; do 66605ec34c4cSmrg arg=$1 6661994689c1Smrg shift 6662994689c1Smrg func_quote_for_eval "$arg" 6663994689c1Smrg qarg=$func_quote_for_eval_unquoted_result 6664994689c1Smrg func_append libtool_args " $func_quote_for_eval_result" 66657a84e134Smrg 6666994689c1Smrg # If the previous option needs an argument, assign it. 6667994689c1Smrg if test -n "$prev"; then 6668994689c1Smrg case $prev in 6669994689c1Smrg output) 6670994689c1Smrg func_append compile_command " @OUTPUT@" 6671994689c1Smrg func_append finalize_command " @OUTPUT@" 6672994689c1Smrg ;; 6673994689c1Smrg esac 66747a84e134Smrg 6675994689c1Smrg case $prev in 6676994689c1Smrg bindir) 66775ec34c4cSmrg bindir=$arg 6678994689c1Smrg prev= 6679994689c1Smrg continue 6680994689c1Smrg ;; 6681994689c1Smrg dlfiles|dlprefiles) 66825ec34c4cSmrg $preload || { 6683994689c1Smrg # Add the symbol object into the linking commands. 6684994689c1Smrg func_append compile_command " @SYMFILE@" 6685994689c1Smrg func_append finalize_command " @SYMFILE@" 66865ec34c4cSmrg preload=: 66875ec34c4cSmrg } 6688994689c1Smrg case $arg in 6689994689c1Smrg *.la | *.lo) ;; # We handle these cases below. 6690994689c1Smrg force) 66915ec34c4cSmrg if test no = "$dlself"; then 6692994689c1Smrg dlself=needless 6693994689c1Smrg export_dynamic=yes 6694e1e1713cSmrg fi 6695994689c1Smrg prev= 6696994689c1Smrg continue 6697994689c1Smrg ;; 6698994689c1Smrg self) 66995ec34c4cSmrg if test dlprefiles = "$prev"; then 6700994689c1Smrg dlself=yes 67015ec34c4cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6702994689c1Smrg dlself=yes 6703e1e1713cSmrg else 6704994689c1Smrg dlself=needless 6705994689c1Smrg export_dynamic=yes 6706e1e1713cSmrg fi 6707994689c1Smrg prev= 6708994689c1Smrg continue 6709994689c1Smrg ;; 6710994689c1Smrg *) 67115ec34c4cSmrg if test dlfiles = "$prev"; then 6712f353fbadSmrg func_append dlfiles " $arg" 6713e1e1713cSmrg else 6714f353fbadSmrg func_append dlprefiles " $arg" 6715e1e1713cSmrg fi 6716994689c1Smrg prev= 6717994689c1Smrg continue 6718994689c1Smrg ;; 6719994689c1Smrg esac 6720994689c1Smrg ;; 6721994689c1Smrg expsyms) 67225ec34c4cSmrg export_symbols=$arg 6723994689c1Smrg test -f "$arg" \ 67245ec34c4cSmrg || func_fatal_error "symbol file '$arg' does not exist" 6725994689c1Smrg prev= 6726994689c1Smrg continue 6727994689c1Smrg ;; 6728994689c1Smrg expsyms_regex) 67295ec34c4cSmrg export_symbols_regex=$arg 6730994689c1Smrg prev= 6731994689c1Smrg continue 6732994689c1Smrg ;; 6733994689c1Smrg framework) 6734e1e1713cSmrg case $host in 6735994689c1Smrg *-*-darwin*) 6736994689c1Smrg case "$deplibs " in 6737994689c1Smrg *" $qarg.ltframework "*) ;; 6738f353fbadSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6739994689c1Smrg ;; 6740994689c1Smrg esac 6741994689c1Smrg ;; 6742e1e1713cSmrg esac 6743994689c1Smrg prev= 6744994689c1Smrg continue 6745e1e1713cSmrg ;; 6746994689c1Smrg inst_prefix) 67475ec34c4cSmrg inst_prefix_dir=$arg 67485ec34c4cSmrg prev= 67495ec34c4cSmrg continue 67505ec34c4cSmrg ;; 67515ec34c4cSmrg mllvm) 67525ec34c4cSmrg # Clang does not use LLVM to link, so we can simply discard any 67535ec34c4cSmrg # '-mllvm $arg' options when doing the link step. 6754994689c1Smrg prev= 6755994689c1Smrg continue 6756e1e1713cSmrg ;; 6757994689c1Smrg objectlist) 6758994689c1Smrg if test -f "$arg"; then 6759994689c1Smrg save_arg=$arg 6760994689c1Smrg moreargs= 6761994689c1Smrg for fil in `cat "$save_arg"` 6762994689c1Smrg do 6763f353fbadSmrg# func_append moreargs " $fil" 6764994689c1Smrg arg=$fil 6765994689c1Smrg # A libtool-controlled object. 67667a84e134Smrg 6767994689c1Smrg # Check to see that this really is a libtool object. 6768994689c1Smrg if func_lalib_unsafe_p "$arg"; then 6769994689c1Smrg pic_object= 6770994689c1Smrg non_pic_object= 6771775e7de9Smrg 6772994689c1Smrg # Read the .lo file 6773994689c1Smrg func_source "$arg" 6774775e7de9Smrg 6775994689c1Smrg if test -z "$pic_object" || 6776994689c1Smrg test -z "$non_pic_object" || 67775ec34c4cSmrg test none = "$pic_object" && 67785ec34c4cSmrg test none = "$non_pic_object"; then 67795ec34c4cSmrg func_fatal_error "cannot find name of object for '$arg'" 6780994689c1Smrg fi 6781775e7de9Smrg 6782994689c1Smrg # Extract subdirectory from the argument. 6783994689c1Smrg func_dirname "$arg" "/" "" 67845ec34c4cSmrg xdir=$func_dirname_result 6785775e7de9Smrg 67865ec34c4cSmrg if test none != "$pic_object"; then 6787994689c1Smrg # Prepend the subdirectory the object is found in. 67885ec34c4cSmrg pic_object=$xdir$pic_object 6789775e7de9Smrg 67905ec34c4cSmrg if test dlfiles = "$prev"; then 67915ec34c4cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6792f353fbadSmrg func_append dlfiles " $pic_object" 6793994689c1Smrg prev= 6794994689c1Smrg continue 6795994689c1Smrg else 6796994689c1Smrg # If libtool objects are unsupported, then we need to preload. 6797994689c1Smrg prev=dlprefiles 6798994689c1Smrg fi 6799994689c1Smrg fi 6800775e7de9Smrg 6801994689c1Smrg # CHECK ME: I think I busted this. -Ossama 68025ec34c4cSmrg if test dlprefiles = "$prev"; then 6803994689c1Smrg # Preload the old-style object. 6804f353fbadSmrg func_append dlprefiles " $pic_object" 6805994689c1Smrg prev= 6806994689c1Smrg fi 6807775e7de9Smrg 6808994689c1Smrg # A PIC object. 6809994689c1Smrg func_append libobjs " $pic_object" 68105ec34c4cSmrg arg=$pic_object 6811994689c1Smrg fi 6812775e7de9Smrg 6813994689c1Smrg # Non-PIC object. 68145ec34c4cSmrg if test none != "$non_pic_object"; then 6815994689c1Smrg # Prepend the subdirectory the object is found in. 68165ec34c4cSmrg non_pic_object=$xdir$non_pic_object 6817775e7de9Smrg 6818994689c1Smrg # A standard non-PIC object 6819994689c1Smrg func_append non_pic_objects " $non_pic_object" 68205ec34c4cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 68215ec34c4cSmrg arg=$non_pic_object 6822994689c1Smrg fi 6823994689c1Smrg else 6824994689c1Smrg # If the PIC object exists, use it instead. 6825994689c1Smrg # $xdir was prepended to $pic_object above. 68265ec34c4cSmrg non_pic_object=$pic_object 6827994689c1Smrg func_append non_pic_objects " $non_pic_object" 6828994689c1Smrg fi 6829994689c1Smrg else 6830994689c1Smrg # Only an error if not doing a dry-run. 6831994689c1Smrg if $opt_dry_run; then 6832994689c1Smrg # Extract subdirectory from the argument. 6833994689c1Smrg func_dirname "$arg" "/" "" 68345ec34c4cSmrg xdir=$func_dirname_result 6835994689c1Smrg 6836994689c1Smrg func_lo2o "$arg" 6837994689c1Smrg pic_object=$xdir$objdir/$func_lo2o_result 6838994689c1Smrg non_pic_object=$xdir$func_lo2o_result 6839994689c1Smrg func_append libobjs " $pic_object" 6840994689c1Smrg func_append non_pic_objects " $non_pic_object" 6841994689c1Smrg else 68425ec34c4cSmrg func_fatal_error "'$arg' is not a valid libtool object" 6843994689c1Smrg fi 6844994689c1Smrg fi 6845994689c1Smrg done 6846e1e1713cSmrg else 68475ec34c4cSmrg func_fatal_error "link input file '$arg' does not exist" 6848e1e1713cSmrg fi 6849994689c1Smrg arg=$save_arg 6850994689c1Smrg prev= 6851994689c1Smrg continue 6852994689c1Smrg ;; 68535ec34c4cSmrg os2dllname) 68545ec34c4cSmrg os2dllname=$arg 68555ec34c4cSmrg prev= 68565ec34c4cSmrg continue 68575ec34c4cSmrg ;; 6858994689c1Smrg precious_regex) 68595ec34c4cSmrg precious_files_regex=$arg 6860994689c1Smrg prev= 6861994689c1Smrg continue 6862994689c1Smrg ;; 6863994689c1Smrg release) 68645ec34c4cSmrg release=-$arg 6865994689c1Smrg prev= 6866994689c1Smrg continue 6867994689c1Smrg ;; 6868994689c1Smrg rpath | xrpath) 6869994689c1Smrg # We need an absolute path. 6870994689c1Smrg case $arg in 6871994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6872994689c1Smrg *) 6873994689c1Smrg func_fatal_error "only absolute run-paths are allowed" 6874994689c1Smrg ;; 6875994689c1Smrg esac 68765ec34c4cSmrg if test rpath = "$prev"; then 6877994689c1Smrg case "$rpath " in 6878994689c1Smrg *" $arg "*) ;; 6879f353fbadSmrg *) func_append rpath " $arg" ;; 6880994689c1Smrg esac 6881e1e1713cSmrg else 6882994689c1Smrg case "$xrpath " in 6883994689c1Smrg *" $arg "*) ;; 6884f353fbadSmrg *) func_append xrpath " $arg" ;; 6885994689c1Smrg esac 6886e1e1713cSmrg fi 6887994689c1Smrg prev= 6888994689c1Smrg continue 6889994689c1Smrg ;; 6890994689c1Smrg shrext) 68915ec34c4cSmrg shrext_cmds=$arg 6892994689c1Smrg prev= 6893994689c1Smrg continue 6894994689c1Smrg ;; 6895994689c1Smrg weak) 6896f353fbadSmrg func_append weak_libs " $arg" 6897994689c1Smrg prev= 6898994689c1Smrg continue 6899994689c1Smrg ;; 6900994689c1Smrg xcclinker) 6901f353fbadSmrg func_append linker_flags " $qarg" 6902f353fbadSmrg func_append compiler_flags " $qarg" 6903994689c1Smrg prev= 6904994689c1Smrg func_append compile_command " $qarg" 6905994689c1Smrg func_append finalize_command " $qarg" 6906994689c1Smrg continue 6907994689c1Smrg ;; 6908994689c1Smrg xcompiler) 6909f353fbadSmrg func_append compiler_flags " $qarg" 6910994689c1Smrg prev= 6911994689c1Smrg func_append compile_command " $qarg" 6912994689c1Smrg func_append finalize_command " $qarg" 6913994689c1Smrg continue 6914994689c1Smrg ;; 6915994689c1Smrg xlinker) 6916f353fbadSmrg func_append linker_flags " $qarg" 6917f353fbadSmrg func_append compiler_flags " $wl$qarg" 6918994689c1Smrg prev= 6919994689c1Smrg func_append compile_command " $wl$qarg" 6920994689c1Smrg func_append finalize_command " $wl$qarg" 6921994689c1Smrg continue 6922994689c1Smrg ;; 6923994689c1Smrg *) 6924994689c1Smrg eval "$prev=\"\$arg\"" 6925994689c1Smrg prev= 6926994689c1Smrg continue 6927994689c1Smrg ;; 6928775e7de9Smrg esac 6929994689c1Smrg fi # test -n "$prev" 6930775e7de9Smrg 69315ec34c4cSmrg prevarg=$arg 6932775e7de9Smrg 6933994689c1Smrg case $arg in 6934994689c1Smrg -all-static) 6935994689c1Smrg if test -n "$link_static_flag"; then 6936994689c1Smrg # See comment for -static flag below, for more details. 6937994689c1Smrg func_append compile_command " $link_static_flag" 6938994689c1Smrg func_append finalize_command " $link_static_flag" 6939994689c1Smrg fi 6940994689c1Smrg continue 6941994689c1Smrg ;; 6942775e7de9Smrg 6943994689c1Smrg -allow-undefined) 6944994689c1Smrg # FIXME: remove this flag sometime in the future. 69455ec34c4cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6946994689c1Smrg ;; 6947775e7de9Smrg 6948994689c1Smrg -avoid-version) 6949994689c1Smrg avoid_version=yes 6950994689c1Smrg continue 6951994689c1Smrg ;; 6952775e7de9Smrg 6953994689c1Smrg -bindir) 6954994689c1Smrg prev=bindir 6955994689c1Smrg continue 6956994689c1Smrg ;; 6957775e7de9Smrg 6958994689c1Smrg -dlopen) 6959994689c1Smrg prev=dlfiles 6960994689c1Smrg continue 6961994689c1Smrg ;; 6962775e7de9Smrg 6963994689c1Smrg -dlpreopen) 6964994689c1Smrg prev=dlprefiles 6965994689c1Smrg continue 6966994689c1Smrg ;; 6967775e7de9Smrg 6968994689c1Smrg -export-dynamic) 6969994689c1Smrg export_dynamic=yes 6970994689c1Smrg continue 6971994689c1Smrg ;; 6972775e7de9Smrg 6973994689c1Smrg -export-symbols | -export-symbols-regex) 6974994689c1Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6975994689c1Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6976994689c1Smrg fi 69775ec34c4cSmrg if test X-export-symbols = "X$arg"; then 6978994689c1Smrg prev=expsyms 6979994689c1Smrg else 6980994689c1Smrg prev=expsyms_regex 6981994689c1Smrg fi 6982994689c1Smrg continue 6983994689c1Smrg ;; 6984775e7de9Smrg 6985994689c1Smrg -framework) 6986994689c1Smrg prev=framework 6987994689c1Smrg continue 6988994689c1Smrg ;; 6989775e7de9Smrg 6990994689c1Smrg -inst-prefix-dir) 6991994689c1Smrg prev=inst_prefix 6992994689c1Smrg continue 6993994689c1Smrg ;; 6994775e7de9Smrg 6995994689c1Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6996994689c1Smrg # so, if we see these flags be careful not to treat them like -L 6997994689c1Smrg -L[A-Z][A-Z]*:*) 6998994689c1Smrg case $with_gcc/$host in 6999994689c1Smrg no/*-*-irix* | /*-*-irix*) 7000994689c1Smrg func_append compile_command " $arg" 7001994689c1Smrg func_append finalize_command " $arg" 7002994689c1Smrg ;; 7003994689c1Smrg esac 7004994689c1Smrg continue 7005994689c1Smrg ;; 7006775e7de9Smrg 7007994689c1Smrg -L*) 7008f353fbadSmrg func_stripname "-L" '' "$arg" 7009f353fbadSmrg if test -z "$func_stripname_result"; then 7010994689c1Smrg if test "$#" -gt 0; then 70115ec34c4cSmrg func_fatal_error "require no space between '-L' and '$1'" 7012994689c1Smrg else 70135ec34c4cSmrg func_fatal_error "need path for '-L' option" 7014994689c1Smrg fi 7015994689c1Smrg fi 7016f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 7017f353fbadSmrg dir=$func_resolve_sysroot_result 7018994689c1Smrg # We need an absolute path. 7019994689c1Smrg case $dir in 7020994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7021994689c1Smrg *) 7022994689c1Smrg absdir=`cd "$dir" && pwd` 7023994689c1Smrg test -z "$absdir" && \ 70245ec34c4cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 70255ec34c4cSmrg dir=$absdir 7026994689c1Smrg ;; 7027994689c1Smrg esac 7028994689c1Smrg case "$deplibs " in 7029f353fbadSmrg *" -L$dir "* | *" $arg "*) 7030f353fbadSmrg # Will only happen for absolute or sysroot arguments 7031f353fbadSmrg ;; 7032994689c1Smrg *) 7033f353fbadSmrg # Preserve sysroot, but never include relative directories 7034f353fbadSmrg case $dir in 7035f353fbadSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7036f353fbadSmrg *) func_append deplibs " -L$dir" ;; 7037f353fbadSmrg esac 7038f353fbadSmrg func_append lib_search_path " $dir" 7039994689c1Smrg ;; 7040994689c1Smrg esac 7041994689c1Smrg case $host in 7042994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7043994689c1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7044994689c1Smrg case :$dllsearchpath: in 7045994689c1Smrg *":$dir:"*) ;; 7046994689c1Smrg ::) dllsearchpath=$dir;; 7047f353fbadSmrg *) func_append dllsearchpath ":$dir";; 7048994689c1Smrg esac 7049994689c1Smrg case :$dllsearchpath: in 7050994689c1Smrg *":$testbindir:"*) ;; 7051994689c1Smrg ::) dllsearchpath=$testbindir;; 7052f353fbadSmrg *) func_append dllsearchpath ":$testbindir";; 7053994689c1Smrg esac 7054994689c1Smrg ;; 7055994689c1Smrg esac 7056994689c1Smrg continue 7057994689c1Smrg ;; 7058775e7de9Smrg 7059994689c1Smrg -l*) 70605ec34c4cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7061994689c1Smrg case $host in 7062994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7063994689c1Smrg # These systems don't actually have a C or math library (as such) 7064994689c1Smrg continue 7065994689c1Smrg ;; 7066994689c1Smrg *-*-os2*) 7067994689c1Smrg # These systems don't actually have a C library (as such) 70685ec34c4cSmrg test X-lc = "X$arg" && continue 7069994689c1Smrg ;; 70705ec34c4cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7071994689c1Smrg # Do not include libc due to us having libc/libc_r. 70725ec34c4cSmrg test X-lc = "X$arg" && continue 7073994689c1Smrg ;; 7074994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7075994689c1Smrg # Rhapsody C and math libraries are in the System framework 7076f353fbadSmrg func_append deplibs " System.ltframework" 7077994689c1Smrg continue 7078994689c1Smrg ;; 7079994689c1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7080994689c1Smrg # Causes problems with __ctype 70815ec34c4cSmrg test X-lc = "X$arg" && continue 7082994689c1Smrg ;; 7083994689c1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7084994689c1Smrg # Compiler inserts libc in the correct place for threads to work 70855ec34c4cSmrg test X-lc = "X$arg" && continue 7086994689c1Smrg ;; 7087994689c1Smrg esac 70885ec34c4cSmrg elif test X-lc_r = "X$arg"; then 7089994689c1Smrg case $host in 70905ec34c4cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7091994689c1Smrg # Do not include libc_r directly, use -pthread flag. 7092994689c1Smrg continue 7093994689c1Smrg ;; 7094994689c1Smrg esac 7095994689c1Smrg fi 7096f353fbadSmrg func_append deplibs " $arg" 7097994689c1Smrg continue 7098994689c1Smrg ;; 7099775e7de9Smrg 71005ec34c4cSmrg -mllvm) 71015ec34c4cSmrg prev=mllvm 71025ec34c4cSmrg continue 71035ec34c4cSmrg ;; 71045ec34c4cSmrg 7105994689c1Smrg -module) 7106994689c1Smrg module=yes 7107994689c1Smrg continue 7108994689c1Smrg ;; 7109775e7de9Smrg 7110994689c1Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7111994689c1Smrg # classes, name mangling, and exception handling. 7112994689c1Smrg # Darwin uses the -arch flag to determine output architecture. 7113f353fbadSmrg -model|-arch|-isysroot|--sysroot) 7114f353fbadSmrg func_append compiler_flags " $arg" 7115994689c1Smrg func_append compile_command " $arg" 7116994689c1Smrg func_append finalize_command " $arg" 7117994689c1Smrg prev=xcompiler 7118994689c1Smrg continue 7119994689c1Smrg ;; 7120775e7de9Smrg 7121421c997bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7122421c997bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7123f353fbadSmrg func_append compiler_flags " $arg" 7124994689c1Smrg func_append compile_command " $arg" 7125994689c1Smrg func_append finalize_command " $arg" 7126994689c1Smrg case "$new_inherited_linker_flags " in 7127994689c1Smrg *" $arg "*) ;; 7128f353fbadSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7129994689c1Smrg esac 71305ec34c4cSmrg 71315ec34c4cSmrg # As we are forced to pass -nostdlib to g++ during linking, the option 71325ec34c4cSmrg # -pthread{,s} is not in effect; add the -lpthread to $deplist 71335ec34c4cSmrg # explicitly to link correctly. 71345ec34c4cSmrg if test "$tagname" = CXX -a x"$with_gcc" = xyes; then 71355ec34c4cSmrg case "$arg" in 71365ec34c4cSmrg -pthread*) func_append deplibs " -lpthread" ;; 71375ec34c4cSmrg esac 71385ec34c4cSmrg fi 71395ec34c4cSmrg 7140994689c1Smrg continue 7141994689c1Smrg ;; 7142775e7de9Smrg 7143994689c1Smrg -multi_module) 71445ec34c4cSmrg single_module=$wl-multi_module 7145994689c1Smrg continue 7146994689c1Smrg ;; 7147775e7de9Smrg 7148994689c1Smrg -no-fast-install) 7149994689c1Smrg fast_install=no 7150994689c1Smrg continue 7151994689c1Smrg ;; 7152775e7de9Smrg 7153994689c1Smrg -no-install) 7154994689c1Smrg case $host in 7155994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7156994689c1Smrg # The PATH hackery in wrapper scripts is required on Windows 7157994689c1Smrg # and Darwin in order for the loader to find any dlls it needs. 71585ec34c4cSmrg func_warning "'-no-install' is ignored for $host" 71595ec34c4cSmrg func_warning "assuming '-no-fast-install' instead" 7160994689c1Smrg fast_install=no 7161994689c1Smrg ;; 7162994689c1Smrg *) no_install=yes ;; 7163994689c1Smrg esac 7164994689c1Smrg continue 7165994689c1Smrg ;; 7166775e7de9Smrg 7167994689c1Smrg -no-undefined) 7168994689c1Smrg allow_undefined=no 7169994689c1Smrg continue 7170994689c1Smrg ;; 7171775e7de9Smrg 7172994689c1Smrg -objectlist) 7173994689c1Smrg prev=objectlist 7174994689c1Smrg continue 7175994689c1Smrg ;; 7176775e7de9Smrg 71775ec34c4cSmrg -os2dllname) 71785ec34c4cSmrg prev=os2dllname 71795ec34c4cSmrg continue 71805ec34c4cSmrg ;; 71815ec34c4cSmrg 7182994689c1Smrg -o) prev=output ;; 7183775e7de9Smrg 7184994689c1Smrg -precious-files-regex) 7185994689c1Smrg prev=precious_regex 7186994689c1Smrg continue 7187994689c1Smrg ;; 7188775e7de9Smrg 7189994689c1Smrg -release) 7190994689c1Smrg prev=release 7191994689c1Smrg continue 7192994689c1Smrg ;; 7193775e7de9Smrg 7194994689c1Smrg -rpath) 7195994689c1Smrg prev=rpath 7196994689c1Smrg continue 7197994689c1Smrg ;; 7198775e7de9Smrg 7199994689c1Smrg -R) 7200994689c1Smrg prev=xrpath 7201994689c1Smrg continue 7202994689c1Smrg ;; 7203775e7de9Smrg 7204994689c1Smrg -R*) 7205994689c1Smrg func_stripname '-R' '' "$arg" 7206994689c1Smrg dir=$func_stripname_result 7207994689c1Smrg # We need an absolute path. 7208994689c1Smrg case $dir in 7209994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7210f353fbadSmrg =*) 7211f353fbadSmrg func_stripname '=' '' "$dir" 7212f353fbadSmrg dir=$lt_sysroot$func_stripname_result 7213f353fbadSmrg ;; 7214994689c1Smrg *) 7215994689c1Smrg func_fatal_error "only absolute run-paths are allowed" 7216994689c1Smrg ;; 7217994689c1Smrg esac 7218994689c1Smrg case "$xrpath " in 7219994689c1Smrg *" $dir "*) ;; 7220f353fbadSmrg *) func_append xrpath " $dir" ;; 7221994689c1Smrg esac 7222994689c1Smrg continue 7223994689c1Smrg ;; 7224775e7de9Smrg 7225994689c1Smrg -shared) 7226994689c1Smrg # The effects of -shared are defined in a previous loop. 7227994689c1Smrg continue 7228994689c1Smrg ;; 7229775e7de9Smrg 7230994689c1Smrg -shrext) 7231994689c1Smrg prev=shrext 7232994689c1Smrg continue 7233994689c1Smrg ;; 7234775e7de9Smrg 7235994689c1Smrg -static | -static-libtool-libs) 7236994689c1Smrg # The effects of -static are defined in a previous loop. 7237994689c1Smrg # We used to do the same as -all-static on platforms that 7238994689c1Smrg # didn't have a PIC flag, but the assumption that the effects 7239994689c1Smrg # would be equivalent was wrong. It would break on at least 7240994689c1Smrg # Digital Unix and AIX. 7241994689c1Smrg continue 7242994689c1Smrg ;; 7243775e7de9Smrg 7244994689c1Smrg -thread-safe) 7245994689c1Smrg thread_safe=yes 7246994689c1Smrg continue 7247994689c1Smrg ;; 7248775e7de9Smrg 7249994689c1Smrg -version-info) 7250994689c1Smrg prev=vinfo 7251994689c1Smrg continue 7252994689c1Smrg ;; 7253775e7de9Smrg 7254994689c1Smrg -version-number) 7255994689c1Smrg prev=vinfo 7256994689c1Smrg vinfo_number=yes 7257994689c1Smrg continue 7258994689c1Smrg ;; 72597a84e134Smrg 7260994689c1Smrg -weak) 7261994689c1Smrg prev=weak 7262994689c1Smrg continue 7263994689c1Smrg ;; 7264e1e1713cSmrg 7265994689c1Smrg -Wc,*) 7266994689c1Smrg func_stripname '-Wc,' '' "$arg" 7267994689c1Smrg args=$func_stripname_result 7268994689c1Smrg arg= 72695ec34c4cSmrg save_ifs=$IFS; IFS=, 7270994689c1Smrg for flag in $args; do 72715ec34c4cSmrg IFS=$save_ifs 7272994689c1Smrg func_quote_for_eval "$flag" 7273f353fbadSmrg func_append arg " $func_quote_for_eval_result" 7274f353fbadSmrg func_append compiler_flags " $func_quote_for_eval_result" 7275994689c1Smrg done 72765ec34c4cSmrg IFS=$save_ifs 7277994689c1Smrg func_stripname ' ' '' "$arg" 7278994689c1Smrg arg=$func_stripname_result 7279994689c1Smrg ;; 7280e1e1713cSmrg 7281994689c1Smrg -Wl,*) 7282994689c1Smrg func_stripname '-Wl,' '' "$arg" 7283994689c1Smrg args=$func_stripname_result 7284994689c1Smrg arg= 72855ec34c4cSmrg save_ifs=$IFS; IFS=, 7286994689c1Smrg for flag in $args; do 72875ec34c4cSmrg IFS=$save_ifs 7288994689c1Smrg func_quote_for_eval "$flag" 7289f353fbadSmrg func_append arg " $wl$func_quote_for_eval_result" 7290f353fbadSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7291f353fbadSmrg func_append linker_flags " $func_quote_for_eval_result" 7292994689c1Smrg done 72935ec34c4cSmrg IFS=$save_ifs 7294994689c1Smrg func_stripname ' ' '' "$arg" 7295994689c1Smrg arg=$func_stripname_result 7296994689c1Smrg ;; 7297e1e1713cSmrg 7298994689c1Smrg -Xcompiler) 7299994689c1Smrg prev=xcompiler 7300994689c1Smrg continue 7301994689c1Smrg ;; 7302e1e1713cSmrg 7303994689c1Smrg -Xlinker) 7304994689c1Smrg prev=xlinker 7305994689c1Smrg continue 7306994689c1Smrg ;; 7307e1e1713cSmrg 7308994689c1Smrg -XCClinker) 7309994689c1Smrg prev=xcclinker 7310994689c1Smrg continue 7311994689c1Smrg ;; 7312e1e1713cSmrg 7313994689c1Smrg # -msg_* for osf cc 7314994689c1Smrg -msg_*) 7315994689c1Smrg func_quote_for_eval "$arg" 73165ec34c4cSmrg arg=$func_quote_for_eval_result 7317994689c1Smrg ;; 7318e1e1713cSmrg 7319994689c1Smrg # Flags to be passed through unchanged, with rationale: 7320994689c1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7321994689c1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7322994689c1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7323994689c1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7324994689c1Smrg # -q* compiler args for the IBM compiler 7325994689c1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7326994689c1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7327994689c1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 73285ec34c4cSmrg # -fstack-protector* stack protector flags for GCC 7329994689c1Smrg # @file GCC response files 7330994689c1Smrg # -tp=* Portland pgcc target processor selection 7331f353fbadSmrg # --sysroot=* for sysroot support 73325ec34c4cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 73335ec34c4cSmrg # -specs=* GCC specs files 73345ec34c4cSmrg # -stdlib=* select c++ std lib with clang 73355ec34c4cSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 73365ec34c4cSmrg # -fuse-ld=* Linker select flags for GCC 7337994689c1Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7338f353fbadSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 73395ec34c4cSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 73405ec34c4cSmrg -specs=*|-fsanitize=*|-fuse-ld=*) 7341994689c1Smrg func_quote_for_eval "$arg" 73425ec34c4cSmrg arg=$func_quote_for_eval_result 7343994689c1Smrg func_append compile_command " $arg" 7344994689c1Smrg func_append finalize_command " $arg" 7345f353fbadSmrg func_append compiler_flags " $arg" 7346994689c1Smrg continue 7347994689c1Smrg ;; 7348e1e1713cSmrg 73495ec34c4cSmrg -Z*) 73505ec34c4cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 73515ec34c4cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 73525ec34c4cSmrg compiler_flags="$compiler_flags $arg" 73535ec34c4cSmrg func_append compile_command " $arg" 73545ec34c4cSmrg func_append finalize_command " $arg" 73555ec34c4cSmrg case $arg in 73565ec34c4cSmrg -Zlinker | -Zstack) 73575ec34c4cSmrg prev=xcompiler 73585ec34c4cSmrg ;; 73595ec34c4cSmrg esac 73605ec34c4cSmrg continue 73615ec34c4cSmrg else 73625ec34c4cSmrg # Otherwise treat like 'Some other compiler flag' below 73635ec34c4cSmrg func_quote_for_eval "$arg" 73645ec34c4cSmrg arg=$func_quote_for_eval_result 73655ec34c4cSmrg fi 73665ec34c4cSmrg ;; 73675ec34c4cSmrg 7368994689c1Smrg # Some other compiler flag. 7369994689c1Smrg -* | +*) 7370994689c1Smrg func_quote_for_eval "$arg" 73715ec34c4cSmrg arg=$func_quote_for_eval_result 7372994689c1Smrg ;; 7373e1e1713cSmrg 7374994689c1Smrg *.$objext) 7375994689c1Smrg # A standard object. 7376f353fbadSmrg func_append objs " $arg" 7377994689c1Smrg ;; 7378e1e1713cSmrg 7379994689c1Smrg *.lo) 7380994689c1Smrg # A libtool-controlled object. 7381e1e1713cSmrg 7382994689c1Smrg # Check to see that this really is a libtool object. 7383994689c1Smrg if func_lalib_unsafe_p "$arg"; then 7384994689c1Smrg pic_object= 7385994689c1Smrg non_pic_object= 7386e1e1713cSmrg 7387994689c1Smrg # Read the .lo file 7388994689c1Smrg func_source "$arg" 7389e1e1713cSmrg 7390994689c1Smrg if test -z "$pic_object" || 7391994689c1Smrg test -z "$non_pic_object" || 73925ec34c4cSmrg test none = "$pic_object" && 73935ec34c4cSmrg test none = "$non_pic_object"; then 73945ec34c4cSmrg func_fatal_error "cannot find name of object for '$arg'" 7395994689c1Smrg fi 7396e1e1713cSmrg 7397994689c1Smrg # Extract subdirectory from the argument. 7398994689c1Smrg func_dirname "$arg" "/" "" 73995ec34c4cSmrg xdir=$func_dirname_result 7400e1e1713cSmrg 74015ec34c4cSmrg test none = "$pic_object" || { 7402994689c1Smrg # Prepend the subdirectory the object is found in. 74035ec34c4cSmrg pic_object=$xdir$pic_object 7404e1e1713cSmrg 74055ec34c4cSmrg if test dlfiles = "$prev"; then 74065ec34c4cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7407f353fbadSmrg func_append dlfiles " $pic_object" 7408994689c1Smrg prev= 7409994689c1Smrg continue 7410994689c1Smrg else 7411994689c1Smrg # If libtool objects are unsupported, then we need to preload. 7412994689c1Smrg prev=dlprefiles 7413994689c1Smrg fi 7414994689c1Smrg fi 7415994689c1Smrg 7416994689c1Smrg # CHECK ME: I think I busted this. -Ossama 74175ec34c4cSmrg if test dlprefiles = "$prev"; then 7418994689c1Smrg # Preload the old-style object. 7419f353fbadSmrg func_append dlprefiles " $pic_object" 7420994689c1Smrg prev= 7421994689c1Smrg fi 7422994689c1Smrg 7423994689c1Smrg # A PIC object. 7424994689c1Smrg func_append libobjs " $pic_object" 74255ec34c4cSmrg arg=$pic_object 74265ec34c4cSmrg } 7427994689c1Smrg 7428994689c1Smrg # Non-PIC object. 74295ec34c4cSmrg if test none != "$non_pic_object"; then 7430994689c1Smrg # Prepend the subdirectory the object is found in. 74315ec34c4cSmrg non_pic_object=$xdir$non_pic_object 7432994689c1Smrg 7433994689c1Smrg # A standard non-PIC object 7434994689c1Smrg func_append non_pic_objects " $non_pic_object" 74355ec34c4cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 74365ec34c4cSmrg arg=$non_pic_object 7437994689c1Smrg fi 7438994689c1Smrg else 7439994689c1Smrg # If the PIC object exists, use it instead. 7440994689c1Smrg # $xdir was prepended to $pic_object above. 74415ec34c4cSmrg non_pic_object=$pic_object 7442994689c1Smrg func_append non_pic_objects " $non_pic_object" 7443994689c1Smrg fi 7444994689c1Smrg else 7445994689c1Smrg # Only an error if not doing a dry-run. 7446994689c1Smrg if $opt_dry_run; then 7447994689c1Smrg # Extract subdirectory from the argument. 7448994689c1Smrg func_dirname "$arg" "/" "" 74495ec34c4cSmrg xdir=$func_dirname_result 7450994689c1Smrg 7451994689c1Smrg func_lo2o "$arg" 7452994689c1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7453994689c1Smrg non_pic_object=$xdir$func_lo2o_result 7454994689c1Smrg func_append libobjs " $pic_object" 7455994689c1Smrg func_append non_pic_objects " $non_pic_object" 7456994689c1Smrg else 74575ec34c4cSmrg func_fatal_error "'$arg' is not a valid libtool object" 7458994689c1Smrg fi 7459994689c1Smrg fi 7460994689c1Smrg ;; 7461994689c1Smrg 7462994689c1Smrg *.$libext) 7463994689c1Smrg # An archive. 7464f353fbadSmrg func_append deplibs " $arg" 7465f353fbadSmrg func_append old_deplibs " $arg" 7466994689c1Smrg continue 7467994689c1Smrg ;; 7468994689c1Smrg 7469994689c1Smrg *.la) 7470994689c1Smrg # A libtool-controlled library. 7471994689c1Smrg 7472f353fbadSmrg func_resolve_sysroot "$arg" 74735ec34c4cSmrg if test dlfiles = "$prev"; then 7474994689c1Smrg # This library was specified with -dlopen. 7475f353fbadSmrg func_append dlfiles " $func_resolve_sysroot_result" 7476994689c1Smrg prev= 74775ec34c4cSmrg elif test dlprefiles = "$prev"; then 7478994689c1Smrg # The library was specified with -dlpreopen. 7479f353fbadSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7480994689c1Smrg prev= 7481994689c1Smrg else 7482f353fbadSmrg func_append deplibs " $func_resolve_sysroot_result" 7483994689c1Smrg fi 7484994689c1Smrg continue 7485994689c1Smrg ;; 7486994689c1Smrg 7487994689c1Smrg # Some other compiler argument. 7488994689c1Smrg *) 7489994689c1Smrg # Unknown arguments in both finalize_command and compile_command need 7490994689c1Smrg # to be aesthetically quoted because they are evaled later. 7491994689c1Smrg func_quote_for_eval "$arg" 74925ec34c4cSmrg arg=$func_quote_for_eval_result 7493994689c1Smrg ;; 7494994689c1Smrg esac # arg 7495994689c1Smrg 7496994689c1Smrg # Now actually substitute the argument into the commands. 7497994689c1Smrg if test -n "$arg"; then 7498994689c1Smrg func_append compile_command " $arg" 7499994689c1Smrg func_append finalize_command " $arg" 7500994689c1Smrg fi 7501994689c1Smrg done # argument parsing loop 7502994689c1Smrg 7503994689c1Smrg test -n "$prev" && \ 75045ec34c4cSmrg func_fatal_help "the '$prevarg' option requires an argument" 7505994689c1Smrg 75065ec34c4cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7507994689c1Smrg eval arg=\"$export_dynamic_flag_spec\" 7508994689c1Smrg func_append compile_command " $arg" 7509994689c1Smrg func_append finalize_command " $arg" 7510994689c1Smrg fi 7511994689c1Smrg 7512994689c1Smrg oldlibs= 7513994689c1Smrg # calculate the name of the file, without its directory 7514994689c1Smrg func_basename "$output" 75155ec34c4cSmrg outputname=$func_basename_result 75165ec34c4cSmrg libobjs_save=$libobjs 7517994689c1Smrg 7518994689c1Smrg if test -n "$shlibpath_var"; then 7519994689c1Smrg # get the directories listed in $shlibpath_var 75205ec34c4cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7521e1e1713cSmrg else 7522994689c1Smrg shlib_search_path= 7523e1e1713cSmrg fi 7524994689c1Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7525994689c1Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 75267a84e134Smrg 75275ec34c4cSmrg # Definition is injected by LT_CONFIG during libtool generation. 75285ec34c4cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 75295ec34c4cSmrg 7530994689c1Smrg func_dirname "$output" "/" "" 75315ec34c4cSmrg output_objdir=$func_dirname_result$objdir 7532f353fbadSmrg func_to_tool_file "$output_objdir/" 7533f353fbadSmrg tool_output_objdir=$func_to_tool_file_result 7534994689c1Smrg # Create the object directory. 7535994689c1Smrg func_mkdir_p "$output_objdir" 75367a84e134Smrg 7537994689c1Smrg # Determine the type of output 7538994689c1Smrg case $output in 7539994689c1Smrg "") 7540994689c1Smrg func_fatal_help "you must specify an output file" 7541994689c1Smrg ;; 7542994689c1Smrg *.$libext) linkmode=oldlib ;; 7543994689c1Smrg *.lo | *.$objext) linkmode=obj ;; 7544994689c1Smrg *.la) linkmode=lib ;; 7545994689c1Smrg *) linkmode=prog ;; # Anything else should be a program. 7546994689c1Smrg esac 7547994689c1Smrg 7548994689c1Smrg specialdeplibs= 7549994689c1Smrg 7550994689c1Smrg libs= 7551994689c1Smrg # Find all interdependent deplibs by searching for libraries 7552994689c1Smrg # that are linked more than once (e.g. -la -lb -la) 7553994689c1Smrg for deplib in $deplibs; do 75545ec34c4cSmrg if $opt_preserve_dup_deps; then 7555994689c1Smrg case "$libs " in 7556f353fbadSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7557994689c1Smrg esac 7558994689c1Smrg fi 7559f353fbadSmrg func_append libs " $deplib" 7560994689c1Smrg done 7561994689c1Smrg 75625ec34c4cSmrg if test lib = "$linkmode"; then 7563994689c1Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7564994689c1Smrg 7565994689c1Smrg # Compute libraries that are listed more than once in $predeps 7566994689c1Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7567994689c1Smrg # not to be eliminated). 7568994689c1Smrg pre_post_deps= 7569994689c1Smrg if $opt_duplicate_compiler_generated_deps; then 7570994689c1Smrg for pre_post_dep in $predeps $postdeps; do 7571994689c1Smrg case "$pre_post_deps " in 7572f353fbadSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7573994689c1Smrg esac 7574f353fbadSmrg func_append pre_post_deps " $pre_post_dep" 7575994689c1Smrg done 7576994689c1Smrg fi 7577994689c1Smrg pre_post_deps= 7578994689c1Smrg fi 7579994689c1Smrg 7580994689c1Smrg deplibs= 7581994689c1Smrg newdependency_libs= 7582994689c1Smrg newlib_search_path= 7583994689c1Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7584994689c1Smrg notinst_deplibs= # not-installed libtool libraries 7585994689c1Smrg notinst_path= # paths that contain not-installed libtool libraries 7586994689c1Smrg 7587994689c1Smrg case $linkmode in 7588994689c1Smrg lib) 7589994689c1Smrg passes="conv dlpreopen link" 7590994689c1Smrg for file in $dlfiles $dlprefiles; do 7591994689c1Smrg case $file in 7592994689c1Smrg *.la) ;; 7593994689c1Smrg *) 75945ec34c4cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7595994689c1Smrg ;; 7596994689c1Smrg esac 7597994689c1Smrg done 7598994689c1Smrg ;; 7599994689c1Smrg prog) 7600994689c1Smrg compile_deplibs= 7601994689c1Smrg finalize_deplibs= 76025ec34c4cSmrg alldeplibs=false 7603994689c1Smrg newdlfiles= 7604994689c1Smrg newdlprefiles= 7605994689c1Smrg passes="conv scan dlopen dlpreopen link" 7606994689c1Smrg ;; 7607994689c1Smrg *) passes="conv" 7608994689c1Smrg ;; 7609994689c1Smrg esac 7610994689c1Smrg 7611994689c1Smrg for pass in $passes; do 7612994689c1Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7613994689c1Smrg # so that -L comes before libs that need it for instance... 76145ec34c4cSmrg if test lib,link = "$linkmode,$pass"; then 7615994689c1Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7616994689c1Smrg ## order, and fix it there properly 7617994689c1Smrg tmp_deplibs= 7618994689c1Smrg for deplib in $deplibs; do 7619994689c1Smrg tmp_deplibs="$deplib $tmp_deplibs" 7620994689c1Smrg done 76215ec34c4cSmrg deplibs=$tmp_deplibs 7622994689c1Smrg fi 7623994689c1Smrg 76245ec34c4cSmrg if test lib,link = "$linkmode,$pass" || 76255ec34c4cSmrg test prog,scan = "$linkmode,$pass"; then 76265ec34c4cSmrg libs=$deplibs 7627994689c1Smrg deplibs= 7628994689c1Smrg fi 76295ec34c4cSmrg if test prog = "$linkmode"; then 7630994689c1Smrg case $pass in 76315ec34c4cSmrg dlopen) libs=$dlfiles ;; 76325ec34c4cSmrg dlpreopen) libs=$dlprefiles ;; 7633994689c1Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7634994689c1Smrg esac 7635994689c1Smrg fi 76365ec34c4cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7637994689c1Smrg # Collect and forward deplibs of preopened libtool libs 7638994689c1Smrg for lib in $dlprefiles; do 7639994689c1Smrg # Ignore non-libtool-libs 7640994689c1Smrg dependency_libs= 7641f353fbadSmrg func_resolve_sysroot "$lib" 7642994689c1Smrg case $lib in 7643f353fbadSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7644994689c1Smrg esac 7645994689c1Smrg 7646994689c1Smrg # Collect preopened libtool deplibs, except any this library 7647994689c1Smrg # has declared as weak libs 7648994689c1Smrg for deplib in $dependency_libs; do 7649994689c1Smrg func_basename "$deplib" 7650994689c1Smrg deplib_base=$func_basename_result 7651994689c1Smrg case " $weak_libs " in 7652994689c1Smrg *" $deplib_base "*) ;; 7653f353fbadSmrg *) func_append deplibs " $deplib" ;; 7654994689c1Smrg esac 7655994689c1Smrg done 7656994689c1Smrg done 76575ec34c4cSmrg libs=$dlprefiles 7658994689c1Smrg fi 76595ec34c4cSmrg if test dlopen = "$pass"; then 7660994689c1Smrg # Collect dlpreopened libraries 76615ec34c4cSmrg save_deplibs=$deplibs 7662994689c1Smrg deplibs= 7663994689c1Smrg fi 7664994689c1Smrg 7665994689c1Smrg for deplib in $libs; do 7666994689c1Smrg lib= 76675ec34c4cSmrg found=false 7668994689c1Smrg case $deplib in 7669421c997bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7670421c997bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 76715ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 7672994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7673994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7674994689c1Smrg else 7675f353fbadSmrg func_append compiler_flags " $deplib" 76765ec34c4cSmrg if test lib = "$linkmode"; then 7677994689c1Smrg case "$new_inherited_linker_flags " in 7678994689c1Smrg *" $deplib "*) ;; 7679f353fbadSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7680994689c1Smrg esac 7681994689c1Smrg fi 7682994689c1Smrg fi 7683994689c1Smrg continue 7684994689c1Smrg ;; 7685994689c1Smrg -l*) 76865ec34c4cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 76875ec34c4cSmrg func_warning "'-l' is ignored for archives/objects" 7688994689c1Smrg continue 7689994689c1Smrg fi 7690994689c1Smrg func_stripname '-l' '' "$deplib" 7691994689c1Smrg name=$func_stripname_result 76925ec34c4cSmrg if test lib = "$linkmode"; then 7693994689c1Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7694994689c1Smrg else 7695994689c1Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7696994689c1Smrg fi 7697994689c1Smrg for searchdir in $searchdirs; do 7698994689c1Smrg for search_ext in .la $std_shrext .so .a; do 7699994689c1Smrg # Search the libtool library 77005ec34c4cSmrg lib=$searchdir/lib$name$search_ext 7701994689c1Smrg if test -f "$lib"; then 77025ec34c4cSmrg if test .la = "$search_ext"; then 77035ec34c4cSmrg found=: 7704994689c1Smrg else 77055ec34c4cSmrg found=false 7706994689c1Smrg fi 7707994689c1Smrg break 2 7708994689c1Smrg fi 7709994689c1Smrg done 7710994689c1Smrg done 77115ec34c4cSmrg if $found; then 77125ec34c4cSmrg # deplib is a libtool library 7713994689c1Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7714994689c1Smrg # We need to do some special things here, and not later. 77155ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7716994689c1Smrg case " $predeps $postdeps " in 7717994689c1Smrg *" $deplib "*) 7718994689c1Smrg if func_lalib_p "$lib"; then 7719994689c1Smrg library_names= 7720994689c1Smrg old_library= 7721994689c1Smrg func_source "$lib" 7722994689c1Smrg for l in $old_library $library_names; do 77235ec34c4cSmrg ll=$l 7724994689c1Smrg done 77255ec34c4cSmrg if test "X$ll" = "X$old_library"; then # only static version available 77265ec34c4cSmrg found=false 7727994689c1Smrg func_dirname "$lib" "" "." 77285ec34c4cSmrg ladir=$func_dirname_result 7729994689c1Smrg lib=$ladir/$old_library 77305ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 7731994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7732994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7733994689c1Smrg else 7734994689c1Smrg deplibs="$deplib $deplibs" 77355ec34c4cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7736994689c1Smrg fi 7737994689c1Smrg continue 7738994689c1Smrg fi 7739994689c1Smrg fi 7740994689c1Smrg ;; 7741994689c1Smrg *) ;; 7742994689c1Smrg esac 7743994689c1Smrg fi 77445ec34c4cSmrg else 77455ec34c4cSmrg # deplib doesn't seem to be a libtool library 77465ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 77475ec34c4cSmrg compile_deplibs="$deplib $compile_deplibs" 77485ec34c4cSmrg finalize_deplibs="$deplib $finalize_deplibs" 77495ec34c4cSmrg else 77505ec34c4cSmrg deplibs="$deplib $deplibs" 77515ec34c4cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 77525ec34c4cSmrg fi 77535ec34c4cSmrg continue 7754994689c1Smrg fi 7755994689c1Smrg ;; # -l 7756994689c1Smrg *.ltframework) 77575ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 7758994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7759994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7760994689c1Smrg else 7761994689c1Smrg deplibs="$deplib $deplibs" 77625ec34c4cSmrg if test lib = "$linkmode"; then 7763994689c1Smrg case "$new_inherited_linker_flags " in 7764994689c1Smrg *" $deplib "*) ;; 7765f353fbadSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7766994689c1Smrg esac 7767994689c1Smrg fi 7768994689c1Smrg fi 7769994689c1Smrg continue 7770994689c1Smrg ;; 7771994689c1Smrg -L*) 7772994689c1Smrg case $linkmode in 7773994689c1Smrg lib) 7774994689c1Smrg deplibs="$deplib $deplibs" 77755ec34c4cSmrg test conv = "$pass" && continue 7776994689c1Smrg newdependency_libs="$deplib $newdependency_libs" 7777994689c1Smrg func_stripname '-L' '' "$deplib" 7778f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 7779f353fbadSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7780994689c1Smrg ;; 7781994689c1Smrg prog) 77825ec34c4cSmrg if test conv = "$pass"; then 7783994689c1Smrg deplibs="$deplib $deplibs" 7784994689c1Smrg continue 7785994689c1Smrg fi 77865ec34c4cSmrg if test scan = "$pass"; then 7787994689c1Smrg deplibs="$deplib $deplibs" 7788994689c1Smrg else 7789994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7790994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7791994689c1Smrg fi 7792994689c1Smrg func_stripname '-L' '' "$deplib" 7793f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 7794f353fbadSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7795994689c1Smrg ;; 7796994689c1Smrg *) 77975ec34c4cSmrg func_warning "'-L' is ignored for archives/objects" 7798994689c1Smrg ;; 7799994689c1Smrg esac # linkmode 7800994689c1Smrg continue 7801994689c1Smrg ;; # -L 7802994689c1Smrg -R*) 78035ec34c4cSmrg if test link = "$pass"; then 7804994689c1Smrg func_stripname '-R' '' "$deplib" 7805f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 7806f353fbadSmrg dir=$func_resolve_sysroot_result 7807994689c1Smrg # Make sure the xrpath contains only unique directories. 7808994689c1Smrg case "$xrpath " in 7809994689c1Smrg *" $dir "*) ;; 7810f353fbadSmrg *) func_append xrpath " $dir" ;; 7811994689c1Smrg esac 7812994689c1Smrg fi 7813994689c1Smrg deplibs="$deplib $deplibs" 7814994689c1Smrg continue 7815994689c1Smrg ;; 7816f353fbadSmrg *.la) 7817f353fbadSmrg func_resolve_sysroot "$deplib" 7818f353fbadSmrg lib=$func_resolve_sysroot_result 7819f353fbadSmrg ;; 7820994689c1Smrg *.$libext) 78215ec34c4cSmrg if test conv = "$pass"; then 7822994689c1Smrg deplibs="$deplib $deplibs" 7823994689c1Smrg continue 7824994689c1Smrg fi 7825994689c1Smrg case $linkmode in 7826994689c1Smrg lib) 7827994689c1Smrg # Linking convenience modules into shared libraries is allowed, 7828994689c1Smrg # but linking other static libraries is non-portable. 7829994689c1Smrg case " $dlpreconveniencelibs " in 7830994689c1Smrg *" $deplib "*) ;; 7831994689c1Smrg *) 78325ec34c4cSmrg valid_a_lib=false 7833994689c1Smrg case $deplibs_check_method in 7834994689c1Smrg match_pattern*) 7835994689c1Smrg set dummy $deplibs_check_method; shift 7836994689c1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7837994689c1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7838994689c1Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 78395ec34c4cSmrg valid_a_lib=: 7840994689c1Smrg fi 7841994689c1Smrg ;; 7842994689c1Smrg pass_all) 78435ec34c4cSmrg valid_a_lib=: 7844994689c1Smrg ;; 7845994689c1Smrg esac 78465ec34c4cSmrg if $valid_a_lib; then 78475ec34c4cSmrg echo 78485ec34c4cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 78495ec34c4cSmrg $ECHO "*** static library $deplib is not portable!" 78505ec34c4cSmrg deplibs="$deplib $deplibs" 78515ec34c4cSmrg else 7852994689c1Smrg echo 7853994689c1Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7854994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 7855994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 7856994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 7857994689c1Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 7858994689c1Smrg echo "*** that it is just a static archive that I should not use here." 7859994689c1Smrg fi 7860994689c1Smrg ;; 7861994689c1Smrg esac 7862994689c1Smrg continue 7863994689c1Smrg ;; 7864994689c1Smrg prog) 78655ec34c4cSmrg if test link != "$pass"; then 7866994689c1Smrg deplibs="$deplib $deplibs" 7867994689c1Smrg else 7868994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7869994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7870994689c1Smrg fi 7871994689c1Smrg continue 7872994689c1Smrg ;; 7873994689c1Smrg esac # linkmode 7874994689c1Smrg ;; # *.$libext 7875994689c1Smrg *.lo | *.$objext) 78765ec34c4cSmrg if test conv = "$pass"; then 7877994689c1Smrg deplibs="$deplib $deplibs" 78785ec34c4cSmrg elif test prog = "$linkmode"; then 78795ec34c4cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7880994689c1Smrg # If there is no dlopen support or we're linking statically, 7881994689c1Smrg # we need to preload. 7882f353fbadSmrg func_append newdlprefiles " $deplib" 7883994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7884994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7885994689c1Smrg else 7886f353fbadSmrg func_append newdlfiles " $deplib" 7887994689c1Smrg fi 7888994689c1Smrg fi 7889994689c1Smrg continue 7890994689c1Smrg ;; 7891994689c1Smrg %DEPLIBS%) 78925ec34c4cSmrg alldeplibs=: 7893994689c1Smrg continue 7894994689c1Smrg ;; 7895994689c1Smrg esac # case $deplib 7896994689c1Smrg 78975ec34c4cSmrg $found || test -f "$lib" \ 78985ec34c4cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7899994689c1Smrg 7900994689c1Smrg # Check to see that this really is a libtool archive. 7901994689c1Smrg func_lalib_unsafe_p "$lib" \ 79025ec34c4cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7903994689c1Smrg 7904994689c1Smrg func_dirname "$lib" "" "." 79055ec34c4cSmrg ladir=$func_dirname_result 7906994689c1Smrg 7907994689c1Smrg dlname= 7908994689c1Smrg dlopen= 7909994689c1Smrg dlpreopen= 7910994689c1Smrg libdir= 7911994689c1Smrg library_names= 7912994689c1Smrg old_library= 7913994689c1Smrg inherited_linker_flags= 7914994689c1Smrg # If the library was installed with an old release of libtool, 7915994689c1Smrg # it will not redefine variables installed, or shouldnotlink 7916994689c1Smrg installed=yes 7917994689c1Smrg shouldnotlink=no 7918994689c1Smrg avoidtemprpath= 7919994689c1Smrg 7920994689c1Smrg 7921994689c1Smrg # Read the .la file 7922994689c1Smrg func_source "$lib" 7923994689c1Smrg 7924994689c1Smrg # Convert "-framework foo" to "foo.ltframework" 7925994689c1Smrg if test -n "$inherited_linker_flags"; then 7926994689c1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7927994689c1Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7928994689c1Smrg case " $new_inherited_linker_flags " in 7929994689c1Smrg *" $tmp_inherited_linker_flag "*) ;; 7930f353fbadSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7931994689c1Smrg esac 7932994689c1Smrg done 7933994689c1Smrg fi 7934994689c1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 79355ec34c4cSmrg if test lib,link = "$linkmode,$pass" || 79365ec34c4cSmrg test prog,scan = "$linkmode,$pass" || 79375ec34c4cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7938f353fbadSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7939f353fbadSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7940994689c1Smrg fi 7941994689c1Smrg 79425ec34c4cSmrg if test conv = "$pass"; then 7943994689c1Smrg # Only check for convenience libraries 7944994689c1Smrg deplibs="$lib $deplibs" 7945994689c1Smrg if test -z "$libdir"; then 7946994689c1Smrg if test -z "$old_library"; then 79475ec34c4cSmrg func_fatal_error "cannot find name of link library for '$lib'" 7948994689c1Smrg fi 7949994689c1Smrg # It is a libtool convenience library, so add in its objects. 7950f353fbadSmrg func_append convenience " $ladir/$objdir/$old_library" 7951f353fbadSmrg func_append old_convenience " $ladir/$objdir/$old_library" 79525ec34c4cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 79535ec34c4cSmrg func_fatal_error "'$lib' is not a convenience library" 7954994689c1Smrg fi 7955994689c1Smrg tmp_libs= 7956994689c1Smrg for deplib in $dependency_libs; do 7957994689c1Smrg deplibs="$deplib $deplibs" 79585ec34c4cSmrg if $opt_preserve_dup_deps; then 7959994689c1Smrg case "$tmp_libs " in 7960f353fbadSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7961994689c1Smrg esac 7962994689c1Smrg fi 7963f353fbadSmrg func_append tmp_libs " $deplib" 7964994689c1Smrg done 7965994689c1Smrg continue 7966994689c1Smrg fi # $pass = conv 7967994689c1Smrg 7968994689c1Smrg 7969994689c1Smrg # Get the name of the library we link against. 7970994689c1Smrg linklib= 7971f353fbadSmrg if test -n "$old_library" && 79725ec34c4cSmrg { test yes = "$prefer_static_libs" || 79735ec34c4cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7974f353fbadSmrg linklib=$old_library 7975f353fbadSmrg else 7976f353fbadSmrg for l in $old_library $library_names; do 79775ec34c4cSmrg linklib=$l 7978f353fbadSmrg done 7979f353fbadSmrg fi 7980994689c1Smrg if test -z "$linklib"; then 79815ec34c4cSmrg func_fatal_error "cannot find name of link library for '$lib'" 7982994689c1Smrg fi 7983994689c1Smrg 7984994689c1Smrg # This library was specified with -dlopen. 79855ec34c4cSmrg if test dlopen = "$pass"; then 79865ec34c4cSmrg test -z "$libdir" \ 79875ec34c4cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7988994689c1Smrg if test -z "$dlname" || 79895ec34c4cSmrg test yes != "$dlopen_support" || 79905ec34c4cSmrg test no = "$build_libtool_libs" 79915ec34c4cSmrg then 7992994689c1Smrg # If there is no dlname, no dlopen support or we're linking 7993994689c1Smrg # statically, we need to preload. We also need to preload any 7994994689c1Smrg # dependent libraries so libltdl's deplib preloader doesn't 7995994689c1Smrg # bomb out in the load deplibs phase. 7996f353fbadSmrg func_append dlprefiles " $lib $dependency_libs" 7997994689c1Smrg else 7998f353fbadSmrg func_append newdlfiles " $lib" 7999994689c1Smrg fi 8000994689c1Smrg continue 8001994689c1Smrg fi # $pass = dlopen 8002994689c1Smrg 8003994689c1Smrg # We need an absolute path. 8004994689c1Smrg case $ladir in 80055ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8006994689c1Smrg *) 8007994689c1Smrg abs_ladir=`cd "$ladir" && pwd` 8008994689c1Smrg if test -z "$abs_ladir"; then 80095ec34c4cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8010994689c1Smrg func_warning "passing it literally to the linker, although it might fail" 80115ec34c4cSmrg abs_ladir=$ladir 8012994689c1Smrg fi 8013994689c1Smrg ;; 8014994689c1Smrg esac 8015994689c1Smrg func_basename "$lib" 80165ec34c4cSmrg laname=$func_basename_result 8017994689c1Smrg 8018994689c1Smrg # Find the relevant object directory and library name. 80195ec34c4cSmrg if test yes = "$installed"; then 8020f353fbadSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 80215ec34c4cSmrg func_warning "library '$lib' was moved." 80225ec34c4cSmrg dir=$ladir 80235ec34c4cSmrg absdir=$abs_ladir 80245ec34c4cSmrg libdir=$abs_ladir 8025994689c1Smrg else 80265ec34c4cSmrg dir=$lt_sysroot$libdir 80275ec34c4cSmrg absdir=$lt_sysroot$libdir 8028994689c1Smrg fi 80295ec34c4cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8030994689c1Smrg else 8031994689c1Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 80325ec34c4cSmrg dir=$ladir 80335ec34c4cSmrg absdir=$abs_ladir 8034994689c1Smrg # Remove this search path later 8035f353fbadSmrg func_append notinst_path " $abs_ladir" 8036994689c1Smrg else 80375ec34c4cSmrg dir=$ladir/$objdir 80385ec34c4cSmrg absdir=$abs_ladir/$objdir 8039994689c1Smrg # Remove this search path later 8040f353fbadSmrg func_append notinst_path " $abs_ladir" 8041994689c1Smrg fi 8042994689c1Smrg fi # $installed = yes 8043994689c1Smrg func_stripname 'lib' '.la' "$laname" 8044994689c1Smrg name=$func_stripname_result 8045994689c1Smrg 8046994689c1Smrg # This library was specified with -dlpreopen. 80475ec34c4cSmrg if test dlpreopen = "$pass"; then 80485ec34c4cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 80495ec34c4cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8050994689c1Smrg fi 80515ec34c4cSmrg case $host in 8052f353fbadSmrg # special handling for platforms with PE-DLLs. 8053f353fbadSmrg *cygwin* | *mingw* | *cegcc* ) 8054f353fbadSmrg # Linker will automatically link against shared library if both 8055f353fbadSmrg # static and shared are present. Therefore, ensure we extract 8056f353fbadSmrg # symbols from the import library if a shared library is present 8057f353fbadSmrg # (otherwise, the dlopen module name will be incorrect). We do 8058f353fbadSmrg # this by putting the import library name into $newdlprefiles. 8059f353fbadSmrg # We recover the dlopen module name by 'saving' the la file 8060f353fbadSmrg # name in a special purpose variable, and (later) extracting the 8061f353fbadSmrg # dlname from the la file. 8062f353fbadSmrg if test -n "$dlname"; then 8063f353fbadSmrg func_tr_sh "$dir/$linklib" 8064f353fbadSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8065f353fbadSmrg func_append newdlprefiles " $dir/$linklib" 8066f353fbadSmrg else 8067f353fbadSmrg func_append newdlprefiles " $dir/$old_library" 8068f353fbadSmrg # Keep a list of preopened convenience libraries to check 8069f353fbadSmrg # that they are being used correctly in the link pass. 8070f353fbadSmrg test -z "$libdir" && \ 8071f353fbadSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8072f353fbadSmrg fi 8073f353fbadSmrg ;; 8074f353fbadSmrg * ) 8075f353fbadSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8076f353fbadSmrg # are required to link). 8077f353fbadSmrg if test -n "$old_library"; then 8078f353fbadSmrg func_append newdlprefiles " $dir/$old_library" 8079f353fbadSmrg # Keep a list of preopened convenience libraries to check 8080f353fbadSmrg # that they are being used correctly in the link pass. 8081f353fbadSmrg test -z "$libdir" && \ 8082f353fbadSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8083f353fbadSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8084f353fbadSmrg elif test -n "$dlname"; then 8085f353fbadSmrg func_append newdlprefiles " $dir/$dlname" 8086f353fbadSmrg else 8087f353fbadSmrg func_append newdlprefiles " $dir/$linklib" 8088f353fbadSmrg fi 8089f353fbadSmrg ;; 8090f353fbadSmrg esac 8091994689c1Smrg fi # $pass = dlpreopen 8092994689c1Smrg 8093994689c1Smrg if test -z "$libdir"; then 8094994689c1Smrg # Link the convenience library 80955ec34c4cSmrg if test lib = "$linkmode"; then 8096994689c1Smrg deplibs="$dir/$old_library $deplibs" 80975ec34c4cSmrg elif test prog,link = "$linkmode,$pass"; then 8098994689c1Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8099994689c1Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8100994689c1Smrg else 8101994689c1Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8102994689c1Smrg fi 8103994689c1Smrg continue 8104994689c1Smrg fi 8105994689c1Smrg 8106994689c1Smrg 81075ec34c4cSmrg if test prog = "$linkmode" && test link != "$pass"; then 8108f353fbadSmrg func_append newlib_search_path " $ladir" 8109994689c1Smrg deplibs="$lib $deplibs" 8110994689c1Smrg 81115ec34c4cSmrg linkalldeplibs=false 81125ec34c4cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 81135ec34c4cSmrg test no = "$build_libtool_libs"; then 81145ec34c4cSmrg linkalldeplibs=: 8115994689c1Smrg fi 8116994689c1Smrg 8117994689c1Smrg tmp_libs= 8118994689c1Smrg for deplib in $dependency_libs; do 8119994689c1Smrg case $deplib in 8120994689c1Smrg -L*) func_stripname '-L' '' "$deplib" 8121f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 8122f353fbadSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8123994689c1Smrg ;; 8124994689c1Smrg esac 8125994689c1Smrg # Need to link against all dependency_libs? 81265ec34c4cSmrg if $linkalldeplibs; then 8127994689c1Smrg deplibs="$deplib $deplibs" 8128994689c1Smrg else 8129994689c1Smrg # Need to hardcode shared library paths 8130994689c1Smrg # or/and link against static libraries 8131994689c1Smrg newdependency_libs="$deplib $newdependency_libs" 8132994689c1Smrg fi 81335ec34c4cSmrg if $opt_preserve_dup_deps; then 8134994689c1Smrg case "$tmp_libs " in 8135f353fbadSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8136994689c1Smrg esac 8137994689c1Smrg fi 8138f353fbadSmrg func_append tmp_libs " $deplib" 8139994689c1Smrg done # for deplib 8140994689c1Smrg continue 8141994689c1Smrg fi # $linkmode = prog... 8142994689c1Smrg 81435ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 8144994689c1Smrg if test -n "$library_names" && 81455ec34c4cSmrg { { test no = "$prefer_static_libs" || 81465ec34c4cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8147994689c1Smrg test -z "$old_library"; }; then 8148994689c1Smrg # We need to hardcode the library path 81495ec34c4cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8150994689c1Smrg # Make sure the rpath contains only unique directories. 81515ec34c4cSmrg case $temp_rpath: in 8152994689c1Smrg *"$absdir:"*) ;; 8153f353fbadSmrg *) func_append temp_rpath "$absdir:" ;; 8154994689c1Smrg esac 8155994689c1Smrg fi 8156994689c1Smrg 8157994689c1Smrg # Hardcode the library path. 8158994689c1Smrg # Skip directories that are in the system default run-time 8159994689c1Smrg # search path. 8160994689c1Smrg case " $sys_lib_dlsearch_path " in 8161994689c1Smrg *" $absdir "*) ;; 8162994689c1Smrg *) 8163994689c1Smrg case "$compile_rpath " in 8164994689c1Smrg *" $absdir "*) ;; 8165f353fbadSmrg *) func_append compile_rpath " $absdir" ;; 8166994689c1Smrg esac 8167994689c1Smrg ;; 8168994689c1Smrg esac 8169994689c1Smrg case " $sys_lib_dlsearch_path " in 8170994689c1Smrg *" $libdir "*) ;; 8171994689c1Smrg *) 8172994689c1Smrg case "$finalize_rpath " in 8173994689c1Smrg *" $libdir "*) ;; 8174f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 8175994689c1Smrg esac 8176994689c1Smrg ;; 8177994689c1Smrg esac 8178994689c1Smrg fi # $linkmode,$pass = prog,link... 8179994689c1Smrg 81805ec34c4cSmrg if $alldeplibs && 81815ec34c4cSmrg { test pass_all = "$deplibs_check_method" || 81825ec34c4cSmrg { test yes = "$build_libtool_libs" && 8183994689c1Smrg test -n "$library_names"; }; }; then 8184994689c1Smrg # We only need to search for static libraries 8185994689c1Smrg continue 8186994689c1Smrg fi 8187994689c1Smrg fi 8188994689c1Smrg 8189994689c1Smrg link_static=no # Whether the deplib will be linked statically 8190994689c1Smrg use_static_libs=$prefer_static_libs 81915ec34c4cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8192994689c1Smrg use_static_libs=no 8193994689c1Smrg fi 8194994689c1Smrg if test -n "$library_names" && 81955ec34c4cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8196994689c1Smrg case $host in 81975ec34c4cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8198994689c1Smrg # No point in relinking DLLs because paths are not encoded 8199f353fbadSmrg func_append notinst_deplibs " $lib" 8200994689c1Smrg need_relink=no 8201994689c1Smrg ;; 8202994689c1Smrg *) 82035ec34c4cSmrg if test no = "$installed"; then 8204f353fbadSmrg func_append notinst_deplibs " $lib" 8205994689c1Smrg need_relink=yes 8206994689c1Smrg fi 8207994689c1Smrg ;; 8208994689c1Smrg esac 8209994689c1Smrg # This is a shared library 8210994689c1Smrg 8211994689c1Smrg # Warn about portability, can't link against -module's on some 8212994689c1Smrg # systems (darwin). Don't bleat about dlopened modules though! 82135ec34c4cSmrg dlopenmodule= 8214994689c1Smrg for dlpremoduletest in $dlprefiles; do 8215994689c1Smrg if test "X$dlpremoduletest" = "X$lib"; then 82165ec34c4cSmrg dlopenmodule=$dlpremoduletest 8217994689c1Smrg break 8218994689c1Smrg fi 8219994689c1Smrg done 82205ec34c4cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8221994689c1Smrg echo 82225ec34c4cSmrg if test prog = "$linkmode"; then 8223994689c1Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8224994689c1Smrg else 8225994689c1Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8226994689c1Smrg fi 8227994689c1Smrg $ECHO "*** $linklib is not portable!" 8228994689c1Smrg fi 82295ec34c4cSmrg if test lib = "$linkmode" && 82305ec34c4cSmrg test yes = "$hardcode_into_libs"; then 8231994689c1Smrg # Hardcode the library path. 8232994689c1Smrg # Skip directories that are in the system default run-time 8233994689c1Smrg # search path. 8234994689c1Smrg case " $sys_lib_dlsearch_path " in 8235994689c1Smrg *" $absdir "*) ;; 8236994689c1Smrg *) 8237994689c1Smrg case "$compile_rpath " in 8238994689c1Smrg *" $absdir "*) ;; 8239f353fbadSmrg *) func_append compile_rpath " $absdir" ;; 8240994689c1Smrg esac 8241994689c1Smrg ;; 8242994689c1Smrg esac 8243994689c1Smrg case " $sys_lib_dlsearch_path " in 8244994689c1Smrg *" $libdir "*) ;; 8245994689c1Smrg *) 8246994689c1Smrg case "$finalize_rpath " in 8247994689c1Smrg *" $libdir "*) ;; 8248f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 8249994689c1Smrg esac 8250994689c1Smrg ;; 8251994689c1Smrg esac 8252994689c1Smrg fi 8253994689c1Smrg 8254994689c1Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8255994689c1Smrg # figure out the soname 8256994689c1Smrg set dummy $library_names 8257994689c1Smrg shift 82585ec34c4cSmrg realname=$1 8259994689c1Smrg shift 8260994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8261994689c1Smrg # use dlname if we got it. it's perfectly good, no? 8262994689c1Smrg if test -n "$dlname"; then 82635ec34c4cSmrg soname=$dlname 8264994689c1Smrg elif test -n "$soname_spec"; then 8265994689c1Smrg # bleh windows 8266994689c1Smrg case $host in 82675ec34c4cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8268994689c1Smrg func_arith $current - $age 8269994689c1Smrg major=$func_arith_result 82705ec34c4cSmrg versuffix=-$major 8271994689c1Smrg ;; 8272994689c1Smrg esac 8273994689c1Smrg eval soname=\"$soname_spec\" 8274994689c1Smrg else 82755ec34c4cSmrg soname=$realname 8276994689c1Smrg fi 8277994689c1Smrg 8278994689c1Smrg # Make a new name for the extract_expsyms_cmds to use 82795ec34c4cSmrg soroot=$soname 8280994689c1Smrg func_basename "$soroot" 82815ec34c4cSmrg soname=$func_basename_result 8282994689c1Smrg func_stripname 'lib' '.dll' "$soname" 8283994689c1Smrg newlib=libimp-$func_stripname_result.a 8284994689c1Smrg 8285994689c1Smrg # If the library has no export list, then create one now 8286994689c1Smrg if test -f "$output_objdir/$soname-def"; then : 8287994689c1Smrg else 82885ec34c4cSmrg func_verbose "extracting exported symbol list from '$soname'" 8289994689c1Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8290994689c1Smrg fi 8291994689c1Smrg 8292994689c1Smrg # Create $newlib 8293994689c1Smrg if test -f "$output_objdir/$newlib"; then :; else 82945ec34c4cSmrg func_verbose "generating import library for '$soname'" 8295994689c1Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8296994689c1Smrg fi 8297994689c1Smrg # make sure the library variables are pointing to the new library 8298994689c1Smrg dir=$output_objdir 8299994689c1Smrg linklib=$newlib 8300994689c1Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8301994689c1Smrg 83025ec34c4cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8303994689c1Smrg add_shlibpath= 8304994689c1Smrg add_dir= 8305994689c1Smrg add= 8306994689c1Smrg lib_linked=yes 8307994689c1Smrg case $hardcode_action in 8308994689c1Smrg immediate | unsupported) 83095ec34c4cSmrg if test no = "$hardcode_direct"; then 83105ec34c4cSmrg add=$dir/$linklib 8311994689c1Smrg case $host in 83125ec34c4cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 83135ec34c4cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8314994689c1Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 83155ec34c4cSmrg *-*-unixware7*) add_dir=-L$dir ;; 8316994689c1Smrg *-*-darwin* ) 83175ec34c4cSmrg # if the lib is a (non-dlopened) module then we cannot 8318994689c1Smrg # link against it, someone is ignoring the earlier warnings 8319994689c1Smrg if /usr/bin/file -L $add 2> /dev/null | 83205ec34c4cSmrg $GREP ": [^:]* bundle" >/dev/null; then 8321994689c1Smrg if test "X$dlopenmodule" != "X$lib"; then 8322994689c1Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 83235ec34c4cSmrg if test -z "$old_library"; then 8324994689c1Smrg echo 8325994689c1Smrg echo "*** And there doesn't seem to be a static archive available" 8326994689c1Smrg echo "*** The link will probably fail, sorry" 8327994689c1Smrg else 83285ec34c4cSmrg add=$dir/$old_library 8329994689c1Smrg fi 8330994689c1Smrg elif test -n "$old_library"; then 83315ec34c4cSmrg add=$dir/$old_library 8332994689c1Smrg fi 8333994689c1Smrg fi 8334994689c1Smrg esac 83355ec34c4cSmrg elif test no = "$hardcode_minus_L"; then 8336994689c1Smrg case $host in 83375ec34c4cSmrg *-*-sunos*) add_shlibpath=$dir ;; 8338994689c1Smrg esac 83395ec34c4cSmrg add_dir=-L$dir 83405ec34c4cSmrg add=-l$name 83415ec34c4cSmrg elif test no = "$hardcode_shlibpath_var"; then 83425ec34c4cSmrg add_shlibpath=$dir 83435ec34c4cSmrg add=-l$name 8344994689c1Smrg else 8345994689c1Smrg lib_linked=no 8346994689c1Smrg fi 8347994689c1Smrg ;; 8348994689c1Smrg relink) 83495ec34c4cSmrg if test yes = "$hardcode_direct" && 83505ec34c4cSmrg test no = "$hardcode_direct_absolute"; then 83515ec34c4cSmrg add=$dir/$linklib 83525ec34c4cSmrg elif test yes = "$hardcode_minus_L"; then 83535ec34c4cSmrg add_dir=-L$absdir 8354994689c1Smrg # Try looking first in the location we're being installed to. 8355994689c1Smrg if test -n "$inst_prefix_dir"; then 8356994689c1Smrg case $libdir in 8357994689c1Smrg [\\/]*) 8358f353fbadSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8359994689c1Smrg ;; 8360994689c1Smrg esac 8361994689c1Smrg fi 83625ec34c4cSmrg add=-l$name 83635ec34c4cSmrg elif test yes = "$hardcode_shlibpath_var"; then 83645ec34c4cSmrg add_shlibpath=$dir 83655ec34c4cSmrg add=-l$name 8366994689c1Smrg else 8367994689c1Smrg lib_linked=no 8368994689c1Smrg fi 8369994689c1Smrg ;; 8370994689c1Smrg *) lib_linked=no ;; 8371994689c1Smrg esac 8372994689c1Smrg 83735ec34c4cSmrg if test yes != "$lib_linked"; then 8374994689c1Smrg func_fatal_configuration "unsupported hardcode properties" 8375994689c1Smrg fi 8376994689c1Smrg 8377994689c1Smrg if test -n "$add_shlibpath"; then 8378994689c1Smrg case :$compile_shlibpath: in 8379994689c1Smrg *":$add_shlibpath:"*) ;; 8380f353fbadSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8381994689c1Smrg esac 8382994689c1Smrg fi 83835ec34c4cSmrg if test prog = "$linkmode"; then 8384994689c1Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8385994689c1Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8386994689c1Smrg else 8387994689c1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8388994689c1Smrg test -n "$add" && deplibs="$add $deplibs" 83895ec34c4cSmrg if test yes != "$hardcode_direct" && 83905ec34c4cSmrg test yes != "$hardcode_minus_L" && 83915ec34c4cSmrg test yes = "$hardcode_shlibpath_var"; then 8392994689c1Smrg case :$finalize_shlibpath: in 8393994689c1Smrg *":$libdir:"*) ;; 8394f353fbadSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8395994689c1Smrg esac 8396994689c1Smrg fi 8397994689c1Smrg fi 8398994689c1Smrg fi 8399994689c1Smrg 84005ec34c4cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8401994689c1Smrg add_shlibpath= 8402994689c1Smrg add_dir= 8403994689c1Smrg add= 8404994689c1Smrg # Finalize command for both is simple: just hardcode it. 84055ec34c4cSmrg if test yes = "$hardcode_direct" && 84065ec34c4cSmrg test no = "$hardcode_direct_absolute"; then 84075ec34c4cSmrg add=$libdir/$linklib 84085ec34c4cSmrg elif test yes = "$hardcode_minus_L"; then 84095ec34c4cSmrg add_dir=-L$libdir 84105ec34c4cSmrg add=-l$name 84115ec34c4cSmrg elif test yes = "$hardcode_shlibpath_var"; then 8412994689c1Smrg case :$finalize_shlibpath: in 8413994689c1Smrg *":$libdir:"*) ;; 8414f353fbadSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8415994689c1Smrg esac 84165ec34c4cSmrg add=-l$name 84175ec34c4cSmrg elif test yes = "$hardcode_automatic"; then 8418994689c1Smrg if test -n "$inst_prefix_dir" && 84195ec34c4cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 84205ec34c4cSmrg add=$inst_prefix_dir$libdir/$linklib 8421994689c1Smrg else 84225ec34c4cSmrg add=$libdir/$linklib 8423994689c1Smrg fi 8424994689c1Smrg else 8425994689c1Smrg # We cannot seem to hardcode it, guess we'll fake it. 84265ec34c4cSmrg add_dir=-L$libdir 8427994689c1Smrg # Try looking first in the location we're being installed to. 8428994689c1Smrg if test -n "$inst_prefix_dir"; then 8429994689c1Smrg case $libdir in 8430994689c1Smrg [\\/]*) 8431f353fbadSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8432994689c1Smrg ;; 8433994689c1Smrg esac 8434994689c1Smrg fi 84355ec34c4cSmrg add=-l$name 8436994689c1Smrg fi 8437994689c1Smrg 84385ec34c4cSmrg if test prog = "$linkmode"; then 8439994689c1Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8440994689c1Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8441994689c1Smrg else 8442994689c1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8443994689c1Smrg test -n "$add" && deplibs="$add $deplibs" 8444994689c1Smrg fi 8445994689c1Smrg fi 84465ec34c4cSmrg elif test prog = "$linkmode"; then 8447994689c1Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8448994689c1Smrg # is not unsupported. This is valid on all known static and 8449994689c1Smrg # shared platforms. 84505ec34c4cSmrg if test unsupported != "$hardcode_direct"; then 84515ec34c4cSmrg test -n "$old_library" && linklib=$old_library 8452994689c1Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8453994689c1Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8454994689c1Smrg else 8455994689c1Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8456994689c1Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8457994689c1Smrg fi 84585ec34c4cSmrg elif test yes = "$build_libtool_libs"; then 8459994689c1Smrg # Not a shared library 84605ec34c4cSmrg if test pass_all != "$deplibs_check_method"; then 8461994689c1Smrg # We're trying link a shared library against a static one 8462994689c1Smrg # but the system doesn't support it. 8463994689c1Smrg 8464994689c1Smrg # Just print a warning and add the library to dependency_libs so 8465994689c1Smrg # that the program can be linked against the static library. 8466994689c1Smrg echo 84675ec34c4cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8468994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 8469994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 8470994689c1Smrg echo "*** shared version of the library, which you do not appear to have." 84715ec34c4cSmrg if test yes = "$module"; then 8472994689c1Smrg echo "*** But as you try to build a module library, libtool will still create " 8473994689c1Smrg echo "*** a static module, that should work as long as the dlopening application" 8474994689c1Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8475994689c1Smrg if test -z "$global_symbol_pipe"; then 8476994689c1Smrg echo 8477994689c1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 84785ec34c4cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8479994689c1Smrg echo "*** not find such a program. So, this module is probably useless." 84805ec34c4cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8481994689c1Smrg fi 84825ec34c4cSmrg if test no = "$build_old_libs"; then 8483994689c1Smrg build_libtool_libs=module 8484994689c1Smrg build_old_libs=yes 8485994689c1Smrg else 8486994689c1Smrg build_libtool_libs=no 8487994689c1Smrg fi 8488994689c1Smrg fi 8489994689c1Smrg else 8490994689c1Smrg deplibs="$dir/$old_library $deplibs" 8491994689c1Smrg link_static=yes 8492994689c1Smrg fi 8493994689c1Smrg fi # link shared/static library? 8494994689c1Smrg 84955ec34c4cSmrg if test lib = "$linkmode"; then 8496994689c1Smrg if test -n "$dependency_libs" && 84975ec34c4cSmrg { test yes != "$hardcode_into_libs" || 84985ec34c4cSmrg test yes = "$build_old_libs" || 84995ec34c4cSmrg test yes = "$link_static"; }; then 8500994689c1Smrg # Extract -R from dependency_libs 8501994689c1Smrg temp_deplibs= 8502994689c1Smrg for libdir in $dependency_libs; do 8503994689c1Smrg case $libdir in 8504994689c1Smrg -R*) func_stripname '-R' '' "$libdir" 8505994689c1Smrg temp_xrpath=$func_stripname_result 8506994689c1Smrg case " $xrpath " in 8507994689c1Smrg *" $temp_xrpath "*) ;; 8508f353fbadSmrg *) func_append xrpath " $temp_xrpath";; 8509994689c1Smrg esac;; 8510f353fbadSmrg *) func_append temp_deplibs " $libdir";; 8511994689c1Smrg esac 8512994689c1Smrg done 85135ec34c4cSmrg dependency_libs=$temp_deplibs 8514994689c1Smrg fi 8515994689c1Smrg 8516f353fbadSmrg func_append newlib_search_path " $absdir" 8517994689c1Smrg # Link against this library 85185ec34c4cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8519994689c1Smrg # ... and its dependency_libs 8520994689c1Smrg tmp_libs= 8521994689c1Smrg for deplib in $dependency_libs; do 8522994689c1Smrg newdependency_libs="$deplib $newdependency_libs" 8523f353fbadSmrg case $deplib in 8524f353fbadSmrg -L*) func_stripname '-L' '' "$deplib" 8525f353fbadSmrg func_resolve_sysroot "$func_stripname_result";; 8526f353fbadSmrg *) func_resolve_sysroot "$deplib" ;; 8527f353fbadSmrg esac 85285ec34c4cSmrg if $opt_preserve_dup_deps; then 8529994689c1Smrg case "$tmp_libs " in 8530f353fbadSmrg *" $func_resolve_sysroot_result "*) 8531f353fbadSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8532994689c1Smrg esac 8533994689c1Smrg fi 8534f353fbadSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8535994689c1Smrg done 8536994689c1Smrg 85375ec34c4cSmrg if test no != "$link_all_deplibs"; then 8538994689c1Smrg # Add the search paths of all dependency libraries 8539994689c1Smrg for deplib in $dependency_libs; do 8540994689c1Smrg path= 8541994689c1Smrg case $deplib in 85425ec34c4cSmrg -L*) path=$deplib ;; 8543994689c1Smrg *.la) 8544f353fbadSmrg func_resolve_sysroot "$deplib" 8545f353fbadSmrg deplib=$func_resolve_sysroot_result 8546994689c1Smrg func_dirname "$deplib" "" "." 8547f353fbadSmrg dir=$func_dirname_result 8548994689c1Smrg # We need an absolute path. 8549994689c1Smrg case $dir in 85505ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8551994689c1Smrg *) 8552994689c1Smrg absdir=`cd "$dir" && pwd` 8553994689c1Smrg if test -z "$absdir"; then 85545ec34c4cSmrg func_warning "cannot determine absolute directory name of '$dir'" 85555ec34c4cSmrg absdir=$dir 8556994689c1Smrg fi 8557994689c1Smrg ;; 8558994689c1Smrg esac 8559994689c1Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8560994689c1Smrg case $host in 8561994689c1Smrg *-*-darwin*) 8562994689c1Smrg depdepl= 85635ec34c4cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 85645ec34c4cSmrg if test -n "$deplibrary_names"; then 85655ec34c4cSmrg for tmp in $deplibrary_names; do 8566994689c1Smrg depdepl=$tmp 8567994689c1Smrg done 85685ec34c4cSmrg if test -f "$absdir/$objdir/$depdepl"; then 85695ec34c4cSmrg depdepl=$absdir/$objdir/$depdepl 85705ec34c4cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8571994689c1Smrg if test -z "$darwin_install_name"; then 85725ec34c4cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8573994689c1Smrg fi 85745ec34c4cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 85755ec34c4cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8576994689c1Smrg path= 8577994689c1Smrg fi 8578994689c1Smrg fi 8579994689c1Smrg ;; 8580994689c1Smrg *) 85815ec34c4cSmrg path=-L$absdir/$objdir 8582994689c1Smrg ;; 8583994689c1Smrg esac 8584994689c1Smrg else 85855ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8586994689c1Smrg test -z "$libdir" && \ 85875ec34c4cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8588994689c1Smrg test "$absdir" != "$libdir" && \ 85895ec34c4cSmrg func_warning "'$deplib' seems to be moved" 8590994689c1Smrg 85915ec34c4cSmrg path=-L$absdir 8592994689c1Smrg fi 8593994689c1Smrg ;; 8594994689c1Smrg esac 8595994689c1Smrg case " $deplibs " in 8596994689c1Smrg *" $path "*) ;; 8597994689c1Smrg *) deplibs="$path $deplibs" ;; 8598994689c1Smrg esac 8599994689c1Smrg done 8600994689c1Smrg fi # link_all_deplibs != no 8601994689c1Smrg fi # linkmode = lib 8602994689c1Smrg done # for deplib in $libs 86035ec34c4cSmrg if test link = "$pass"; then 86045ec34c4cSmrg if test prog = "$linkmode"; then 8605994689c1Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8606994689c1Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8607994689c1Smrg else 8608994689c1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8609994689c1Smrg fi 8610994689c1Smrg fi 86115ec34c4cSmrg dependency_libs=$newdependency_libs 86125ec34c4cSmrg if test dlpreopen = "$pass"; then 8613994689c1Smrg # Link the dlpreopened libraries before other libraries 8614994689c1Smrg for deplib in $save_deplibs; do 8615994689c1Smrg deplibs="$deplib $deplibs" 8616994689c1Smrg done 8617994689c1Smrg fi 86185ec34c4cSmrg if test dlopen != "$pass"; then 86195ec34c4cSmrg test conv = "$pass" || { 8620994689c1Smrg # Make sure lib_search_path contains only unique directories. 8621994689c1Smrg lib_search_path= 8622994689c1Smrg for dir in $newlib_search_path; do 8623994689c1Smrg case "$lib_search_path " in 8624994689c1Smrg *" $dir "*) ;; 8625f353fbadSmrg *) func_append lib_search_path " $dir" ;; 8626994689c1Smrg esac 8627994689c1Smrg done 8628994689c1Smrg newlib_search_path= 86295ec34c4cSmrg } 8630994689c1Smrg 86315ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 8632994689c1Smrg vars="compile_deplibs finalize_deplibs" 86335ec34c4cSmrg else 86345ec34c4cSmrg vars=deplibs 8635994689c1Smrg fi 8636994689c1Smrg for var in $vars dependency_libs; do 8637994689c1Smrg # Add libraries to $var in reverse order 8638994689c1Smrg eval tmp_libs=\"\$$var\" 8639994689c1Smrg new_libs= 8640994689c1Smrg for deplib in $tmp_libs; do 8641994689c1Smrg # FIXME: Pedantically, this is the right thing to do, so 8642994689c1Smrg # that some nasty dependency loop isn't accidentally 8643994689c1Smrg # broken: 8644994689c1Smrg #new_libs="$deplib $new_libs" 8645994689c1Smrg # Pragmatically, this seems to cause very few problems in 8646994689c1Smrg # practice: 8647994689c1Smrg case $deplib in 8648994689c1Smrg -L*) new_libs="$deplib $new_libs" ;; 8649994689c1Smrg -R*) ;; 8650994689c1Smrg *) 8651994689c1Smrg # And here is the reason: when a library appears more 8652994689c1Smrg # than once as an explicit dependence of a library, or 8653994689c1Smrg # is implicitly linked in more than once by the 8654994689c1Smrg # compiler, it is considered special, and multiple 8655994689c1Smrg # occurrences thereof are not removed. Compare this 8656994689c1Smrg # with having the same library being listed as a 8657994689c1Smrg # dependency of multiple other libraries: in this case, 8658994689c1Smrg # we know (pedantically, we assume) the library does not 8659994689c1Smrg # need to be listed more than once, so we keep only the 8660994689c1Smrg # last copy. This is not always right, but it is rare 8661994689c1Smrg # enough that we require users that really mean to play 8662994689c1Smrg # such unportable linking tricks to link the library 8663994689c1Smrg # using -Wl,-lname, so that libtool does not consider it 8664994689c1Smrg # for duplicate removal. 8665994689c1Smrg case " $specialdeplibs " in 8666994689c1Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8667994689c1Smrg *) 8668994689c1Smrg case " $new_libs " in 8669994689c1Smrg *" $deplib "*) ;; 8670994689c1Smrg *) new_libs="$deplib $new_libs" ;; 8671994689c1Smrg esac 8672994689c1Smrg ;; 8673994689c1Smrg esac 8674994689c1Smrg ;; 8675994689c1Smrg esac 8676994689c1Smrg done 8677994689c1Smrg tmp_libs= 8678994689c1Smrg for deplib in $new_libs; do 8679994689c1Smrg case $deplib in 8680994689c1Smrg -L*) 8681994689c1Smrg case " $tmp_libs " in 8682994689c1Smrg *" $deplib "*) ;; 8683f353fbadSmrg *) func_append tmp_libs " $deplib" ;; 8684994689c1Smrg esac 8685994689c1Smrg ;; 8686f353fbadSmrg *) func_append tmp_libs " $deplib" ;; 8687994689c1Smrg esac 8688994689c1Smrg done 8689994689c1Smrg eval $var=\"$tmp_libs\" 8690994689c1Smrg done # for var 8691994689c1Smrg fi 86925ec34c4cSmrg 86935ec34c4cSmrg # Add Sun CC postdeps if required: 86945ec34c4cSmrg test CXX = "$tagname" && { 86955ec34c4cSmrg case $host_os in 86965ec34c4cSmrg linux*) 86975ec34c4cSmrg case `$CC -V 2>&1 | sed 5q` in 86985ec34c4cSmrg *Sun\ C*) # Sun C++ 5.9 86995ec34c4cSmrg func_suncc_cstd_abi 87005ec34c4cSmrg 87015ec34c4cSmrg if test no != "$suncc_use_cstd_abi"; then 87025ec34c4cSmrg func_append postdeps ' -library=Cstd -library=Crun' 87035ec34c4cSmrg fi 87045ec34c4cSmrg ;; 87055ec34c4cSmrg esac 87065ec34c4cSmrg ;; 87075ec34c4cSmrg 87085ec34c4cSmrg solaris*) 87095ec34c4cSmrg func_cc_basename "$CC" 87105ec34c4cSmrg case $func_cc_basename_result in 87115ec34c4cSmrg CC* | sunCC*) 87125ec34c4cSmrg func_suncc_cstd_abi 87135ec34c4cSmrg 87145ec34c4cSmrg if test no != "$suncc_use_cstd_abi"; then 87155ec34c4cSmrg func_append postdeps ' -library=Cstd -library=Crun' 87165ec34c4cSmrg fi 87175ec34c4cSmrg ;; 87185ec34c4cSmrg esac 87195ec34c4cSmrg ;; 87205ec34c4cSmrg esac 87215ec34c4cSmrg } 87225ec34c4cSmrg 8723994689c1Smrg # Last step: remove runtime libs from dependency_libs 8724994689c1Smrg # (they stay in deplibs) 8725994689c1Smrg tmp_libs= 87265ec34c4cSmrg for i in $dependency_libs; do 8727994689c1Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8728994689c1Smrg *" $i "*) 87295ec34c4cSmrg i= 8730994689c1Smrg ;; 8731994689c1Smrg esac 87325ec34c4cSmrg if test -n "$i"; then 8733f353fbadSmrg func_append tmp_libs " $i" 8734994689c1Smrg fi 8735994689c1Smrg done 8736994689c1Smrg dependency_libs=$tmp_libs 8737994689c1Smrg done # for pass 87385ec34c4cSmrg if test prog = "$linkmode"; then 87395ec34c4cSmrg dlfiles=$newdlfiles 8740994689c1Smrg fi 87415ec34c4cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 87425ec34c4cSmrg dlprefiles=$newdlprefiles 8743994689c1Smrg fi 8744994689c1Smrg 8745994689c1Smrg case $linkmode in 8746994689c1Smrg oldlib) 87475ec34c4cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 87485ec34c4cSmrg func_warning "'-dlopen' is ignored for archives" 8749994689c1Smrg fi 8750994689c1Smrg 8751994689c1Smrg case " $deplibs" in 8752994689c1Smrg *\ -l* | *\ -L*) 87535ec34c4cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8754994689c1Smrg esac 8755994689c1Smrg 8756994689c1Smrg test -n "$rpath" && \ 87575ec34c4cSmrg func_warning "'-rpath' is ignored for archives" 8758994689c1Smrg 8759994689c1Smrg test -n "$xrpath" && \ 87605ec34c4cSmrg func_warning "'-R' is ignored for archives" 8761994689c1Smrg 8762994689c1Smrg test -n "$vinfo" && \ 87635ec34c4cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8764994689c1Smrg 8765994689c1Smrg test -n "$release" && \ 87665ec34c4cSmrg func_warning "'-release' is ignored for archives" 8767994689c1Smrg 8768994689c1Smrg test -n "$export_symbols$export_symbols_regex" && \ 87695ec34c4cSmrg func_warning "'-export-symbols' is ignored for archives" 8770994689c1Smrg 8771994689c1Smrg # Now set the variables for building old libraries. 8772994689c1Smrg build_libtool_libs=no 87735ec34c4cSmrg oldlibs=$output 8774f353fbadSmrg func_append objs "$old_deplibs" 8775994689c1Smrg ;; 8776994689c1Smrg 8777994689c1Smrg lib) 87785ec34c4cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8779994689c1Smrg case $outputname in 8780994689c1Smrg lib*) 8781994689c1Smrg func_stripname 'lib' '.la' "$outputname" 8782994689c1Smrg name=$func_stripname_result 8783994689c1Smrg eval shared_ext=\"$shrext_cmds\" 8784994689c1Smrg eval libname=\"$libname_spec\" 8785994689c1Smrg ;; 8786994689c1Smrg *) 87875ec34c4cSmrg test no = "$module" \ 87885ec34c4cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8789994689c1Smrg 87905ec34c4cSmrg if test no != "$need_lib_prefix"; then 8791994689c1Smrg # Add the "lib" prefix for modules if required 8792994689c1Smrg func_stripname '' '.la' "$outputname" 8793994689c1Smrg name=$func_stripname_result 8794994689c1Smrg eval shared_ext=\"$shrext_cmds\" 8795994689c1Smrg eval libname=\"$libname_spec\" 8796994689c1Smrg else 8797994689c1Smrg func_stripname '' '.la' "$outputname" 8798994689c1Smrg libname=$func_stripname_result 8799994689c1Smrg fi 8800994689c1Smrg ;; 8801994689c1Smrg esac 8802994689c1Smrg 8803994689c1Smrg if test -n "$objs"; then 88045ec34c4cSmrg if test pass_all != "$deplibs_check_method"; then 88055ec34c4cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8806994689c1Smrg else 8807994689c1Smrg echo 8808994689c1Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8809994689c1Smrg $ECHO "*** objects $objs is not portable!" 8810f353fbadSmrg func_append libobjs " $objs" 8811994689c1Smrg fi 8812994689c1Smrg fi 8813994689c1Smrg 88145ec34c4cSmrg test no = "$dlself" \ 88155ec34c4cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8816994689c1Smrg 8817994689c1Smrg set dummy $rpath 8818994689c1Smrg shift 88195ec34c4cSmrg test 1 -lt "$#" \ 88205ec34c4cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8821994689c1Smrg 88225ec34c4cSmrg install_libdir=$1 8823994689c1Smrg 8824994689c1Smrg oldlibs= 8825994689c1Smrg if test -z "$rpath"; then 88265ec34c4cSmrg if test yes = "$build_libtool_libs"; then 8827994689c1Smrg # Building a libtool convenience library. 88285ec34c4cSmrg # Some compilers have problems with a '.al' extension so 8829994689c1Smrg # convenience libraries should have the same extension an 8830994689c1Smrg # archive normally would. 8831994689c1Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8832994689c1Smrg build_libtool_libs=convenience 8833994689c1Smrg build_old_libs=yes 8834994689c1Smrg fi 8835994689c1Smrg 8836994689c1Smrg test -n "$vinfo" && \ 88375ec34c4cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8838994689c1Smrg 8839994689c1Smrg test -n "$release" && \ 88405ec34c4cSmrg func_warning "'-release' is ignored for convenience libraries" 8841994689c1Smrg else 8842994689c1Smrg 8843994689c1Smrg # Parse the version information argument. 88445ec34c4cSmrg save_ifs=$IFS; IFS=: 8845994689c1Smrg set dummy $vinfo 0 0 0 8846994689c1Smrg shift 88475ec34c4cSmrg IFS=$save_ifs 8848994689c1Smrg 8849994689c1Smrg test -n "$7" && \ 88505ec34c4cSmrg func_fatal_help "too many parameters to '-version-info'" 8851994689c1Smrg 8852994689c1Smrg # convert absolute version numbers to libtool ages 8853994689c1Smrg # this retains compatibility with .la files and attempts 8854994689c1Smrg # to make the code below a bit more comprehensible 8855994689c1Smrg 8856994689c1Smrg case $vinfo_number in 8857994689c1Smrg yes) 88585ec34c4cSmrg number_major=$1 88595ec34c4cSmrg number_minor=$2 88605ec34c4cSmrg number_revision=$3 8861994689c1Smrg # 8862994689c1Smrg # There are really only two kinds -- those that 8863994689c1Smrg # use the current revision as the major version 8864994689c1Smrg # and those that subtract age and use age as 8865994689c1Smrg # a minor version. But, then there is irix 88665ec34c4cSmrg # that has an extra 1 added just for fun 8867994689c1Smrg # 8868994689c1Smrg case $version_type in 8869421c997bSmrg # correct linux to gnu/linux during the next big refactor 88705ec34c4cSmrg darwin|freebsd-elf|linux|osf|windows|none) 8871994689c1Smrg func_arith $number_major + $number_minor 8872994689c1Smrg current=$func_arith_result 88735ec34c4cSmrg age=$number_minor 88745ec34c4cSmrg revision=$number_revision 8875994689c1Smrg ;; 88765ec34c4cSmrg freebsd-aout|qnx|sunos) 88775ec34c4cSmrg current=$number_major 88785ec34c4cSmrg revision=$number_minor 88795ec34c4cSmrg age=0 8880994689c1Smrg ;; 8881994689c1Smrg irix|nonstopux) 8882994689c1Smrg func_arith $number_major + $number_minor 8883994689c1Smrg current=$func_arith_result 88845ec34c4cSmrg age=$number_minor 88855ec34c4cSmrg revision=$number_minor 8886994689c1Smrg lt_irix_increment=no 8887994689c1Smrg ;; 8888994689c1Smrg esac 8889994689c1Smrg ;; 8890994689c1Smrg no) 88915ec34c4cSmrg current=$1 88925ec34c4cSmrg revision=$2 88935ec34c4cSmrg age=$3 8894994689c1Smrg ;; 8895994689c1Smrg esac 8896994689c1Smrg 8897994689c1Smrg # Check that each of the things are valid numbers. 8898994689c1Smrg case $current in 8899994689c1Smrg 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]) ;; 8900994689c1Smrg *) 89015ec34c4cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 89025ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 8903994689c1Smrg ;; 8904994689c1Smrg esac 8905994689c1Smrg 8906994689c1Smrg case $revision in 8907994689c1Smrg 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]) ;; 8908994689c1Smrg *) 89095ec34c4cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 89105ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 8911994689c1Smrg ;; 8912994689c1Smrg esac 8913994689c1Smrg 8914994689c1Smrg case $age in 8915994689c1Smrg 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]) ;; 8916994689c1Smrg *) 89175ec34c4cSmrg func_error "AGE '$age' must be a nonnegative integer" 89185ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 8919994689c1Smrg ;; 8920994689c1Smrg esac 8921994689c1Smrg 8922994689c1Smrg if test "$age" -gt "$current"; then 89235ec34c4cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 89245ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 8925994689c1Smrg fi 8926994689c1Smrg 8927994689c1Smrg # Calculate the version variables. 8928994689c1Smrg major= 8929994689c1Smrg versuffix= 8930994689c1Smrg verstring= 8931994689c1Smrg case $version_type in 8932994689c1Smrg none) ;; 8933994689c1Smrg 8934994689c1Smrg darwin) 8935994689c1Smrg # Like Linux, but with the current version available in 8936994689c1Smrg # verstring for coding it into the library header 8937994689c1Smrg func_arith $current - $age 8938994689c1Smrg major=.$func_arith_result 89395ec34c4cSmrg versuffix=$major.$age.$revision 8940994689c1Smrg # Darwin ld doesn't like 0 for these options... 8941994689c1Smrg func_arith $current + 1 8942994689c1Smrg minor_current=$func_arith_result 89435ec34c4cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8944994689c1Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 89455ec34c4cSmrg # On Darwin other compilers 89465ec34c4cSmrg case $CC in 89475ec34c4cSmrg nagfor*) 89485ec34c4cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 89495ec34c4cSmrg ;; 89505ec34c4cSmrg *) 89515ec34c4cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 89525ec34c4cSmrg ;; 89535ec34c4cSmrg esac 8954994689c1Smrg ;; 8955994689c1Smrg 8956994689c1Smrg freebsd-aout) 89575ec34c4cSmrg major=.$current 89585ec34c4cSmrg versuffix=.$current.$revision 8959994689c1Smrg ;; 8960994689c1Smrg 8961994689c1Smrg freebsd-elf) 89625ec34c4cSmrg func_arith $current - $age 89635ec34c4cSmrg major=.$func_arith_result 89645ec34c4cSmrg versuffix=$major.$age.$revision 8965994689c1Smrg ;; 8966994689c1Smrg 8967994689c1Smrg irix | nonstopux) 89685ec34c4cSmrg if test no = "$lt_irix_increment"; then 8969994689c1Smrg func_arith $current - $age 8970994689c1Smrg else 8971994689c1Smrg func_arith $current - $age + 1 8972994689c1Smrg fi 8973994689c1Smrg major=$func_arith_result 8974994689c1Smrg 8975994689c1Smrg case $version_type in 8976994689c1Smrg nonstopux) verstring_prefix=nonstopux ;; 8977994689c1Smrg *) verstring_prefix=sgi ;; 8978994689c1Smrg esac 89795ec34c4cSmrg verstring=$verstring_prefix$major.$revision 8980994689c1Smrg 8981994689c1Smrg # Add in all the interfaces that we are compatible with. 8982994689c1Smrg loop=$revision 89835ec34c4cSmrg while test 0 -ne "$loop"; do 8984994689c1Smrg func_arith $revision - $loop 8985994689c1Smrg iface=$func_arith_result 8986994689c1Smrg func_arith $loop - 1 8987994689c1Smrg loop=$func_arith_result 89885ec34c4cSmrg verstring=$verstring_prefix$major.$iface:$verstring 8989994689c1Smrg done 8990994689c1Smrg 89915ec34c4cSmrg # Before this point, $major must not contain '.'. 8992994689c1Smrg major=.$major 89935ec34c4cSmrg versuffix=$major.$revision 8994994689c1Smrg ;; 8995994689c1Smrg 8996421c997bSmrg linux) # correct to gnu/linux during the next big refactor 8997994689c1Smrg func_arith $current - $age 8998994689c1Smrg major=.$func_arith_result 89995ec34c4cSmrg versuffix=$major.$age.$revision 9000994689c1Smrg ;; 9001994689c1Smrg 9002994689c1Smrg osf) 9003994689c1Smrg func_arith $current - $age 9004994689c1Smrg major=.$func_arith_result 90055ec34c4cSmrg versuffix=.$current.$age.$revision 90065ec34c4cSmrg verstring=$current.$age.$revision 9007994689c1Smrg 9008994689c1Smrg # Add in all the interfaces that we are compatible with. 9009994689c1Smrg loop=$age 90105ec34c4cSmrg while test 0 -ne "$loop"; do 9011994689c1Smrg func_arith $current - $loop 9012994689c1Smrg iface=$func_arith_result 9013994689c1Smrg func_arith $loop - 1 9014994689c1Smrg loop=$func_arith_result 90155ec34c4cSmrg verstring=$verstring:$iface.0 9016994689c1Smrg done 9017994689c1Smrg 9018994689c1Smrg # Make executables depend on our current version. 90195ec34c4cSmrg func_append verstring ":$current.0" 9020994689c1Smrg ;; 9021994689c1Smrg 9022994689c1Smrg qnx) 90235ec34c4cSmrg major=.$current 90245ec34c4cSmrg versuffix=.$current 90255ec34c4cSmrg ;; 90265ec34c4cSmrg 90275ec34c4cSmrg sco) 90285ec34c4cSmrg major=.$current 90295ec34c4cSmrg versuffix=.$current 9030994689c1Smrg ;; 9031994689c1Smrg 9032994689c1Smrg sunos) 90335ec34c4cSmrg major=.$current 90345ec34c4cSmrg versuffix=.$current.$revision 9035994689c1Smrg ;; 9036994689c1Smrg 9037994689c1Smrg windows) 9038994689c1Smrg # Use '-' rather than '.', since we only want one 90395ec34c4cSmrg # extension on DOS 8.3 file systems. 9040994689c1Smrg func_arith $current - $age 9041994689c1Smrg major=$func_arith_result 90425ec34c4cSmrg versuffix=-$major 9043994689c1Smrg ;; 9044994689c1Smrg 9045994689c1Smrg *) 90465ec34c4cSmrg func_fatal_configuration "unknown library version type '$version_type'" 9047994689c1Smrg ;; 9048994689c1Smrg esac 9049994689c1Smrg 9050994689c1Smrg # Clear the version info if we defaulted, and they specified a release. 9051994689c1Smrg if test -z "$vinfo" && test -n "$release"; then 9052994689c1Smrg major= 9053994689c1Smrg case $version_type in 9054994689c1Smrg darwin) 9055994689c1Smrg # we can't check for "0.0" in archive_cmds due to quoting 9056994689c1Smrg # problems, so we reset it completely 9057994689c1Smrg verstring= 9058994689c1Smrg ;; 9059994689c1Smrg *) 90605ec34c4cSmrg verstring=0.0 9061994689c1Smrg ;; 9062994689c1Smrg esac 90635ec34c4cSmrg if test no = "$need_version"; then 9064994689c1Smrg versuffix= 9065994689c1Smrg else 90665ec34c4cSmrg versuffix=.0.0 9067994689c1Smrg fi 9068994689c1Smrg fi 9069994689c1Smrg 9070994689c1Smrg # Remove version info from name if versioning should be avoided 90715ec34c4cSmrg if test yes,no = "$avoid_version,$need_version"; then 9072994689c1Smrg major= 9073994689c1Smrg versuffix= 90745ec34c4cSmrg verstring= 9075994689c1Smrg fi 9076994689c1Smrg 9077994689c1Smrg # Check to see if the archive will have undefined symbols. 90785ec34c4cSmrg if test yes = "$allow_undefined"; then 90795ec34c4cSmrg if test unsupported = "$allow_undefined_flag"; then 90805ec34c4cSmrg if test yes = "$build_old_libs"; then 90815ec34c4cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 90825ec34c4cSmrg build_libtool_libs=no 90835ec34c4cSmrg else 90845ec34c4cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 90855ec34c4cSmrg fi 9086994689c1Smrg fi 9087994689c1Smrg else 9088994689c1Smrg # Don't allow undefined symbols. 90895ec34c4cSmrg allow_undefined_flag=$no_undefined_flag 9090994689c1Smrg fi 9091994689c1Smrg 9092994689c1Smrg fi 9093994689c1Smrg 90945ec34c4cSmrg func_generate_dlsyms "$libname" "$libname" : 9095f353fbadSmrg func_append libobjs " $symfileobj" 90965ec34c4cSmrg test " " = "$libobjs" && libobjs= 9097994689c1Smrg 90985ec34c4cSmrg if test relink != "$opt_mode"; then 9099994689c1Smrg # Remove our outputs, but don't remove object files since they 9100994689c1Smrg # may have been created when compiling PIC objects. 9101994689c1Smrg removelist= 9102994689c1Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9103994689c1Smrg for p in $tempremovelist; do 9104994689c1Smrg case $p in 9105994689c1Smrg *.$objext | *.gcno) 9106994689c1Smrg ;; 91075ec34c4cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 91085ec34c4cSmrg if test -n "$precious_files_regex"; then 9109994689c1Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9110994689c1Smrg then 9111994689c1Smrg continue 9112994689c1Smrg fi 9113994689c1Smrg fi 9114f353fbadSmrg func_append removelist " $p" 9115994689c1Smrg ;; 9116994689c1Smrg *) ;; 9117994689c1Smrg esac 9118994689c1Smrg done 9119994689c1Smrg test -n "$removelist" && \ 9120994689c1Smrg func_show_eval "${RM}r \$removelist" 9121994689c1Smrg fi 9122994689c1Smrg 9123994689c1Smrg # Now set the variables for building old libraries. 91245ec34c4cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9125f353fbadSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9126994689c1Smrg 9127994689c1Smrg # Transform .lo files to .o files. 91285ec34c4cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9129994689c1Smrg fi 9130994689c1Smrg 9131994689c1Smrg # Eliminate all temporary directories. 9132994689c1Smrg #for path in $notinst_path; do 9133994689c1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9134994689c1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9135994689c1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9136994689c1Smrg #done 9137994689c1Smrg 9138994689c1Smrg if test -n "$xrpath"; then 9139994689c1Smrg # If the user specified any rpath flags, then add them. 9140994689c1Smrg temp_xrpath= 9141994689c1Smrg for libdir in $xrpath; do 9142f353fbadSmrg func_replace_sysroot "$libdir" 9143f353fbadSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9144994689c1Smrg case "$finalize_rpath " in 9145994689c1Smrg *" $libdir "*) ;; 9146f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 9147994689c1Smrg esac 9148994689c1Smrg done 91495ec34c4cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9150994689c1Smrg dependency_libs="$temp_xrpath $dependency_libs" 9151994689c1Smrg fi 9152994689c1Smrg fi 9153994689c1Smrg 9154994689c1Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 91555ec34c4cSmrg old_dlfiles=$dlfiles 9156994689c1Smrg dlfiles= 9157994689c1Smrg for lib in $old_dlfiles; do 9158994689c1Smrg case " $dlprefiles $dlfiles " in 9159994689c1Smrg *" $lib "*) ;; 9160f353fbadSmrg *) func_append dlfiles " $lib" ;; 9161994689c1Smrg esac 9162994689c1Smrg done 9163994689c1Smrg 9164994689c1Smrg # Make sure dlprefiles contains only unique files 91655ec34c4cSmrg old_dlprefiles=$dlprefiles 9166994689c1Smrg dlprefiles= 9167994689c1Smrg for lib in $old_dlprefiles; do 9168994689c1Smrg case "$dlprefiles " in 9169994689c1Smrg *" $lib "*) ;; 9170f353fbadSmrg *) func_append dlprefiles " $lib" ;; 9171994689c1Smrg esac 9172994689c1Smrg done 9173994689c1Smrg 91745ec34c4cSmrg if test yes = "$build_libtool_libs"; then 9175994689c1Smrg if test -n "$rpath"; then 9176994689c1Smrg case $host in 9177994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9178994689c1Smrg # these systems don't actually have a c library (as such)! 9179994689c1Smrg ;; 9180994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9181994689c1Smrg # Rhapsody C library is in the System framework 9182f353fbadSmrg func_append deplibs " System.ltframework" 9183994689c1Smrg ;; 9184994689c1Smrg *-*-netbsd*) 9185994689c1Smrg # Don't link with libc until the a.out ld.so is fixed. 9186994689c1Smrg ;; 9187994689c1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9188994689c1Smrg # Do not include libc due to us having libc/libc_r. 9189994689c1Smrg ;; 9190994689c1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9191994689c1Smrg # Causes problems with __ctype 9192994689c1Smrg ;; 9193994689c1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9194994689c1Smrg # Compiler inserts libc in the correct place for threads to work 9195994689c1Smrg ;; 9196994689c1Smrg *) 9197994689c1Smrg # Add libc to deplibs on all other systems if necessary. 91985ec34c4cSmrg if test yes = "$build_libtool_need_lc"; then 9199f353fbadSmrg func_append deplibs " -lc" 9200994689c1Smrg fi 9201994689c1Smrg ;; 9202994689c1Smrg esac 9203994689c1Smrg fi 9204994689c1Smrg 9205994689c1Smrg # Transform deplibs into only deplibs that can be linked in shared. 9206994689c1Smrg name_save=$name 9207994689c1Smrg libname_save=$libname 9208994689c1Smrg release_save=$release 9209994689c1Smrg versuffix_save=$versuffix 9210994689c1Smrg major_save=$major 9211994689c1Smrg # I'm not sure if I'm treating the release correctly. I think 9212994689c1Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9213994689c1Smrg # add it in twice. Is that correct? 92145ec34c4cSmrg release= 92155ec34c4cSmrg versuffix= 92165ec34c4cSmrg major= 9217994689c1Smrg newdeplibs= 9218994689c1Smrg droppeddeps=no 9219994689c1Smrg case $deplibs_check_method in 9220994689c1Smrg pass_all) 9221994689c1Smrg # Don't check for shared/static. Everything works. 9222994689c1Smrg # This might be a little naive. We might want to check 9223994689c1Smrg # whether the library exists or not. But this is on 9224994689c1Smrg # osf3 & osf4 and I'm not really sure... Just 9225994689c1Smrg # implementing what was already the behavior. 9226994689c1Smrg newdeplibs=$deplibs 9227994689c1Smrg ;; 9228994689c1Smrg test_compile) 9229994689c1Smrg # This code stresses the "libraries are programs" paradigm to its 9230994689c1Smrg # limits. Maybe even breaks it. We compile a program, linking it 9231994689c1Smrg # against the deplibs as a proxy for the library. Then we can check 9232994689c1Smrg # whether they linked in statically or dynamically with ldd. 9233994689c1Smrg $opt_dry_run || $RM conftest.c 9234994689c1Smrg cat > conftest.c <<EOF 9235994689c1Smrg int main() { return 0; } 9236994689c1SmrgEOF 9237994689c1Smrg $opt_dry_run || $RM conftest 9238994689c1Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9239994689c1Smrg ldd_output=`ldd conftest` 9240994689c1Smrg for i in $deplibs; do 9241994689c1Smrg case $i in 9242994689c1Smrg -l*) 9243994689c1Smrg func_stripname -l '' "$i" 9244994689c1Smrg name=$func_stripname_result 92455ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9246994689c1Smrg case " $predeps $postdeps " in 9247994689c1Smrg *" $i "*) 9248f353fbadSmrg func_append newdeplibs " $i" 92495ec34c4cSmrg i= 9250994689c1Smrg ;; 9251994689c1Smrg esac 9252994689c1Smrg fi 92535ec34c4cSmrg if test -n "$i"; then 9254994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9255994689c1Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9256994689c1Smrg set dummy $deplib_matches; shift 9257994689c1Smrg deplib_match=$1 92585ec34c4cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9259f353fbadSmrg func_append newdeplibs " $i" 9260994689c1Smrg else 9261994689c1Smrg droppeddeps=yes 9262994689c1Smrg echo 9263994689c1Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9264994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9265994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9266994689c1Smrg echo "*** shared version of the library, which I believe you do not have" 9267994689c1Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9268994689c1Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9269994689c1Smrg fi 9270994689c1Smrg fi 9271994689c1Smrg ;; 9272994689c1Smrg *) 9273f353fbadSmrg func_append newdeplibs " $i" 9274994689c1Smrg ;; 9275994689c1Smrg esac 9276994689c1Smrg done 9277994689c1Smrg else 9278994689c1Smrg # Error occurred in the first compile. Let's try to salvage 9279994689c1Smrg # the situation: Compile a separate program for each library. 9280994689c1Smrg for i in $deplibs; do 9281994689c1Smrg case $i in 9282994689c1Smrg -l*) 9283994689c1Smrg func_stripname -l '' "$i" 9284994689c1Smrg name=$func_stripname_result 9285994689c1Smrg $opt_dry_run || $RM conftest 9286994689c1Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9287994689c1Smrg ldd_output=`ldd conftest` 92885ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9289994689c1Smrg case " $predeps $postdeps " in 9290994689c1Smrg *" $i "*) 9291f353fbadSmrg func_append newdeplibs " $i" 92925ec34c4cSmrg i= 9293994689c1Smrg ;; 9294994689c1Smrg esac 9295994689c1Smrg fi 92965ec34c4cSmrg if test -n "$i"; then 9297994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9298994689c1Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9299994689c1Smrg set dummy $deplib_matches; shift 9300994689c1Smrg deplib_match=$1 93015ec34c4cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9302f353fbadSmrg func_append newdeplibs " $i" 9303994689c1Smrg else 9304994689c1Smrg droppeddeps=yes 9305994689c1Smrg echo 9306994689c1Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9307994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9308994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9309994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 9310994689c1Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9311994689c1Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9312994689c1Smrg fi 9313994689c1Smrg fi 9314994689c1Smrg else 9315994689c1Smrg droppeddeps=yes 9316994689c1Smrg echo 9317994689c1Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9318994689c1Smrg echo "*** make it link in! You will probably need to install it or some" 9319994689c1Smrg echo "*** library that it depends on before this library will be fully" 9320994689c1Smrg echo "*** functional. Installing it before continuing would be even better." 9321994689c1Smrg fi 9322994689c1Smrg ;; 9323994689c1Smrg *) 9324f353fbadSmrg func_append newdeplibs " $i" 9325994689c1Smrg ;; 9326994689c1Smrg esac 9327994689c1Smrg done 9328994689c1Smrg fi 9329994689c1Smrg ;; 9330994689c1Smrg file_magic*) 9331994689c1Smrg set dummy $deplibs_check_method; shift 9332994689c1Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9333994689c1Smrg for a_deplib in $deplibs; do 9334994689c1Smrg case $a_deplib in 9335994689c1Smrg -l*) 9336994689c1Smrg func_stripname -l '' "$a_deplib" 9337994689c1Smrg name=$func_stripname_result 93385ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9339994689c1Smrg case " $predeps $postdeps " in 9340994689c1Smrg *" $a_deplib "*) 9341f353fbadSmrg func_append newdeplibs " $a_deplib" 93425ec34c4cSmrg a_deplib= 9343994689c1Smrg ;; 9344994689c1Smrg esac 9345994689c1Smrg fi 93465ec34c4cSmrg if test -n "$a_deplib"; then 9347994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9348f353fbadSmrg if test -n "$file_magic_glob"; then 9349f353fbadSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9350f353fbadSmrg else 9351f353fbadSmrg libnameglob=$libname 9352f353fbadSmrg fi 93535ec34c4cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9354994689c1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93555ec34c4cSmrg if test yes = "$want_nocaseglob"; then 9356f353fbadSmrg shopt -s nocaseglob 9357f353fbadSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9358f353fbadSmrg $nocaseglob 9359f353fbadSmrg else 9360f353fbadSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9361f353fbadSmrg fi 9362994689c1Smrg for potent_lib in $potential_libs; do 9363994689c1Smrg # Follow soft links. 9364994689c1Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9365994689c1Smrg $GREP " -> " >/dev/null; then 9366994689c1Smrg continue 9367994689c1Smrg fi 9368994689c1Smrg # The statement above tries to avoid entering an 9369994689c1Smrg # endless loop below, in case of cyclic links. 9370994689c1Smrg # We might still enter an endless loop, since a link 9371994689c1Smrg # loop can be closed while we follow links, 9372994689c1Smrg # but so what? 93735ec34c4cSmrg potlib=$potent_lib 9374994689c1Smrg while test -h "$potlib" 2>/dev/null; do 93755ec34c4cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9376994689c1Smrg case $potliblink in 93775ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 93785ec34c4cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9379994689c1Smrg esac 9380994689c1Smrg done 9381994689c1Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9382994689c1Smrg $SED -e 10q | 9383994689c1Smrg $EGREP "$file_magic_regex" > /dev/null; then 9384f353fbadSmrg func_append newdeplibs " $a_deplib" 93855ec34c4cSmrg a_deplib= 9386994689c1Smrg break 2 9387994689c1Smrg fi 9388994689c1Smrg done 9389994689c1Smrg done 9390994689c1Smrg fi 93915ec34c4cSmrg if test -n "$a_deplib"; then 9392994689c1Smrg droppeddeps=yes 9393994689c1Smrg echo 9394994689c1Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9395994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9396994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9397994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 9398994689c1Smrg echo "*** because I did check the linker path looking for a file starting" 93995ec34c4cSmrg if test -z "$potlib"; then 9400994689c1Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9401994689c1Smrg else 9402994689c1Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9403994689c1Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9404994689c1Smrg fi 9405994689c1Smrg fi 9406994689c1Smrg ;; 9407994689c1Smrg *) 9408994689c1Smrg # Add a -L argument. 9409f353fbadSmrg func_append newdeplibs " $a_deplib" 9410994689c1Smrg ;; 9411994689c1Smrg esac 9412994689c1Smrg done # Gone through all deplibs. 9413994689c1Smrg ;; 9414994689c1Smrg match_pattern*) 9415994689c1Smrg set dummy $deplibs_check_method; shift 9416994689c1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9417994689c1Smrg for a_deplib in $deplibs; do 9418994689c1Smrg case $a_deplib in 9419994689c1Smrg -l*) 9420994689c1Smrg func_stripname -l '' "$a_deplib" 9421994689c1Smrg name=$func_stripname_result 94225ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9423994689c1Smrg case " $predeps $postdeps " in 9424994689c1Smrg *" $a_deplib "*) 9425f353fbadSmrg func_append newdeplibs " $a_deplib" 94265ec34c4cSmrg a_deplib= 9427994689c1Smrg ;; 9428994689c1Smrg esac 9429994689c1Smrg fi 94305ec34c4cSmrg if test -n "$a_deplib"; then 9431994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9432994689c1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9433994689c1Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9434994689c1Smrg for potent_lib in $potential_libs; do 94355ec34c4cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9436994689c1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9437994689c1Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9438f353fbadSmrg func_append newdeplibs " $a_deplib" 94395ec34c4cSmrg a_deplib= 9440994689c1Smrg break 2 9441994689c1Smrg fi 9442994689c1Smrg done 9443994689c1Smrg done 9444994689c1Smrg fi 94455ec34c4cSmrg if test -n "$a_deplib"; then 9446994689c1Smrg droppeddeps=yes 9447994689c1Smrg echo 9448994689c1Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9449994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9450994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9451994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 9452994689c1Smrg echo "*** because I did check the linker path looking for a file starting" 94535ec34c4cSmrg if test -z "$potlib"; then 9454994689c1Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9455994689c1Smrg else 9456994689c1Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9457994689c1Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9458994689c1Smrg fi 9459994689c1Smrg fi 9460994689c1Smrg ;; 9461994689c1Smrg *) 9462994689c1Smrg # Add a -L argument. 9463f353fbadSmrg func_append newdeplibs " $a_deplib" 9464994689c1Smrg ;; 9465994689c1Smrg esac 9466994689c1Smrg done # Gone through all deplibs. 9467994689c1Smrg ;; 9468994689c1Smrg none | unknown | *) 94695ec34c4cSmrg newdeplibs= 9470994689c1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 94715ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94725ec34c4cSmrg for i in $predeps $postdeps; do 9473994689c1Smrg # can't use Xsed below, because $i might contain '/' 94745ec34c4cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9475994689c1Smrg done 9476994689c1Smrg fi 9477994689c1Smrg case $tmp_deplibs in 9478994689c1Smrg *[!\ \ ]*) 9479994689c1Smrg echo 94805ec34c4cSmrg if test none = "$deplibs_check_method"; then 9481994689c1Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9482994689c1Smrg else 9483994689c1Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9484994689c1Smrg fi 9485994689c1Smrg echo "*** All declared inter-library dependencies are being dropped." 9486994689c1Smrg droppeddeps=yes 9487994689c1Smrg ;; 9488994689c1Smrg esac 9489994689c1Smrg ;; 9490994689c1Smrg esac 9491994689c1Smrg versuffix=$versuffix_save 9492994689c1Smrg major=$major_save 9493994689c1Smrg release=$release_save 9494994689c1Smrg libname=$libname_save 9495994689c1Smrg name=$name_save 9496994689c1Smrg 9497994689c1Smrg case $host in 9498994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9499994689c1Smrg # On Rhapsody replace the C library with the System framework 9500994689c1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9501994689c1Smrg ;; 9502994689c1Smrg esac 9503994689c1Smrg 95045ec34c4cSmrg if test yes = "$droppeddeps"; then 95055ec34c4cSmrg if test yes = "$module"; then 9506994689c1Smrg echo 9507994689c1Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9508994689c1Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9509994689c1Smrg echo "*** a static module, that should work as long as the dlopening" 9510994689c1Smrg echo "*** application is linked with the -dlopen flag." 9511994689c1Smrg if test -z "$global_symbol_pipe"; then 9512994689c1Smrg echo 9513994689c1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 95145ec34c4cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9515994689c1Smrg echo "*** not find such a program. So, this module is probably useless." 95165ec34c4cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9517994689c1Smrg fi 95185ec34c4cSmrg if test no = "$build_old_libs"; then 95195ec34c4cSmrg oldlibs=$output_objdir/$libname.$libext 9520994689c1Smrg build_libtool_libs=module 9521994689c1Smrg build_old_libs=yes 9522994689c1Smrg else 9523994689c1Smrg build_libtool_libs=no 9524994689c1Smrg fi 9525994689c1Smrg else 9526994689c1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9527994689c1Smrg echo "*** automatically added whenever a program is linked with this library" 9528994689c1Smrg echo "*** or is declared to -dlopen it." 9529994689c1Smrg 95305ec34c4cSmrg if test no = "$allow_undefined"; then 9531994689c1Smrg echo 9532994689c1Smrg echo "*** Since this library must not contain undefined symbols," 9533994689c1Smrg echo "*** because either the platform does not support them or" 9534994689c1Smrg echo "*** it was explicitly requested with -no-undefined," 9535994689c1Smrg echo "*** libtool will only create a static version of it." 95365ec34c4cSmrg if test no = "$build_old_libs"; then 95375ec34c4cSmrg oldlibs=$output_objdir/$libname.$libext 9538994689c1Smrg build_libtool_libs=module 9539994689c1Smrg build_old_libs=yes 9540994689c1Smrg else 9541994689c1Smrg build_libtool_libs=no 9542994689c1Smrg fi 9543994689c1Smrg fi 9544994689c1Smrg fi 9545994689c1Smrg fi 9546994689c1Smrg # Done checking deplibs! 9547994689c1Smrg deplibs=$newdeplibs 9548994689c1Smrg fi 9549994689c1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9550994689c1Smrg case $host in 9551994689c1Smrg *-*-darwin*) 9552994689c1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9553994689c1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9554994689c1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9555994689c1Smrg ;; 9556994689c1Smrg esac 9557994689c1Smrg 9558994689c1Smrg # move library search paths that coincide with paths to not yet 9559994689c1Smrg # installed libraries to the beginning of the library search list 9560994689c1Smrg new_libs= 9561994689c1Smrg for path in $notinst_path; do 9562994689c1Smrg case " $new_libs " in 9563994689c1Smrg *" -L$path/$objdir "*) ;; 9564994689c1Smrg *) 9565994689c1Smrg case " $deplibs " in 9566994689c1Smrg *" -L$path/$objdir "*) 9567f353fbadSmrg func_append new_libs " -L$path/$objdir" ;; 9568994689c1Smrg esac 9569994689c1Smrg ;; 9570994689c1Smrg esac 9571994689c1Smrg done 9572994689c1Smrg for deplib in $deplibs; do 9573994689c1Smrg case $deplib in 9574994689c1Smrg -L*) 9575994689c1Smrg case " $new_libs " in 9576994689c1Smrg *" $deplib "*) ;; 9577f353fbadSmrg *) func_append new_libs " $deplib" ;; 9578994689c1Smrg esac 9579994689c1Smrg ;; 9580f353fbadSmrg *) func_append new_libs " $deplib" ;; 9581994689c1Smrg esac 9582994689c1Smrg done 95835ec34c4cSmrg deplibs=$new_libs 9584994689c1Smrg 9585994689c1Smrg # All the library-specific variables (install_libdir is set above). 9586994689c1Smrg library_names= 9587994689c1Smrg old_library= 9588994689c1Smrg dlname= 9589994689c1Smrg 9590994689c1Smrg # Test again, we may have decided not to build it any more 95915ec34c4cSmrg if test yes = "$build_libtool_libs"; then 95925ec34c4cSmrg # Remove $wl instances when linking with ld. 9593421c997bSmrg # FIXME: should test the right _cmds variable. 9594421c997bSmrg case $archive_cmds in 9595421c997bSmrg *\$LD\ *) wl= ;; 9596421c997bSmrg esac 95975ec34c4cSmrg if test yes = "$hardcode_into_libs"; then 9598994689c1Smrg # Hardcode the library paths 9599994689c1Smrg hardcode_libdirs= 9600994689c1Smrg dep_rpath= 96015ec34c4cSmrg rpath=$finalize_rpath 96025ec34c4cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9603994689c1Smrg for libdir in $rpath; do 9604994689c1Smrg if test -n "$hardcode_libdir_flag_spec"; then 9605994689c1Smrg if test -n "$hardcode_libdir_separator"; then 9606f353fbadSmrg func_replace_sysroot "$libdir" 9607f353fbadSmrg libdir=$func_replace_sysroot_result 9608994689c1Smrg if test -z "$hardcode_libdirs"; then 96095ec34c4cSmrg hardcode_libdirs=$libdir 9610994689c1Smrg else 9611994689c1Smrg # Just accumulate the unique libdirs. 9612994689c1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9613994689c1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9614994689c1Smrg ;; 9615994689c1Smrg *) 9616f353fbadSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9617994689c1Smrg ;; 9618994689c1Smrg esac 9619994689c1Smrg fi 9620994689c1Smrg else 9621994689c1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9622f353fbadSmrg func_append dep_rpath " $flag" 9623994689c1Smrg fi 9624994689c1Smrg elif test -n "$runpath_var"; then 9625994689c1Smrg case "$perm_rpath " in 9626994689c1Smrg *" $libdir "*) ;; 9627421c997bSmrg *) func_append perm_rpath " $libdir" ;; 9628994689c1Smrg esac 9629994689c1Smrg fi 9630994689c1Smrg done 9631994689c1Smrg # Substitute the hardcoded libdirs into the rpath. 9632994689c1Smrg if test -n "$hardcode_libdir_separator" && 9633994689c1Smrg test -n "$hardcode_libdirs"; then 96345ec34c4cSmrg libdir=$hardcode_libdirs 9635421c997bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9636994689c1Smrg fi 9637994689c1Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9638994689c1Smrg # We should set the runpath_var. 9639994689c1Smrg rpath= 9640994689c1Smrg for dir in $perm_rpath; do 9641f353fbadSmrg func_append rpath "$dir:" 9642994689c1Smrg done 9643994689c1Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9644994689c1Smrg fi 9645994689c1Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9646994689c1Smrg fi 96477a84e134Smrg 96485ec34c4cSmrg shlibpath=$finalize_shlibpath 96495ec34c4cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9650994689c1Smrg if test -n "$shlibpath"; then 9651994689c1Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9652994689c1Smrg fi 96537a84e134Smrg 9654994689c1Smrg # Get the real and link names of the library. 9655994689c1Smrg eval shared_ext=\"$shrext_cmds\" 9656994689c1Smrg eval library_names=\"$library_names_spec\" 9657994689c1Smrg set dummy $library_names 9658994689c1Smrg shift 96595ec34c4cSmrg realname=$1 9660994689c1Smrg shift 96617a84e134Smrg 9662994689c1Smrg if test -n "$soname_spec"; then 9663994689c1Smrg eval soname=\"$soname_spec\" 9664994689c1Smrg else 96655ec34c4cSmrg soname=$realname 9666994689c1Smrg fi 9667994689c1Smrg if test -z "$dlname"; then 9668994689c1Smrg dlname=$soname 9669994689c1Smrg fi 96707a84e134Smrg 96715ec34c4cSmrg lib=$output_objdir/$realname 9672994689c1Smrg linknames= 9673994689c1Smrg for link 9674994689c1Smrg do 9675f353fbadSmrg func_append linknames " $link" 9676994689c1Smrg done 96777a84e134Smrg 9678994689c1Smrg # Use standard objects if they are pic 9679994689c1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9680994689c1Smrg test "X$libobjs" = "X " && libobjs= 96817a84e134Smrg 9682994689c1Smrg delfiles= 9683994689c1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9684994689c1Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 96855ec34c4cSmrg export_symbols=$output_objdir/$libname.uexp 9686f353fbadSmrg func_append delfiles " $export_symbols" 9687994689c1Smrg fi 96887a84e134Smrg 9689994689c1Smrg orig_export_symbols= 9690994689c1Smrg case $host_os in 9691994689c1Smrg cygwin* | mingw* | cegcc*) 9692994689c1Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9693994689c1Smrg # exporting using user supplied symfile 96945ec34c4cSmrg func_dll_def_p "$export_symbols" || { 9695994689c1Smrg # and it's NOT already a .def file. Must figure out 9696994689c1Smrg # which of the given symbols are data symbols and tag 9697994689c1Smrg # them as such. So, trigger use of export_symbols_cmds. 9698994689c1Smrg # export_symbols gets reassigned inside the "prepare 9699994689c1Smrg # the list of exported symbols" if statement, so the 9700994689c1Smrg # include_expsyms logic still works. 97015ec34c4cSmrg orig_export_symbols=$export_symbols 9702994689c1Smrg export_symbols= 9703994689c1Smrg always_export_symbols=yes 97045ec34c4cSmrg } 9705994689c1Smrg fi 9706994689c1Smrg ;; 9707994689c1Smrg esac 97087a84e134Smrg 9709994689c1Smrg # Prepare the list of exported symbols 9710994689c1Smrg if test -z "$export_symbols"; then 97115ec34c4cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 97125ec34c4cSmrg func_verbose "generating symbol list for '$libname.la'" 97135ec34c4cSmrg export_symbols=$output_objdir/$libname.exp 9714994689c1Smrg $opt_dry_run || $RM $export_symbols 9715994689c1Smrg cmds=$export_symbols_cmds 97165ec34c4cSmrg save_ifs=$IFS; IFS='~' 9717f353fbadSmrg for cmd1 in $cmds; do 97185ec34c4cSmrg IFS=$save_ifs 9719f353fbadSmrg # Take the normal branch if the nm_file_list_spec branch 9720f353fbadSmrg # doesn't work or if tool conversion is not needed. 9721f353fbadSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9722f353fbadSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9723f353fbadSmrg try_normal_branch=yes 9724f353fbadSmrg eval cmd=\"$cmd1\" 9725f353fbadSmrg func_len " $cmd" 9726f353fbadSmrg len=$func_len_result 9727f353fbadSmrg ;; 9728f353fbadSmrg *) 9729f353fbadSmrg try_normal_branch=no 9730f353fbadSmrg ;; 9731f353fbadSmrg esac 97325ec34c4cSmrg if test yes = "$try_normal_branch" \ 9733f353fbadSmrg && { test "$len" -lt "$max_cmd_len" \ 9734f353fbadSmrg || test "$max_cmd_len" -le -1; } 9735f353fbadSmrg then 9736f353fbadSmrg func_show_eval "$cmd" 'exit $?' 9737f353fbadSmrg skipped_export=false 9738f353fbadSmrg elif test -n "$nm_file_list_spec"; then 9739f353fbadSmrg func_basename "$output" 9740f353fbadSmrg output_la=$func_basename_result 9741f353fbadSmrg save_libobjs=$libobjs 9742f353fbadSmrg save_output=$output 97435ec34c4cSmrg output=$output_objdir/$output_la.nm 9744f353fbadSmrg func_to_tool_file "$output" 9745f353fbadSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9746f353fbadSmrg func_append delfiles " $output" 9747f353fbadSmrg func_verbose "creating $NM input file list: $output" 9748f353fbadSmrg for obj in $save_libobjs; do 9749f353fbadSmrg func_to_tool_file "$obj" 9750f353fbadSmrg $ECHO "$func_to_tool_file_result" 9751f353fbadSmrg done > "$output" 9752f353fbadSmrg eval cmd=\"$cmd1\" 9753994689c1Smrg func_show_eval "$cmd" 'exit $?' 9754f353fbadSmrg output=$save_output 9755f353fbadSmrg libobjs=$save_libobjs 9756994689c1Smrg skipped_export=false 9757994689c1Smrg else 9758994689c1Smrg # The command line is too long to execute in one step. 9759994689c1Smrg func_verbose "using reloadable object file for export list..." 9760994689c1Smrg skipped_export=: 9761994689c1Smrg # Break out early, otherwise skipped_export may be 9762994689c1Smrg # set to false by a later but shorter cmd. 9763994689c1Smrg break 9764994689c1Smrg fi 9765994689c1Smrg done 97665ec34c4cSmrg IFS=$save_ifs 97675ec34c4cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9768994689c1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9769994689c1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9770994689c1Smrg fi 9771994689c1Smrg fi 9772994689c1Smrg fi 97737a84e134Smrg 9774994689c1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 97755ec34c4cSmrg tmp_export_symbols=$export_symbols 97765ec34c4cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9777994689c1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9778994689c1Smrg fi 97797a84e134Smrg 97805ec34c4cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9781994689c1Smrg # The given exports_symbols file has to be filtered, so filter it. 97825ec34c4cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9783994689c1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 97845ec34c4cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9785994689c1Smrg # though. Also, the filter scales superlinearly with the number of 9786994689c1Smrg # global variables. join(1) would be nice here, but unfortunately 9787994689c1Smrg # isn't a blessed tool. 9788994689c1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9789f353fbadSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9790994689c1Smrg export_symbols=$output_objdir/$libname.def 9791994689c1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97927a84e134Smrg fi 97937a84e134Smrg 9794994689c1Smrg tmp_deplibs= 9795994689c1Smrg for test_deplib in $deplibs; do 9796994689c1Smrg case " $convenience " in 9797994689c1Smrg *" $test_deplib "*) ;; 9798994689c1Smrg *) 9799f353fbadSmrg func_append tmp_deplibs " $test_deplib" 9800994689c1Smrg ;; 9801994689c1Smrg esac 9802994689c1Smrg done 98035ec34c4cSmrg deplibs=$tmp_deplibs 98047a84e134Smrg 9805994689c1Smrg if test -n "$convenience"; then 9806994689c1Smrg if test -n "$whole_archive_flag_spec" && 98075ec34c4cSmrg test yes = "$compiler_needs_object" && 9808994689c1Smrg test -z "$libobjs"; then 9809994689c1Smrg # extract the archives, so we have objects to list. 9810994689c1Smrg # TODO: could optimize this to just extract one archive. 9811994689c1Smrg whole_archive_flag_spec= 9812994689c1Smrg fi 9813994689c1Smrg if test -n "$whole_archive_flag_spec"; then 9814994689c1Smrg save_libobjs=$libobjs 9815994689c1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9816994689c1Smrg test "X$libobjs" = "X " && libobjs= 9817994689c1Smrg else 98185ec34c4cSmrg gentop=$output_objdir/${outputname}x 9819f353fbadSmrg func_append generated " $gentop" 98207a84e134Smrg 9821994689c1Smrg func_extract_archives $gentop $convenience 9822f353fbadSmrg func_append libobjs " $func_extract_archives_result" 9823994689c1Smrg test "X$libobjs" = "X " && libobjs= 9824994689c1Smrg fi 9825994689c1Smrg fi 98267a84e134Smrg 98275ec34c4cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9828994689c1Smrg eval flag=\"$thread_safe_flag_spec\" 9829f353fbadSmrg func_append linker_flags " $flag" 9830994689c1Smrg fi 98317a84e134Smrg 9832994689c1Smrg # Make a backup of the uninstalled library when relinking 98335ec34c4cSmrg if test relink = "$opt_mode"; then 9834994689c1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9835e1e1713cSmrg fi 98367a84e134Smrg 9837994689c1Smrg # Do each of the archive commands. 98385ec34c4cSmrg if test yes = "$module" && test -n "$module_cmds"; then 9839994689c1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9840994689c1Smrg eval test_cmds=\"$module_expsym_cmds\" 9841994689c1Smrg cmds=$module_expsym_cmds 9842994689c1Smrg else 9843994689c1Smrg eval test_cmds=\"$module_cmds\" 9844994689c1Smrg cmds=$module_cmds 9845994689c1Smrg fi 9846994689c1Smrg else 9847994689c1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9848994689c1Smrg eval test_cmds=\"$archive_expsym_cmds\" 9849994689c1Smrg cmds=$archive_expsym_cmds 9850994689c1Smrg else 9851994689c1Smrg eval test_cmds=\"$archive_cmds\" 9852994689c1Smrg cmds=$archive_cmds 9853994689c1Smrg fi 9854e1e1713cSmrg fi 9855775e7de9Smrg 98565ec34c4cSmrg if test : != "$skipped_export" && 9857994689c1Smrg func_len " $test_cmds" && 9858994689c1Smrg len=$func_len_result && 9859994689c1Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9860994689c1Smrg : 9861994689c1Smrg else 9862994689c1Smrg # The command line is too long to link in one step, link piecewise 9863994689c1Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9864994689c1Smrg # script. 98657a84e134Smrg 9866994689c1Smrg # Save the value of $output and $libobjs because we want to 9867994689c1Smrg # use them later. If we have whole_archive_flag_spec, we 9868994689c1Smrg # want to use save_libobjs as it was before 9869994689c1Smrg # whole_archive_flag_spec was expanded, because we can't 9870994689c1Smrg # assume the linker understands whole_archive_flag_spec. 9871994689c1Smrg # This may have to be revisited, in case too many 9872994689c1Smrg # convenience libraries get linked in and end up exceeding 9873994689c1Smrg # the spec. 9874994689c1Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9875994689c1Smrg save_libobjs=$libobjs 9876994689c1Smrg fi 9877994689c1Smrg save_output=$output 9878994689c1Smrg func_basename "$output" 9879994689c1Smrg output_la=$func_basename_result 98807a84e134Smrg 9881994689c1Smrg # Clear the reloadable object creation command queue and 9882994689c1Smrg # initialize k to one. 9883994689c1Smrg test_cmds= 9884994689c1Smrg concat_cmds= 9885994689c1Smrg objlist= 9886994689c1Smrg last_robj= 9887994689c1Smrg k=1 98887a84e134Smrg 98895ec34c4cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 98905ec34c4cSmrg output=$output_objdir/$output_la.lnkscript 9891994689c1Smrg func_verbose "creating GNU ld script: $output" 9892994689c1Smrg echo 'INPUT (' > $output 9893994689c1Smrg for obj in $save_libobjs 9894994689c1Smrg do 9895f353fbadSmrg func_to_tool_file "$obj" 9896f353fbadSmrg $ECHO "$func_to_tool_file_result" >> $output 9897994689c1Smrg done 9898994689c1Smrg echo ')' >> $output 9899f353fbadSmrg func_append delfiles " $output" 9900f353fbadSmrg func_to_tool_file "$output" 9901f353fbadSmrg output=$func_to_tool_file_result 99025ec34c4cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 99035ec34c4cSmrg output=$output_objdir/$output_la.lnk 9904994689c1Smrg func_verbose "creating linker input file list: $output" 9905994689c1Smrg : > $output 9906994689c1Smrg set x $save_libobjs 9907994689c1Smrg shift 9908994689c1Smrg firstobj= 99095ec34c4cSmrg if test yes = "$compiler_needs_object"; then 9910994689c1Smrg firstobj="$1 " 9911994689c1Smrg shift 9912994689c1Smrg fi 9913994689c1Smrg for obj 9914994689c1Smrg do 9915f353fbadSmrg func_to_tool_file "$obj" 9916f353fbadSmrg $ECHO "$func_to_tool_file_result" >> $output 9917994689c1Smrg done 9918f353fbadSmrg func_append delfiles " $output" 9919f353fbadSmrg func_to_tool_file "$output" 9920f353fbadSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9921994689c1Smrg else 9922994689c1Smrg if test -n "$save_libobjs"; then 9923994689c1Smrg func_verbose "creating reloadable object files..." 99245ec34c4cSmrg output=$output_objdir/$output_la-$k.$objext 9925994689c1Smrg eval test_cmds=\"$reload_cmds\" 9926994689c1Smrg func_len " $test_cmds" 9927994689c1Smrg len0=$func_len_result 9928994689c1Smrg len=$len0 9929994689c1Smrg 9930994689c1Smrg # Loop over the list of objects to be linked. 9931994689c1Smrg for obj in $save_libobjs 9932994689c1Smrg do 9933994689c1Smrg func_len " $obj" 9934994689c1Smrg func_arith $len + $func_len_result 9935994689c1Smrg len=$func_arith_result 99365ec34c4cSmrg if test -z "$objlist" || 9937994689c1Smrg test "$len" -lt "$max_cmd_len"; then 9938994689c1Smrg func_append objlist " $obj" 9939994689c1Smrg else 9940994689c1Smrg # The command $test_cmds is almost too long, add a 9941994689c1Smrg # command to the queue. 99425ec34c4cSmrg if test 1 -eq "$k"; then 9943994689c1Smrg # The first file doesn't have a previous command to add. 9944994689c1Smrg reload_objs=$objlist 9945994689c1Smrg eval concat_cmds=\"$reload_cmds\" 9946994689c1Smrg else 9947994689c1Smrg # All subsequent reloadable object files will link in 9948994689c1Smrg # the last one created. 9949994689c1Smrg reload_objs="$objlist $last_robj" 9950994689c1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9951994689c1Smrg fi 99525ec34c4cSmrg last_robj=$output_objdir/$output_la-$k.$objext 9953994689c1Smrg func_arith $k + 1 9954994689c1Smrg k=$func_arith_result 99555ec34c4cSmrg output=$output_objdir/$output_la-$k.$objext 9956994689c1Smrg objlist=" $obj" 9957994689c1Smrg func_len " $last_robj" 9958994689c1Smrg func_arith $len0 + $func_len_result 9959994689c1Smrg len=$func_arith_result 9960994689c1Smrg fi 9961994689c1Smrg done 9962994689c1Smrg # Handle the remaining objects by creating one last 9963994689c1Smrg # reloadable object file. All subsequent reloadable object 9964994689c1Smrg # files will link in the last one created. 9965994689c1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9966994689c1Smrg reload_objs="$objlist $last_robj" 99675ec34c4cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9968994689c1Smrg if test -n "$last_robj"; then 99695ec34c4cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9970994689c1Smrg fi 9971f353fbadSmrg func_append delfiles " $output" 9972994689c1Smrg 9973994689c1Smrg else 9974994689c1Smrg output= 9975994689c1Smrg fi 99767a84e134Smrg 99775ec34c4cSmrg ${skipped_export-false} && { 99785ec34c4cSmrg func_verbose "generating symbol list for '$libname.la'" 99795ec34c4cSmrg export_symbols=$output_objdir/$libname.exp 9980994689c1Smrg $opt_dry_run || $RM $export_symbols 9981994689c1Smrg libobjs=$output 9982994689c1Smrg # Append the command to create the export file. 9983994689c1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9984994689c1Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9985994689c1Smrg if test -n "$last_robj"; then 9986994689c1Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9987994689c1Smrg fi 99885ec34c4cSmrg } 99897a84e134Smrg 9990994689c1Smrg test -n "$save_libobjs" && 9991994689c1Smrg func_verbose "creating a temporary reloadable object file: $output" 99927a84e134Smrg 9993994689c1Smrg # Loop through the commands generated above and execute them. 99945ec34c4cSmrg save_ifs=$IFS; IFS='~' 9995994689c1Smrg for cmd in $concat_cmds; do 99965ec34c4cSmrg IFS=$save_ifs 99975ec34c4cSmrg $opt_quiet || { 9998994689c1Smrg func_quote_for_expand "$cmd" 9999994689c1Smrg eval "func_echo $func_quote_for_expand_result" 10000994689c1Smrg } 10001994689c1Smrg $opt_dry_run || eval "$cmd" || { 10002994689c1Smrg lt_exit=$? 10003994689c1Smrg 10004994689c1Smrg # Restore the uninstalled library and exit 100055ec34c4cSmrg if test relink = "$opt_mode"; then 10006994689c1Smrg ( cd "$output_objdir" && \ 10007994689c1Smrg $RM "${realname}T" && \ 10008994689c1Smrg $MV "${realname}U" "$realname" ) 10009994689c1Smrg fi 100107a84e134Smrg 10011994689c1Smrg exit $lt_exit 10012994689c1Smrg } 10013994689c1Smrg done 100145ec34c4cSmrg IFS=$save_ifs 100157a84e134Smrg 10016994689c1Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10017994689c1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10018994689c1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10019775e7de9Smrg fi 10020775e7de9Smrg fi 100217a84e134Smrg 100225ec34c4cSmrg ${skipped_export-false} && { 10023994689c1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 100245ec34c4cSmrg tmp_export_symbols=$export_symbols 100255ec34c4cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10026994689c1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10027994689c1Smrg fi 100287a84e134Smrg 10029994689c1Smrg if test -n "$orig_export_symbols"; then 10030994689c1Smrg # The given exports_symbols file has to be filtered, so filter it. 100315ec34c4cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10032994689c1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100335ec34c4cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10034994689c1Smrg # though. Also, the filter scales superlinearly with the number of 10035994689c1Smrg # global variables. join(1) would be nice here, but unfortunately 10036994689c1Smrg # isn't a blessed tool. 10037994689c1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10038f353fbadSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10039994689c1Smrg export_symbols=$output_objdir/$libname.def 10040994689c1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10041994689c1Smrg fi 100425ec34c4cSmrg } 100437a84e134Smrg 10044994689c1Smrg libobjs=$output 10045994689c1Smrg # Restore the value of output. 10046994689c1Smrg output=$save_output 10047e1e1713cSmrg 10048994689c1Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10049994689c1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10050994689c1Smrg test "X$libobjs" = "X " && libobjs= 10051994689c1Smrg fi 10052994689c1Smrg # Expand the library linking commands again to reset the 10053994689c1Smrg # value of $libobjs for piecewise linking. 10054994689c1Smrg 10055994689c1Smrg # Do each of the archive commands. 100565ec34c4cSmrg if test yes = "$module" && test -n "$module_cmds"; then 10057994689c1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10058994689c1Smrg cmds=$module_expsym_cmds 10059775e7de9Smrg else 10060994689c1Smrg cmds=$module_cmds 100617a84e134Smrg fi 100627a84e134Smrg else 10063994689c1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10064994689c1Smrg cmds=$archive_expsym_cmds 10065994689c1Smrg else 10066994689c1Smrg cmds=$archive_cmds 10067994689c1Smrg fi 100687a84e134Smrg fi 10069775e7de9Smrg fi 100707a84e134Smrg 10071994689c1Smrg if test -n "$delfiles"; then 10072994689c1Smrg # Append the command to remove temporary files to $cmds. 10073994689c1Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10074994689c1Smrg fi 10075775e7de9Smrg 10076994689c1Smrg # Add any objects from preloaded convenience libraries 10077994689c1Smrg if test -n "$dlprefiles"; then 100785ec34c4cSmrg gentop=$output_objdir/${outputname}x 10079f353fbadSmrg func_append generated " $gentop" 100807a84e134Smrg 10081994689c1Smrg func_extract_archives $gentop $dlprefiles 10082f353fbadSmrg func_append libobjs " $func_extract_archives_result" 10083994689c1Smrg test "X$libobjs" = "X " && libobjs= 10084775e7de9Smrg fi 100857a84e134Smrg 100865ec34c4cSmrg save_ifs=$IFS; IFS='~' 10087994689c1Smrg for cmd in $cmds; do 100885ec34c4cSmrg IFS=$sp$nl 10089994689c1Smrg eval cmd=\"$cmd\" 100905ec34c4cSmrg IFS=$save_ifs 100915ec34c4cSmrg $opt_quiet || { 10092994689c1Smrg func_quote_for_expand "$cmd" 10093994689c1Smrg eval "func_echo $func_quote_for_expand_result" 10094994689c1Smrg } 10095994689c1Smrg $opt_dry_run || eval "$cmd" || { 10096994689c1Smrg lt_exit=$? 100977a84e134Smrg 10098994689c1Smrg # Restore the uninstalled library and exit 100995ec34c4cSmrg if test relink = "$opt_mode"; then 10100994689c1Smrg ( cd "$output_objdir" && \ 10101994689c1Smrg $RM "${realname}T" && \ 10102994689c1Smrg $MV "${realname}U" "$realname" ) 10103e1e1713cSmrg fi 101047a84e134Smrg 10105994689c1Smrg exit $lt_exit 10106994689c1Smrg } 10107994689c1Smrg done 101085ec34c4cSmrg IFS=$save_ifs 101097a84e134Smrg 10110994689c1Smrg # Restore the uninstalled library and exit 101115ec34c4cSmrg if test relink = "$opt_mode"; then 10112994689c1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 101137a84e134Smrg 10114994689c1Smrg if test -n "$convenience"; then 10115994689c1Smrg if test -z "$whole_archive_flag_spec"; then 10116994689c1Smrg func_show_eval '${RM}r "$gentop"' 10117994689c1Smrg fi 10118994689c1Smrg fi 101197a84e134Smrg 10120994689c1Smrg exit $EXIT_SUCCESS 10121994689c1Smrg fi 10122775e7de9Smrg 10123994689c1Smrg # Create links to the real library. 10124994689c1Smrg for linkname in $linknames; do 10125994689c1Smrg if test "$realname" != "$linkname"; then 10126994689c1Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10127994689c1Smrg fi 10128994689c1Smrg done 10129775e7de9Smrg 10130994689c1Smrg # If -module or -export-dynamic was specified, set the dlname. 101315ec34c4cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10132994689c1Smrg # On all known operating systems, these are identical. 101335ec34c4cSmrg dlname=$soname 10134994689c1Smrg fi 10135994689c1Smrg fi 10136994689c1Smrg ;; 10137775e7de9Smrg 10138994689c1Smrg obj) 101395ec34c4cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 101405ec34c4cSmrg func_warning "'-dlopen' is ignored for objects" 10141994689c1Smrg fi 10142775e7de9Smrg 10143994689c1Smrg case " $deplibs" in 10144994689c1Smrg *\ -l* | *\ -L*) 101455ec34c4cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10146994689c1Smrg esac 10147775e7de9Smrg 10148994689c1Smrg test -n "$rpath" && \ 101495ec34c4cSmrg func_warning "'-rpath' is ignored for objects" 10150775e7de9Smrg 10151994689c1Smrg test -n "$xrpath" && \ 101525ec34c4cSmrg func_warning "'-R' is ignored for objects" 10153994689c1Smrg 10154994689c1Smrg test -n "$vinfo" && \ 101555ec34c4cSmrg func_warning "'-version-info' is ignored for objects" 101567a84e134Smrg 10157994689c1Smrg test -n "$release" && \ 101585ec34c4cSmrg func_warning "'-release' is ignored for objects" 10159e1e1713cSmrg 10160994689c1Smrg case $output in 10161994689c1Smrg *.lo) 10162994689c1Smrg test -n "$objs$old_deplibs" && \ 101635ec34c4cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10164994689c1Smrg 10165994689c1Smrg libobj=$output 10166994689c1Smrg func_lo2o "$libobj" 10167994689c1Smrg obj=$func_lo2o_result 10168994689c1Smrg ;; 10169994689c1Smrg *) 10170994689c1Smrg libobj= 101715ec34c4cSmrg obj=$output 10172e1e1713cSmrg ;; 10173775e7de9Smrg esac 101747a84e134Smrg 10175994689c1Smrg # Delete the old objects. 10176994689c1Smrg $opt_dry_run || $RM $obj $libobj 101777a84e134Smrg 10178994689c1Smrg # Objects from convenience libraries. This assumes 10179994689c1Smrg # single-version convenience libraries. Whenever we create 10180994689c1Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10181994689c1Smrg # the extraction. 10182994689c1Smrg reload_conv_objs= 10183994689c1Smrg gentop= 101845ec34c4cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 101855ec34c4cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 101865ec34c4cSmrg # into space. 101875ec34c4cSmrg case $reload_cmds in 101885ec34c4cSmrg *\$LD[\ \$]*) wl= ;; 101895ec34c4cSmrg esac 10190994689c1Smrg if test -n "$convenience"; then 10191994689c1Smrg if test -n "$whole_archive_flag_spec"; then 10192994689c1Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 101935ec34c4cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 101945ec34c4cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10195e1e1713cSmrg else 101965ec34c4cSmrg gentop=$output_objdir/${obj}x 10197f353fbadSmrg func_append generated " $gentop" 10198994689c1Smrg 10199994689c1Smrg func_extract_archives $gentop $convenience 10200994689c1Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10201e1e1713cSmrg fi 10202994689c1Smrg fi 102037a84e134Smrg 10204f353fbadSmrg # If we're not building shared, we need to use non_pic_objs 102055ec34c4cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10206f353fbadSmrg 10207994689c1Smrg # Create the old-style object. 102085ec34c4cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 102097a84e134Smrg 102105ec34c4cSmrg output=$obj 10211994689c1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 102127a84e134Smrg 10213994689c1Smrg # Exit if we aren't doing a library object file. 10214994689c1Smrg if test -z "$libobj"; then 10215994689c1Smrg if test -n "$gentop"; then 10216994689c1Smrg func_show_eval '${RM}r "$gentop"' 10217994689c1Smrg fi 10218e1e1713cSmrg 10219994689c1Smrg exit $EXIT_SUCCESS 10220e1e1713cSmrg fi 10221e1e1713cSmrg 102225ec34c4cSmrg test yes = "$build_libtool_libs" || { 10223994689c1Smrg if test -n "$gentop"; then 10224994689c1Smrg func_show_eval '${RM}r "$gentop"' 10225994689c1Smrg fi 10226e1e1713cSmrg 10227994689c1Smrg # Create an invalid libtool object if no PIC, so that we don't 10228994689c1Smrg # accidentally link it into a program. 10229994689c1Smrg # $show "echo timestamp > $libobj" 10230994689c1Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10231994689c1Smrg exit $EXIT_SUCCESS 102325ec34c4cSmrg } 10233e1e1713cSmrg 102345ec34c4cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10235994689c1Smrg # Only do commands if we really have different PIC objects. 10236994689c1Smrg reload_objs="$libobjs $reload_conv_objs" 102375ec34c4cSmrg output=$libobj 10238994689c1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10239e1e1713cSmrg fi 10240994689c1Smrg 10241994689c1Smrg if test -n "$gentop"; then 10242994689c1Smrg func_show_eval '${RM}r "$gentop"' 10243994689c1Smrg fi 10244994689c1Smrg 10245994689c1Smrg exit $EXIT_SUCCESS 10246e1e1713cSmrg ;; 102477a84e134Smrg 10248994689c1Smrg prog) 10249994689c1Smrg case $host in 10250994689c1Smrg *cygwin*) func_stripname '' '.exe' "$output" 10251994689c1Smrg output=$func_stripname_result.exe;; 10252994689c1Smrg esac 10253994689c1Smrg test -n "$vinfo" && \ 102545ec34c4cSmrg func_warning "'-version-info' is ignored for programs" 102557a84e134Smrg 10256994689c1Smrg test -n "$release" && \ 102575ec34c4cSmrg func_warning "'-release' is ignored for programs" 102587a84e134Smrg 102595ec34c4cSmrg $preload \ 102605ec34c4cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 102615ec34c4cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10262994689c1Smrg 10263994689c1Smrg case $host in 10264994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10265994689c1Smrg # On Rhapsody replace the C library is the System framework 10266994689c1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10267994689c1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10268e1e1713cSmrg ;; 10269994689c1Smrg esac 10270e1e1713cSmrg 10271994689c1Smrg case $host in 10272994689c1Smrg *-*-darwin*) 10273994689c1Smrg # Don't allow lazy linking, it breaks C++ global constructors 10274994689c1Smrg # But is supposedly fixed on 10.4 or later (yay!). 102755ec34c4cSmrg if test CXX = "$tagname"; then 10276994689c1Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10277994689c1Smrg 10.[0123]) 102785ec34c4cSmrg func_append compile_command " $wl-bind_at_load" 102795ec34c4cSmrg func_append finalize_command " $wl-bind_at_load" 10280994689c1Smrg ;; 10281994689c1Smrg esac 10282e1e1713cSmrg fi 10283994689c1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10284994689c1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10285994689c1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10286994689c1Smrg ;; 10287994689c1Smrg esac 10288e1e1713cSmrg 10289e1e1713cSmrg 10290994689c1Smrg # move library search paths that coincide with paths to not yet 10291994689c1Smrg # installed libraries to the beginning of the library search list 10292994689c1Smrg new_libs= 10293994689c1Smrg for path in $notinst_path; do 10294994689c1Smrg case " $new_libs " in 10295994689c1Smrg *" -L$path/$objdir "*) ;; 10296994689c1Smrg *) 10297994689c1Smrg case " $compile_deplibs " in 10298994689c1Smrg *" -L$path/$objdir "*) 10299f353fbadSmrg func_append new_libs " -L$path/$objdir" ;; 10300775e7de9Smrg esac 10301994689c1Smrg ;; 10302994689c1Smrg esac 10303994689c1Smrg done 10304994689c1Smrg for deplib in $compile_deplibs; do 10305994689c1Smrg case $deplib in 10306994689c1Smrg -L*) 10307994689c1Smrg case " $new_libs " in 10308994689c1Smrg *" $deplib "*) ;; 10309f353fbadSmrg *) func_append new_libs " $deplib" ;; 10310775e7de9Smrg esac 10311994689c1Smrg ;; 10312f353fbadSmrg *) func_append new_libs " $deplib" ;; 10313994689c1Smrg esac 10314994689c1Smrg done 103155ec34c4cSmrg compile_deplibs=$new_libs 103167a84e134Smrg 10317e1e1713cSmrg 10318f353fbadSmrg func_append compile_command " $compile_deplibs" 10319f353fbadSmrg func_append finalize_command " $finalize_deplibs" 10320e1e1713cSmrg 10321994689c1Smrg if test -n "$rpath$xrpath"; then 10322994689c1Smrg # If the user specified any rpath flags, then add them. 10323994689c1Smrg for libdir in $rpath $xrpath; do 10324994689c1Smrg # This is the magic to use -rpath. 10325994689c1Smrg case "$finalize_rpath " in 10326994689c1Smrg *" $libdir "*) ;; 10327f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 10328994689c1Smrg esac 10329994689c1Smrg done 10330994689c1Smrg fi 10331e1e1713cSmrg 10332994689c1Smrg # Now hardcode the library paths 10333994689c1Smrg rpath= 10334994689c1Smrg hardcode_libdirs= 10335994689c1Smrg for libdir in $compile_rpath $finalize_rpath; do 10336994689c1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10337994689c1Smrg if test -n "$hardcode_libdir_separator"; then 10338994689c1Smrg if test -z "$hardcode_libdirs"; then 103395ec34c4cSmrg hardcode_libdirs=$libdir 10340994689c1Smrg else 10341994689c1Smrg # Just accumulate the unique libdirs. 10342994689c1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10343994689c1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10344994689c1Smrg ;; 10345994689c1Smrg *) 10346f353fbadSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10347994689c1Smrg ;; 10348994689c1Smrg esac 10349994689c1Smrg fi 10350e1e1713cSmrg else 10351994689c1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10352f353fbadSmrg func_append rpath " $flag" 10353e1e1713cSmrg fi 10354994689c1Smrg elif test -n "$runpath_var"; then 10355994689c1Smrg case "$perm_rpath " in 10356994689c1Smrg *" $libdir "*) ;; 10357f353fbadSmrg *) func_append perm_rpath " $libdir" ;; 10358994689c1Smrg esac 10359994689c1Smrg fi 10360994689c1Smrg case $host in 10361994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 103625ec34c4cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10363994689c1Smrg case :$dllsearchpath: in 10364994689c1Smrg *":$libdir:"*) ;; 10365994689c1Smrg ::) dllsearchpath=$libdir;; 10366f353fbadSmrg *) func_append dllsearchpath ":$libdir";; 10367994689c1Smrg esac 10368994689c1Smrg case :$dllsearchpath: in 10369994689c1Smrg *":$testbindir:"*) ;; 10370994689c1Smrg ::) dllsearchpath=$testbindir;; 10371f353fbadSmrg *) func_append dllsearchpath ":$testbindir";; 10372994689c1Smrg esac 10373994689c1Smrg ;; 10374994689c1Smrg esac 10375994689c1Smrg done 10376994689c1Smrg # Substitute the hardcoded libdirs into the rpath. 10377994689c1Smrg if test -n "$hardcode_libdir_separator" && 10378994689c1Smrg test -n "$hardcode_libdirs"; then 103795ec34c4cSmrg libdir=$hardcode_libdirs 10380994689c1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10381994689c1Smrg fi 103825ec34c4cSmrg compile_rpath=$rpath 10383e1e1713cSmrg 10384994689c1Smrg rpath= 10385994689c1Smrg hardcode_libdirs= 10386994689c1Smrg for libdir in $finalize_rpath; do 10387994689c1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10388994689c1Smrg if test -n "$hardcode_libdir_separator"; then 10389994689c1Smrg if test -z "$hardcode_libdirs"; then 103905ec34c4cSmrg hardcode_libdirs=$libdir 10391994689c1Smrg else 10392994689c1Smrg # Just accumulate the unique libdirs. 10393994689c1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10394994689c1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10395994689c1Smrg ;; 10396994689c1Smrg *) 10397f353fbadSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10398994689c1Smrg ;; 10399994689c1Smrg esac 10400994689c1Smrg fi 104017a84e134Smrg else 10402994689c1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10403f353fbadSmrg func_append rpath " $flag" 104047a84e134Smrg fi 10405994689c1Smrg elif test -n "$runpath_var"; then 10406994689c1Smrg case "$finalize_perm_rpath " in 10407994689c1Smrg *" $libdir "*) ;; 10408f353fbadSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10409994689c1Smrg esac 104107a84e134Smrg fi 10411994689c1Smrg done 10412994689c1Smrg # Substitute the hardcoded libdirs into the rpath. 10413994689c1Smrg if test -n "$hardcode_libdir_separator" && 10414994689c1Smrg test -n "$hardcode_libdirs"; then 104155ec34c4cSmrg libdir=$hardcode_libdirs 10416994689c1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10417994689c1Smrg fi 104185ec34c4cSmrg finalize_rpath=$rpath 104197a84e134Smrg 104205ec34c4cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10421994689c1Smrg # Transform all the library objects into standard objects. 10422994689c1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10423994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10424994689c1Smrg fi 104257a84e134Smrg 104265ec34c4cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 104277a84e134Smrg 10428994689c1Smrg # template prelinking step 10429994689c1Smrg if test -n "$prelink_cmds"; then 10430994689c1Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10431994689c1Smrg fi 104327a84e134Smrg 104335ec34c4cSmrg wrappers_required=: 10434994689c1Smrg case $host in 10435994689c1Smrg *cegcc* | *mingw32ce*) 10436994689c1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 104375ec34c4cSmrg wrappers_required=false 10438994689c1Smrg ;; 10439994689c1Smrg *cygwin* | *mingw* ) 104405ec34c4cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10441994689c1Smrg ;; 10442994689c1Smrg *) 104435ec34c4cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 104445ec34c4cSmrg wrappers_required=false 10445994689c1Smrg fi 10446994689c1Smrg ;; 10447994689c1Smrg esac 104485ec34c4cSmrg $wrappers_required || { 10449994689c1Smrg # Replace the output file specification. 10450994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104515ec34c4cSmrg link_command=$compile_command$compile_rpath 104527a84e134Smrg 10453994689c1Smrg # We have no uninstalled library dependencies, so finalize right now. 10454994689c1Smrg exit_status=0 10455994689c1Smrg func_show_eval "$link_command" 'exit_status=$?' 104567a84e134Smrg 10457f353fbadSmrg if test -n "$postlink_cmds"; then 10458f353fbadSmrg func_to_tool_file "$output" 10459f353fbadSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10460f353fbadSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10461f353fbadSmrg fi 10462f353fbadSmrg 10463994689c1Smrg # Delete the generated files. 104645ec34c4cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 104655ec34c4cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 104667a84e134Smrg fi 104677a84e134Smrg 10468994689c1Smrg exit $exit_status 104695ec34c4cSmrg } 104707a84e134Smrg 10471994689c1Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10472994689c1Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10473994689c1Smrg fi 10474994689c1Smrg if test -n "$finalize_shlibpath"; then 10475994689c1Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10476994689c1Smrg fi 10477e1e1713cSmrg 10478994689c1Smrg compile_var= 10479994689c1Smrg finalize_var= 10480994689c1Smrg if test -n "$runpath_var"; then 10481994689c1Smrg if test -n "$perm_rpath"; then 10482994689c1Smrg # We should set the runpath_var. 10483994689c1Smrg rpath= 10484994689c1Smrg for dir in $perm_rpath; do 10485f353fbadSmrg func_append rpath "$dir:" 10486994689c1Smrg done 10487994689c1Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 104887a84e134Smrg fi 10489994689c1Smrg if test -n "$finalize_perm_rpath"; then 10490994689c1Smrg # We should set the runpath_var. 10491994689c1Smrg rpath= 10492994689c1Smrg for dir in $finalize_perm_rpath; do 10493f353fbadSmrg func_append rpath "$dir:" 10494994689c1Smrg done 10495994689c1Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 104967a84e134Smrg fi 10497994689c1Smrg fi 104987a84e134Smrg 104995ec34c4cSmrg if test yes = "$no_install"; then 10500994689c1Smrg # We don't need to create a wrapper script. 105015ec34c4cSmrg link_command=$compile_var$compile_command$compile_rpath 10502994689c1Smrg # Replace the output file specification. 10503994689c1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10504994689c1Smrg # Delete the old output file. 10505994689c1Smrg $opt_dry_run || $RM $output 10506994689c1Smrg # Link the executable and exit 10507994689c1Smrg func_show_eval "$link_command" 'exit $?' 10508f353fbadSmrg 10509f353fbadSmrg if test -n "$postlink_cmds"; then 10510f353fbadSmrg func_to_tool_file "$output" 10511f353fbadSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10512f353fbadSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10513f353fbadSmrg fi 10514f353fbadSmrg 10515e1e1713cSmrg exit $EXIT_SUCCESS 10516994689c1Smrg fi 10517775e7de9Smrg 105185ec34c4cSmrg case $hardcode_action,$fast_install in 105195ec34c4cSmrg relink,*) 105205ec34c4cSmrg # Fast installation is not supported 105215ec34c4cSmrg link_command=$compile_var$compile_command$compile_rpath 105225ec34c4cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10523994689c1Smrg 105245ec34c4cSmrg func_warning "this platform does not like uninstalled shared libraries" 105255ec34c4cSmrg func_warning "'$output' will be relinked during installation" 105265ec34c4cSmrg ;; 105275ec34c4cSmrg *,yes) 105285ec34c4cSmrg link_command=$finalize_var$compile_command$finalize_rpath 105295ec34c4cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 105305ec34c4cSmrg ;; 105315ec34c4cSmrg *,no) 105325ec34c4cSmrg link_command=$compile_var$compile_command$compile_rpath 105335ec34c4cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 105345ec34c4cSmrg ;; 105355ec34c4cSmrg *,needless) 105365ec34c4cSmrg link_command=$finalize_var$compile_command$finalize_rpath 105375ec34c4cSmrg relink_command= 105385ec34c4cSmrg ;; 105395ec34c4cSmrg esac 105407a84e134Smrg 10541994689c1Smrg # Replace the output file specification. 10542994689c1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 105437a84e134Smrg 10544994689c1Smrg # Delete the old output files. 10545994689c1Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 105467a84e134Smrg 10547994689c1Smrg func_show_eval "$link_command" 'exit $?' 10548e1e1713cSmrg 10549f353fbadSmrg if test -n "$postlink_cmds"; then 10550f353fbadSmrg func_to_tool_file "$output_objdir/$outputname" 10551f353fbadSmrg 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'` 10552f353fbadSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10553f353fbadSmrg fi 10554f353fbadSmrg 10555994689c1Smrg # Now create the wrapper script. 10556994689c1Smrg func_verbose "creating $output" 10557e1e1713cSmrg 10558994689c1Smrg # Quote the relink command for shipping. 10559994689c1Smrg if test -n "$relink_command"; then 10560994689c1Smrg # Preserve any variables that may affect compiler behavior 10561994689c1Smrg for var in $variables_saved_for_relink; do 10562994689c1Smrg if eval test -z \"\${$var+set}\"; then 10563994689c1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10564994689c1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10565994689c1Smrg relink_command="$var=; export $var; $relink_command" 105667a84e134Smrg else 10567994689c1Smrg func_quote_for_eval "$var_value" 10568994689c1Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 105697a84e134Smrg fi 10570994689c1Smrg done 105715ec34c4cSmrg func_quote "(cd `pwd`; $relink_command)" 105725ec34c4cSmrg relink_command=$func_quote_result 10573994689c1Smrg fi 10574775e7de9Smrg 10575994689c1Smrg # Only actually do things if not in dry run mode. 10576994689c1Smrg $opt_dry_run || { 10577994689c1Smrg # win32 will think the script is a binary if it has 10578994689c1Smrg # a .exe suffix, so we strip it off here. 10579994689c1Smrg case $output in 10580994689c1Smrg *.exe) func_stripname '' '.exe' "$output" 10581994689c1Smrg output=$func_stripname_result ;; 10582994689c1Smrg esac 10583994689c1Smrg # test for cygwin because mv fails w/o .exe extensions 10584994689c1Smrg case $host in 10585994689c1Smrg *cygwin*) 10586994689c1Smrg exeext=.exe 10587994689c1Smrg func_stripname '' '.exe' "$outputname" 10588994689c1Smrg outputname=$func_stripname_result ;; 10589994689c1Smrg *) exeext= ;; 105907a84e134Smrg esac 10591994689c1Smrg case $host in 10592994689c1Smrg *cygwin* | *mingw* ) 10593994689c1Smrg func_dirname_and_basename "$output" "" "." 10594994689c1Smrg output_name=$func_basename_result 10595994689c1Smrg output_path=$func_dirname_result 105965ec34c4cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 105975ec34c4cSmrg cwrapper=$output_path/$output_name.exe 10598994689c1Smrg $RM $cwrappersource $cwrapper 10599994689c1Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10600994689c1Smrg 10601994689c1Smrg func_emit_cwrapperexe_src > $cwrappersource 10602994689c1Smrg 10603994689c1Smrg # The wrapper executable is built using the $host compiler, 10604994689c1Smrg # because it contains $host paths and files. If cross- 10605994689c1Smrg # compiling, it, like the target executable, must be 10606994689c1Smrg # executed on the $host or under an emulation environment. 10607994689c1Smrg $opt_dry_run || { 10608994689c1Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10609994689c1Smrg $STRIP $cwrapper 10610994689c1Smrg } 106117a84e134Smrg 10612994689c1Smrg # Now, create the wrapper script for func_source use: 10613994689c1Smrg func_ltwrapper_scriptname $cwrapper 10614994689c1Smrg $RM $func_ltwrapper_scriptname_result 10615994689c1Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10616994689c1Smrg $opt_dry_run || { 10617994689c1Smrg # note: this script will not be executed, so do not chmod. 106185ec34c4cSmrg if test "x$build" = "x$host"; then 10619994689c1Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10620994689c1Smrg else 10621994689c1Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10622994689c1Smrg fi 10623994689c1Smrg } 10624994689c1Smrg ;; 10625994689c1Smrg * ) 10626994689c1Smrg $RM $output 10627994689c1Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 106287a84e134Smrg 10629994689c1Smrg func_emit_wrapper no > $output 10630994689c1Smrg chmod +x $output 10631994689c1Smrg ;; 10632994689c1Smrg esac 10633994689c1Smrg } 10634994689c1Smrg exit $EXIT_SUCCESS 10635994689c1Smrg ;; 10636994689c1Smrg esac 106377a84e134Smrg 10638994689c1Smrg # See if we need to build an old-fashioned archive. 10639994689c1Smrg for oldlib in $oldlibs; do 106407a84e134Smrg 106415ec34c4cSmrg case $build_libtool_libs in 106425ec34c4cSmrg convenience) 106435ec34c4cSmrg oldobjs="$libobjs_save $symfileobj" 106445ec34c4cSmrg addlibs=$convenience 10645994689c1Smrg build_libtool_libs=no 106465ec34c4cSmrg ;; 106475ec34c4cSmrg module) 106485ec34c4cSmrg oldobjs=$libobjs_save 106495ec34c4cSmrg addlibs=$old_convenience 106505ec34c4cSmrg build_libtool_libs=no 106515ec34c4cSmrg ;; 106525ec34c4cSmrg *) 10653994689c1Smrg oldobjs="$old_deplibs $non_pic_objects" 106545ec34c4cSmrg $preload && test -f "$symfileobj" \ 106555ec34c4cSmrg && func_append oldobjs " $symfileobj" 106565ec34c4cSmrg addlibs=$old_convenience 106575ec34c4cSmrg ;; 106585ec34c4cSmrg esac 106597a84e134Smrg 10660994689c1Smrg if test -n "$addlibs"; then 106615ec34c4cSmrg gentop=$output_objdir/${outputname}x 10662f353fbadSmrg func_append generated " $gentop" 106637a84e134Smrg 10664994689c1Smrg func_extract_archives $gentop $addlibs 10665f353fbadSmrg func_append oldobjs " $func_extract_archives_result" 10666994689c1Smrg fi 106677a84e134Smrg 10668994689c1Smrg # Do each command in the archive commands. 106695ec34c4cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10670994689c1Smrg cmds=$old_archive_from_new_cmds 10671994689c1Smrg else 106727a84e134Smrg 10673994689c1Smrg # Add any objects from preloaded convenience libraries 10674994689c1Smrg if test -n "$dlprefiles"; then 106755ec34c4cSmrg gentop=$output_objdir/${outputname}x 10676f353fbadSmrg func_append generated " $gentop" 106777a84e134Smrg 10678994689c1Smrg func_extract_archives $gentop $dlprefiles 10679f353fbadSmrg func_append oldobjs " $func_extract_archives_result" 10680994689c1Smrg fi 106817a84e134Smrg 10682994689c1Smrg # POSIX demands no paths to be encoded in archives. We have 10683994689c1Smrg # to avoid creating archives with duplicate basenames if we 10684994689c1Smrg # might have to extract them afterwards, e.g., when creating a 10685994689c1Smrg # static archive out of a convenience library, or when linking 10686994689c1Smrg # the entirety of a libtool archive into another (currently 10687994689c1Smrg # not supported by libtool). 10688994689c1Smrg if (for obj in $oldobjs 10689994689c1Smrg do 10690994689c1Smrg func_basename "$obj" 10691994689c1Smrg $ECHO "$func_basename_result" 10692994689c1Smrg done | sort | sort -uc >/dev/null 2>&1); then 10693994689c1Smrg : 10694994689c1Smrg else 10695994689c1Smrg echo "copying selected object files to avoid basename conflicts..." 106965ec34c4cSmrg gentop=$output_objdir/${outputname}x 10697f353fbadSmrg func_append generated " $gentop" 10698994689c1Smrg func_mkdir_p "$gentop" 10699994689c1Smrg save_oldobjs=$oldobjs 10700994689c1Smrg oldobjs= 10701994689c1Smrg counter=1 10702994689c1Smrg for obj in $save_oldobjs 10703994689c1Smrg do 10704994689c1Smrg func_basename "$obj" 107055ec34c4cSmrg objbase=$func_basename_result 10706994689c1Smrg case " $oldobjs " in 10707994689c1Smrg " ") oldobjs=$obj ;; 10708994689c1Smrg *[\ /]"$objbase "*) 10709994689c1Smrg while :; do 10710994689c1Smrg # Make sure we don't pick an alternate name that also 10711994689c1Smrg # overlaps. 10712994689c1Smrg newobj=lt$counter-$objbase 10713994689c1Smrg func_arith $counter + 1 10714994689c1Smrg counter=$func_arith_result 10715994689c1Smrg case " $oldobjs " in 10716994689c1Smrg *[\ /]"$newobj "*) ;; 10717994689c1Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10718994689c1Smrg esac 10719994689c1Smrg done 10720994689c1Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10721f353fbadSmrg func_append oldobjs " $gentop/$newobj" 10722994689c1Smrg ;; 10723f353fbadSmrg *) func_append oldobjs " $obj" ;; 10724994689c1Smrg esac 107257a84e134Smrg done 10726775e7de9Smrg fi 10727421c997bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10728421c997bSmrg tool_oldlib=$func_to_tool_file_result 10729994689c1Smrg eval cmds=\"$old_archive_cmds\" 10730e1e1713cSmrg 10731994689c1Smrg func_len " $cmds" 10732994689c1Smrg len=$func_len_result 10733994689c1Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10734994689c1Smrg cmds=$old_archive_cmds 10735f353fbadSmrg elif test -n "$archiver_list_spec"; then 10736f353fbadSmrg func_verbose "using command file archive linking..." 10737f353fbadSmrg for obj in $oldobjs 10738f353fbadSmrg do 10739f353fbadSmrg func_to_tool_file "$obj" 10740f353fbadSmrg $ECHO "$func_to_tool_file_result" 10741f353fbadSmrg done > $output_objdir/$libname.libcmd 10742f353fbadSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10743f353fbadSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10744f353fbadSmrg cmds=$old_archive_cmds 10745994689c1Smrg else 10746994689c1Smrg # the command line is too long to link in one step, link in parts 10747994689c1Smrg func_verbose "using piecewise archive linking..." 10748994689c1Smrg save_RANLIB=$RANLIB 10749994689c1Smrg RANLIB=: 10750994689c1Smrg objlist= 10751994689c1Smrg concat_cmds= 10752994689c1Smrg save_oldobjs=$oldobjs 10753994689c1Smrg oldobjs= 10754994689c1Smrg # Is there a better way of finding the last object in the list? 10755994689c1Smrg for obj in $save_oldobjs 10756994689c1Smrg do 10757994689c1Smrg last_oldobj=$obj 10758994689c1Smrg done 10759994689c1Smrg eval test_cmds=\"$old_archive_cmds\" 10760994689c1Smrg func_len " $test_cmds" 10761994689c1Smrg len0=$func_len_result 10762994689c1Smrg len=$len0 10763994689c1Smrg for obj in $save_oldobjs 10764994689c1Smrg do 10765994689c1Smrg func_len " $obj" 10766994689c1Smrg func_arith $len + $func_len_result 10767994689c1Smrg len=$func_arith_result 10768994689c1Smrg func_append objlist " $obj" 10769994689c1Smrg if test "$len" -lt "$max_cmd_len"; then 10770994689c1Smrg : 10771994689c1Smrg else 10772994689c1Smrg # the above command should be used before it gets too long 10773994689c1Smrg oldobjs=$objlist 107745ec34c4cSmrg if test "$obj" = "$last_oldobj"; then 10775994689c1Smrg RANLIB=$save_RANLIB 10776994689c1Smrg fi 10777994689c1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 107785ec34c4cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10779994689c1Smrg objlist= 10780994689c1Smrg len=$len0 10781994689c1Smrg fi 10782994689c1Smrg done 10783994689c1Smrg RANLIB=$save_RANLIB 10784994689c1Smrg oldobjs=$objlist 107855ec34c4cSmrg if test -z "$oldobjs"; then 10786994689c1Smrg eval cmds=\"\$concat_cmds\" 10787994689c1Smrg else 10788994689c1Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10789994689c1Smrg fi 10790994689c1Smrg fi 10791994689c1Smrg fi 10792994689c1Smrg func_execute_cmds "$cmds" 'exit $?' 107937a84e134Smrg done 107947a84e134Smrg 10795994689c1Smrg test -n "$generated" && \ 10796994689c1Smrg func_show_eval "${RM}r$generated" 107977a84e134Smrg 10798994689c1Smrg # Now create the libtool archive. 10799994689c1Smrg case $output in 10800994689c1Smrg *.la) 10801994689c1Smrg old_library= 108025ec34c4cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10803994689c1Smrg func_verbose "creating $output" 10804775e7de9Smrg 10805994689c1Smrg # Preserve any variables that may affect compiler behavior 10806994689c1Smrg for var in $variables_saved_for_relink; do 10807994689c1Smrg if eval test -z \"\${$var+set}\"; then 10808994689c1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10809994689c1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10810994689c1Smrg relink_command="$var=; export $var; $relink_command" 10811e1e1713cSmrg else 10812994689c1Smrg func_quote_for_eval "$var_value" 10813994689c1Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10814e1e1713cSmrg fi 10815994689c1Smrg done 10816994689c1Smrg # Quote the link command for shipping. 108175ec34c4cSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 108185ec34c4cSmrg func_quote "$relink_command" 108195ec34c4cSmrg relink_command=$func_quote_result 108205ec34c4cSmrg if test yes = "$hardcode_automatic"; then 10821994689c1Smrg relink_command= 10822994689c1Smrg fi 108237a84e134Smrg 10824994689c1Smrg # Only create the output if not a dry run. 10825994689c1Smrg $opt_dry_run || { 10826994689c1Smrg for installed in no yes; do 108275ec34c4cSmrg if test yes = "$installed"; then 10828994689c1Smrg if test -z "$install_libdir"; then 10829994689c1Smrg break 10830994689c1Smrg fi 108315ec34c4cSmrg output=$output_objdir/${outputname}i 10832994689c1Smrg # Replace all uninstalled libtool libraries with the installed ones 10833994689c1Smrg newdependency_libs= 10834994689c1Smrg for deplib in $dependency_libs; do 10835994689c1Smrg case $deplib in 10836994689c1Smrg *.la) 10837994689c1Smrg func_basename "$deplib" 108385ec34c4cSmrg name=$func_basename_result 10839421c997bSmrg func_resolve_sysroot "$deplib" 108405ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10841994689c1Smrg test -z "$libdir" && \ 108425ec34c4cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10843f353fbadSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10844f353fbadSmrg ;; 10845f353fbadSmrg -L*) 10846f353fbadSmrg func_stripname -L '' "$deplib" 10847f353fbadSmrg func_replace_sysroot "$func_stripname_result" 10848f353fbadSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10849f353fbadSmrg ;; 10850f353fbadSmrg -R*) 10851f353fbadSmrg func_stripname -R '' "$deplib" 10852f353fbadSmrg func_replace_sysroot "$func_stripname_result" 10853f353fbadSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10854994689c1Smrg ;; 10855f353fbadSmrg *) func_append newdependency_libs " $deplib" ;; 10856994689c1Smrg esac 10857994689c1Smrg done 108585ec34c4cSmrg dependency_libs=$newdependency_libs 10859994689c1Smrg newdlfiles= 10860994689c1Smrg 10861994689c1Smrg for lib in $dlfiles; do 10862994689c1Smrg case $lib in 10863994689c1Smrg *.la) 10864994689c1Smrg func_basename "$lib" 108655ec34c4cSmrg name=$func_basename_result 108665ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10867994689c1Smrg test -z "$libdir" && \ 108685ec34c4cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10869f353fbadSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10870994689c1Smrg ;; 10871f353fbadSmrg *) func_append newdlfiles " $lib" ;; 10872994689c1Smrg esac 10873994689c1Smrg done 108745ec34c4cSmrg dlfiles=$newdlfiles 10875994689c1Smrg newdlprefiles= 10876994689c1Smrg for lib in $dlprefiles; do 10877994689c1Smrg case $lib in 10878994689c1Smrg *.la) 10879994689c1Smrg # Only pass preopened files to the pseudo-archive (for 10880994689c1Smrg # eventual linking with the app. that links it) if we 10881994689c1Smrg # didn't already link the preopened objects directly into 10882994689c1Smrg # the library: 10883994689c1Smrg func_basename "$lib" 108845ec34c4cSmrg name=$func_basename_result 108855ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10886994689c1Smrg test -z "$libdir" && \ 108875ec34c4cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10888f353fbadSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10889994689c1Smrg ;; 10890994689c1Smrg esac 10891994689c1Smrg done 108925ec34c4cSmrg dlprefiles=$newdlprefiles 10893994689c1Smrg else 10894994689c1Smrg newdlfiles= 10895994689c1Smrg for lib in $dlfiles; do 10896994689c1Smrg case $lib in 108975ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10898994689c1Smrg *) abs=`pwd`"/$lib" ;; 10899994689c1Smrg esac 10900f353fbadSmrg func_append newdlfiles " $abs" 10901994689c1Smrg done 109025ec34c4cSmrg dlfiles=$newdlfiles 10903994689c1Smrg newdlprefiles= 10904994689c1Smrg for lib in $dlprefiles; do 10905994689c1Smrg case $lib in 109065ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10907994689c1Smrg *) abs=`pwd`"/$lib" ;; 10908994689c1Smrg esac 10909f353fbadSmrg func_append newdlprefiles " $abs" 10910994689c1Smrg done 109115ec34c4cSmrg dlprefiles=$newdlprefiles 10912994689c1Smrg fi 10913994689c1Smrg $RM $output 10914994689c1Smrg # place dlname in correct position for cygwin 10915994689c1Smrg # In fact, it would be nice if we could use this code for all target 10916994689c1Smrg # systems that can't hard-code library paths into their executables 10917994689c1Smrg # and that have no shared library path variable independent of PATH, 10918994689c1Smrg # but it turns out we can't easily determine that from inspecting 10919994689c1Smrg # libtool variables, so we have to hard-code the OSs to which it 10920994689c1Smrg # applies here; at the moment, that means platforms that use the PE 10921994689c1Smrg # object format with DLL files. See the long comment at the top of 10922994689c1Smrg # tests/bindir.at for full details. 10923994689c1Smrg tdlname=$dlname 10924994689c1Smrg case $host,$output,$installed,$module,$dlname in 10925994689c1Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10926994689c1Smrg # If a -bindir argument was supplied, place the dll there. 109275ec34c4cSmrg if test -n "$bindir"; then 10928994689c1Smrg func_relative_path "$install_libdir" "$bindir" 109295ec34c4cSmrg tdlname=$func_relative_path_result/$dlname 10930994689c1Smrg else 10931994689c1Smrg # Otherwise fall back on heuristic. 10932994689c1Smrg tdlname=../bin/$dlname 10933994689c1Smrg fi 10934994689c1Smrg ;; 10935994689c1Smrg esac 10936994689c1Smrg $ECHO > $output "\ 10937994689c1Smrg# $outputname - a libtool library file 109385ec34c4cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10939994689c1Smrg# 10940994689c1Smrg# Please DO NOT delete this file! 10941994689c1Smrg# It is necessary for linking the library. 109427a84e134Smrg 10943994689c1Smrg# The name that we can dlopen(3). 10944994689c1Smrgdlname='$tdlname' 109457a84e134Smrg 10946994689c1Smrg# Names of this library. 10947994689c1Smrglibrary_names='$library_names' 109487a84e134Smrg 10949994689c1Smrg# The name of the static archive. 10950994689c1Smrgold_library='$old_library' 109517a84e134Smrg 109525ec34c4cSmrg# Linker flags that cannot go in dependency_libs. 10953994689c1Smrginherited_linker_flags='$new_inherited_linker_flags' 109547a84e134Smrg 10955994689c1Smrg# Libraries that this one depends upon. 10956994689c1Smrgdependency_libs='$dependency_libs' 109577a84e134Smrg 10958994689c1Smrg# Names of additional weak libraries provided by this library 10959994689c1Smrgweak_library_names='$weak_libs' 109607a84e134Smrg 10961994689c1Smrg# Version information for $libname. 10962994689c1Smrgcurrent=$current 10963994689c1Smrgage=$age 10964994689c1Smrgrevision=$revision 109657a84e134Smrg 10966994689c1Smrg# Is this an already installed library? 10967994689c1Smrginstalled=$installed 109687a84e134Smrg 10969994689c1Smrg# Should we warn about portability when linking against -modules? 10970994689c1Smrgshouldnotlink=$module 109717a84e134Smrg 10972994689c1Smrg# Files to dlopen/dlpreopen 10973994689c1Smrgdlopen='$dlfiles' 10974994689c1Smrgdlpreopen='$dlprefiles' 109757a84e134Smrg 10976994689c1Smrg# Directory that this library needs to be installed in: 10977994689c1Smrglibdir='$install_libdir'" 109785ec34c4cSmrg if test no,yes = "$installed,$need_relink"; then 10979994689c1Smrg $ECHO >> $output "\ 10980994689c1Smrgrelink_command=\"$relink_command\"" 10981994689c1Smrg fi 10982994689c1Smrg done 10983994689c1Smrg } 109847a84e134Smrg 10985994689c1Smrg # Do a symbolic link so that the libtool archive can be found in 10986994689c1Smrg # LD_LIBRARY_PATH before the program is installed. 10987994689c1Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10988994689c1Smrg ;; 10989994689c1Smrg esac 10990994689c1Smrg exit $EXIT_SUCCESS 10991994689c1Smrg} 10992e1e1713cSmrg 109935ec34c4cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 109945ec34c4cSmrg func_mode_link ${1+"$@"} 109955ec34c4cSmrgfi 109967a84e134Smrg 109977a84e134Smrg 10998994689c1Smrg# func_mode_uninstall arg... 10999994689c1Smrgfunc_mode_uninstall () 11000994689c1Smrg{ 110015ec34c4cSmrg $debug_cmd 110025ec34c4cSmrg 110035ec34c4cSmrg RM=$nonopt 110047a84e134Smrg files= 110055ec34c4cSmrg rmforce=false 110067a84e134Smrg exit_status=0 110077a84e134Smrg 110087a84e134Smrg # This variable tells wrapper scripts just to set variables rather 110097a84e134Smrg # than running their programs. 110105ec34c4cSmrg libtool_install_magic=$magic 110117a84e134Smrg 110127a84e134Smrg for arg 110137a84e134Smrg do 110147a84e134Smrg case $arg in 110155ec34c4cSmrg -f) func_append RM " $arg"; rmforce=: ;; 11016f353fbadSmrg -*) func_append RM " $arg" ;; 11017f353fbadSmrg *) func_append files " $arg" ;; 110187a84e134Smrg esac 110197a84e134Smrg done 110207a84e134Smrg 11021994689c1Smrg test -z "$RM" && \ 11022994689c1Smrg func_fatal_help "you must specify an RM program" 110237a84e134Smrg 110247a84e134Smrg rmdirs= 110257a84e134Smrg 110267a84e134Smrg for file in $files; do 11027994689c1Smrg func_dirname "$file" "" "." 110285ec34c4cSmrg dir=$func_dirname_result 110295ec34c4cSmrg if test . = "$dir"; then 110305ec34c4cSmrg odir=$objdir 110317a84e134Smrg else 110325ec34c4cSmrg odir=$dir/$objdir 110337a84e134Smrg fi 11034994689c1Smrg func_basename "$file" 110355ec34c4cSmrg name=$func_basename_result 110365ec34c4cSmrg test uninstall = "$opt_mode" && odir=$dir 110377a84e134Smrg 11038f353fbadSmrg # Remember odir for removal later, being careful to avoid duplicates 110395ec34c4cSmrg if test clean = "$opt_mode"; then 110407a84e134Smrg case " $rmdirs " in 11041f353fbadSmrg *" $odir "*) ;; 11042f353fbadSmrg *) func_append rmdirs " $odir" ;; 110437a84e134Smrg esac 110447a84e134Smrg fi 110457a84e134Smrg 110467a84e134Smrg # Don't error if the file doesn't exist and rm -f was used. 11047994689c1Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11048994689c1Smrg { test -h "$file"; } >/dev/null 2>&1 || 11049994689c1Smrg test -f "$file"; then 110507a84e134Smrg : 110517a84e134Smrg elif test -d "$file"; then 110527a84e134Smrg exit_status=1 110537a84e134Smrg continue 110545ec34c4cSmrg elif $rmforce; then 110557a84e134Smrg continue 110567a84e134Smrg fi 110577a84e134Smrg 110585ec34c4cSmrg rmfiles=$file 110597a84e134Smrg 110607a84e134Smrg case $name in 110617a84e134Smrg *.la) 110627a84e134Smrg # Possibly a libtool archive, so verify it. 11063994689c1Smrg if func_lalib_p "$file"; then 11064994689c1Smrg func_source $dir/$name 110657a84e134Smrg 110667a84e134Smrg # Delete the libtool libraries and symlinks. 110677a84e134Smrg for n in $library_names; do 11068f353fbadSmrg func_append rmfiles " $odir/$n" 110697a84e134Smrg done 11070f353fbadSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 110717a84e134Smrg 110725ec34c4cSmrg case $opt_mode in 110737a84e134Smrg clean) 11074f353fbadSmrg case " $library_names " in 110757a84e134Smrg *" $dlname "*) ;; 11076f353fbadSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 110777a84e134Smrg esac 11078f353fbadSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 110797a84e134Smrg ;; 110807a84e134Smrg uninstall) 110817a84e134Smrg if test -n "$library_names"; then 110827a84e134Smrg # Do each command in the postuninstall commands. 110835ec34c4cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 110847a84e134Smrg fi 110857a84e134Smrg 110867a84e134Smrg if test -n "$old_library"; then 110877a84e134Smrg # Do each command in the old_postuninstall commands. 110885ec34c4cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 110897a84e134Smrg fi 110907a84e134Smrg # FIXME: should reinstall the best remaining shared library. 110917a84e134Smrg ;; 110927a84e134Smrg esac 110937a84e134Smrg fi 110947a84e134Smrg ;; 110957a84e134Smrg 110967a84e134Smrg *.lo) 110977a84e134Smrg # Possibly a libtool object, so verify it. 11098994689c1Smrg if func_lalib_p "$file"; then 110997a84e134Smrg 111007a84e134Smrg # Read the .lo file 11101994689c1Smrg func_source $dir/$name 111027a84e134Smrg 111037a84e134Smrg # Add PIC object to the list of files to remove. 111045ec34c4cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11105f353fbadSmrg func_append rmfiles " $dir/$pic_object" 111067a84e134Smrg fi 111077a84e134Smrg 111087a84e134Smrg # Add non-PIC object to the list of files to remove. 111095ec34c4cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11110f353fbadSmrg func_append rmfiles " $dir/$non_pic_object" 111117a84e134Smrg fi 111127a84e134Smrg fi 111137a84e134Smrg ;; 111147a84e134Smrg 111157a84e134Smrg *) 111165ec34c4cSmrg if test clean = "$opt_mode"; then 111177a84e134Smrg noexename=$name 111187a84e134Smrg case $file in 111197a84e134Smrg *.exe) 11120994689c1Smrg func_stripname '' '.exe' "$file" 11121994689c1Smrg file=$func_stripname_result 11122994689c1Smrg func_stripname '' '.exe' "$name" 11123994689c1Smrg noexename=$func_stripname_result 111247a84e134Smrg # $file with .exe has already been added to rmfiles, 111257a84e134Smrg # add $file without .exe 11126f353fbadSmrg func_append rmfiles " $file" 111277a84e134Smrg ;; 111287a84e134Smrg esac 111297a84e134Smrg # Do a test to see if this is a libtool program. 11130994689c1Smrg if func_ltwrapper_p "$file"; then 11131994689c1Smrg if func_ltwrapper_executable_p "$file"; then 11132994689c1Smrg func_ltwrapper_scriptname "$file" 11133994689c1Smrg relink_command= 11134994689c1Smrg func_source $func_ltwrapper_scriptname_result 11135f353fbadSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11136994689c1Smrg else 11137994689c1Smrg relink_command= 11138994689c1Smrg func_source $dir/$noexename 11139994689c1Smrg fi 111407a84e134Smrg 111417a84e134Smrg # note $name still contains .exe if it was in $file originally 111427a84e134Smrg # as does the version of $file that was added into $rmfiles 111435ec34c4cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 111445ec34c4cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11145f353fbadSmrg func_append rmfiles " $odir/lt-$name" 111467a84e134Smrg fi 111475ec34c4cSmrg if test "X$noexename" != "X$name"; then 111485ec34c4cSmrg func_append rmfiles " $odir/lt-$noexename.c" 111497a84e134Smrg fi 111507a84e134Smrg fi 111517a84e134Smrg fi 111527a84e134Smrg ;; 111537a84e134Smrg esac 11154994689c1Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 111557a84e134Smrg done 111567a84e134Smrg 111575ec34c4cSmrg # Try to remove the $objdir's in the directories where we deleted files 111587a84e134Smrg for dir in $rmdirs; do 111597a84e134Smrg if test -d "$dir"; then 11160994689c1Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 111617a84e134Smrg fi 111627a84e134Smrg done 111637a84e134Smrg 111647a84e134Smrg exit $exit_status 11165994689c1Smrg} 111667a84e134Smrg 111675ec34c4cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 111685ec34c4cSmrg func_mode_uninstall ${1+"$@"} 111695ec34c4cSmrgfi 11170775e7de9Smrg 11171f353fbadSmrgtest -z "$opt_mode" && { 111725ec34c4cSmrg help=$generic_help 11173994689c1Smrg func_fatal_help "you must specify a MODE" 11174994689c1Smrg} 11175994689c1Smrg 11176994689c1Smrgtest -z "$exec_cmd" && \ 111775ec34c4cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 111787a84e134Smrg 111797a84e134Smrgif test -n "$exec_cmd"; then 11180994689c1Smrg eval exec "$exec_cmd" 111817a84e134Smrg exit $EXIT_FAILURE 111827a84e134Smrgfi 111837a84e134Smrg 11184994689c1Smrgexit $exit_status 11185e1e1713cSmrg 111867a84e134Smrg 111877a84e134Smrg# The TAGs below are defined such that we never get into a situation 111885ec34c4cSmrg# where we disable both kinds of libraries. Given conflicting 111897a84e134Smrg# choices, we go for a static library, that is the most portable, 111907a84e134Smrg# since we can't tell whether shared libraries were disabled because 111917a84e134Smrg# the user asked for that or because the platform doesn't support 111927a84e134Smrg# them. This is particularly important on AIX, because we don't 111937a84e134Smrg# support having both static and shared libraries enabled at the same 111947a84e134Smrg# time on that platform, so we default to a shared-only configuration. 111957a84e134Smrg# If a disable-shared tag is given, we'll fallback to a static-only 111967a84e134Smrg# configuration. But we'll never go from static-only to shared-only. 111977a84e134Smrg 111987a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11199994689c1Smrgbuild_libtool_libs=no 11200994689c1Smrgbuild_old_libs=yes 112017a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 112027a84e134Smrg 112037a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11204994689c1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 112057a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-static 112067a84e134Smrg 112077a84e134Smrg# Local Variables: 112087a84e134Smrg# mode:shell-script 112097a84e134Smrg# sh-indentation:2 112107a84e134Smrg# End: 11211