ltmain.sh revision c3e29c03
1c3e29c03Smrg#! /usr/bin/env sh 226372658Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3c3e29c03Smrg## by inline-source v2019-02-19.15 449dc963fSmrg 5c3e29c03Smrg# libtool (GNU libtool) 2.4.7 626372658Smrg# Provide generalized library-building support services. 749dc963fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 849dc963fSmrg 9c3e29c03Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 1049dc963fSmrg# This is free software; see the source for copying conditions. There is NO 1149dc963fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1249dc963fSmrg 1349dc963fSmrg# GNU Libtool is free software; you can redistribute it and/or modify 144b0ead49Smrg# it under the terms of the GNU General Public License as published by 154b0ead49Smrg# the Free Software Foundation; either version 2 of the License, or 164b0ead49Smrg# (at your option) any later version. 174b0ead49Smrg# 1849dc963fSmrg# As a special exception to the GNU General Public License, 1949dc963fSmrg# if you distribute this file as part of a program or library that 2049dc963fSmrg# is built using GNU Libtool, you may include this file under the 2149dc963fSmrg# same distribution terms that you use for the rest of that program. 2249dc963fSmrg# 2349dc963fSmrg# GNU Libtool is distributed in the hope that it will be useful, but 244b0ead49Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 254b0ead49Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 264b0ead49Smrg# General Public License for more details. 274b0ead49Smrg# 284b0ead49Smrg# You should have received a copy of the GNU General Public License 2926372658Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 304b0ead49Smrg 314b0ead49Smrg 327aa89044SmrgPROGRAM=libtool 334b0ead49SmrgPACKAGE=libtool 34c3e29c03SmrgVERSION=2.4.7 35c3e29c03Smrgpackage_revision=2.4.7 3652b01e16Smrg 3726372658Smrg 3826372658Smrg## ------ ## 3926372658Smrg## Usage. ## 4026372658Smrg## ------ ## 4126372658Smrg 4226372658Smrg# Run './libtool --help' for help with using this script from the 4326372658Smrg# command line. 4426372658Smrg 4526372658Smrg 4626372658Smrg## ------------------------------- ## 4726372658Smrg## User overridable command paths. ## 4826372658Smrg## ------------------------------- ## 4926372658Smrg 5026372658Smrg# After configure completes, it has a better idea of some of the 5126372658Smrg# shell tools we need than the defaults used by the functions shared 5226372658Smrg# with bootstrap, so set those here where they can still be over- 5326372658Smrg# ridden by the user, but otherwise take precedence. 5426372658Smrg 5526372658Smrg: ${AUTOCONF="autoconf"} 5626372658Smrg: ${AUTOMAKE="automake"} 5726372658Smrg 5826372658Smrg 5926372658Smrg## -------------------------- ## 6026372658Smrg## Source external libraries. ## 6126372658Smrg## -------------------------- ## 6226372658Smrg 6326372658Smrg# Much of our low-level functionality needs to be sourced from external 6426372658Smrg# libraries, which are installed to $pkgauxdir. 6526372658Smrg 6626372658Smrg# Set a version string for this script. 67c3e29c03Smrgscriptversion=2019-02-19.15; # UTC 6826372658Smrg 6926372658Smrg# General shell script boiler plate, and helper functions. 7026372658Smrg# Written by Gary V. Vaughan, 2004 7126372658Smrg 72c3e29c03Smrg# This is free software. There is NO warranty; not even for 73c3e29c03Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74c3e29c03Smrg# 75c3e29c03Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76c3e29c03Smrg# 77c3e29c03Smrg# This file is dual licensed under the terms of the MIT license 78c3e29c03Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79c3e29c03Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80c3e29c03Smrg# these licenses when using or redistributing this software or any of 81c3e29c03Smrg# the files within it. See the URLs above, or the file `LICENSE` 82c3e29c03Smrg# included in the Bootstrap distribution for the full license texts. 8326372658Smrg 84c3e29c03Smrg# Please report bugs or propose patches to: 85c3e29c03Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 8626372658Smrg 8726372658Smrg 8826372658Smrg## ------ ## 8926372658Smrg## Usage. ## 9026372658Smrg## ------ ## 9126372658Smrg 9226372658Smrg# Evaluate this file near the top of your script to gain access to 9326372658Smrg# the functions and variables defined here: 9426372658Smrg# 9526372658Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 9626372658Smrg# 9726372658Smrg# If you need to override any of the default environment variable 9826372658Smrg# settings, do that before evaluating this file. 9926372658Smrg 10026372658Smrg 10126372658Smrg## -------------------- ## 10226372658Smrg## Shell normalisation. ## 10326372658Smrg## -------------------- ## 10426372658Smrg 10526372658Smrg# Some shells need a little help to be as Bourne compatible as possible. 10626372658Smrg# Before doing anything else, make sure all that help has been provided! 10726372658Smrg 10826372658SmrgDUALCASE=1; export DUALCASE # for MKS sh 10926372658Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11052b01e16Smrg emulate sh 11152b01e16Smrg NULLCMD=: 11226372658Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 11352b01e16Smrg # is contrary to our usage. Disable this feature. 11452b01e16Smrg alias -g '${1+"$@"}'='"$@"' 1154b0ead49Smrg setopt NO_GLOB_SUBST 11652b01e16Smrgelse 11726372658Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1184b0ead49Smrgfi 1197aa89044Smrg 12026372658Smrg# NLS nuisances: We save the old values in case they are required later. 12126372658Smrg_G_user_locale= 12226372658Smrg_G_safe_locale= 12326372658Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 12452b01e16Smrgdo 12526372658Smrg eval "if test set = \"\${$_G_var+set}\"; then 12626372658Smrg save_$_G_var=\$$_G_var 12726372658Smrg $_G_var=C 12826372658Smrg export $_G_var 12926372658Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13026372658Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 13152b01e16Smrg fi" 13252b01e16Smrgdone 133c3e29c03Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134c3e29c03Smrg# in case the environment reset is needed later and the $save_* variant is not 135c3e29c03Smrg# defined (see the code above). 136c3e29c03SmrgLC_ALL=C 137c3e29c03SmrgLANGUAGE=C 138c3e29c03Smrgexport LANGUAGE LC_ALL 13949dc963fSmrg 14026372658Smrg# Make sure IFS has a sensible default 14126372658Smrgsp=' ' 14226372658Smrgnl=' 14326372658Smrg' 14426372658SmrgIFS="$sp $nl" 14526372658Smrg 14626372658Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 14726372658Smrgif test "${PATH_SEPARATOR+set}" != set; then 14826372658Smrg PATH_SEPARATOR=: 14926372658Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15026372658Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15126372658Smrg PATH_SEPARATOR=';' 15226372658Smrg } 15326372658Smrgfi 15449dc963fSmrg 15549dc963fSmrg 156c3e29c03Smrg# func_unset VAR 157c3e29c03Smrg# -------------- 158c3e29c03Smrg# Portably unset VAR. 159c3e29c03Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160c3e29c03Smrg# status if VAR is already unset, which might be problematic if the 161c3e29c03Smrg# statement is used at the end of a function (thus poisoning its return 162c3e29c03Smrg# value) or when 'set -e' is active (causing even a spurious abort of 163c3e29c03Smrg# the script in this case). 164c3e29c03Smrgfunc_unset () 165c3e29c03Smrg{ 166c3e29c03Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167c3e29c03Smrg} 168c3e29c03Smrg 169c3e29c03Smrg 170c3e29c03Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171c3e29c03Smrgfunc_unset CDPATH 172c3e29c03Smrg 173c3e29c03Smrg# Make sure ${,E,F}GREP behave sanely. 174c3e29c03Smrgfunc_unset GREP_OPTIONS 175c3e29c03Smrg 17649dc963fSmrg 17726372658Smrg## ------------------------- ## 17826372658Smrg## Locate command utilities. ## 17926372658Smrg## ------------------------- ## 18026372658Smrg 18126372658Smrg 18226372658Smrg# func_executable_p FILE 18326372658Smrg# ---------------------- 18426372658Smrg# Check that FILE is an executable regular file. 18526372658Smrgfunc_executable_p () 18626372658Smrg{ 18726372658Smrg test -f "$1" && test -x "$1" 18826372658Smrg} 18926372658Smrg 19026372658Smrg 19126372658Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 19226372658Smrg# -------------------------------------------- 19326372658Smrg# Search for either a program that responds to --version with output 19426372658Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 19526372658Smrg# trying all the directories in PATH with each of the elements of 19626372658Smrg# PROGS_LIST. 19726372658Smrg# 19826372658Smrg# CHECK_FUNC should accept the path to a candidate program, and 19926372658Smrg# set $func_check_prog_result if it truncates its output less than 20026372658Smrg# $_G_path_prog_max characters. 20126372658Smrgfunc_path_progs () 20226372658Smrg{ 20326372658Smrg _G_progs_list=$1 20426372658Smrg _G_check_func=$2 20526372658Smrg _G_PATH=${3-"$PATH"} 20626372658Smrg 20726372658Smrg _G_path_prog_max=0 20826372658Smrg _G_path_prog_found=false 20926372658Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 21026372658Smrg for _G_dir in $_G_PATH; do 21126372658Smrg IFS=$_G_save_IFS 21226372658Smrg test -z "$_G_dir" && _G_dir=. 21326372658Smrg for _G_prog_name in $_G_progs_list; do 21426372658Smrg for _exeext in '' .EXE; do 21526372658Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 21626372658Smrg func_executable_p "$_G_path_prog" || continue 21726372658Smrg case `"$_G_path_prog" --version 2>&1` in 21826372658Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 21926372658Smrg *) $_G_check_func $_G_path_prog 22026372658Smrg func_path_progs_result=$func_check_prog_result 22126372658Smrg ;; 22226372658Smrg esac 22326372658Smrg $_G_path_prog_found && break 3 22426372658Smrg done 22526372658Smrg done 22626372658Smrg done 22726372658Smrg IFS=$_G_save_IFS 22826372658Smrg test -z "$func_path_progs_result" && { 22926372658Smrg echo "no acceptable sed could be found in \$PATH" >&2 23026372658Smrg exit 1 23126372658Smrg } 23226372658Smrg} 23326372658Smrg 23426372658Smrg 23526372658Smrg# We want to be able to use the functions in this file before configure 23626372658Smrg# has figured out where the best binaries are kept, which means we have 23726372658Smrg# to search for them ourselves - except when the results are already set 23826372658Smrg# where we skip the searches. 23926372658Smrg 24026372658Smrg# Unless the user overrides by setting SED, search the path for either GNU 24126372658Smrg# sed, or the sed that truncates its output the least. 24226372658Smrgtest -z "$SED" && { 24326372658Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 24426372658Smrg for _G_i in 1 2 3 4 5 6 7; do 24526372658Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 24626372658Smrg done 24726372658Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 24826372658Smrg _G_sed_script= 24926372658Smrg 25026372658Smrg func_check_prog_sed () 25126372658Smrg { 25226372658Smrg _G_path_prog=$1 25326372658Smrg 25426372658Smrg _G_count=0 25526372658Smrg printf 0123456789 >conftest.in 25626372658Smrg while : 25726372658Smrg do 25826372658Smrg cat conftest.in conftest.in >conftest.tmp 25926372658Smrg mv conftest.tmp conftest.in 26026372658Smrg cp conftest.in conftest.nl 26126372658Smrg echo '' >> conftest.nl 26226372658Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 26326372658Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 26426372658Smrg _G_count=`expr $_G_count + 1` 26526372658Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 26626372658Smrg # Best one so far, save it but keep looking for a better one 26726372658Smrg func_check_prog_result=$_G_path_prog 26826372658Smrg _G_path_prog_max=$_G_count 26926372658Smrg fi 27026372658Smrg # 10*(2^10) chars as input seems more than enough 27126372658Smrg test 10 -lt "$_G_count" && break 27226372658Smrg done 27326372658Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 27426372658Smrg } 27526372658Smrg 276c3e29c03Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 27726372658Smrg rm -f conftest.sed 27826372658Smrg SED=$func_path_progs_result 27926372658Smrg} 28026372658Smrg 28126372658Smrg 28226372658Smrg# Unless the user overrides by setting GREP, search the path for either GNU 28326372658Smrg# grep, or the grep that truncates its output the least. 28426372658Smrgtest -z "$GREP" && { 28526372658Smrg func_check_prog_grep () 28626372658Smrg { 28726372658Smrg _G_path_prog=$1 28826372658Smrg 28926372658Smrg _G_count=0 29026372658Smrg _G_path_prog_max=0 29126372658Smrg printf 0123456789 >conftest.in 29226372658Smrg while : 29326372658Smrg do 29426372658Smrg cat conftest.in conftest.in >conftest.tmp 29526372658Smrg mv conftest.tmp conftest.in 29626372658Smrg cp conftest.in conftest.nl 29726372658Smrg echo 'GREP' >> conftest.nl 29826372658Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 29926372658Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 30026372658Smrg _G_count=`expr $_G_count + 1` 30126372658Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 30226372658Smrg # Best one so far, save it but keep looking for a better one 30326372658Smrg func_check_prog_result=$_G_path_prog 30426372658Smrg _G_path_prog_max=$_G_count 30526372658Smrg fi 30626372658Smrg # 10*(2^10) chars as input seems more than enough 30726372658Smrg test 10 -lt "$_G_count" && break 30826372658Smrg done 30926372658Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 31026372658Smrg } 31126372658Smrg 312c3e29c03Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 31326372658Smrg GREP=$func_path_progs_result 31426372658Smrg} 31526372658Smrg 31626372658Smrg 31726372658Smrg## ------------------------------- ## 31826372658Smrg## User overridable command paths. ## 31926372658Smrg## ------------------------------- ## 32026372658Smrg 32126372658Smrg# All uppercase variable names are used for environment variables. These 32226372658Smrg# variables can be overridden by the user before calling a script that 32326372658Smrg# uses them if a suitable command of that name is not already available 32426372658Smrg# in the command search PATH. 32549dc963fSmrg 32649dc963fSmrg: ${CP="cp -f"} 32726372658Smrg: ${ECHO="printf %s\n"} 32826372658Smrg: ${EGREP="$GREP -E"} 32926372658Smrg: ${FGREP="$GREP -F"} 33026372658Smrg: ${LN_S="ln -s"} 33149dc963fSmrg: ${MAKE="make"} 33249dc963fSmrg: ${MKDIR="mkdir"} 33349dc963fSmrg: ${MV="mv -f"} 33449dc963fSmrg: ${RM="rm -f"} 33549dc963fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3364b0ead49Smrg 33749dc963fSmrg 33826372658Smrg## -------------------- ## 33926372658Smrg## Useful sed snippets. ## 34026372658Smrg## -------------------- ## 3414e7590efSmrg 34226372658Smrgsed_dirname='s|/[^/]*$||' 34326372658Smrgsed_basename='s|^.*/||' 3444e7590efSmrg 34526372658Smrg# Sed substitution that helps us do robust quoting. It backslashifies 34626372658Smrg# metacharacters that are still active within double-quoted strings. 34726372658Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3484e7590efSmrg 34926372658Smrg# Same as above, but do not quote variable references. 35026372658Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3514e7590efSmrg 35226372658Smrg# Sed substitution that turns a string into a regex matching for the 35326372658Smrg# string literally. 35426372658Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3554e7590efSmrg 35626372658Smrg# Sed substitution that converts a w32 file name or path 35726372658Smrg# that contains forward slashes, into one that contains 35826372658Smrg# (escaped) backslashes. A very naive implementation. 35926372658Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 36026372658Smrg 36126372658Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 36226372658Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 36326372658Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 36426372658Smrg# expansion. Since each input '\' is now two '\'s, look for any number 36526372658Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 36626372658Smrg_G_bs='\\' 36726372658Smrg_G_bs2='\\\\' 36826372658Smrg_G_bs4='\\\\\\\\' 36926372658Smrg_G_dollar='\$' 37026372658Smrgsed_double_backslash="\ 37126372658Smrg s/$_G_bs4/&\\ 37226372658Smrg/g 37326372658Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 37426372658Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 37526372658Smrg s/\n//g" 3764e7590efSmrg 377c3e29c03Smrg# require_check_ifs_backslash 378c3e29c03Smrg# --------------------------- 379c3e29c03Smrg# Check if we can use backslash as IFS='\' separator, and set 380c3e29c03Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 381c3e29c03Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382c3e29c03Smrgfunc_require_check_ifs_backslash () 383c3e29c03Smrg{ 384c3e29c03Smrg _G_save_IFS=$IFS 385c3e29c03Smrg IFS='\' 386c3e29c03Smrg _G_check_ifs_backshlash='a\\b' 387c3e29c03Smrg for _G_i in $_G_check_ifs_backshlash 388c3e29c03Smrg do 389c3e29c03Smrg case $_G_i in 390c3e29c03Smrg a) 391c3e29c03Smrg check_ifs_backshlash_broken=false 392c3e29c03Smrg ;; 393c3e29c03Smrg '') 394c3e29c03Smrg break 395c3e29c03Smrg ;; 396c3e29c03Smrg *) 397c3e29c03Smrg check_ifs_backshlash_broken=: 398c3e29c03Smrg break 399c3e29c03Smrg ;; 400c3e29c03Smrg esac 401c3e29c03Smrg done 402c3e29c03Smrg IFS=$_G_save_IFS 403c3e29c03Smrg require_check_ifs_backslash=: 404c3e29c03Smrg} 405c3e29c03Smrg 4064b0ead49Smrg 40726372658Smrg## ----------------- ## 40826372658Smrg## Global variables. ## 40926372658Smrg## ----------------- ## 41049dc963fSmrg 41126372658Smrg# Except for the global variables explicitly listed below, the following 41226372658Smrg# functions in the '^func_' namespace, and the '^require_' namespace 41326372658Smrg# variables initialised in the 'Resource management' section, sourcing 41426372658Smrg# this file will not pollute your global namespace with anything 41526372658Smrg# else. There's no portable way to scope variables in Bourne shell 41626372658Smrg# though, so actually running these functions will sometimes place 41726372658Smrg# results into a variable named after the function, and often use 41826372658Smrg# temporary variables in the '^_G_' namespace. If you are careful to 41926372658Smrg# avoid using those namespaces casually in your sourcing script, things 42026372658Smrg# should continue to work as you expect. And, of course, you can freely 42126372658Smrg# overwrite any of the functions or variables defined here before 42226372658Smrg# calling anything to customize them. 4237aa89044Smrg 42426372658SmrgEXIT_SUCCESS=0 42526372658SmrgEXIT_FAILURE=1 42626372658SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 42726372658SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 4287aa89044Smrg 42926372658Smrg# Allow overriding, eg assuming that you follow the convention of 43026372658Smrg# putting '$debug_cmd' at the start of all your functions, you can get 43126372658Smrg# bash to show function call trace with: 43226372658Smrg# 43326372658Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 43426372658Smrgdebug_cmd=${debug_cmd-":"} 43526372658Smrgexit_cmd=: 4367aa89044Smrg 43726372658Smrg# By convention, finish your script with: 43826372658Smrg# 43926372658Smrg# exit $exit_status 44026372658Smrg# 44126372658Smrg# so that you can set exit_status to non-zero if you want to indicate 44226372658Smrg# something went wrong during execution without actually bailing out at 44326372658Smrg# the point of failure. 44426372658Smrgexit_status=$EXIT_SUCCESS 4457aa89044Smrg 44626372658Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 44726372658Smrg# is ksh but when the shell is invoked as "sh" and the current value of 44826372658Smrg# the _XPG environment variable is not equal to 1 (one), the special 44926372658Smrg# positional parameter $0, within a function call, is the name of the 45026372658Smrg# function. 45126372658Smrgprogpath=$0 45249dc963fSmrg 45326372658Smrg# The name of this program. 45426372658Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 45549dc963fSmrg 45626372658Smrg# Make sure we have an absolute progpath for reexecution: 45749dc963fSmrgcase $progpath in 45849dc963fSmrg [\\/]*|[A-Za-z]:\\*) ;; 45949dc963fSmrg *[\\/]*) 46026372658Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 46149dc963fSmrg progdir=`cd "$progdir" && pwd` 46226372658Smrg progpath=$progdir/$progname 46349dc963fSmrg ;; 46449dc963fSmrg *) 46526372658Smrg _G_IFS=$IFS 4664e7590efSmrg IFS=${PATH_SEPARATOR-:} 46749dc963fSmrg for progdir in $PATH; do 46826372658Smrg IFS=$_G_IFS 46949dc963fSmrg test -x "$progdir/$progname" && break 47049dc963fSmrg done 47126372658Smrg IFS=$_G_IFS 47249dc963fSmrg test -n "$progdir" || progdir=`pwd` 47326372658Smrg progpath=$progdir/$progname 47449dc963fSmrg ;; 47549dc963fSmrgesac 47649dc963fSmrg 47749dc963fSmrg 47826372658Smrg## ----------------- ## 47926372658Smrg## Standard options. ## 48026372658Smrg## ----------------- ## 4814e7590efSmrg 48226372658Smrg# The following options affect the operation of the functions defined 48326372658Smrg# below, and should be set appropriately depending on run-time para- 48426372658Smrg# meters passed on the command line. 48549dc963fSmrg 48649dc963fSmrgopt_dry_run=false 48749dc963fSmrgopt_quiet=false 48849dc963fSmrgopt_verbose=false 48949dc963fSmrg 49026372658Smrg# Categories 'all' and 'none' are always available. Append any others 49126372658Smrg# you will pass as the first argument to func_warning from your own 49226372658Smrg# code. 49326372658Smrgwarning_categories= 49449dc963fSmrg 49526372658Smrg# By default, display warnings according to 'opt_warning_types'. Set 49626372658Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 49726372658Smrg# treat the next displayed warning as a fatal error. 49826372658Smrgwarning_func=func_warn_and_continue 49949dc963fSmrg 50026372658Smrg# Set to 'all' to display all warnings, 'none' to suppress all 50126372658Smrg# warnings, or a space delimited list of some subset of 50226372658Smrg# 'warning_categories' to display only the listed warnings. 50326372658Smrgopt_warning_types=all 50449dc963fSmrg 5057aa89044Smrg 50626372658Smrg## -------------------- ## 50726372658Smrg## Resource management. ## 50826372658Smrg## -------------------- ## 50949dc963fSmrg 51026372658Smrg# This section contains definitions for functions that each ensure a 51126372658Smrg# particular resource (a file, or a non-empty configuration variable for 51226372658Smrg# example) is available, and if appropriate to extract default values 51326372658Smrg# from pertinent package files. Call them using their associated 51426372658Smrg# 'require_*' variable to ensure that they are executed, at most, once. 51526372658Smrg# 51626372658Smrg# It's entirely deliberate that calling these functions can set 51726372658Smrg# variables that don't obey the namespace limitations obeyed by the rest 51826372658Smrg# of this file, in order that that they be as useful as possible to 51926372658Smrg# callers. 52049dc963fSmrg 52149dc963fSmrg 52226372658Smrg# require_term_colors 52326372658Smrg# ------------------- 52426372658Smrg# Allow display of bold text on terminals that support it. 52526372658Smrgrequire_term_colors=func_require_term_colors 52626372658Smrgfunc_require_term_colors () 52749dc963fSmrg{ 52826372658Smrg $debug_cmd 52926372658Smrg 53026372658Smrg test -t 1 && { 53126372658Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 53226372658Smrg # precedence, because most terminfo databases neglect to describe 53326372658Smrg # whether color sequences are supported. 53426372658Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 53526372658Smrg 53626372658Smrg if test 1 = "$USE_ANSI_COLORS"; then 53726372658Smrg # Standard ANSI escape sequences 53826372658Smrg tc_reset='[0m' 53926372658Smrg tc_bold='[1m'; tc_standout='[7m' 54026372658Smrg tc_red='[31m'; tc_green='[32m' 54126372658Smrg tc_blue='[34m'; tc_cyan='[36m' 54226372658Smrg else 54326372658Smrg # Otherwise trust the terminfo database after all. 54426372658Smrg test -n "`tput sgr0 2>/dev/null`" && { 54526372658Smrg tc_reset=`tput sgr0` 54626372658Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 54726372658Smrg tc_standout=$tc_bold 54826372658Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 54926372658Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 55026372658Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 55126372658Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 55226372658Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 55326372658Smrg } 55426372658Smrg fi 55526372658Smrg } 55649dc963fSmrg 55726372658Smrg require_term_colors=: 55849dc963fSmrg} 55949dc963fSmrg 56049dc963fSmrg 56126372658Smrg## ----------------- ## 56226372658Smrg## Function library. ## 56326372658Smrg## ----------------- ## 56426372658Smrg 56526372658Smrg# This section contains a variety of useful functions to call in your 56626372658Smrg# scripts. Take note of the portable wrappers for features provided by 56726372658Smrg# some modern shells, which will fall back to slower equivalents on 56826372658Smrg# less featureful shells. 56926372658Smrg 57026372658Smrg 57126372658Smrg# func_append VAR VALUE 57226372658Smrg# --------------------- 57326372658Smrg# Append VALUE onto the existing contents of VAR. 57426372658Smrg 57526372658Smrg # We should try to minimise forks, especially on Windows where they are 57626372658Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 57726372658Smrg # being used: 57826372658Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 57926372658Smrg : ${_G_HAVE_ARITH_OP="yes"} 58026372658Smrg : ${_G_HAVE_XSI_OPS="yes"} 58126372658Smrg # The += operator was introduced in bash 3.1 58226372658Smrg case $BASH_VERSION in 58326372658Smrg [12].* | 3.0 | 3.0*) ;; 58426372658Smrg *) 58526372658Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 58626372658Smrg ;; 58726372658Smrg esac 58826372658Smrg fi 58926372658Smrg 59026372658Smrg # _G_HAVE_PLUSEQ_OP 59126372658Smrg # Can be empty, in which case the shell is probed, "yes" if += is 59226372658Smrg # useable or anything else if it does not work. 59326372658Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 59426372658Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 59526372658Smrg && _G_HAVE_PLUSEQ_OP=yes 59626372658Smrg 59726372658Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 59826372658Smrgthen 59926372658Smrg # This is an XSI compatible shell, allowing a faster implementation... 60026372658Smrg eval 'func_append () 60126372658Smrg { 60226372658Smrg $debug_cmd 60326372658Smrg 60426372658Smrg eval "$1+=\$2" 60526372658Smrg }' 60626372658Smrgelse 60726372658Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 60826372658Smrg func_append () 60926372658Smrg { 61026372658Smrg $debug_cmd 61126372658Smrg 61226372658Smrg eval "$1=\$$1\$2" 61326372658Smrg } 61426372658Smrgfi 61526372658Smrg 61626372658Smrg 61726372658Smrg# func_append_quoted VAR VALUE 61826372658Smrg# ---------------------------- 61926372658Smrg# Quote VALUE and append to the end of shell variable VAR, separated 62026372658Smrg# by a space. 62126372658Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 62226372658Smrg eval 'func_append_quoted () 62326372658Smrg { 62426372658Smrg $debug_cmd 62526372658Smrg 626c3e29c03Smrg func_quote_arg pretty "$2" 627c3e29c03Smrg eval "$1+=\\ \$func_quote_arg_result" 62826372658Smrg }' 62926372658Smrgelse 63026372658Smrg func_append_quoted () 63126372658Smrg { 63226372658Smrg $debug_cmd 63326372658Smrg 634c3e29c03Smrg func_quote_arg pretty "$2" 635c3e29c03Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 63626372658Smrg } 63726372658Smrgfi 63826372658Smrg 63926372658Smrg 64026372658Smrg# func_append_uniq VAR VALUE 64126372658Smrg# -------------------------- 64226372658Smrg# Append unique VALUE onto the existing contents of VAR, assuming 64326372658Smrg# entries are delimited by the first character of VALUE. For example: 64426372658Smrg# 64526372658Smrg# func_append_uniq options " --another-option option-argument" 64626372658Smrg# 64726372658Smrg# will only append to $options if " --another-option option-argument " 64826372658Smrg# is not already present somewhere in $options already (note spaces at 64926372658Smrg# each end implied by leading space in second argument). 65026372658Smrgfunc_append_uniq () 65126372658Smrg{ 65226372658Smrg $debug_cmd 65326372658Smrg 65426372658Smrg eval _G_current_value='`$ECHO $'$1'`' 65526372658Smrg _G_delim=`expr "$2" : '\(.\)'` 65626372658Smrg 65726372658Smrg case $_G_delim$_G_current_value$_G_delim in 65826372658Smrg *"$2$_G_delim"*) ;; 65926372658Smrg *) func_append "$@" ;; 66026372658Smrg esac 66126372658Smrg} 66226372658Smrg 66326372658Smrg 66426372658Smrg# func_arith TERM... 66526372658Smrg# ------------------ 66626372658Smrg# Set func_arith_result to the result of evaluating TERMs. 66726372658Smrg test -z "$_G_HAVE_ARITH_OP" \ 66826372658Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 66926372658Smrg && _G_HAVE_ARITH_OP=yes 67026372658Smrg 67126372658Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 67226372658Smrg eval 'func_arith () 67326372658Smrg { 67426372658Smrg $debug_cmd 67526372658Smrg 67626372658Smrg func_arith_result=$(( $* )) 67726372658Smrg }' 67826372658Smrgelse 67926372658Smrg func_arith () 68026372658Smrg { 68126372658Smrg $debug_cmd 68226372658Smrg 68326372658Smrg func_arith_result=`expr "$@"` 68426372658Smrg } 68526372658Smrgfi 68626372658Smrg 68726372658Smrg 68826372658Smrg# func_basename FILE 68926372658Smrg# ------------------ 69026372658Smrg# Set func_basename_result to FILE with everything up to and including 69126372658Smrg# the last / stripped. 69226372658Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 69326372658Smrg # If this shell supports suffix pattern removal, then use it to avoid 69426372658Smrg # forking. Hide the definitions single quotes in case the shell chokes 69526372658Smrg # on unsupported syntax... 69626372658Smrg _b='func_basename_result=${1##*/}' 69726372658Smrg _d='case $1 in 69826372658Smrg */*) func_dirname_result=${1%/*}$2 ;; 69926372658Smrg * ) func_dirname_result=$3 ;; 70026372658Smrg esac' 70126372658Smrg 70226372658Smrgelse 70326372658Smrg # ...otherwise fall back to using sed. 70426372658Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 70526372658Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 70626372658Smrg if test "X$func_dirname_result" = "X$1"; then 70726372658Smrg func_dirname_result=$3 70826372658Smrg else 70926372658Smrg func_append func_dirname_result "$2" 71026372658Smrg fi' 71126372658Smrgfi 71226372658Smrg 71326372658Smrgeval 'func_basename () 71426372658Smrg{ 71526372658Smrg $debug_cmd 71626372658Smrg 71726372658Smrg '"$_b"' 71826372658Smrg}' 71926372658Smrg 72026372658Smrg 72126372658Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 72226372658Smrg# ------------------------------------------- 72326372658Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 72426372658Smrg# otherwise set result to NONDIR_REPLACEMENT. 72526372658Smrgeval 'func_dirname () 72626372658Smrg{ 72726372658Smrg $debug_cmd 72826372658Smrg 72926372658Smrg '"$_d"' 73026372658Smrg}' 73126372658Smrg 73226372658Smrg 73326372658Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 73426372658Smrg# -------------------------------------------------------- 73526372658Smrg# Perform func_basename and func_dirname in a single function 73626372658Smrg# call: 73726372658Smrg# dirname: Compute the dirname of FILE. If nonempty, 73826372658Smrg# add APPEND to the result, otherwise set result 73926372658Smrg# to NONDIR_REPLACEMENT. 74026372658Smrg# value returned in "$func_dirname_result" 74126372658Smrg# basename: Compute filename of FILE. 74226372658Smrg# value retuned in "$func_basename_result" 74326372658Smrg# For efficiency, we do not delegate to the functions above but instead 74426372658Smrg# duplicate the functionality here. 74526372658Smrgeval 'func_dirname_and_basename () 74626372658Smrg{ 74726372658Smrg $debug_cmd 74826372658Smrg 74926372658Smrg '"$_b"' 75026372658Smrg '"$_d"' 75126372658Smrg}' 75226372658Smrg 75326372658Smrg 75426372658Smrg# func_echo ARG... 75526372658Smrg# ---------------- 75626372658Smrg# Echo program name prefixed message. 75726372658Smrgfunc_echo () 75826372658Smrg{ 75926372658Smrg $debug_cmd 76026372658Smrg 76126372658Smrg _G_message=$* 76226372658Smrg 76326372658Smrg func_echo_IFS=$IFS 76426372658Smrg IFS=$nl 76526372658Smrg for _G_line in $_G_message; do 76626372658Smrg IFS=$func_echo_IFS 76726372658Smrg $ECHO "$progname: $_G_line" 76826372658Smrg done 76926372658Smrg IFS=$func_echo_IFS 77026372658Smrg} 77126372658Smrg 77226372658Smrg 77326372658Smrg# func_echo_all ARG... 77426372658Smrg# -------------------- 77526372658Smrg# Invoke $ECHO with all args, space-separated. 77626372658Smrgfunc_echo_all () 77726372658Smrg{ 77826372658Smrg $ECHO "$*" 77926372658Smrg} 78026372658Smrg 78126372658Smrg 78226372658Smrg# func_echo_infix_1 INFIX ARG... 78326372658Smrg# ------------------------------ 78426372658Smrg# Echo program name, followed by INFIX on the first line, with any 78526372658Smrg# additional lines not showing INFIX. 78626372658Smrgfunc_echo_infix_1 () 78726372658Smrg{ 78826372658Smrg $debug_cmd 78926372658Smrg 79026372658Smrg $require_term_colors 79126372658Smrg 79226372658Smrg _G_infix=$1; shift 79326372658Smrg _G_indent=$_G_infix 79426372658Smrg _G_prefix="$progname: $_G_infix: " 79526372658Smrg _G_message=$* 79626372658Smrg 79726372658Smrg # Strip color escape sequences before counting printable length 79826372658Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 79926372658Smrg do 80026372658Smrg test -n "$_G_tc" && { 80126372658Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 80226372658Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 80326372658Smrg } 80426372658Smrg done 80526372658Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 80626372658Smrg 80726372658Smrg func_echo_infix_1_IFS=$IFS 80826372658Smrg IFS=$nl 80926372658Smrg for _G_line in $_G_message; do 81026372658Smrg IFS=$func_echo_infix_1_IFS 81126372658Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 81226372658Smrg _G_prefix=$_G_indent 81326372658Smrg done 81426372658Smrg IFS=$func_echo_infix_1_IFS 81526372658Smrg} 81626372658Smrg 81726372658Smrg 81826372658Smrg# func_error ARG... 81926372658Smrg# ----------------- 82026372658Smrg# Echo program name prefixed message to standard error. 82126372658Smrgfunc_error () 82226372658Smrg{ 82326372658Smrg $debug_cmd 82426372658Smrg 82526372658Smrg $require_term_colors 82626372658Smrg 82726372658Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 82826372658Smrg} 82926372658Smrg 83026372658Smrg 83126372658Smrg# func_fatal_error ARG... 83226372658Smrg# ----------------------- 83326372658Smrg# Echo program name prefixed message to standard error, and exit. 83426372658Smrgfunc_fatal_error () 83526372658Smrg{ 83626372658Smrg $debug_cmd 83726372658Smrg 83826372658Smrg func_error "$*" 83926372658Smrg exit $EXIT_FAILURE 84026372658Smrg} 84126372658Smrg 84226372658Smrg 84326372658Smrg# func_grep EXPRESSION FILENAME 84426372658Smrg# ----------------------------- 84549dc963fSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84649dc963fSmrgfunc_grep () 84749dc963fSmrg{ 84826372658Smrg $debug_cmd 84926372658Smrg 85049dc963fSmrg $GREP "$1" "$2" >/dev/null 2>&1 85149dc963fSmrg} 85249dc963fSmrg 85349dc963fSmrg 85426372658Smrg# func_len STRING 85526372658Smrg# --------------- 85626372658Smrg# Set func_len_result to the length of STRING. STRING may not 85726372658Smrg# start with a hyphen. 85826372658Smrg test -z "$_G_HAVE_XSI_OPS" \ 85926372658Smrg && (eval 'x=a/b/c; 86026372658Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 86126372658Smrg && _G_HAVE_XSI_OPS=yes 86226372658Smrg 86326372658Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 86426372658Smrg eval 'func_len () 86526372658Smrg { 86626372658Smrg $debug_cmd 86726372658Smrg 86826372658Smrg func_len_result=${#1} 86926372658Smrg }' 87026372658Smrgelse 87126372658Smrg func_len () 87226372658Smrg { 87326372658Smrg $debug_cmd 87426372658Smrg 87526372658Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 87626372658Smrg } 87726372658Smrgfi 87826372658Smrg 87926372658Smrg 88026372658Smrg# func_mkdir_p DIRECTORY-PATH 88126372658Smrg# --------------------------- 88249dc963fSmrg# Make sure the entire path to DIRECTORY-PATH is available. 88349dc963fSmrgfunc_mkdir_p () 88449dc963fSmrg{ 88526372658Smrg $debug_cmd 88649dc963fSmrg 88726372658Smrg _G_directory_path=$1 88826372658Smrg _G_dir_list= 88949dc963fSmrg 89026372658Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89126372658Smrg 89226372658Smrg # Protect directory names starting with '-' 89326372658Smrg case $_G_directory_path in 89426372658Smrg -*) _G_directory_path=./$_G_directory_path ;; 89549dc963fSmrg esac 89649dc963fSmrg 89749dc963fSmrg # While some portion of DIR does not yet exist... 89826372658Smrg while test ! -d "$_G_directory_path"; do 89949dc963fSmrg # ...make a list in topmost first order. Use a colon delimited 90049dc963fSmrg # list incase some portion of path contains whitespace. 90126372658Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 90249dc963fSmrg 90349dc963fSmrg # If the last portion added has no slash in it, the list is done 90426372658Smrg case $_G_directory_path in */*) ;; *) break ;; esac 90549dc963fSmrg 90649dc963fSmrg # ...otherwise throw away the child directory and loop 90726372658Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 90849dc963fSmrg done 90926372658Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 91049dc963fSmrg 91126372658Smrg func_mkdir_p_IFS=$IFS; IFS=: 91226372658Smrg for _G_dir in $_G_dir_list; do 91326372658Smrg IFS=$func_mkdir_p_IFS 91426372658Smrg # mkdir can fail with a 'File exist' error if two processes 91549dc963fSmrg # try to create one of the directories concurrently. Don't 91649dc963fSmrg # stop in that case! 91726372658Smrg $MKDIR "$_G_dir" 2>/dev/null || : 91849dc963fSmrg done 91926372658Smrg IFS=$func_mkdir_p_IFS 92049dc963fSmrg 92149dc963fSmrg # Bail out if we (or some other process) failed to create a directory. 92226372658Smrg test -d "$_G_directory_path" || \ 92326372658Smrg func_fatal_error "Failed to create '$1'" 92449dc963fSmrg fi 92549dc963fSmrg} 9264b0ead49Smrg 9274b0ead49Smrg 92826372658Smrg# func_mktempdir [BASENAME] 92926372658Smrg# ------------------------- 9304b0ead49Smrg# Make a temporary directory that won't clash with other running 9314b0ead49Smrg# libtool processes, and avoids race conditions if possible. If 93226372658Smrg# given, BASENAME is the basename for that directory. 9334b0ead49Smrgfunc_mktempdir () 9344b0ead49Smrg{ 93526372658Smrg $debug_cmd 93626372658Smrg 93726372658Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9384b0ead49Smrg 93926372658Smrg if test : = "$opt_dry_run"; then 9404b0ead49Smrg # Return a directory name, but don't create it in dry-run mode 94126372658Smrg _G_tmpdir=$_G_template-$$ 9424b0ead49Smrg else 9434b0ead49Smrg 9444b0ead49Smrg # If mktemp works, use that first and foremost 94526372658Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9464b0ead49Smrg 94726372658Smrg if test ! -d "$_G_tmpdir"; then 94849dc963fSmrg # Failing that, at least try and use $RANDOM to avoid a race 94926372658Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9504b0ead49Smrg 95126372658Smrg func_mktempdir_umask=`umask` 95249dc963fSmrg umask 0077 95326372658Smrg $MKDIR "$_G_tmpdir" 95426372658Smrg umask $func_mktempdir_umask 9554b0ead49Smrg fi 9564b0ead49Smrg 9574b0ead49Smrg # If we're not in dry-run mode, bomb out on failure 95826372658Smrg test -d "$_G_tmpdir" || \ 95926372658Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 96026372658Smrg fi 96126372658Smrg 96226372658Smrg $ECHO "$_G_tmpdir" 96326372658Smrg} 96426372658Smrg 96526372658Smrg 96626372658Smrg# func_normal_abspath PATH 96726372658Smrg# ------------------------ 96826372658Smrg# Remove doubled-up and trailing slashes, "." path components, 96926372658Smrg# and cancel out any ".." path components in PATH after making 97026372658Smrg# it an absolute path. 97126372658Smrgfunc_normal_abspath () 97226372658Smrg{ 97326372658Smrg $debug_cmd 97426372658Smrg 97526372658Smrg # These SED scripts presuppose an absolute path with a trailing slash. 97626372658Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 97726372658Smrg _G_pathcdr='s|^/[^/]*||' 97826372658Smrg _G_removedotparts=':dotsl 97926372658Smrg s|/\./|/|g 98026372658Smrg t dotsl 98126372658Smrg s|/\.$|/|' 98226372658Smrg _G_collapseslashes='s|/\{1,\}|/|g' 98326372658Smrg _G_finalslash='s|/*$|/|' 98426372658Smrg 98526372658Smrg # Start from root dir and reassemble the path. 98626372658Smrg func_normal_abspath_result= 98726372658Smrg func_normal_abspath_tpath=$1 98826372658Smrg func_normal_abspath_altnamespace= 98926372658Smrg case $func_normal_abspath_tpath in 99026372658Smrg "") 99126372658Smrg # Empty path, that just means $cwd. 99226372658Smrg func_stripname '' '/' "`pwd`" 99326372658Smrg func_normal_abspath_result=$func_stripname_result 99426372658Smrg return 99526372658Smrg ;; 99626372658Smrg # The next three entries are used to spot a run of precisely 99726372658Smrg # two leading slashes without using negated character classes; 99826372658Smrg # we take advantage of case's first-match behaviour. 99926372658Smrg ///*) 100026372658Smrg # Unusual form of absolute path, do nothing. 100126372658Smrg ;; 100226372658Smrg //*) 100326372658Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 100426372658Smrg # and for example Cygwin uses it to access remote file shares 100526372658Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 100626372658Smrg func_normal_abspath_altnamespace=/ 100726372658Smrg ;; 100826372658Smrg /*) 100926372658Smrg # Absolute path, do nothing. 101026372658Smrg ;; 101126372658Smrg *) 101226372658Smrg # Relative path, prepend $cwd. 101326372658Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 101426372658Smrg ;; 101526372658Smrg esac 101626372658Smrg 101726372658Smrg # Cancel out all the simple stuff to save iterations. We also want 101826372658Smrg # the path to end with a slash for ease of parsing, so make sure 101926372658Smrg # there is one (and only one) here. 102026372658Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 102126372658Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 102226372658Smrg while :; do 102326372658Smrg # Processed it all yet? 102426372658Smrg if test / = "$func_normal_abspath_tpath"; then 102526372658Smrg # If we ascended to the root using ".." the result may be empty now. 102626372658Smrg if test -z "$func_normal_abspath_result"; then 102726372658Smrg func_normal_abspath_result=/ 102826372658Smrg fi 102926372658Smrg break 103026372658Smrg fi 103126372658Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103226372658Smrg -e "$_G_pathcar"` 103326372658Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103426372658Smrg -e "$_G_pathcdr"` 103526372658Smrg # Figure out what to do with it 103626372658Smrg case $func_normal_abspath_tcomponent in 103726372658Smrg "") 103826372658Smrg # Trailing empty path component, ignore it. 103926372658Smrg ;; 104026372658Smrg ..) 104126372658Smrg # Parent dir; strip last assembled component from result. 104226372658Smrg func_dirname "$func_normal_abspath_result" 104326372658Smrg func_normal_abspath_result=$func_dirname_result 104426372658Smrg ;; 104526372658Smrg *) 104626372658Smrg # Actual path component, append it. 104726372658Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 104826372658Smrg ;; 104926372658Smrg esac 105026372658Smrg done 105126372658Smrg # Restore leading double-slash if one was found on entry. 105226372658Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 105326372658Smrg} 105426372658Smrg 105526372658Smrg 105626372658Smrg# func_notquiet ARG... 105726372658Smrg# -------------------- 105826372658Smrg# Echo program name prefixed message only when not in quiet mode. 105926372658Smrgfunc_notquiet () 106026372658Smrg{ 106126372658Smrg $debug_cmd 106226372658Smrg 106326372658Smrg $opt_quiet || func_echo ${1+"$@"} 106426372658Smrg 106526372658Smrg # A bug in bash halts the script if the last line of a function 106626372658Smrg # fails when set -e is in force, so we need another command to 106726372658Smrg # work around that: 106826372658Smrg : 106926372658Smrg} 107026372658Smrg 107126372658Smrg 107226372658Smrg# func_relative_path SRCDIR DSTDIR 107326372658Smrg# -------------------------------- 107426372658Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 107526372658Smrgfunc_relative_path () 107626372658Smrg{ 107726372658Smrg $debug_cmd 107826372658Smrg 107926372658Smrg func_relative_path_result= 108026372658Smrg func_normal_abspath "$1" 108126372658Smrg func_relative_path_tlibdir=$func_normal_abspath_result 108226372658Smrg func_normal_abspath "$2" 108326372658Smrg func_relative_path_tbindir=$func_normal_abspath_result 108426372658Smrg 108526372658Smrg # Ascend the tree starting from libdir 108626372658Smrg while :; do 108726372658Smrg # check if we have found a prefix of bindir 108826372658Smrg case $func_relative_path_tbindir in 108926372658Smrg $func_relative_path_tlibdir) 109026372658Smrg # found an exact match 109126372658Smrg func_relative_path_tcancelled= 109226372658Smrg break 109326372658Smrg ;; 109426372658Smrg $func_relative_path_tlibdir*) 109526372658Smrg # found a matching prefix 109626372658Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 109726372658Smrg func_relative_path_tcancelled=$func_stripname_result 109826372658Smrg if test -z "$func_relative_path_result"; then 109926372658Smrg func_relative_path_result=. 110026372658Smrg fi 110126372658Smrg break 110226372658Smrg ;; 110326372658Smrg *) 110426372658Smrg func_dirname $func_relative_path_tlibdir 110526372658Smrg func_relative_path_tlibdir=$func_dirname_result 110626372658Smrg if test -z "$func_relative_path_tlibdir"; then 110726372658Smrg # Have to descend all the way to the root! 110826372658Smrg func_relative_path_result=../$func_relative_path_result 110926372658Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 111026372658Smrg break 111126372658Smrg fi 111226372658Smrg func_relative_path_result=../$func_relative_path_result 111326372658Smrg ;; 111426372658Smrg esac 111526372658Smrg done 111626372658Smrg 111726372658Smrg # Now calculate path; take care to avoid doubling-up slashes. 111826372658Smrg func_stripname '' '/' "$func_relative_path_result" 111926372658Smrg func_relative_path_result=$func_stripname_result 112026372658Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 112126372658Smrg if test -n "$func_stripname_result"; then 112226372658Smrg func_append func_relative_path_result "/$func_stripname_result" 112326372658Smrg fi 112426372658Smrg 112526372658Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 112626372658Smrg if test -n "$func_relative_path_result"; then 112726372658Smrg func_stripname './' '' "$func_relative_path_result" 112826372658Smrg func_relative_path_result=$func_stripname_result 11294b0ead49Smrg fi 11304b0ead49Smrg 113126372658Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 113226372658Smrg 113326372658Smrg : 113426372658Smrg} 113526372658Smrg 113626372658Smrg 1137c3e29c03Smrg# func_quote_portable EVAL ARG 1138c3e29c03Smrg# ---------------------------- 1139c3e29c03Smrg# Internal function to portably implement func_quote_arg. Note that we still 1140c3e29c03Smrg# keep attention to performance here so we as much as possible try to avoid 1141c3e29c03Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142c3e29c03Smrgfunc_quote_portable () 114326372658Smrg{ 114426372658Smrg $debug_cmd 114526372658Smrg 1146c3e29c03Smrg $require_check_ifs_backslash 1147c3e29c03Smrg 1148c3e29c03Smrg func_quote_portable_result=$2 1149c3e29c03Smrg 1150c3e29c03Smrg # one-time-loop (easy break) 1151c3e29c03Smrg while true 1152c3e29c03Smrg do 1153c3e29c03Smrg if $1; then 1154c3e29c03Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155c3e29c03Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156c3e29c03Smrg break 115726372658Smrg fi 115826372658Smrg 1159c3e29c03Smrg # Quote for eval. 1160c3e29c03Smrg case $func_quote_portable_result in 1161c3e29c03Smrg *[\\\`\"\$]*) 1162c3e29c03Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163c3e29c03Smrg # contains the shell wildcard characters. 1164c3e29c03Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165c3e29c03Smrg :*|*[\[\*\?]*) 1166c3e29c03Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167c3e29c03Smrg | $SED "$sed_quote_subst"` 1168c3e29c03Smrg break 1169c3e29c03Smrg ;; 1170c3e29c03Smrg esac 1171c3e29c03Smrg 1172c3e29c03Smrg func_quote_portable_old_IFS=$IFS 1173c3e29c03Smrg for _G_char in '\' '`' '"' '$' 1174c3e29c03Smrg do 1175c3e29c03Smrg # STATE($1) PREV($2) SEPARATOR($3) 1176c3e29c03Smrg set start "" "" 1177c3e29c03Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178c3e29c03Smrg IFS=$_G_char 1179c3e29c03Smrg for _G_part in $func_quote_portable_result 1180c3e29c03Smrg do 1181c3e29c03Smrg case $1 in 1182c3e29c03Smrg quote) 1183c3e29c03Smrg func_append func_quote_portable_result "$3$2" 1184c3e29c03Smrg set quote "$_G_part" "\\$_G_char" 1185c3e29c03Smrg ;; 1186c3e29c03Smrg start) 1187c3e29c03Smrg set first "" "" 1188c3e29c03Smrg func_quote_portable_result= 1189c3e29c03Smrg ;; 1190c3e29c03Smrg first) 1191c3e29c03Smrg set quote "$_G_part" "" 1192c3e29c03Smrg ;; 1193c3e29c03Smrg esac 1194c3e29c03Smrg done 1195c3e29c03Smrg done 1196c3e29c03Smrg IFS=$func_quote_portable_old_IFS 119726372658Smrg ;; 1198c3e29c03Smrg *) ;; 119926372658Smrg esac 1200c3e29c03Smrg break 120126372658Smrg done 1202c3e29c03Smrg 1203c3e29c03Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204c3e29c03Smrg case $func_quote_portable_result in 1205c3e29c03Smrg # double-quote args containing shell metacharacters to delay 1206c3e29c03Smrg # word splitting, command substitution and variable expansion 1207c3e29c03Smrg # for a subsequent eval. 1208c3e29c03Smrg # many bourne shells cannot handle close brackets correctly 1209c3e29c03Smrg # in scan sets, so we specify it separately. 1210c3e29c03Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211c3e29c03Smrg func_quote_portable_result=\"$func_quote_portable_result\" 1212c3e29c03Smrg ;; 1213c3e29c03Smrg esac 121426372658Smrg} 121526372658Smrg 121626372658Smrg 1217c3e29c03Smrg# func_quotefast_eval ARG 1218c3e29c03Smrg# ----------------------- 1219c3e29c03Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220c3e29c03Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221c3e29c03Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222c3e29c03Smrg printf -v _GL_test_printf_tilde %q '~' 1223c3e29c03Smrg if test '\~' = "$_GL_test_printf_tilde"; then 1224c3e29c03Smrg func_quotefast_eval () 1225c3e29c03Smrg { 1226c3e29c03Smrg printf -v func_quotefast_eval_result %q "$1" 1227c3e29c03Smrg } 1228c3e29c03Smrg else 1229c3e29c03Smrg # Broken older Bash implementations. Make those faster too if possible. 1230c3e29c03Smrg func_quotefast_eval () 1231c3e29c03Smrg { 1232c3e29c03Smrg case $1 in 1233c3e29c03Smrg '~'*) 1234c3e29c03Smrg func_quote_portable false "$1" 1235c3e29c03Smrg func_quotefast_eval_result=$func_quote_portable_result 1236c3e29c03Smrg ;; 1237c3e29c03Smrg *) 1238c3e29c03Smrg printf -v func_quotefast_eval_result %q "$1" 1239c3e29c03Smrg ;; 1240c3e29c03Smrg esac 1241c3e29c03Smrg } 1242c3e29c03Smrg fi 1243c3e29c03Smrgelse 1244c3e29c03Smrg func_quotefast_eval () 1245c3e29c03Smrg { 1246c3e29c03Smrg func_quote_portable false "$1" 1247c3e29c03Smrg func_quotefast_eval_result=$func_quote_portable_result 1248c3e29c03Smrg } 1249c3e29c03Smrgfi 125026372658Smrg 1251c3e29c03Smrg 1252c3e29c03Smrg# func_quote_arg MODEs ARG 1253c3e29c03Smrg# ------------------------ 1254c3e29c03Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255c3e29c03Smrg# specifiers listed below separated by ',' character. This function returns two 1256c3e29c03Smrg# values: 1257c3e29c03Smrg# i) func_quote_arg_result 1258c3e29c03Smrg# double-quoted (when needed), suitable for a subsequent eval 1259c3e29c03Smrg# ii) func_quote_arg_unquoted_result 1260c3e29c03Smrg# has all characters that are still active within double 1261c3e29c03Smrg# quotes backslashified. Available only if 'unquoted' is specified. 1262c3e29c03Smrg# 1263c3e29c03Smrg# Available modes: 1264c3e29c03Smrg# ---------------- 1265c3e29c03Smrg# 'eval' (default) 1266c3e29c03Smrg# - escape shell special characters 1267c3e29c03Smrg# 'expand' 1268c3e29c03Smrg# - the same as 'eval'; but do not quote variable references 1269c3e29c03Smrg# 'pretty' 1270c3e29c03Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271c3e29c03Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272c3e29c03Smrg# of 'echo a\ b'. This is slower than default on some shells. 1273c3e29c03Smrg# 'unquoted' 1274c3e29c03Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275c3e29c03Smrg# wrapping double-quotes. 1276c3e29c03Smrg# 1277c3e29c03Smrg# Examples for 'func_quote_arg pretty,unquoted string': 1278c3e29c03Smrg# 1279c3e29c03Smrg# string | *_result | *_unquoted_result 1280c3e29c03Smrg# ------------+-----------------------+------------------- 1281c3e29c03Smrg# " | \" | \" 1282c3e29c03Smrg# a b | "a b" | a b 1283c3e29c03Smrg# "a b" | "\"a b\"" | \"a b\" 1284c3e29c03Smrg# * | "*" | * 1285c3e29c03Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286c3e29c03Smrg# 1287c3e29c03Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288c3e29c03Smrg# 1289c3e29c03Smrg# string | *_result | *_unquoted_result 1290c3e29c03Smrg# --------------+---------------------+-------------------- 1291c3e29c03Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292c3e29c03Smrgfunc_quote_arg () 1293c3e29c03Smrg{ 1294c3e29c03Smrg _G_quote_expand=false 1295c3e29c03Smrg case ,$1, in 1296c3e29c03Smrg *,expand,*) 1297c3e29c03Smrg _G_quote_expand=: 1298c3e29c03Smrg ;; 129926372658Smrg esac 130026372658Smrg 1301c3e29c03Smrg case ,$1, in 1302c3e29c03Smrg *,pretty,*|*,expand,*|*,unquoted,*) 1303c3e29c03Smrg func_quote_portable $_G_quote_expand "$2" 1304c3e29c03Smrg func_quote_arg_result=$func_quote_portable_result 1305c3e29c03Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306c3e29c03Smrg ;; 1307c3e29c03Smrg *) 1308c3e29c03Smrg # Faster quote-for-eval for some shells. 1309c3e29c03Smrg func_quotefast_eval "$2" 1310c3e29c03Smrg func_quote_arg_result=$func_quotefast_eval_result 131126372658Smrg ;; 131226372658Smrg esac 1313c3e29c03Smrg} 1314c3e29c03Smrg 131526372658Smrg 1316c3e29c03Smrg# func_quote MODEs ARGs... 1317c3e29c03Smrg# ------------------------ 1318c3e29c03Smrg# Quote all ARGs to be evaled later and join them into single command. See 1319c3e29c03Smrg# func_quote_arg's description for more info. 1320c3e29c03Smrgfunc_quote () 1321c3e29c03Smrg{ 1322c3e29c03Smrg $debug_cmd 1323c3e29c03Smrg _G_func_quote_mode=$1 ; shift 1324c3e29c03Smrg func_quote_result= 1325c3e29c03Smrg while test 0 -lt $#; do 1326c3e29c03Smrg func_quote_arg "$_G_func_quote_mode" "$1" 1327c3e29c03Smrg if test -n "$func_quote_result"; then 1328c3e29c03Smrg func_append func_quote_result " $func_quote_arg_result" 1329c3e29c03Smrg else 1330c3e29c03Smrg func_append func_quote_result "$func_quote_arg_result" 1331c3e29c03Smrg fi 1332c3e29c03Smrg shift 1333c3e29c03Smrg done 133426372658Smrg} 133526372658Smrg 133626372658Smrg 133726372658Smrg# func_stripname PREFIX SUFFIX NAME 133826372658Smrg# --------------------------------- 133926372658Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 134026372658Smrg# PREFIX and SUFFIX must not contain globbing or regex special 134126372658Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 134226372658Smrg# dot (in which case that matches only a dot). 134326372658Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 134426372658Smrg eval 'func_stripname () 134526372658Smrg { 134626372658Smrg $debug_cmd 134726372658Smrg 134826372658Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 134926372658Smrg # positional parameters, so assign one to ordinary variable first. 135026372658Smrg func_stripname_result=$3 135126372658Smrg func_stripname_result=${func_stripname_result#"$1"} 135226372658Smrg func_stripname_result=${func_stripname_result%"$2"} 135326372658Smrg }' 135426372658Smrgelse 135526372658Smrg func_stripname () 135626372658Smrg { 135726372658Smrg $debug_cmd 135826372658Smrg 135926372658Smrg case $2 in 136026372658Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 136126372658Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 136226372658Smrg esac 136326372658Smrg } 136426372658Smrgfi 136526372658Smrg 136626372658Smrg 136726372658Smrg# func_show_eval CMD [FAIL_EXP] 136826372658Smrg# ----------------------------- 136926372658Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 137026372658Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 137126372658Smrg# is given, then evaluate it. 137226372658Smrgfunc_show_eval () 137326372658Smrg{ 137426372658Smrg $debug_cmd 137526372658Smrg 137626372658Smrg _G_cmd=$1 137726372658Smrg _G_fail_exp=${2-':'} 137826372658Smrg 1379c3e29c03Smrg func_quote_arg pretty,expand "$_G_cmd" 1380c3e29c03Smrg eval "func_notquiet $func_quote_arg_result" 138126372658Smrg 138226372658Smrg $opt_dry_run || { 138326372658Smrg eval "$_G_cmd" 138426372658Smrg _G_status=$? 138526372658Smrg if test 0 -ne "$_G_status"; then 138626372658Smrg eval "(exit $_G_status); $_G_fail_exp" 138726372658Smrg fi 138826372658Smrg } 138926372658Smrg} 139026372658Smrg 139126372658Smrg 139226372658Smrg# func_show_eval_locale CMD [FAIL_EXP] 139326372658Smrg# ------------------------------------ 139426372658Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 139526372658Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 139626372658Smrg# is given, then evaluate it. Use the saved locale for evaluation. 139726372658Smrgfunc_show_eval_locale () 139826372658Smrg{ 139926372658Smrg $debug_cmd 140026372658Smrg 140126372658Smrg _G_cmd=$1 140226372658Smrg _G_fail_exp=${2-':'} 140326372658Smrg 140426372658Smrg $opt_quiet || { 1405c3e29c03Smrg func_quote_arg expand,pretty "$_G_cmd" 1406c3e29c03Smrg eval "func_echo $func_quote_arg_result" 140726372658Smrg } 140826372658Smrg 140926372658Smrg $opt_dry_run || { 141026372658Smrg eval "$_G_user_locale 141126372658Smrg $_G_cmd" 141226372658Smrg _G_status=$? 141326372658Smrg eval "$_G_safe_locale" 141426372658Smrg if test 0 -ne "$_G_status"; then 141526372658Smrg eval "(exit $_G_status); $_G_fail_exp" 141626372658Smrg fi 141726372658Smrg } 141826372658Smrg} 141926372658Smrg 142026372658Smrg 142126372658Smrg# func_tr_sh 142226372658Smrg# ---------- 142326372658Smrg# Turn $1 into a string suitable for a shell variable name. 142426372658Smrg# Result is stored in $func_tr_sh_result. All characters 142526372658Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 142626372658Smrg# if $1 begins with a digit, a '_' is prepended as well. 142726372658Smrgfunc_tr_sh () 142826372658Smrg{ 142926372658Smrg $debug_cmd 143026372658Smrg 143126372658Smrg case $1 in 143226372658Smrg [0-9]* | *[!a-zA-Z0-9_]*) 143326372658Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 143426372658Smrg ;; 143526372658Smrg * ) 143626372658Smrg func_tr_sh_result=$1 143726372658Smrg ;; 143826372658Smrg esac 143926372658Smrg} 144026372658Smrg 144126372658Smrg 144226372658Smrg# func_verbose ARG... 144326372658Smrg# ------------------- 144426372658Smrg# Echo program name prefixed message in verbose mode only. 144526372658Smrgfunc_verbose () 144626372658Smrg{ 144726372658Smrg $debug_cmd 144826372658Smrg 144926372658Smrg $opt_verbose && func_echo "$*" 145026372658Smrg 145126372658Smrg : 145226372658Smrg} 145326372658Smrg 145426372658Smrg 145526372658Smrg# func_warn_and_continue ARG... 145626372658Smrg# ----------------------------- 145726372658Smrg# Echo program name prefixed warning message to standard error. 145826372658Smrgfunc_warn_and_continue () 145926372658Smrg{ 146026372658Smrg $debug_cmd 146126372658Smrg 146226372658Smrg $require_term_colors 146326372658Smrg 146426372658Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 146526372658Smrg} 146626372658Smrg 146726372658Smrg 146826372658Smrg# func_warning CATEGORY ARG... 146926372658Smrg# ---------------------------- 147026372658Smrg# Echo program name prefixed warning message to standard error. Warning 147126372658Smrg# messages can be filtered according to CATEGORY, where this function 147226372658Smrg# elides messages where CATEGORY is not listed in the global variable 147326372658Smrg# 'opt_warning_types'. 147426372658Smrgfunc_warning () 147526372658Smrg{ 147626372658Smrg $debug_cmd 147726372658Smrg 147826372658Smrg # CATEGORY must be in the warning_categories list! 147926372658Smrg case " $warning_categories " in 148026372658Smrg *" $1 "*) ;; 148126372658Smrg *) func_internal_error "invalid warning category '$1'" ;; 148226372658Smrg esac 148326372658Smrg 148426372658Smrg _G_category=$1 148526372658Smrg shift 148626372658Smrg 148726372658Smrg case " $opt_warning_types " in 148826372658Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 148926372658Smrg esac 149026372658Smrg} 149126372658Smrg 149226372658Smrg 149326372658Smrg# func_sort_ver VER1 VER2 149426372658Smrg# ----------------------- 149526372658Smrg# 'sort -V' is not generally available. 149626372658Smrg# Note this deviates from the version comparison in automake 149726372658Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 149826372658Smrg# but this should suffice as we won't be specifying old 149926372658Smrg# version formats or redundant trailing .0 in bootstrap.conf. 150026372658Smrg# If we did want full compatibility then we should probably 150126372658Smrg# use m4_version_compare from autoconf. 150226372658Smrgfunc_sort_ver () 150326372658Smrg{ 150426372658Smrg $debug_cmd 150526372658Smrg 150626372658Smrg printf '%s\n%s\n' "$1" "$2" \ 150726372658Smrg | 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 150826372658Smrg} 150926372658Smrg 151026372658Smrg# func_lt_ver PREV CURR 151126372658Smrg# --------------------- 151226372658Smrg# Return true if PREV and CURR are in the correct order according to 151326372658Smrg# func_sort_ver, otherwise false. Use it like this: 151426372658Smrg# 151526372658Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 151626372658Smrgfunc_lt_ver () 151726372658Smrg{ 151826372658Smrg $debug_cmd 151926372658Smrg 152026372658Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 152126372658Smrg} 152226372658Smrg 152326372658Smrg 152426372658Smrg# Local variables: 152526372658Smrg# mode: shell-script 152626372658Smrg# sh-indentation: 2 152726372658Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 152826372658Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 152926372658Smrg# time-stamp-time-zone: "UTC" 153026372658Smrg# End: 153126372658Smrg#! /bin/sh 153226372658Smrg 153326372658Smrg# A portable, pluggable option parser for Bourne shell. 153426372658Smrg# Written by Gary V. Vaughan, 2010 153526372658Smrg 1536c3e29c03Smrg# This is free software. There is NO warranty; not even for 1537c3e29c03Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538c3e29c03Smrg# 1539c3e29c03Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540c3e29c03Smrg# 1541c3e29c03Smrg# This file is dual licensed under the terms of the MIT license 1542c3e29c03Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543c3e29c03Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544c3e29c03Smrg# these licenses when using or redistributing this software or any of 1545c3e29c03Smrg# the files within it. See the URLs above, or the file `LICENSE` 1546c3e29c03Smrg# included in the Bootstrap distribution for the full license texts. 154726372658Smrg 1548c3e29c03Smrg# Please report bugs or propose patches to: 1549c3e29c03Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 155026372658Smrg 1551c3e29c03Smrg# Set a version string for this script. 1552c3e29c03Smrgscriptversion=2019-02-19.15; # UTC 155326372658Smrg 155426372658Smrg 155526372658Smrg## ------ ## 155626372658Smrg## Usage. ## 155726372658Smrg## ------ ## 155826372658Smrg 155926372658Smrg# This file is a library for parsing options in your shell scripts along 156026372658Smrg# with assorted other useful supporting features that you can make use 156126372658Smrg# of too. 156226372658Smrg# 156326372658Smrg# For the simplest scripts you might need only: 156426372658Smrg# 156526372658Smrg# #!/bin/sh 156626372658Smrg# . relative/path/to/funclib.sh 156726372658Smrg# . relative/path/to/options-parser 156826372658Smrg# scriptversion=1.0 156926372658Smrg# func_options ${1+"$@"} 157026372658Smrg# eval set dummy "$func_options_result"; shift 157126372658Smrg# ...rest of your script... 157226372658Smrg# 157326372658Smrg# In order for the '--version' option to work, you will need to have a 157426372658Smrg# suitably formatted comment like the one at the top of this file 1575c3e29c03Smrg# starting with '# Written by ' and ending with '# Copyright'. 157626372658Smrg# 157726372658Smrg# For '-h' and '--help' to work, you will also need a one line 157826372658Smrg# description of your script's purpose in a comment directly above the 157926372658Smrg# '# Written by ' line, like the one at the top of this file. 158026372658Smrg# 158126372658Smrg# The default options also support '--debug', which will turn on shell 158226372658Smrg# execution tracing (see the comment above debug_cmd below for another 158326372658Smrg# use), and '--verbose' and the func_verbose function to allow your script 158426372658Smrg# to display verbose messages only when your user has specified 158526372658Smrg# '--verbose'. 158626372658Smrg# 1587c3e29c03Smrg# After sourcing this file, you can plug in processing for additional 158826372658Smrg# options by amending the variables from the 'Configuration' section 158926372658Smrg# below, and following the instructions in the 'Option parsing' 159026372658Smrg# section further down. 159126372658Smrg 159226372658Smrg## -------------- ## 159326372658Smrg## Configuration. ## 159426372658Smrg## -------------- ## 159526372658Smrg 159626372658Smrg# You should override these variables in your script after sourcing this 159726372658Smrg# file so that they reflect the customisations you have added to the 159826372658Smrg# option parser. 159926372658Smrg 160026372658Smrg# The usage line for option parsing errors and the start of '-h' and 160126372658Smrg# '--help' output messages. You can embed shell variables for delayed 160226372658Smrg# expansion at the time the message is displayed, but you will need to 160326372658Smrg# quote other shell meta-characters carefully to prevent them being 160426372658Smrg# expanded when the contents are evaled. 160526372658Smrgusage='$progpath [OPTION]...' 160626372658Smrg 160726372658Smrg# Short help message in response to '-h' and '--help'. Add to this or 160826372658Smrg# override it after sourcing this library to reflect the full set of 160926372658Smrg# options your script accepts. 161026372658Smrgusage_message="\ 161126372658Smrg --debug enable verbose shell tracing 161226372658Smrg -W, --warnings=CATEGORY 161326372658Smrg report the warnings falling in CATEGORY [all] 161426372658Smrg -v, --verbose verbosely report processing 161526372658Smrg --version print version information and exit 161626372658Smrg -h, --help print short or long help message and exit 161726372658Smrg" 161826372658Smrg 161926372658Smrg# Additional text appended to 'usage_message' in response to '--help'. 162026372658Smrglong_help_message=" 162126372658SmrgWarning categories include: 162226372658Smrg 'all' show all warnings 162326372658Smrg 'none' turn off all the warnings 162426372658Smrg 'error' warnings are treated as fatal errors" 162526372658Smrg 162626372658Smrg# Help message printed before fatal option parsing errors. 162726372658Smrgfatal_help="Try '\$progname --help' for more information." 162826372658Smrg 162926372658Smrg 163026372658Smrg 163126372658Smrg## ------------------------- ## 163226372658Smrg## Hook function management. ## 163326372658Smrg## ------------------------- ## 163426372658Smrg 163526372658Smrg# This section contains functions for adding, removing, and running hooks 1636c3e29c03Smrg# in the main code. A hook is just a list of function names that can be 1637c3e29c03Smrg# run in order later on. 163826372658Smrg 163926372658Smrg# func_hookable FUNC_NAME 164026372658Smrg# ----------------------- 164126372658Smrg# Declare that FUNC_NAME will run hooks added with 164226372658Smrg# 'func_add_hook FUNC_NAME ...'. 164326372658Smrgfunc_hookable () 164426372658Smrg{ 164526372658Smrg $debug_cmd 164626372658Smrg 164726372658Smrg func_append hookable_fns " $1" 164826372658Smrg} 164926372658Smrg 165026372658Smrg 165126372658Smrg# func_add_hook FUNC_NAME HOOK_FUNC 165226372658Smrg# --------------------------------- 165326372658Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 165426372658Smrg# first have been declared "hookable" by a call to 'func_hookable'. 165526372658Smrgfunc_add_hook () 165626372658Smrg{ 165726372658Smrg $debug_cmd 165826372658Smrg 165926372658Smrg case " $hookable_fns " in 166026372658Smrg *" $1 "*) ;; 166126372658Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 166226372658Smrg esac 166326372658Smrg 166426372658Smrg eval func_append ${1}_hooks '" $2"' 166526372658Smrg} 166626372658Smrg 166726372658Smrg 166826372658Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 166926372658Smrg# ------------------------------------ 1670c3e29c03Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671c3e29c03Smrg# FUNC_NAME. 167226372658Smrgfunc_remove_hook () 167326372658Smrg{ 167426372658Smrg $debug_cmd 167526372658Smrg 167626372658Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 167726372658Smrg} 167826372658Smrg 167926372658Smrg 1680c3e29c03Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681c3e29c03Smrg# --------------------------------------------- 1682c3e29c03Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683c3e29c03Smrg# *_result variable of FUNC_NAME_B. 1684c3e29c03Smrgfunc_propagate_result () 1685c3e29c03Smrg{ 1686c3e29c03Smrg $debug_cmd 1687c3e29c03Smrg 1688c3e29c03Smrg func_propagate_result_result=: 1689c3e29c03Smrg if eval "test \"\${${1}_result+set}\" = set" 1690c3e29c03Smrg then 1691c3e29c03Smrg eval "${2}_result=\$${1}_result" 1692c3e29c03Smrg else 1693c3e29c03Smrg func_propagate_result_result=false 1694c3e29c03Smrg fi 1695c3e29c03Smrg} 1696c3e29c03Smrg 1697c3e29c03Smrg 169826372658Smrg# func_run_hooks FUNC_NAME [ARG]... 169926372658Smrg# --------------------------------- 170026372658Smrg# Run all hook functions registered to FUNC_NAME. 1701c3e29c03Smrg# It's assumed that the list of hook functions contains nothing more 170226372658Smrg# than a whitespace-delimited list of legal shell function names, and 170326372658Smrg# no effort is wasted trying to catch shell meta-characters or preserve 170426372658Smrg# whitespace. 170526372658Smrgfunc_run_hooks () 170626372658Smrg{ 170726372658Smrg $debug_cmd 170826372658Smrg 170926372658Smrg case " $hookable_fns " in 171026372658Smrg *" $1 "*) ;; 1711c3e29c03Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 171226372658Smrg esac 171326372658Smrg 171426372658Smrg eval _G_hook_fns=\$$1_hooks; shift 171526372658Smrg 171626372658Smrg for _G_hook in $_G_hook_fns; do 1717c3e29c03Smrg func_unset "${_G_hook}_result" 1718c3e29c03Smrg eval $_G_hook '${1+"$@"}' 1719c3e29c03Smrg func_propagate_result $_G_hook func_run_hooks 1720c3e29c03Smrg if $func_propagate_result_result; then 1721c3e29c03Smrg eval set dummy "$func_run_hooks_result"; shift 1722c3e29c03Smrg fi 172326372658Smrg done 172426372658Smrg} 172526372658Smrg 172626372658Smrg 172726372658Smrg 172826372658Smrg## --------------- ## 172926372658Smrg## Option parsing. ## 173026372658Smrg## --------------- ## 173126372658Smrg 173226372658Smrg# In order to add your own option parsing hooks, you must accept the 1733c3e29c03Smrg# full positional parameter list from your hook function. You may remove 1734c3e29c03Smrg# or edit any options that you action, and then pass back the remaining 1735c3e29c03Smrg# unprocessed options in '<hooked_function_name>_result', escaped 1736c3e29c03Smrg# suitably for 'eval'. 1737c3e29c03Smrg# 1738c3e29c03Smrg# The '<hooked_function_name>_result' variable is automatically unset 1739c3e29c03Smrg# before your hook gets called; for best performance, only set the 1740c3e29c03Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741c3e29c03Smrg# function unnecessarily because it can be an expensive operation on some 1742c3e29c03Smrg# machines). 1743c3e29c03Smrg# 1744c3e29c03Smrg# Like this: 174526372658Smrg# 174626372658Smrg# my_options_prep () 174726372658Smrg# { 174826372658Smrg# $debug_cmd 174926372658Smrg# 175026372658Smrg# # Extend the existing usage message. 175126372658Smrg# usage_message=$usage_message' 175226372658Smrg# -s, --silent don'\''t print informational messages 175326372658Smrg# ' 1754c3e29c03Smrg# # No change in '$@' (ignored completely by this hook). Leave 1755c3e29c03Smrg# # my_options_prep_result variable intact. 175626372658Smrg# } 175726372658Smrg# func_add_hook func_options_prep my_options_prep 175826372658Smrg# 175926372658Smrg# 176026372658Smrg# my_silent_option () 176126372658Smrg# { 176226372658Smrg# $debug_cmd 176326372658Smrg# 1764c3e29c03Smrg# args_changed=false 1765c3e29c03Smrg# 1766c3e29c03Smrg# # Note that, for efficiency, we parse as many options as we can 176726372658Smrg# # recognise in a loop before passing the remainder back to the 176826372658Smrg# # caller on the first unrecognised argument we encounter. 176926372658Smrg# while test $# -gt 0; do 177026372658Smrg# opt=$1; shift 177126372658Smrg# case $opt in 1772c3e29c03Smrg# --silent|-s) opt_silent=: 1773c3e29c03Smrg# args_changed=: 1774c3e29c03Smrg# ;; 177526372658Smrg# # Separate non-argument short options: 177626372658Smrg# -s*) func_split_short_opt "$_G_opt" 177726372658Smrg# set dummy "$func_split_short_opt_name" \ 177826372658Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 177926372658Smrg# shift 1780c3e29c03Smrg# args_changed=: 178126372658Smrg# ;; 1782c3e29c03Smrg# *) # Make sure the first unrecognised option "$_G_opt" 1783c3e29c03Smrg# # is added back to "$@" in case we need it later, 1784c3e29c03Smrg# # if $args_changed was set to 'true'. 1785c3e29c03Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 178626372658Smrg# esac 178726372658Smrg# done 178826372658Smrg# 1789c3e29c03Smrg# # Only call 'func_quote' here if we processed at least one argument. 1790c3e29c03Smrg# if $args_changed; then 1791c3e29c03Smrg# func_quote eval ${1+"$@"} 1792c3e29c03Smrg# my_silent_option_result=$func_quote_result 1793c3e29c03Smrg# fi 179426372658Smrg# } 179526372658Smrg# func_add_hook func_parse_options my_silent_option 179626372658Smrg# 179726372658Smrg# 179826372658Smrg# my_option_validation () 179926372658Smrg# { 180026372658Smrg# $debug_cmd 180126372658Smrg# 180226372658Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 180326372658Smrg# '--silent' and '--verbose' options are mutually exclusive." 180426372658Smrg# } 180526372658Smrg# func_add_hook func_validate_options my_option_validation 180626372658Smrg# 1807c3e29c03Smrg# You'll also need to manually amend $usage_message to reflect the extra 180826372658Smrg# options you parse. It's preferable to append if you can, so that 180926372658Smrg# multiple option parsing hooks can be added safely. 181026372658Smrg 181126372658Smrg 1812c3e29c03Smrg# func_options_finish [ARG]... 1813c3e29c03Smrg# ---------------------------- 1814c3e29c03Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815c3e29c03Smrgfunc_options_finish () 1816c3e29c03Smrg{ 1817c3e29c03Smrg $debug_cmd 1818c3e29c03Smrg 1819c3e29c03Smrg func_run_hooks func_options ${1+"$@"} 1820c3e29c03Smrg func_propagate_result func_run_hooks func_options_finish 1821c3e29c03Smrg} 1822c3e29c03Smrg 1823c3e29c03Smrg 182426372658Smrg# func_options [ARG]... 182526372658Smrg# --------------------- 182626372658Smrg# All the functions called inside func_options are hookable. See the 182726372658Smrg# individual implementations for details. 182826372658Smrgfunc_hookable func_options 182926372658Smrgfunc_options () 183026372658Smrg{ 183126372658Smrg $debug_cmd 183226372658Smrg 1833c3e29c03Smrg _G_options_quoted=false 183426372658Smrg 1835c3e29c03Smrg for my_func in options_prep parse_options validate_options options_finish 1836c3e29c03Smrg do 1837c3e29c03Smrg func_unset func_${my_func}_result 1838c3e29c03Smrg func_unset func_run_hooks_result 1839c3e29c03Smrg eval func_$my_func '${1+"$@"}' 1840c3e29c03Smrg func_propagate_result func_$my_func func_options 1841c3e29c03Smrg if $func_propagate_result_result; then 1842c3e29c03Smrg eval set dummy "$func_options_result"; shift 1843c3e29c03Smrg _G_options_quoted=: 1844c3e29c03Smrg fi 1845c3e29c03Smrg done 184626372658Smrg 1847c3e29c03Smrg $_G_options_quoted || { 1848c3e29c03Smrg # As we (func_options) are top-level options-parser function and 1849c3e29c03Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850c3e29c03Smrg # caller. 1851c3e29c03Smrg func_quote eval ${1+"$@"} 1852c3e29c03Smrg func_options_result=$func_quote_result 1853c3e29c03Smrg } 18544b0ead49Smrg} 18554b0ead49Smrg 18564b0ead49Smrg 185726372658Smrg# func_options_prep [ARG]... 185826372658Smrg# -------------------------- 185926372658Smrg# All initialisations required before starting the option parse loop. 186026372658Smrg# Note that when calling hook functions, we pass through the list of 186126372658Smrg# positional parameters. If a hook function modifies that list, and 1862c3e29c03Smrg# needs to propagate that back to rest of this script, then the complete 1863c3e29c03Smrg# modified list must be put in 'func_run_hooks_result' before returning. 186426372658Smrgfunc_hookable func_options_prep 186526372658Smrgfunc_options_prep () 18664b0ead49Smrg{ 186726372658Smrg $debug_cmd 186849dc963fSmrg 186926372658Smrg # Option defaults: 187026372658Smrg opt_verbose=false 187126372658Smrg opt_warning_types= 187226372658Smrg 187326372658Smrg func_run_hooks func_options_prep ${1+"$@"} 1874c3e29c03Smrg func_propagate_result func_run_hooks func_options_prep 18754b0ead49Smrg} 18764b0ead49Smrg 18774b0ead49Smrg 187826372658Smrg# func_parse_options [ARG]... 187926372658Smrg# --------------------------- 188026372658Smrg# The main option parsing loop. 188126372658Smrgfunc_hookable func_parse_options 188226372658Smrgfunc_parse_options () 18834b0ead49Smrg{ 188426372658Smrg $debug_cmd 188549dc963fSmrg 1886c3e29c03Smrg _G_parse_options_requote=false 188726372658Smrg # this just eases exit handling 188826372658Smrg while test $# -gt 0; do 188926372658Smrg # Defer to hook functions for initial option parsing, so they 189026372658Smrg # get priority in the event of reusing an option name. 189126372658Smrg func_run_hooks func_parse_options ${1+"$@"} 1892c3e29c03Smrg func_propagate_result func_run_hooks func_parse_options 1893c3e29c03Smrg if $func_propagate_result_result; then 1894c3e29c03Smrg eval set dummy "$func_parse_options_result"; shift 1895c3e29c03Smrg # Even though we may have changed "$@", we passed the "$@" array 1896c3e29c03Smrg # down into the hook and it quoted it for us (because we are in 1897c3e29c03Smrg # this if-branch). No need to quote it again. 1898c3e29c03Smrg _G_parse_options_requote=false 1899c3e29c03Smrg fi 19004b0ead49Smrg 190126372658Smrg # Break out of the loop if we already parsed every option. 190226372658Smrg test $# -gt 0 || break 19034b0ead49Smrg 1904c3e29c03Smrg # We expect that one of the options parsed in this function matches 1905c3e29c03Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906c3e29c03Smrg _G_match_parse_options=: 190726372658Smrg _G_opt=$1 190826372658Smrg shift 190926372658Smrg case $_G_opt in 191026372658Smrg --debug|-x) debug_cmd='set -x' 1911c3e29c03Smrg func_echo "enabling shell trace mode" >&2 191226372658Smrg $debug_cmd 191326372658Smrg ;; 191426372658Smrg 191526372658Smrg --no-warnings|--no-warning|--no-warn) 191626372658Smrg set dummy --warnings none ${1+"$@"} 191726372658Smrg shift 191826372658Smrg ;; 191949dc963fSmrg 192026372658Smrg --warnings|--warning|-W) 1921c3e29c03Smrg if test $# = 0 && func_missing_arg $_G_opt; then 1922c3e29c03Smrg _G_parse_options_requote=: 1923c3e29c03Smrg break 1924c3e29c03Smrg fi 192526372658Smrg case " $warning_categories $1" in 192626372658Smrg *" $1 "*) 192726372658Smrg # trailing space prevents matching last $1 above 192826372658Smrg func_append_uniq opt_warning_types " $1" 192926372658Smrg ;; 193026372658Smrg *all) 193126372658Smrg opt_warning_types=$warning_categories 193226372658Smrg ;; 193326372658Smrg *none) 193426372658Smrg opt_warning_types=none 193526372658Smrg warning_func=: 193626372658Smrg ;; 193726372658Smrg *error) 193826372658Smrg opt_warning_types=$warning_categories 193926372658Smrg warning_func=func_fatal_error 194026372658Smrg ;; 194126372658Smrg *) 194226372658Smrg func_fatal_error \ 194326372658Smrg "unsupported warning category: '$1'" 194426372658Smrg ;; 194526372658Smrg esac 194626372658Smrg shift 194726372658Smrg ;; 194826372658Smrg 194926372658Smrg --verbose|-v) opt_verbose=: ;; 195026372658Smrg --version) func_version ;; 195126372658Smrg -\?|-h) func_usage ;; 195226372658Smrg --help) func_help ;; 195326372658Smrg 195426372658Smrg # Separate optargs to long options (plugins may need this): 195526372658Smrg --*=*) func_split_equals "$_G_opt" 195626372658Smrg set dummy "$func_split_equals_lhs" \ 195726372658Smrg "$func_split_equals_rhs" ${1+"$@"} 195826372658Smrg shift 195926372658Smrg ;; 196026372658Smrg 196126372658Smrg # Separate optargs to short options: 196226372658Smrg -W*) 196326372658Smrg func_split_short_opt "$_G_opt" 196426372658Smrg set dummy "$func_split_short_opt_name" \ 196526372658Smrg "$func_split_short_opt_arg" ${1+"$@"} 196626372658Smrg shift 196726372658Smrg ;; 196826372658Smrg 196926372658Smrg # Separate non-argument short options: 197026372658Smrg -\?*|-h*|-v*|-x*) 197126372658Smrg func_split_short_opt "$_G_opt" 197226372658Smrg set dummy "$func_split_short_opt_name" \ 197326372658Smrg "-$func_split_short_opt_arg" ${1+"$@"} 197426372658Smrg shift 197526372658Smrg ;; 197626372658Smrg 1977c3e29c03Smrg --) _G_parse_options_requote=: ; break ;; 197826372658Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979c3e29c03Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980c3e29c03Smrg _G_match_parse_options=false 1981c3e29c03Smrg break 1982c3e29c03Smrg ;; 198326372658Smrg esac 1984c3e29c03Smrg 1985c3e29c03Smrg if $_G_match_parse_options; then 1986c3e29c03Smrg _G_parse_options_requote=: 1987c3e29c03Smrg fi 198826372658Smrg done 198926372658Smrg 1990c3e29c03Smrg if $_G_parse_options_requote; then 1991c3e29c03Smrg # save modified positional parameters for caller 1992c3e29c03Smrg func_quote eval ${1+"$@"} 1993c3e29c03Smrg func_parse_options_result=$func_quote_result 1994c3e29c03Smrg fi 19954b0ead49Smrg} 19964b0ead49Smrg 199749dc963fSmrg 199826372658Smrg# func_validate_options [ARG]... 199926372658Smrg# ------------------------------ 200026372658Smrg# Perform any sanity checks on option settings and/or unconsumed 200126372658Smrg# arguments. 200226372658Smrgfunc_hookable func_validate_options 200326372658Smrgfunc_validate_options () 20044b0ead49Smrg{ 200526372658Smrg $debug_cmd 200649dc963fSmrg 200726372658Smrg # Display all warnings if -W was not given. 200826372658Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 200949dc963fSmrg 201026372658Smrg func_run_hooks func_validate_options ${1+"$@"} 2011c3e29c03Smrg func_propagate_result func_run_hooks func_validate_options 20124b0ead49Smrg 201326372658Smrg # Bail if the options were screwed! 201426372658Smrg $exit_cmd $EXIT_FAILURE 20154e7590efSmrg} 20164e7590efSmrg 20174b0ead49Smrg 20184e7590efSmrg 201926372658Smrg## ----------------- ## 202026372658Smrg## Helper functions. ## 202126372658Smrg## ----------------- ## 202249dc963fSmrg 202326372658Smrg# This section contains the helper functions used by the rest of the 202426372658Smrg# hookable option parser framework in ascii-betical order. 202526372658Smrg 202626372658Smrg 202726372658Smrg# func_fatal_help ARG... 202826372658Smrg# ---------------------- 202926372658Smrg# Echo program name prefixed message to standard error, followed by 203026372658Smrg# a help hint, and exit. 203126372658Smrgfunc_fatal_help () 203249dc963fSmrg{ 203326372658Smrg $debug_cmd 20344e7590efSmrg 203526372658Smrg eval \$ECHO \""Usage: $usage"\" 203626372658Smrg eval \$ECHO \""$fatal_help"\" 203726372658Smrg func_error ${1+"$@"} 203826372658Smrg exit $EXIT_FAILURE 203949dc963fSmrg} 204049dc963fSmrg 204126372658Smrg 204226372658Smrg# func_help 204326372658Smrg# --------- 204426372658Smrg# Echo long help message to standard output and exit. 204549dc963fSmrgfunc_help () 204649dc963fSmrg{ 204726372658Smrg $debug_cmd 204826372658Smrg 204926372658Smrg func_usage_message 205026372658Smrg $ECHO "$long_help_message" 205126372658Smrg exit 0 205249dc963fSmrg} 205349dc963fSmrg 205426372658Smrg 205526372658Smrg# func_missing_arg ARGNAME 205626372658Smrg# ------------------------ 205749dc963fSmrg# Echo program name prefixed message to standard error and set global 205849dc963fSmrg# exit_cmd. 205949dc963fSmrgfunc_missing_arg () 206049dc963fSmrg{ 206126372658Smrg $debug_cmd 20624e7590efSmrg 206326372658Smrg func_error "Missing argument for '$1'." 206449dc963fSmrg exit_cmd=exit 20654b0ead49Smrg} 20664b0ead49Smrg 20674b0ead49Smrg 206826372658Smrg# func_split_equals STRING 206926372658Smrg# ------------------------ 2070c3e29c03Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071c3e29c03Smrg# after splitting STRING at the '=' sign. 207226372658Smrgtest -z "$_G_HAVE_XSI_OPS" \ 207326372658Smrg && (eval 'x=a/b/c; 207426372658Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 207526372658Smrg && _G_HAVE_XSI_OPS=yes 207626372658Smrg 207726372658Smrgif test yes = "$_G_HAVE_XSI_OPS" 207826372658Smrgthen 207926372658Smrg # This is an XSI compatible shell, allowing a faster implementation... 208026372658Smrg eval 'func_split_equals () 208126372658Smrg { 208226372658Smrg $debug_cmd 208326372658Smrg 208426372658Smrg func_split_equals_lhs=${1%%=*} 208526372658Smrg func_split_equals_rhs=${1#*=} 2086c3e29c03Smrg if test "x$func_split_equals_lhs" = "x$1"; then 2087c3e29c03Smrg func_split_equals_rhs= 2088c3e29c03Smrg fi 208926372658Smrg }' 209026372658Smrgelse 209126372658Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 209226372658Smrg func_split_equals () 209326372658Smrg { 209426372658Smrg $debug_cmd 209526372658Smrg 209626372658Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 209726372658Smrg func_split_equals_rhs= 2098c3e29c03Smrg test "x$func_split_equals_lhs=" = "x$1" \ 209926372658Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 210026372658Smrg } 210126372658Smrgfi #func_split_equals 210226372658Smrg 210326372658Smrg 210426372658Smrg# func_split_short_opt SHORTOPT 210526372658Smrg# ----------------------------- 21064e7590efSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21074e7590efSmrg# variables after splitting SHORTOPT after the 2nd character. 210826372658Smrgif test yes = "$_G_HAVE_XSI_OPS" 210926372658Smrgthen 211026372658Smrg # This is an XSI compatible shell, allowing a faster implementation... 211126372658Smrg eval 'func_split_short_opt () 211226372658Smrg { 211326372658Smrg $debug_cmd 211426372658Smrg 211526372658Smrg func_split_short_opt_arg=${1#??} 211626372658Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 211726372658Smrg }' 211826372658Smrgelse 211926372658Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 212026372658Smrg func_split_short_opt () 212126372658Smrg { 212226372658Smrg $debug_cmd 212326372658Smrg 2124c3e29c03Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 212526372658Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 212626372658Smrg } 212726372658Smrgfi #func_split_short_opt 212826372658Smrg 212926372658Smrg 213026372658Smrg# func_usage 213126372658Smrg# ---------- 213226372658Smrg# Echo short help message to standard output and exit. 213326372658Smrgfunc_usage () 21344e7590efSmrg{ 213526372658Smrg $debug_cmd 21364e7590efSmrg 213726372658Smrg func_usage_message 213826372658Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 213926372658Smrg exit 0 214026372658Smrg} 21414e7590efSmrg 21424e7590efSmrg 214326372658Smrg# func_usage_message 214426372658Smrg# ------------------ 214526372658Smrg# Echo short help message to standard output. 214626372658Smrgfunc_usage_message () 21474e7590efSmrg{ 214826372658Smrg $debug_cmd 21494e7590efSmrg 215026372658Smrg eval \$ECHO \""Usage: $usage"\" 215126372658Smrg echo 215226372658Smrg $SED -n 's|^# || 215326372658Smrg /^Written by/{ 215426372658Smrg x;p;x 215526372658Smrg } 215626372658Smrg h 215726372658Smrg /^Written by/q' < "$progpath" 215826372658Smrg echo 215926372658Smrg eval \$ECHO \""$usage_message"\" 216026372658Smrg} 21614e7590efSmrg 21624b0ead49Smrg 216326372658Smrg# func_version 216426372658Smrg# ------------ 216526372658Smrg# Echo version message to standard output and exit. 2166c3e29c03Smrg# The version message is extracted from the calling file's header 2167c3e29c03Smrg# comments, with leading '# ' stripped: 2168c3e29c03Smrg# 1. First display the progname and version 2169c3e29c03Smrg# 2. Followed by the header comment line matching /^# Written by / 2170c3e29c03Smrg# 3. Then a blank line followed by the first following line matching 2171c3e29c03Smrg# /^# Copyright / 2172c3e29c03Smrg# 4. Immediately followed by any lines between the previous matches, 2173c3e29c03Smrg# except lines preceding the intervening completely blank line. 2174c3e29c03Smrg# For example, see the header comments of this file. 217526372658Smrgfunc_version () 217626372658Smrg{ 217726372658Smrg $debug_cmd 217849dc963fSmrg 217926372658Smrg printf '%s\n' "$progname $scriptversion" 218026372658Smrg $SED -n ' 2181c3e29c03Smrg /^# Written by /!b 2182c3e29c03Smrg s|^# ||; p; n 2183c3e29c03Smrg 2184c3e29c03Smrg :fwd2blnk 2185c3e29c03Smrg /./ { 2186c3e29c03Smrg n 2187c3e29c03Smrg b fwd2blnk 218826372658Smrg } 2189c3e29c03Smrg p; n 2190c3e29c03Smrg 2191c3e29c03Smrg :holdwrnt 2192c3e29c03Smrg s|^# || 2193c3e29c03Smrg s|^# *$|| 2194c3e29c03Smrg /^Copyright /!{ 2195c3e29c03Smrg /./H 2196c3e29c03Smrg n 2197c3e29c03Smrg b holdwrnt 219826372658Smrg } 2199c3e29c03Smrg 2200c3e29c03Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201c3e29c03Smrg G 2202c3e29c03Smrg s|\(\n\)\n*|\1|g 2203c3e29c03Smrg p; q' < "$progpath" 220449dc963fSmrg 220526372658Smrg exit $? 220626372658Smrg} 220749dc963fSmrg 22084b0ead49Smrg 220926372658Smrg# Local variables: 221026372658Smrg# mode: shell-script 221126372658Smrg# sh-indentation: 2 221226372658Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213c3e29c03Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 221426372658Smrg# time-stamp-time-zone: "UTC" 221526372658Smrg# End: 22164b0ead49Smrg 221726372658Smrg# Set a version string. 2218c3e29c03Smrgscriptversion='(GNU libtool) 2.4.7' 22194b0ead49Smrg 222049dc963fSmrg 222126372658Smrg# func_echo ARG... 222226372658Smrg# ---------------- 222326372658Smrg# Libtool also displays the current mode in messages, so override 222426372658Smrg# funclib.sh func_echo with this custom definition. 222526372658Smrgfunc_echo () 22264e7590efSmrg{ 222726372658Smrg $debug_cmd 22284e7590efSmrg 222926372658Smrg _G_message=$* 22304e7590efSmrg 223126372658Smrg func_echo_IFS=$IFS 223226372658Smrg IFS=$nl 223326372658Smrg for _G_line in $_G_message; do 223426372658Smrg IFS=$func_echo_IFS 223526372658Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 223626372658Smrg done 223726372658Smrg IFS=$func_echo_IFS 223826372658Smrg} 22394e7590efSmrg 224026372658Smrg 224126372658Smrg# func_warning ARG... 224226372658Smrg# ------------------- 224326372658Smrg# Libtool warnings are not categorized, so override funclib.sh 224426372658Smrg# func_warning with this simpler definition. 224526372658Smrgfunc_warning () 22464e7590efSmrg{ 224726372658Smrg $debug_cmd 22484e7590efSmrg 224926372658Smrg $warning_func ${1+"$@"} 225026372658Smrg} 22514e7590efSmrg 22524e7590efSmrg 225326372658Smrg## ---------------- ## 225426372658Smrg## Options parsing. ## 225526372658Smrg## ---------------- ## 225626372658Smrg 225726372658Smrg# Hook in the functions to make sure our own options are parsed during 225826372658Smrg# the option parsing loop. 225926372658Smrg 226026372658Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 226126372658Smrg 226226372658Smrg# Short help message in response to '-h'. 226326372658Smrgusage_message="Options: 226426372658Smrg --config show all configuration variables 226526372658Smrg --debug enable verbose shell tracing 226626372658Smrg -n, --dry-run display commands without modifying any files 226726372658Smrg --features display basic configuration information and exit 226826372658Smrg --mode=MODE use operation mode MODE 226926372658Smrg --no-warnings equivalent to '-Wnone' 227026372658Smrg --preserve-dup-deps don't remove duplicate dependency libraries 227126372658Smrg --quiet, --silent don't print informational messages 227226372658Smrg --tag=TAG use configuration variables from tag TAG 227326372658Smrg -v, --verbose print more informational messages than default 227426372658Smrg --version print version information 227526372658Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 227626372658Smrg -h, --help, --help-all print short, long, or detailed help message 227726372658Smrg" 22784e7590efSmrg 227926372658Smrg# Additional text appended to 'usage_message' in response to '--help'. 228026372658Smrgfunc_help () 22814e7590efSmrg{ 228226372658Smrg $debug_cmd 228326372658Smrg 228426372658Smrg func_usage_message 228526372658Smrg $ECHO "$long_help_message 228626372658Smrg 228726372658SmrgMODE must be one of the following: 228826372658Smrg 228926372658Smrg clean remove files from the build directory 229026372658Smrg compile compile a source file into a libtool object 229126372658Smrg execute automatically set library path, then run a program 229226372658Smrg finish complete the installation of libtool libraries 229326372658Smrg install install libraries or executables 229426372658Smrg link create a library or an executable 229526372658Smrg uninstall remove libraries from an installed directory 229626372658Smrg 229726372658SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 229826372658Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 229926372658SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 230026372658Smrg 230126372658SmrgWhen reporting a bug, please describe a test case to reproduce it and 230226372658Smrginclude the following information: 230326372658Smrg 230426372658Smrg host-triplet: $host 230526372658Smrg shell: $SHELL 230626372658Smrg compiler: $LTCC 230726372658Smrg compiler flags: $LTCFLAGS 230826372658Smrg linker: $LD (gnu? $with_gnu_ld) 2309c3e29c03Smrg version: $progname (GNU libtool) 2.4.7 231026372658Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 231126372658Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 231226372658Smrg 231326372658SmrgReport bugs to <bug-libtool@gnu.org>. 2314c3e29c03SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 231526372658SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 231626372658Smrg exit 0 231726372658Smrg} 23184e7590efSmrg 23194e7590efSmrg 232026372658Smrg# func_lo2o OBJECT-NAME 232126372658Smrg# --------------------- 232226372658Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 232326372658Smrg# object suffix. 232426372658Smrg 232526372658Smrglo2o=s/\\.lo\$/.$objext/ 232626372658Smrgo2lo=s/\\.$objext\$/.lo/ 232726372658Smrg 232826372658Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 232926372658Smrg eval 'func_lo2o () 233026372658Smrg { 233126372658Smrg case $1 in 233226372658Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 233326372658Smrg * ) func_lo2o_result=$1 ;; 233426372658Smrg esac 233526372658Smrg }' 233626372658Smrg 233726372658Smrg # func_xform LIBOBJ-OR-SOURCE 233826372658Smrg # --------------------------- 233926372658Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 234026372658Smrg # suffix to a '.lo' libtool-object suffix. 234126372658Smrg eval 'func_xform () 234226372658Smrg { 234326372658Smrg func_xform_result=${1%.*}.lo 234426372658Smrg }' 234526372658Smrgelse 234626372658Smrg # ...otherwise fall back to using sed. 234726372658Smrg func_lo2o () 234826372658Smrg { 234926372658Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 235026372658Smrg } 235126372658Smrg 235226372658Smrg func_xform () 235326372658Smrg { 235426372658Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 235526372658Smrg } 235626372658Smrgfi 23574e7590efSmrg 23584e7590efSmrg 235926372658Smrg# func_fatal_configuration ARG... 236026372658Smrg# ------------------------------- 236149dc963fSmrg# Echo program name prefixed message to standard error, followed by 236249dc963fSmrg# a configuration failure hint, and exit. 236349dc963fSmrgfunc_fatal_configuration () 236449dc963fSmrg{ 2365c3e29c03Smrg func_fatal_error ${1+"$@"} \ 236626372658Smrg "See the $PACKAGE documentation for more information." \ 236726372658Smrg "Fatal configuration error." 236849dc963fSmrg} 23694b0ead49Smrg 237052b01e16Smrg 237149dc963fSmrg# func_config 237226372658Smrg# ----------- 237349dc963fSmrg# Display the configuration for all the tags in this script. 237449dc963fSmrgfunc_config () 237549dc963fSmrg{ 237649dc963fSmrg re_begincf='^# ### BEGIN LIBTOOL' 237749dc963fSmrg re_endcf='^# ### END LIBTOOL' 237849dc963fSmrg 237949dc963fSmrg # Default configuration. 238049dc963fSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23814b0ead49Smrg 23824b0ead49Smrg # Now print the configurations for the tags. 23834b0ead49Smrg for tagname in $taglist; do 238449dc963fSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23854b0ead49Smrg done 23864b0ead49Smrg 238749dc963fSmrg exit $? 238849dc963fSmrg} 23894b0ead49Smrg 239026372658Smrg 239149dc963fSmrg# func_features 239226372658Smrg# ------------- 239349dc963fSmrg# Display the features supported by this script. 239449dc963fSmrgfunc_features () 239549dc963fSmrg{ 23967aa89044Smrg echo "host: $host" 239726372658Smrg if test yes = "$build_libtool_libs"; then 23987aa89044Smrg echo "enable shared libraries" 23994b0ead49Smrg else 24007aa89044Smrg echo "disable shared libraries" 24014b0ead49Smrg fi 240226372658Smrg if test yes = "$build_old_libs"; then 24037aa89044Smrg echo "enable static libraries" 24044b0ead49Smrg else 24057aa89044Smrg echo "disable static libraries" 24064b0ead49Smrg fi 240749dc963fSmrg 24084b0ead49Smrg exit $? 240949dc963fSmrg} 24104b0ead49Smrg 241126372658Smrg 241226372658Smrg# func_enable_tag TAGNAME 241326372658Smrg# ----------------------- 241449dc963fSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 241549dc963fSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 241649dc963fSmrg# variable here. 241749dc963fSmrgfunc_enable_tag () 241849dc963fSmrg{ 241926372658Smrg # Global variable: 242026372658Smrg tagname=$1 24214b0ead49Smrg 242226372658Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 242326372658Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 242426372658Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24254b0ead49Smrg 242626372658Smrg # Validate tagname. 242726372658Smrg case $tagname in 242826372658Smrg *[!-_A-Za-z0-9,/]*) 242926372658Smrg func_fatal_error "invalid tag name: $tagname" 243026372658Smrg ;; 243126372658Smrg esac 24324b0ead49Smrg 243326372658Smrg # Don't test for the "default" C tag, as we know it's 243426372658Smrg # there but not specially marked. 243526372658Smrg case $tagname in 243626372658Smrg CC) ;; 243749dc963fSmrg *) 243826372658Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 243926372658Smrg taglist="$taglist $tagname" 244026372658Smrg 244126372658Smrg # Evaluate the configuration. Be careful to quote the path 244226372658Smrg # and the sed script, to avoid splitting on whitespace, but 244326372658Smrg # also don't use non-portable quotes within backquotes within 244426372658Smrg # quotes we have to do it in 2 steps: 244526372658Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 244626372658Smrg eval "$extractedcf" 244726372658Smrg else 244826372658Smrg func_error "ignoring unknown tag $tagname" 244926372658Smrg fi 245026372658Smrg ;; 245126372658Smrg esac 245249dc963fSmrg} 245349dc963fSmrg 245426372658Smrg 24554e7590efSmrg# func_check_version_match 245626372658Smrg# ------------------------ 24574e7590efSmrg# Ensure that we are using m4 macros, and libtool script from the same 24584e7590efSmrg# release of libtool. 24594e7590efSmrgfunc_check_version_match () 246049dc963fSmrg{ 246126372658Smrg if test "$package_revision" != "$macro_revision"; then 246226372658Smrg if test "$VERSION" != "$macro_version"; then 246326372658Smrg if test -z "$macro_version"; then 246426372658Smrg cat >&2 <<_LT_EOF 24654e7590efSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24664e7590efSmrg$progname: definition of this LT_INIT comes from an older release. 24674e7590efSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24684e7590efSmrg$progname: and run autoconf again. 24694e7590efSmrg_LT_EOF 247026372658Smrg else 247126372658Smrg cat >&2 <<_LT_EOF 24724e7590efSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24734e7590efSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24744e7590efSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24754e7590efSmrg$progname: and run autoconf again. 24764e7590efSmrg_LT_EOF 247726372658Smrg fi 247826372658Smrg else 247926372658Smrg cat >&2 <<_LT_EOF 24804e7590efSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24814e7590efSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24824e7590efSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24834e7590efSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 24844e7590efSmrg_LT_EOF 248526372658Smrg fi 24864e7590efSmrg 248726372658Smrg exit $EXIT_MISMATCH 248826372658Smrg fi 24894e7590efSmrg} 24904e7590efSmrg 24914e7590efSmrg 249226372658Smrg# libtool_options_prep [ARG]... 249326372658Smrg# ----------------------------- 249426372658Smrg# Preparation for options parsed by libtool. 249526372658Smrglibtool_options_prep () 249626372658Smrg{ 249726372658Smrg $debug_mode 24984e7590efSmrg 249926372658Smrg # Option defaults: 250026372658Smrg opt_config=false 250126372658Smrg opt_dlopen= 250226372658Smrg opt_dry_run=false 250326372658Smrg opt_help=false 250426372658Smrg opt_mode= 250526372658Smrg opt_preserve_dup_deps=false 250626372658Smrg opt_quiet=false 25074e7590efSmrg 250826372658Smrg nonopt= 250926372658Smrg preserve_args= 25104e7590efSmrg 2511c3e29c03Smrg _G_rc_lt_options_prep=: 2512c3e29c03Smrg 251326372658Smrg # Shorthand for --mode=foo, only valid as the first argument 251426372658Smrg case $1 in 251526372658Smrg clean|clea|cle|cl) 251626372658Smrg shift; set dummy --mode clean ${1+"$@"}; shift 251726372658Smrg ;; 251826372658Smrg compile|compil|compi|comp|com|co|c) 251926372658Smrg shift; set dummy --mode compile ${1+"$@"}; shift 252026372658Smrg ;; 252126372658Smrg execute|execut|execu|exec|exe|ex|e) 252226372658Smrg shift; set dummy --mode execute ${1+"$@"}; shift 252326372658Smrg ;; 252426372658Smrg finish|finis|fini|fin|fi|f) 252526372658Smrg shift; set dummy --mode finish ${1+"$@"}; shift 252626372658Smrg ;; 252726372658Smrg install|instal|insta|inst|ins|in|i) 252826372658Smrg shift; set dummy --mode install ${1+"$@"}; shift 252926372658Smrg ;; 253026372658Smrg link|lin|li|l) 253126372658Smrg shift; set dummy --mode link ${1+"$@"}; shift 253226372658Smrg ;; 253326372658Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 253426372658Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 253526372658Smrg ;; 2536c3e29c03Smrg *) 2537c3e29c03Smrg _G_rc_lt_options_prep=false 2538c3e29c03Smrg ;; 253926372658Smrg esac 254026372658Smrg 2541c3e29c03Smrg if $_G_rc_lt_options_prep; then 2542c3e29c03Smrg # Pass back the list of options. 2543c3e29c03Smrg func_quote eval ${1+"$@"} 2544c3e29c03Smrg libtool_options_prep_result=$func_quote_result 2545c3e29c03Smrg fi 254626372658Smrg} 254726372658Smrgfunc_add_hook func_options_prep libtool_options_prep 25484b0ead49Smrg 25494b0ead49Smrg 255026372658Smrg# libtool_parse_options [ARG]... 255126372658Smrg# --------------------------------- 255226372658Smrg# Provide handling for libtool specific options. 255326372658Smrglibtool_parse_options () 25544e7590efSmrg{ 255526372658Smrg $debug_cmd 255649dc963fSmrg 2557c3e29c03Smrg _G_rc_lt_parse_options=false 2558c3e29c03Smrg 255926372658Smrg # Perform our own loop to consume as many options as possible in 256026372658Smrg # each iteration. 256126372658Smrg while test $# -gt 0; do 2562c3e29c03Smrg _G_match_lt_parse_options=: 256326372658Smrg _G_opt=$1 256426372658Smrg shift 256526372658Smrg case $_G_opt in 256626372658Smrg --dry-run|--dryrun|-n) 256726372658Smrg opt_dry_run=: 256826372658Smrg ;; 256926372658Smrg 257026372658Smrg --config) func_config ;; 257126372658Smrg 257226372658Smrg --dlopen|-dlopen) 257326372658Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 257426372658Smrg}$1" 257526372658Smrg shift 257626372658Smrg ;; 257726372658Smrg 257826372658Smrg --preserve-dup-deps) 257926372658Smrg opt_preserve_dup_deps=: ;; 258026372658Smrg 258126372658Smrg --features) func_features ;; 258226372658Smrg 258326372658Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 258426372658Smrg 258526372658Smrg --help) opt_help=: ;; 258626372658Smrg 258726372658Smrg --help-all) opt_help=': help-all' ;; 258826372658Smrg 258926372658Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 259026372658Smrg opt_mode=$1 259126372658Smrg case $1 in 259226372658Smrg # Valid mode arguments: 259326372658Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 259426372658Smrg 259526372658Smrg # Catch anything else as an error 259626372658Smrg *) func_error "invalid argument for $_G_opt" 259726372658Smrg exit_cmd=exit 259826372658Smrg break 259926372658Smrg ;; 260026372658Smrg esac 260126372658Smrg shift 260226372658Smrg ;; 260326372658Smrg 260426372658Smrg --no-silent|--no-quiet) 260526372658Smrg opt_quiet=false 260626372658Smrg func_append preserve_args " $_G_opt" 260726372658Smrg ;; 260826372658Smrg 260926372658Smrg --no-warnings|--no-warning|--no-warn) 261026372658Smrg opt_warning=false 261126372658Smrg func_append preserve_args " $_G_opt" 261226372658Smrg ;; 261326372658Smrg 261426372658Smrg --no-verbose) 261526372658Smrg opt_verbose=false 261626372658Smrg func_append preserve_args " $_G_opt" 261726372658Smrg ;; 261826372658Smrg 261926372658Smrg --silent|--quiet) 262026372658Smrg opt_quiet=: 262126372658Smrg opt_verbose=false 262226372658Smrg func_append preserve_args " $_G_opt" 262326372658Smrg ;; 262426372658Smrg 262526372658Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 262626372658Smrg opt_tag=$1 262726372658Smrg func_append preserve_args " $_G_opt $1" 262826372658Smrg func_enable_tag "$1" 262926372658Smrg shift 263026372658Smrg ;; 263126372658Smrg 263226372658Smrg --verbose|-v) opt_quiet=false 263326372658Smrg opt_verbose=: 263426372658Smrg func_append preserve_args " $_G_opt" 263526372658Smrg ;; 263626372658Smrg 2637c3e29c03Smrg # An option not handled by this hook function: 2638c3e29c03Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639c3e29c03Smrg _G_match_lt_parse_options=false 2640c3e29c03Smrg break 2641c3e29c03Smrg ;; 264226372658Smrg esac 2643c3e29c03Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 264426372658Smrg done 26454e7590efSmrg 2646c3e29c03Smrg if $_G_rc_lt_parse_options; then 2647c3e29c03Smrg # save modified positional parameters for caller 2648c3e29c03Smrg func_quote eval ${1+"$@"} 2649c3e29c03Smrg libtool_parse_options_result=$func_quote_result 2650c3e29c03Smrg fi 265126372658Smrg} 265226372658Smrgfunc_add_hook func_parse_options libtool_parse_options 265349dc963fSmrg 26544b0ead49Smrg 265549dc963fSmrg 265626372658Smrg# libtool_validate_options [ARG]... 265726372658Smrg# --------------------------------- 265826372658Smrg# Perform any sanity checks on option settings and/or unconsumed 265926372658Smrg# arguments. 266026372658Smrglibtool_validate_options () 266126372658Smrg{ 266226372658Smrg # save first non-option argument 266326372658Smrg if test 0 -lt $#; then 266426372658Smrg nonopt=$1 266526372658Smrg shift 266649dc963fSmrg fi 266749dc963fSmrg 266826372658Smrg # preserve --debug 266926372658Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 267049dc963fSmrg 267126372658Smrg case $host in 267226372658Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 267326372658Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 267426372658Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 267526372658Smrg # don't eliminate duplications in $postdeps and $predeps 267626372658Smrg opt_duplicate_compiler_generated_deps=: 267726372658Smrg ;; 267826372658Smrg *) 267926372658Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 268026372658Smrg ;; 268126372658Smrg esac 268249dc963fSmrg 268326372658Smrg $opt_help || { 268426372658Smrg # Sanity checks first: 268526372658Smrg func_check_version_match 268626372658Smrg 268726372658Smrg test yes != "$build_libtool_libs" \ 268826372658Smrg && test yes != "$build_old_libs" \ 268926372658Smrg && func_fatal_configuration "not configured to build any kind of library" 269026372658Smrg 269126372658Smrg # Darwin sucks 269226372658Smrg eval std_shrext=\"$shrext_cmds\" 269326372658Smrg 269426372658Smrg # Only execute mode is allowed to have -dlopen flags. 269526372658Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 269626372658Smrg func_error "unrecognized option '-dlopen'" 269726372658Smrg $ECHO "$help" 1>&2 269826372658Smrg exit $EXIT_FAILURE 269926372658Smrg fi 270049dc963fSmrg 270126372658Smrg # Change the help message to a mode-specific one. 270226372658Smrg generic_help=$help 270326372658Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 270426372658Smrg } 270549dc963fSmrg 270626372658Smrg # Pass back the unparsed argument list 2707c3e29c03Smrg func_quote eval ${1+"$@"} 2708c3e29c03Smrg libtool_validate_options_result=$func_quote_result 27094e7590efSmrg} 271026372658Smrgfunc_add_hook func_validate_options libtool_validate_options 271149dc963fSmrg 271249dc963fSmrg 271326372658Smrg# Process options as early as possible so that --help and --version 271426372658Smrg# can return quickly. 271526372658Smrgfunc_options ${1+"$@"} 271626372658Smrgeval set dummy "$func_options_result"; shift 271726372658Smrg 27184b0ead49Smrg 27194b0ead49Smrg 27204e7590efSmrg## ----------- ## 27214e7590efSmrg## Main. ## 27224e7590efSmrg## ----------- ## 27234b0ead49Smrg 272426372658Smrgmagic='%%%MAGIC variable%%%' 272526372658Smrgmagic_exe='%%%MAGIC EXE variable%%%' 272626372658Smrg 272726372658Smrg# Global variables. 272826372658Smrgextracted_archives= 272926372658Smrgextracted_serial=0 273026372658Smrg 273126372658Smrg# If this variable is set in any of the actions, the command in it 273226372658Smrg# will be execed at the end. This prevents here-documents from being 273326372658Smrg# left over by shells. 273426372658Smrgexec_cmd= 273526372658Smrg 273626372658Smrg 273726372658Smrg# A function that is used when there is no print builtin or printf. 273826372658Smrgfunc_fallback_echo () 273926372658Smrg{ 274026372658Smrg eval 'cat <<_LTECHO_EOF 274126372658Smrg$1 274226372658Smrg_LTECHO_EOF' 274326372658Smrg} 274426372658Smrg 274526372658Smrg# func_generated_by_libtool 274626372658Smrg# True iff stdin has been generated by Libtool. This function is only 274726372658Smrg# a basic sanity check; it will hardly flush out determined imposters. 274826372658Smrgfunc_generated_by_libtool_p () 274926372658Smrg{ 275026372658Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 275126372658Smrg} 275226372658Smrg 275349dc963fSmrg# func_lalib_p file 275426372658Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 275549dc963fSmrg# This function is only a basic sanity check; it will hardly flush out 275649dc963fSmrg# determined imposters. 275749dc963fSmrgfunc_lalib_p () 275849dc963fSmrg{ 275949dc963fSmrg test -f "$1" && 276026372658Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 276149dc963fSmrg} 27624b0ead49Smrg 276349dc963fSmrg# func_lalib_unsafe_p file 276426372658Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 276549dc963fSmrg# This function implements the same check as func_lalib_p without 276649dc963fSmrg# resorting to external programs. To this end, it redirects stdin and 276749dc963fSmrg# closes it afterwards, without saving the original file descriptor. 276849dc963fSmrg# As a safety measure, use it only where a negative result would be 276926372658Smrg# fatal anyway. Works if 'file' does not exist. 277049dc963fSmrgfunc_lalib_unsafe_p () 277149dc963fSmrg{ 277249dc963fSmrg lalib_p=no 277349dc963fSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 277449dc963fSmrg for lalib_p_l in 1 2 3 4 277549dc963fSmrg do 277649dc963fSmrg read lalib_p_line 277726372658Smrg case $lalib_p_line in 277849dc963fSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 277949dc963fSmrg esac 278049dc963fSmrg done 278149dc963fSmrg exec 0<&5 5<&- 278249dc963fSmrg fi 278326372658Smrg test yes = "$lalib_p" 278449dc963fSmrg} 27854b0ead49Smrg 278649dc963fSmrg# func_ltwrapper_script_p file 278749dc963fSmrg# True iff FILE is a libtool wrapper script 278849dc963fSmrg# This function is only a basic sanity check; it will hardly flush out 278949dc963fSmrg# determined imposters. 279049dc963fSmrgfunc_ltwrapper_script_p () 279149dc963fSmrg{ 279226372658Smrg test -f "$1" && 279326372658Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 279449dc963fSmrg} 27954b0ead49Smrg 279649dc963fSmrg# func_ltwrapper_executable_p file 279749dc963fSmrg# True iff FILE is a libtool wrapper executable 279849dc963fSmrg# This function is only a basic sanity check; it will hardly flush out 279949dc963fSmrg# determined imposters. 280049dc963fSmrgfunc_ltwrapper_executable_p () 280149dc963fSmrg{ 280249dc963fSmrg func_ltwrapper_exec_suffix= 280349dc963fSmrg case $1 in 280449dc963fSmrg *.exe) ;; 280549dc963fSmrg *) func_ltwrapper_exec_suffix=.exe ;; 280649dc963fSmrg esac 280749dc963fSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 280849dc963fSmrg} 28094b0ead49Smrg 281049dc963fSmrg# func_ltwrapper_scriptname file 281149dc963fSmrg# Assumes file is an ltwrapper_executable 281249dc963fSmrg# uses $file to determine the appropriate filename for a 281349dc963fSmrg# temporary ltwrapper_script. 281449dc963fSmrgfunc_ltwrapper_scriptname () 281549dc963fSmrg{ 28164e7590efSmrg func_dirname_and_basename "$1" "" "." 28174e7590efSmrg func_stripname '' '.exe' "$func_basename_result" 281826372658Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 281949dc963fSmrg} 282049dc963fSmrg 282149dc963fSmrg# func_ltwrapper_p file 282249dc963fSmrg# True iff FILE is a libtool wrapper script or wrapper executable 282349dc963fSmrg# This function is only a basic sanity check; it will hardly flush out 282449dc963fSmrg# determined imposters. 282549dc963fSmrgfunc_ltwrapper_p () 282649dc963fSmrg{ 282749dc963fSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 282849dc963fSmrg} 282949dc963fSmrg 283049dc963fSmrg 283149dc963fSmrg# func_execute_cmds commands fail_cmd 283249dc963fSmrg# Execute tilde-delimited COMMANDS. 283349dc963fSmrg# If FAIL_CMD is given, eval that upon failure. 283449dc963fSmrg# FAIL_CMD may read-access the current command in variable CMD! 283549dc963fSmrgfunc_execute_cmds () 283649dc963fSmrg{ 283726372658Smrg $debug_cmd 283826372658Smrg 283949dc963fSmrg save_ifs=$IFS; IFS='~' 284049dc963fSmrg for cmd in $1; do 284126372658Smrg IFS=$sp$nl 284249dc963fSmrg eval cmd=\"$cmd\" 284326372658Smrg IFS=$save_ifs 284449dc963fSmrg func_show_eval "$cmd" "${2-:}" 284549dc963fSmrg done 284649dc963fSmrg IFS=$save_ifs 284749dc963fSmrg} 284849dc963fSmrg 284949dc963fSmrg 285049dc963fSmrg# func_source file 285149dc963fSmrg# Source FILE, adding directory component if necessary. 285249dc963fSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 285349dc963fSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 285449dc963fSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 285526372658Smrg# 'FILE.' does not work on cygwin managed mounts. 285649dc963fSmrgfunc_source () 285749dc963fSmrg{ 285826372658Smrg $debug_cmd 285926372658Smrg 286049dc963fSmrg case $1 in 286149dc963fSmrg */* | *\\*) . "$1" ;; 286249dc963fSmrg *) . "./$1" ;; 286349dc963fSmrg esac 286449dc963fSmrg} 286549dc963fSmrg 286649dc963fSmrg 28674e7590efSmrg# func_resolve_sysroot PATH 28684e7590efSmrg# Replace a leading = in PATH with a sysroot. Store the result into 28694e7590efSmrg# func_resolve_sysroot_result 28704e7590efSmrgfunc_resolve_sysroot () 28714e7590efSmrg{ 28724e7590efSmrg func_resolve_sysroot_result=$1 28734e7590efSmrg case $func_resolve_sysroot_result in 28744e7590efSmrg =*) 28754e7590efSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 28764e7590efSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28774e7590efSmrg ;; 28784e7590efSmrg esac 28794e7590efSmrg} 28804e7590efSmrg 28814e7590efSmrg# func_replace_sysroot PATH 28824e7590efSmrg# If PATH begins with the sysroot, replace it with = and 28834e7590efSmrg# store the result into func_replace_sysroot_result. 28844e7590efSmrgfunc_replace_sysroot () 28854e7590efSmrg{ 288626372658Smrg case $lt_sysroot:$1 in 28874e7590efSmrg ?*:"$lt_sysroot"*) 28884e7590efSmrg func_stripname "$lt_sysroot" '' "$1" 288926372658Smrg func_replace_sysroot_result='='$func_stripname_result 28904e7590efSmrg ;; 28914e7590efSmrg *) 28924e7590efSmrg # Including no sysroot. 28934e7590efSmrg func_replace_sysroot_result=$1 28944e7590efSmrg ;; 28954e7590efSmrg esac 28964e7590efSmrg} 28974e7590efSmrg 289849dc963fSmrg# func_infer_tag arg 289949dc963fSmrg# Infer tagged configuration to use if any are available and 290049dc963fSmrg# if one wasn't chosen via the "--tag" command line option. 290149dc963fSmrg# Only attempt this if the compiler in the base compile 290249dc963fSmrg# command doesn't match the default compiler. 290349dc963fSmrg# arg is usually of the form 'gcc ...' 290449dc963fSmrgfunc_infer_tag () 290549dc963fSmrg{ 290626372658Smrg $debug_cmd 290726372658Smrg 290849dc963fSmrg if test -n "$available_tags" && test -z "$tagname"; then 290949dc963fSmrg CC_quoted= 291049dc963fSmrg for arg in $CC; do 29114e7590efSmrg func_append_quoted CC_quoted "$arg" 291249dc963fSmrg done 29137aa89044Smrg CC_expanded=`func_echo_all $CC` 29147aa89044Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 291549dc963fSmrg case $@ in 291649dc963fSmrg # Blanks in the command may have been stripped by the calling shell, 291749dc963fSmrg # but not from the CC environment variable when configure was run. 29187aa89044Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29197aa89044Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 292049dc963fSmrg # Blanks at the start of $base_compile will cause this to fail 292149dc963fSmrg # if we don't check for them as well. 292249dc963fSmrg *) 292349dc963fSmrg for z in $available_tags; do 292449dc963fSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 292549dc963fSmrg # Evaluate the configuration. 292626372658Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 292749dc963fSmrg CC_quoted= 292849dc963fSmrg for arg in $CC; do 292949dc963fSmrg # Double-quote args containing other shell metacharacters. 29304e7590efSmrg func_append_quoted CC_quoted "$arg" 293149dc963fSmrg done 29327aa89044Smrg CC_expanded=`func_echo_all $CC` 29337aa89044Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 293449dc963fSmrg case "$@ " in 29357aa89044Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29367aa89044Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 293749dc963fSmrg # The compiler in the base compile command matches 293849dc963fSmrg # the one in the tagged configuration. 293949dc963fSmrg # Assume this is the tagged configuration we want. 294049dc963fSmrg tagname=$z 294149dc963fSmrg break 294249dc963fSmrg ;; 294349dc963fSmrg esac 294449dc963fSmrg fi 294549dc963fSmrg done 294649dc963fSmrg # If $tagname still isn't set, then no tagged configuration 294749dc963fSmrg # was found and let the user know that the "--tag" command 294849dc963fSmrg # line option must be used. 294949dc963fSmrg if test -z "$tagname"; then 295049dc963fSmrg func_echo "unable to infer tagged configuration" 295126372658Smrg func_fatal_error "specify a tag with '--tag'" 295249dc963fSmrg# else 295349dc963fSmrg# func_verbose "using $tagname tagged configuration" 295449dc963fSmrg fi 295549dc963fSmrg ;; 295649dc963fSmrg esac 295749dc963fSmrg fi 295849dc963fSmrg} 295949dc963fSmrg 296049dc963fSmrg 29614e7590efSmrg 29624e7590efSmrg# func_write_libtool_object output_name pic_name nonpic_name 29634e7590efSmrg# Create a libtool object file (analogous to a ".la" file), 29644e7590efSmrg# but don't create it if we're doing a dry run. 29654e7590efSmrgfunc_write_libtool_object () 29664e7590efSmrg{ 296726372658Smrg write_libobj=$1 296826372658Smrg if test yes = "$build_libtool_libs"; then 296926372658Smrg write_lobj=\'$2\' 29704e7590efSmrg else 29714e7590efSmrg write_lobj=none 29724e7590efSmrg fi 29734e7590efSmrg 297426372658Smrg if test yes = "$build_old_libs"; then 297526372658Smrg write_oldobj=\'$3\' 29764e7590efSmrg else 29774e7590efSmrg write_oldobj=none 29784e7590efSmrg fi 29794e7590efSmrg 29804e7590efSmrg $opt_dry_run || { 29814e7590efSmrg cat >${write_libobj}T <<EOF 29824e7590efSmrg# $write_libobj - a libtool object file 298326372658Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29844e7590efSmrg# 29854e7590efSmrg# Please DO NOT delete this file! 29864e7590efSmrg# It is necessary for linking the library. 29874e7590efSmrg 29884e7590efSmrg# Name of the PIC object. 29894e7590efSmrgpic_object=$write_lobj 29904e7590efSmrg 29914e7590efSmrg# Name of the non-PIC object 29924e7590efSmrgnon_pic_object=$write_oldobj 29934e7590efSmrg 29944e7590efSmrgEOF 299526372658Smrg $MV "${write_libobj}T" "$write_libobj" 29964e7590efSmrg } 29974e7590efSmrg} 29984e7590efSmrg 29994e7590efSmrg 30004e7590efSmrg################################################## 30014e7590efSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30024e7590efSmrg################################################## 30034e7590efSmrg 30044e7590efSmrg# func_convert_core_file_wine_to_w32 ARG 30054e7590efSmrg# Helper function used by file name conversion functions when $build is *nix, 30064e7590efSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30074e7590efSmrg# correctly configured wine environment available, with the winepath program 30084e7590efSmrg# in $build's $PATH. 30094e7590efSmrg# 30104e7590efSmrg# ARG is the $build file name to be converted to w32 format. 30114e7590efSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30124e7590efSmrg# be empty on error (or when ARG is empty) 30134e7590efSmrgfunc_convert_core_file_wine_to_w32 () 30144e7590efSmrg{ 301526372658Smrg $debug_cmd 301626372658Smrg 301726372658Smrg func_convert_core_file_wine_to_w32_result=$1 30184e7590efSmrg if test -n "$1"; then 30194e7590efSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30204e7590efSmrg # are forced to check the contents of stdout. On the other hand, if the 30214e7590efSmrg # command is not found, the shell will set an exit code of 127 and print 30224e7590efSmrg # *an error message* to stdout. So we must check for both error code of 30234e7590efSmrg # zero AND non-empty stdout, which explains the odd construction: 30244e7590efSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 302526372658Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30264e7590efSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 302726372658Smrg $SED -e "$sed_naive_backslashify"` 30284e7590efSmrg else 30294e7590efSmrg func_convert_core_file_wine_to_w32_result= 30304e7590efSmrg fi 30314e7590efSmrg fi 30324e7590efSmrg} 30334e7590efSmrg# end: func_convert_core_file_wine_to_w32 30344e7590efSmrg 30354e7590efSmrg 30364e7590efSmrg# func_convert_core_path_wine_to_w32 ARG 30374e7590efSmrg# Helper function used by path conversion functions when $build is *nix, and 30384e7590efSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30394e7590efSmrg# configured wine environment available, with the winepath program in $build's 30404e7590efSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30414e7590efSmrg# 30424e7590efSmrg# ARG is path to be converted from $build format to win32. 30434e7590efSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30444e7590efSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30454e7590efSmrg# are convertible, then the result may be empty. 30464e7590efSmrgfunc_convert_core_path_wine_to_w32 () 30474e7590efSmrg{ 304826372658Smrg $debug_cmd 304926372658Smrg 30504e7590efSmrg # unfortunately, winepath doesn't convert paths, only file names 305126372658Smrg func_convert_core_path_wine_to_w32_result= 30524e7590efSmrg if test -n "$1"; then 30534e7590efSmrg oldIFS=$IFS 30544e7590efSmrg IFS=: 30554e7590efSmrg for func_convert_core_path_wine_to_w32_f in $1; do 30564e7590efSmrg IFS=$oldIFS 30574e7590efSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 305826372658Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30594e7590efSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 306026372658Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30614e7590efSmrg else 30624e7590efSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30634e7590efSmrg fi 30644e7590efSmrg fi 30654e7590efSmrg done 30664e7590efSmrg IFS=$oldIFS 30674e7590efSmrg fi 30684e7590efSmrg} 30694e7590efSmrg# end: func_convert_core_path_wine_to_w32 30704e7590efSmrg 30714e7590efSmrg 30724e7590efSmrg# func_cygpath ARGS... 30734e7590efSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30744e7590efSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30754e7590efSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30764e7590efSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30774e7590efSmrg# file name or path is assumed to be in w32 format, as previously converted 30784e7590efSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30794e7590efSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 30804e7590efSmrg# Cygwin format). Returns an empty string on error. 30814e7590efSmrg# 30824e7590efSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 30834e7590efSmrg# be converted. 30844e7590efSmrg# 30854e7590efSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30864e7590efSmrg# environment variable; do not put it in $PATH. 30874e7590efSmrgfunc_cygpath () 30884e7590efSmrg{ 308926372658Smrg $debug_cmd 309026372658Smrg 30914e7590efSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30924e7590efSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30934e7590efSmrg if test "$?" -ne 0; then 30944e7590efSmrg # on failure, ensure result is empty 30954e7590efSmrg func_cygpath_result= 30964e7590efSmrg fi 30974e7590efSmrg else 30984e7590efSmrg func_cygpath_result= 309926372658Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31004e7590efSmrg fi 31014e7590efSmrg} 31024e7590efSmrg#end: func_cygpath 31034e7590efSmrg 31044e7590efSmrg 31054e7590efSmrg# func_convert_core_msys_to_w32 ARG 31064e7590efSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 31074e7590efSmrg# result in func_convert_core_msys_to_w32_result. 31084e7590efSmrgfunc_convert_core_msys_to_w32 () 31094e7590efSmrg{ 311026372658Smrg $debug_cmd 311126372658Smrg 31124e7590efSmrg # awkward: cmd appends spaces to result 31134e7590efSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 311426372658Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31154e7590efSmrg} 31164e7590efSmrg#end: func_convert_core_msys_to_w32 31174e7590efSmrg 31184e7590efSmrg 31194e7590efSmrg# func_convert_file_check ARG1 ARG2 31204e7590efSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 31214e7590efSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31224e7590efSmrg# func_to_host_file_result to ARG1). 31234e7590efSmrgfunc_convert_file_check () 31244e7590efSmrg{ 312526372658Smrg $debug_cmd 312626372658Smrg 312726372658Smrg if test -z "$2" && test -n "$1"; then 31284e7590efSmrg func_error "Could not determine host file name corresponding to" 312926372658Smrg func_error " '$1'" 31304e7590efSmrg func_error "Continuing, but uninstalled executables may not work." 31314e7590efSmrg # Fallback: 313226372658Smrg func_to_host_file_result=$1 31334e7590efSmrg fi 31344e7590efSmrg} 31354e7590efSmrg# end func_convert_file_check 31364e7590efSmrg 31374e7590efSmrg 31384e7590efSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31394e7590efSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31404e7590efSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31414e7590efSmrg# func_to_host_file_result to a simplistic fallback value (see below). 31424e7590efSmrgfunc_convert_path_check () 31434e7590efSmrg{ 314426372658Smrg $debug_cmd 314526372658Smrg 31464e7590efSmrg if test -z "$4" && test -n "$3"; then 31474e7590efSmrg func_error "Could not determine the host path corresponding to" 314826372658Smrg func_error " '$3'" 31494e7590efSmrg func_error "Continuing, but uninstalled executables may not work." 31504e7590efSmrg # Fallback. This is a deliberately simplistic "conversion" and 31514e7590efSmrg # should not be "improved". See libtool.info. 31524e7590efSmrg if test "x$1" != "x$2"; then 31534e7590efSmrg lt_replace_pathsep_chars="s|$1|$2|g" 31544e7590efSmrg func_to_host_path_result=`echo "$3" | 31554e7590efSmrg $SED -e "$lt_replace_pathsep_chars"` 31564e7590efSmrg else 315726372658Smrg func_to_host_path_result=$3 31584e7590efSmrg fi 31594e7590efSmrg fi 31604e7590efSmrg} 31614e7590efSmrg# end func_convert_path_check 31624e7590efSmrg 31634e7590efSmrg 31644e7590efSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31654e7590efSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31664e7590efSmrg# and appending REPL if ORIG matches BACKPAT. 31674e7590efSmrgfunc_convert_path_front_back_pathsep () 31684e7590efSmrg{ 316926372658Smrg $debug_cmd 317026372658Smrg 31714e7590efSmrg case $4 in 317226372658Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31734e7590efSmrg ;; 31744e7590efSmrg esac 31754e7590efSmrg case $4 in 31764e7590efSmrg $2 ) func_append func_to_host_path_result "$3" 31774e7590efSmrg ;; 31784e7590efSmrg esac 31794e7590efSmrg} 31804e7590efSmrg# end func_convert_path_front_back_pathsep 31814e7590efSmrg 31824e7590efSmrg 31834e7590efSmrg################################################## 31844e7590efSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31854e7590efSmrg################################################## 318626372658Smrg# invoked via '$to_host_file_cmd ARG' 31874e7590efSmrg# 31884e7590efSmrg# In each case, ARG is the path to be converted from $build to $host format. 31894e7590efSmrg# Result will be available in $func_to_host_file_result. 31904e7590efSmrg 31914e7590efSmrg 31924e7590efSmrg# func_to_host_file ARG 31934e7590efSmrg# Converts the file name ARG from $build format to $host format. Return result 31944e7590efSmrg# in func_to_host_file_result. 31954e7590efSmrgfunc_to_host_file () 31964e7590efSmrg{ 319726372658Smrg $debug_cmd 319826372658Smrg 31994e7590efSmrg $to_host_file_cmd "$1" 32004e7590efSmrg} 32014e7590efSmrg# end func_to_host_file 32024e7590efSmrg 32034e7590efSmrg 32044e7590efSmrg# func_to_tool_file ARG LAZY 32054e7590efSmrg# converts the file name ARG from $build format to toolchain format. Return 32064e7590efSmrg# result in func_to_tool_file_result. If the conversion in use is listed 32074e7590efSmrg# in (the comma separated) LAZY, no conversion takes place. 32084e7590efSmrgfunc_to_tool_file () 32094e7590efSmrg{ 321026372658Smrg $debug_cmd 321126372658Smrg 32124e7590efSmrg case ,$2, in 32134e7590efSmrg *,"$to_tool_file_cmd",*) 32144e7590efSmrg func_to_tool_file_result=$1 32154e7590efSmrg ;; 32164e7590efSmrg *) 32174e7590efSmrg $to_tool_file_cmd "$1" 32184e7590efSmrg func_to_tool_file_result=$func_to_host_file_result 32194e7590efSmrg ;; 32204e7590efSmrg esac 32214e7590efSmrg} 32224e7590efSmrg# end func_to_tool_file 32234e7590efSmrg 32244e7590efSmrg 32254e7590efSmrg# func_convert_file_noop ARG 32264e7590efSmrg# Copy ARG to func_to_host_file_result. 32274e7590efSmrgfunc_convert_file_noop () 32284e7590efSmrg{ 322926372658Smrg func_to_host_file_result=$1 32304e7590efSmrg} 32314e7590efSmrg# end func_convert_file_noop 32324e7590efSmrg 32334e7590efSmrg 32344e7590efSmrg# func_convert_file_msys_to_w32 ARG 32354e7590efSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32364e7590efSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 32374e7590efSmrg# func_to_host_file_result. 32384e7590efSmrgfunc_convert_file_msys_to_w32 () 32394e7590efSmrg{ 324026372658Smrg $debug_cmd 324126372658Smrg 324226372658Smrg func_to_host_file_result=$1 32434e7590efSmrg if test -n "$1"; then 32444e7590efSmrg func_convert_core_msys_to_w32 "$1" 324526372658Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32464e7590efSmrg fi 32474e7590efSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32484e7590efSmrg} 32494e7590efSmrg# end func_convert_file_msys_to_w32 32504e7590efSmrg 32514e7590efSmrg 32524e7590efSmrg# func_convert_file_cygwin_to_w32 ARG 32534e7590efSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32544e7590efSmrg# func_to_host_file_result. 32554e7590efSmrgfunc_convert_file_cygwin_to_w32 () 32564e7590efSmrg{ 325726372658Smrg $debug_cmd 325826372658Smrg 325926372658Smrg func_to_host_file_result=$1 32604e7590efSmrg if test -n "$1"; then 32614e7590efSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32624e7590efSmrg # LT_CYGPATH in this case. 32634e7590efSmrg func_to_host_file_result=`cygpath -m "$1"` 32644e7590efSmrg fi 32654e7590efSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32664e7590efSmrg} 32674e7590efSmrg# end func_convert_file_cygwin_to_w32 32684e7590efSmrg 32694e7590efSmrg 32704e7590efSmrg# func_convert_file_nix_to_w32 ARG 32714e7590efSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32724e7590efSmrg# and a working winepath. Returns result in func_to_host_file_result. 32734e7590efSmrgfunc_convert_file_nix_to_w32 () 32744e7590efSmrg{ 327526372658Smrg $debug_cmd 327626372658Smrg 327726372658Smrg func_to_host_file_result=$1 32784e7590efSmrg if test -n "$1"; then 32794e7590efSmrg func_convert_core_file_wine_to_w32 "$1" 328026372658Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32814e7590efSmrg fi 32824e7590efSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32834e7590efSmrg} 32844e7590efSmrg# end func_convert_file_nix_to_w32 32854e7590efSmrg 32864e7590efSmrg 32874e7590efSmrg# func_convert_file_msys_to_cygwin ARG 32884e7590efSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32894e7590efSmrg# Returns result in func_to_host_file_result. 32904e7590efSmrgfunc_convert_file_msys_to_cygwin () 32914e7590efSmrg{ 329226372658Smrg $debug_cmd 329326372658Smrg 329426372658Smrg func_to_host_file_result=$1 32954e7590efSmrg if test -n "$1"; then 32964e7590efSmrg func_convert_core_msys_to_w32 "$1" 32974e7590efSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 329826372658Smrg func_to_host_file_result=$func_cygpath_result 32994e7590efSmrg fi 33004e7590efSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33014e7590efSmrg} 33024e7590efSmrg# end func_convert_file_msys_to_cygwin 33034e7590efSmrg 33044e7590efSmrg 33054e7590efSmrg# func_convert_file_nix_to_cygwin ARG 33064e7590efSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33074e7590efSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33084e7590efSmrg# in func_to_host_file_result. 33094e7590efSmrgfunc_convert_file_nix_to_cygwin () 33104e7590efSmrg{ 331126372658Smrg $debug_cmd 331226372658Smrg 331326372658Smrg func_to_host_file_result=$1 33144e7590efSmrg if test -n "$1"; then 33154e7590efSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33164e7590efSmrg func_convert_core_file_wine_to_w32 "$1" 33174e7590efSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 331826372658Smrg func_to_host_file_result=$func_cygpath_result 33194e7590efSmrg fi 33204e7590efSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33214e7590efSmrg} 33224e7590efSmrg# end func_convert_file_nix_to_cygwin 33234e7590efSmrg 33244e7590efSmrg 33254e7590efSmrg############################################# 33264e7590efSmrg# $build to $host PATH CONVERSION FUNCTIONS # 33274e7590efSmrg############################################# 332826372658Smrg# invoked via '$to_host_path_cmd ARG' 33294e7590efSmrg# 33304e7590efSmrg# In each case, ARG is the path to be converted from $build to $host format. 33314e7590efSmrg# The result will be available in $func_to_host_path_result. 33324e7590efSmrg# 33334e7590efSmrg# Path separators are also converted from $build format to $host format. If 33344e7590efSmrg# ARG begins or ends with a path separator character, it is preserved (but 33354e7590efSmrg# converted to $host format) on output. 33364e7590efSmrg# 33374e7590efSmrg# All path conversion functions are named using the following convention: 33384e7590efSmrg# file name conversion function : func_convert_file_X_to_Y () 33394e7590efSmrg# path conversion function : func_convert_path_X_to_Y () 33404e7590efSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33414e7590efSmrg# same. If conversion functions are added for new $build/$host combinations, 33424e7590efSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33434e7590efSmrg# will break. 33444e7590efSmrg 33454e7590efSmrg 33464e7590efSmrg# func_init_to_host_path_cmd 33474e7590efSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33484e7590efSmrg# appropriate value, based on the value of $to_host_file_cmd. 33494e7590efSmrgto_host_path_cmd= 33504e7590efSmrgfunc_init_to_host_path_cmd () 33514e7590efSmrg{ 335226372658Smrg $debug_cmd 335326372658Smrg 33544e7590efSmrg if test -z "$to_host_path_cmd"; then 33554e7590efSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 335626372658Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 33574e7590efSmrg fi 33584e7590efSmrg} 33594e7590efSmrg 33604e7590efSmrg 33614e7590efSmrg# func_to_host_path ARG 33624e7590efSmrg# Converts the path ARG from $build format to $host format. Return result 33634e7590efSmrg# in func_to_host_path_result. 33644e7590efSmrgfunc_to_host_path () 33654e7590efSmrg{ 336626372658Smrg $debug_cmd 336726372658Smrg 33684e7590efSmrg func_init_to_host_path_cmd 33694e7590efSmrg $to_host_path_cmd "$1" 33704e7590efSmrg} 33714e7590efSmrg# end func_to_host_path 33724e7590efSmrg 33734e7590efSmrg 33744e7590efSmrg# func_convert_path_noop ARG 33754e7590efSmrg# Copy ARG to func_to_host_path_result. 33764e7590efSmrgfunc_convert_path_noop () 33774e7590efSmrg{ 337826372658Smrg func_to_host_path_result=$1 33794e7590efSmrg} 33804e7590efSmrg# end func_convert_path_noop 33814e7590efSmrg 33824e7590efSmrg 33834e7590efSmrg# func_convert_path_msys_to_w32 ARG 33844e7590efSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33854e7590efSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 33864e7590efSmrg# func_to_host_path_result. 33874e7590efSmrgfunc_convert_path_msys_to_w32 () 33884e7590efSmrg{ 338926372658Smrg $debug_cmd 339026372658Smrg 339126372658Smrg func_to_host_path_result=$1 33924e7590efSmrg if test -n "$1"; then 33934e7590efSmrg # Remove leading and trailing path separator characters from ARG. MSYS 33944e7590efSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33954e7590efSmrg # and winepath ignores them completely. 33964e7590efSmrg func_stripname : : "$1" 33974e7590efSmrg func_to_host_path_tmp1=$func_stripname_result 33984e7590efSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 339926372658Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34004e7590efSmrg func_convert_path_check : ";" \ 34014e7590efSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34024e7590efSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34034e7590efSmrg fi 34044e7590efSmrg} 34054e7590efSmrg# end func_convert_path_msys_to_w32 34064e7590efSmrg 34074e7590efSmrg 34084e7590efSmrg# func_convert_path_cygwin_to_w32 ARG 34094e7590efSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 34104e7590efSmrg# func_to_host_file_result. 34114e7590efSmrgfunc_convert_path_cygwin_to_w32 () 34124e7590efSmrg{ 341326372658Smrg $debug_cmd 341426372658Smrg 341526372658Smrg func_to_host_path_result=$1 34164e7590efSmrg if test -n "$1"; then 34174e7590efSmrg # See func_convert_path_msys_to_w32: 34184e7590efSmrg func_stripname : : "$1" 34194e7590efSmrg func_to_host_path_tmp1=$func_stripname_result 34204e7590efSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34214e7590efSmrg func_convert_path_check : ";" \ 34224e7590efSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34234e7590efSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34244e7590efSmrg fi 34254e7590efSmrg} 34264e7590efSmrg# end func_convert_path_cygwin_to_w32 34274e7590efSmrg 34284e7590efSmrg 34294e7590efSmrg# func_convert_path_nix_to_w32 ARG 34304e7590efSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34314e7590efSmrg# a working winepath. Returns result in func_to_host_file_result. 34324e7590efSmrgfunc_convert_path_nix_to_w32 () 343349dc963fSmrg{ 343426372658Smrg $debug_cmd 343526372658Smrg 343626372658Smrg func_to_host_path_result=$1 34374e7590efSmrg if test -n "$1"; then 34384e7590efSmrg # See func_convert_path_msys_to_w32: 34394e7590efSmrg func_stripname : : "$1" 34404e7590efSmrg func_to_host_path_tmp1=$func_stripname_result 34414e7590efSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 344226372658Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34434e7590efSmrg func_convert_path_check : ";" \ 34444e7590efSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34454e7590efSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34464e7590efSmrg fi 34474e7590efSmrg} 34484e7590efSmrg# end func_convert_path_nix_to_w32 344949dc963fSmrg 345049dc963fSmrg 34514e7590efSmrg# func_convert_path_msys_to_cygwin ARG 34524e7590efSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34534e7590efSmrg# Returns result in func_to_host_file_result. 34544e7590efSmrgfunc_convert_path_msys_to_cygwin () 34554e7590efSmrg{ 345626372658Smrg $debug_cmd 345726372658Smrg 345826372658Smrg func_to_host_path_result=$1 34594e7590efSmrg if test -n "$1"; then 34604e7590efSmrg # See func_convert_path_msys_to_w32: 34614e7590efSmrg func_stripname : : "$1" 34624e7590efSmrg func_to_host_path_tmp1=$func_stripname_result 34634e7590efSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34644e7590efSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 346526372658Smrg func_to_host_path_result=$func_cygpath_result 34664e7590efSmrg func_convert_path_check : : \ 34674e7590efSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34684e7590efSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34694e7590efSmrg fi 34704e7590efSmrg} 34714e7590efSmrg# end func_convert_path_msys_to_cygwin 347249dc963fSmrg 347349dc963fSmrg 34744e7590efSmrg# func_convert_path_nix_to_cygwin ARG 34754e7590efSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34764e7590efSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34774e7590efSmrg# func_to_host_file_result. 34784e7590efSmrgfunc_convert_path_nix_to_cygwin () 34794e7590efSmrg{ 348026372658Smrg $debug_cmd 348126372658Smrg 348226372658Smrg func_to_host_path_result=$1 34834e7590efSmrg if test -n "$1"; then 34844e7590efSmrg # Remove leading and trailing path separator characters from 34854e7590efSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 34864e7590efSmrg # into '.;' and ';.', and winepath ignores them completely. 34874e7590efSmrg func_stripname : : "$1" 34884e7590efSmrg func_to_host_path_tmp1=$func_stripname_result 34894e7590efSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34904e7590efSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 349126372658Smrg func_to_host_path_result=$func_cygpath_result 34924e7590efSmrg func_convert_path_check : : \ 34934e7590efSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34944e7590efSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34954e7590efSmrg fi 349649dc963fSmrg} 34974e7590efSmrg# end func_convert_path_nix_to_cygwin 34984e7590efSmrg 349949dc963fSmrg 350026372658Smrg# func_dll_def_p FILE 350126372658Smrg# True iff FILE is a Windows DLL '.def' file. 350226372658Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 350326372658Smrgfunc_dll_def_p () 350426372658Smrg{ 350526372658Smrg $debug_cmd 350626372658Smrg 350726372658Smrg func_dll_def_p_tmp=`$SED -n \ 350826372658Smrg -e 's/^[ ]*//' \ 350926372658Smrg -e '/^\(;.*\)*$/d' \ 351026372658Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 351126372658Smrg -e q \ 351226372658Smrg "$1"` 351326372658Smrg test DEF = "$func_dll_def_p_tmp" 351426372658Smrg} 351526372658Smrg 351626372658Smrg 351749dc963fSmrg# func_mode_compile arg... 351849dc963fSmrgfunc_mode_compile () 351949dc963fSmrg{ 352026372658Smrg $debug_cmd 352126372658Smrg 352249dc963fSmrg # Get the compilation command and the source file. 352349dc963fSmrg base_compile= 352426372658Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 352549dc963fSmrg suppress_opt=yes 352649dc963fSmrg suppress_output= 352749dc963fSmrg arg_mode=normal 352849dc963fSmrg libobj= 352949dc963fSmrg later= 353049dc963fSmrg pie_flag= 353149dc963fSmrg 353249dc963fSmrg for arg 353349dc963fSmrg do 353449dc963fSmrg case $arg_mode in 353549dc963fSmrg arg ) 353649dc963fSmrg # do not "continue". Instead, add this to base_compile 353726372658Smrg lastarg=$arg 353849dc963fSmrg arg_mode=normal 353949dc963fSmrg ;; 354049dc963fSmrg 354149dc963fSmrg target ) 354226372658Smrg libobj=$arg 354349dc963fSmrg arg_mode=normal 354449dc963fSmrg continue 354549dc963fSmrg ;; 354649dc963fSmrg 354749dc963fSmrg normal ) 354849dc963fSmrg # Accept any command-line options. 354949dc963fSmrg case $arg in 355049dc963fSmrg -o) 355149dc963fSmrg test -n "$libobj" && \ 355226372658Smrg func_fatal_error "you cannot specify '-o' more than once" 355349dc963fSmrg arg_mode=target 355449dc963fSmrg continue 355549dc963fSmrg ;; 355649dc963fSmrg 355749dc963fSmrg -pie | -fpie | -fPIE) 35584e7590efSmrg func_append pie_flag " $arg" 355949dc963fSmrg continue 356049dc963fSmrg ;; 356149dc963fSmrg 356249dc963fSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 35634e7590efSmrg func_append later " $arg" 356449dc963fSmrg continue 356549dc963fSmrg ;; 356649dc963fSmrg 356749dc963fSmrg -no-suppress) 35684b0ead49Smrg suppress_opt=no 35694b0ead49Smrg continue 35704b0ead49Smrg ;; 35714b0ead49Smrg 35724b0ead49Smrg -Xcompiler) 35734b0ead49Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 35744b0ead49Smrg continue # The current "srcfile" will either be retained or 35754b0ead49Smrg ;; # replaced later. I would guess that would be a bug. 35764b0ead49Smrg 35774b0ead49Smrg -Wc,*) 357849dc963fSmrg func_stripname '-Wc,' '' "$arg" 357949dc963fSmrg args=$func_stripname_result 35804b0ead49Smrg lastarg= 358126372658Smrg save_ifs=$IFS; IFS=, 358249dc963fSmrg for arg in $args; do 358326372658Smrg IFS=$save_ifs 35844e7590efSmrg func_append_quoted lastarg "$arg" 35854b0ead49Smrg done 358626372658Smrg IFS=$save_ifs 358749dc963fSmrg func_stripname ' ' '' "$lastarg" 358849dc963fSmrg lastarg=$func_stripname_result 35894b0ead49Smrg 35904b0ead49Smrg # Add the arguments to base_compile. 35914e7590efSmrg func_append base_compile " $lastarg" 35924b0ead49Smrg continue 35934b0ead49Smrg ;; 35944b0ead49Smrg 359549dc963fSmrg *) 35964b0ead49Smrg # Accept the current argument as the source file. 35974b0ead49Smrg # The previous "srcfile" becomes the current argument. 35984b0ead49Smrg # 359926372658Smrg lastarg=$srcfile 360026372658Smrg srcfile=$arg 36014b0ead49Smrg ;; 36024b0ead49Smrg esac # case $arg 36034b0ead49Smrg ;; 36044b0ead49Smrg esac # case $arg_mode 36054b0ead49Smrg 36064b0ead49Smrg # Aesthetically quote the previous argument. 36074e7590efSmrg func_append_quoted base_compile "$lastarg" 36084b0ead49Smrg done # for arg 36094b0ead49Smrg 36104b0ead49Smrg case $arg_mode in 36114b0ead49Smrg arg) 361249dc963fSmrg func_fatal_error "you must specify an argument for -Xcompile" 36134b0ead49Smrg ;; 36144b0ead49Smrg target) 361526372658Smrg func_fatal_error "you must specify a target with '-o'" 36164b0ead49Smrg ;; 36174b0ead49Smrg *) 36184b0ead49Smrg # Get the name of the library object. 361949dc963fSmrg test -z "$libobj" && { 362049dc963fSmrg func_basename "$srcfile" 362126372658Smrg libobj=$func_basename_result 362249dc963fSmrg } 36234b0ead49Smrg ;; 36244b0ead49Smrg esac 36254b0ead49Smrg 36264b0ead49Smrg # Recognize several different file suffixes. 36274b0ead49Smrg # If the user specifies -o file.o, it is replaced with file.lo 36284b0ead49Smrg case $libobj in 362949dc963fSmrg *.[cCFSifmso] | \ 363049dc963fSmrg *.ada | *.adb | *.ads | *.asm | \ 363149dc963fSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36324e7590efSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 363349dc963fSmrg func_xform "$libobj" 363449dc963fSmrg libobj=$func_xform_result 363549dc963fSmrg ;; 36364b0ead49Smrg esac 36374b0ead49Smrg 36384b0ead49Smrg case $libobj in 363949dc963fSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36404b0ead49Smrg *) 364126372658Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 36424b0ead49Smrg ;; 36434b0ead49Smrg esac 36444b0ead49Smrg 36454b0ead49Smrg func_infer_tag $base_compile 36464b0ead49Smrg 36474b0ead49Smrg for arg in $later; do 36484b0ead49Smrg case $arg in 364949dc963fSmrg -shared) 365026372658Smrg test yes = "$build_libtool_libs" \ 365126372658Smrg || func_fatal_configuration "cannot build a shared library" 365249dc963fSmrg build_old_libs=no 365349dc963fSmrg continue 365449dc963fSmrg ;; 365549dc963fSmrg 36564b0ead49Smrg -static) 365749dc963fSmrg build_libtool_libs=no 36584b0ead49Smrg build_old_libs=yes 36594b0ead49Smrg continue 36604b0ead49Smrg ;; 36614b0ead49Smrg 36624b0ead49Smrg -prefer-pic) 36634b0ead49Smrg pic_mode=yes 36644b0ead49Smrg continue 36654b0ead49Smrg ;; 36664b0ead49Smrg 36674b0ead49Smrg -prefer-non-pic) 36684b0ead49Smrg pic_mode=no 36694b0ead49Smrg continue 36704b0ead49Smrg ;; 36714b0ead49Smrg esac 36724b0ead49Smrg done 36734b0ead49Smrg 3674c3e29c03Smrg func_quote_arg pretty "$libobj" 3675c3e29c03Smrg test "X$libobj" != "X$func_quote_arg_result" \ 367649dc963fSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 367726372658Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 367849dc963fSmrg func_dirname_and_basename "$obj" "/" "" 367926372658Smrg objname=$func_basename_result 368026372658Smrg xdir=$func_dirname_result 368126372658Smrg lobj=$xdir$objdir/$objname 36824b0ead49Smrg 368349dc963fSmrg test -z "$base_compile" && \ 368449dc963fSmrg func_fatal_help "you must specify a compilation command" 36854b0ead49Smrg 36864b0ead49Smrg # Delete any leftover library objects. 368726372658Smrg if test yes = "$build_old_libs"; then 36884b0ead49Smrg removelist="$obj $lobj $libobj ${libobj}T" 36894b0ead49Smrg else 36904b0ead49Smrg removelist="$lobj $libobj ${libobj}T" 36914b0ead49Smrg fi 36924b0ead49Smrg 36934b0ead49Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 36944b0ead49Smrg case $host_os in 369549dc963fSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36964b0ead49Smrg pic_mode=default 36974b0ead49Smrg ;; 36984b0ead49Smrg esac 369926372658Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37004b0ead49Smrg # non-PIC code in shared libraries is not supported 37014b0ead49Smrg pic_mode=default 37024b0ead49Smrg fi 37034b0ead49Smrg 37044b0ead49Smrg # Calculate the filename of the output object if compiler does 37054b0ead49Smrg # not support -o with -c 370626372658Smrg if test no = "$compiler_c_o"; then 370726372658Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 370826372658Smrg lockfile=$output_obj.lock 37094b0ead49Smrg else 37104b0ead49Smrg output_obj= 37114b0ead49Smrg need_locks=no 37124b0ead49Smrg lockfile= 37134b0ead49Smrg fi 37144b0ead49Smrg 37154b0ead49Smrg # Lock this critical section if it is needed 37164b0ead49Smrg # We use this script file to make the link, it avoids creating a new file 371726372658Smrg if test yes = "$need_locks"; then 371849dc963fSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371949dc963fSmrg func_echo "Waiting for $lockfile to be removed" 37204b0ead49Smrg sleep 2 37214b0ead49Smrg done 372226372658Smrg elif test warn = "$need_locks"; then 37234b0ead49Smrg if test -f "$lockfile"; then 372449dc963fSmrg $ECHO "\ 37254b0ead49Smrg*** ERROR, $lockfile exists and contains: 37264b0ead49Smrg`cat $lockfile 2>/dev/null` 37274b0ead49Smrg 37284b0ead49SmrgThis indicates that another process is trying to use the same 37294b0ead49Smrgtemporary object file, and libtool could not work around it because 373026372658Smrgyour compiler does not support '-c' and '-o' together. If you 37314b0ead49Smrgrepeat this compilation, it may succeed, by chance, but you had better 37324b0ead49Smrgavoid parallel builds (make -j) in this platform, or get a better 37334b0ead49Smrgcompiler." 37344b0ead49Smrg 373549dc963fSmrg $opt_dry_run || $RM $removelist 37364b0ead49Smrg exit $EXIT_FAILURE 37374b0ead49Smrg fi 37384e7590efSmrg func_append removelist " $output_obj" 373949dc963fSmrg $ECHO "$srcfile" > "$lockfile" 37404b0ead49Smrg fi 37414b0ead49Smrg 374249dc963fSmrg $opt_dry_run || $RM $removelist 37434e7590efSmrg func_append removelist " $lockfile" 374449dc963fSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 374549dc963fSmrg 37464e7590efSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37474e7590efSmrg srcfile=$func_to_tool_file_result 3748c3e29c03Smrg func_quote_arg pretty "$srcfile" 3749c3e29c03Smrg qsrcfile=$func_quote_arg_result 37504b0ead49Smrg 37514b0ead49Smrg # Only build a PIC object if we are building libtool libraries. 375226372658Smrg if test yes = "$build_libtool_libs"; then 37534b0ead49Smrg # Without this assignment, base_compile gets emptied. 37544b0ead49Smrg fbsd_hideous_sh_bug=$base_compile 37554b0ead49Smrg 375626372658Smrg if test no != "$pic_mode"; then 37574b0ead49Smrg command="$base_compile $qsrcfile $pic_flag" 37584b0ead49Smrg else 37594b0ead49Smrg # Don't build PIC code 37604b0ead49Smrg command="$base_compile $qsrcfile" 37614b0ead49Smrg fi 37624b0ead49Smrg 376349dc963fSmrg func_mkdir_p "$xdir$objdir" 37644b0ead49Smrg 37654b0ead49Smrg if test -z "$output_obj"; then 37664b0ead49Smrg # Place PIC objects in $objdir 37674e7590efSmrg func_append command " -o $lobj" 37684b0ead49Smrg fi 37694b0ead49Smrg 377049dc963fSmrg func_show_eval_locale "$command" \ 377149dc963fSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37724b0ead49Smrg 377326372658Smrg if test warn = "$need_locks" && 37744b0ead49Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 377549dc963fSmrg $ECHO "\ 37764b0ead49Smrg*** ERROR, $lockfile contains: 37774b0ead49Smrg`cat $lockfile 2>/dev/null` 37784b0ead49Smrg 37794b0ead49Smrgbut it should contain: 37804b0ead49Smrg$srcfile 37814b0ead49Smrg 37824b0ead49SmrgThis indicates that another process is trying to use the same 37834b0ead49Smrgtemporary object file, and libtool could not work around it because 378426372658Smrgyour compiler does not support '-c' and '-o' together. If you 37854b0ead49Smrgrepeat this compilation, it may succeed, by chance, but you had better 37864b0ead49Smrgavoid parallel builds (make -j) in this platform, or get a better 37874b0ead49Smrgcompiler." 37884b0ead49Smrg 378949dc963fSmrg $opt_dry_run || $RM $removelist 37904b0ead49Smrg exit $EXIT_FAILURE 37914b0ead49Smrg fi 37924b0ead49Smrg 37934b0ead49Smrg # Just move the object if needed, then go on to compile the next one 37944b0ead49Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 379549dc963fSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 379649dc963fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37974b0ead49Smrg fi 37984b0ead49Smrg 37994b0ead49Smrg # Allow error messages only from the first compilation. 380026372658Smrg if test yes = "$suppress_opt"; then 380149dc963fSmrg suppress_output=' >/dev/null 2>&1' 38024b0ead49Smrg fi 38034b0ead49Smrg fi 38044b0ead49Smrg 38054b0ead49Smrg # Only build a position-dependent object if we build old libraries. 380626372658Smrg if test yes = "$build_old_libs"; then 380726372658Smrg if test yes != "$pic_mode"; then 38084b0ead49Smrg # Don't build PIC code 380949dc963fSmrg command="$base_compile $qsrcfile$pie_flag" 38104b0ead49Smrg else 38114b0ead49Smrg command="$base_compile $qsrcfile $pic_flag" 38124b0ead49Smrg fi 381326372658Smrg if test yes = "$compiler_c_o"; then 38144e7590efSmrg func_append command " -o $obj" 38154b0ead49Smrg fi 38164b0ead49Smrg 38174b0ead49Smrg # Suppress compiler output if we already did a PIC compilation. 38184e7590efSmrg func_append command "$suppress_output" 381949dc963fSmrg func_show_eval_locale "$command" \ 382049dc963fSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38214b0ead49Smrg 382226372658Smrg if test warn = "$need_locks" && 38234b0ead49Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 382449dc963fSmrg $ECHO "\ 38254b0ead49Smrg*** ERROR, $lockfile contains: 38264b0ead49Smrg`cat $lockfile 2>/dev/null` 38274b0ead49Smrg 38284b0ead49Smrgbut it should contain: 38294b0ead49Smrg$srcfile 38304b0ead49Smrg 38314b0ead49SmrgThis indicates that another process is trying to use the same 38324b0ead49Smrgtemporary object file, and libtool could not work around it because 383326372658Smrgyour compiler does not support '-c' and '-o' together. If you 38344b0ead49Smrgrepeat this compilation, it may succeed, by chance, but you had better 38354b0ead49Smrgavoid parallel builds (make -j) in this platform, or get a better 38364b0ead49Smrgcompiler." 38374b0ead49Smrg 383849dc963fSmrg $opt_dry_run || $RM $removelist 38394b0ead49Smrg exit $EXIT_FAILURE 38404b0ead49Smrg fi 38414b0ead49Smrg 38424b0ead49Smrg # Just move the object if needed 38434b0ead49Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 384449dc963fSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 384549dc963fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38464b0ead49Smrg fi 38474b0ead49Smrg fi 38484b0ead49Smrg 384949dc963fSmrg $opt_dry_run || { 385049dc963fSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38514b0ead49Smrg 385249dc963fSmrg # Unlock the critical section if it was locked 385326372658Smrg if test no != "$need_locks"; then 385449dc963fSmrg removelist=$lockfile 385549dc963fSmrg $RM "$lockfile" 385649dc963fSmrg fi 385749dc963fSmrg } 38584b0ead49Smrg 38594b0ead49Smrg exit $EXIT_SUCCESS 386049dc963fSmrg} 38614b0ead49Smrg 386249dc963fSmrg$opt_help || { 386326372658Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 386449dc963fSmrg} 38654b0ead49Smrg 386649dc963fSmrgfunc_mode_help () 386749dc963fSmrg{ 386849dc963fSmrg # We need to display help for each of the modes. 38694e7590efSmrg case $opt_mode in 387049dc963fSmrg "") 387149dc963fSmrg # Generic help is extracted from the usage comments 387249dc963fSmrg # at the start of this file. 387349dc963fSmrg func_help 387449dc963fSmrg ;; 38754b0ead49Smrg 387649dc963fSmrg clean) 387749dc963fSmrg $ECHO \ 387849dc963fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38794b0ead49Smrg 388049dc963fSmrgRemove files from the build directory. 38814b0ead49Smrg 388249dc963fSmrgRM is the name of the program to use to delete files associated with each FILE 388326372658Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 388449dc963fSmrgto RM. 38854b0ead49Smrg 388649dc963fSmrgIf FILE is a libtool library, object or program, all the files associated 388749dc963fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 388849dc963fSmrg ;; 38894b0ead49Smrg 389049dc963fSmrg compile) 389149dc963fSmrg $ECHO \ 389249dc963fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38934b0ead49Smrg 389449dc963fSmrgCompile a source file into a libtool library object. 38954b0ead49Smrg 389649dc963fSmrgThis mode accepts the following additional options: 38974b0ead49Smrg 389849dc963fSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 389949dc963fSmrg -no-suppress do not suppress compiler output for multiple passes 39007aa89044Smrg -prefer-pic try to build PIC objects only 39017aa89044Smrg -prefer-non-pic try to build non-PIC objects only 390226372658Smrg -shared do not build a '.o' file suitable for static linking 390326372658Smrg -static only build a '.o' file suitable for static linking 3904c3e29c03Smrg -Wc,FLAG 3905c3e29c03Smrg -Xcompiler FLAG pass FLAG directly to the compiler 39064b0ead49Smrg 390726372658SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 390849dc963fSmrgfrom the given SOURCEFILE. 39094b0ead49Smrg 391049dc963fSmrgThe output file name is determined by removing the directory component from 391126372658SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 391226372658Smrglibrary object suffix, '.lo'." 391349dc963fSmrg ;; 39144b0ead49Smrg 391549dc963fSmrg execute) 391649dc963fSmrg $ECHO \ 391749dc963fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39184b0ead49Smrg 391949dc963fSmrgAutomatically set library path, then run a program. 39204b0ead49Smrg 392149dc963fSmrgThis mode accepts the following additional options: 39224b0ead49Smrg 392349dc963fSmrg -dlopen FILE add the directory containing FILE to the library path 39244b0ead49Smrg 392526372658SmrgThis mode sets the library path environment variable according to '-dlopen' 392649dc963fSmrgflags. 39274b0ead49Smrg 392849dc963fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 392949dc963fSmrginto their corresponding uninstalled binary, and any of their required library 393049dc963fSmrgdirectories are added to the library path. 39314b0ead49Smrg 393249dc963fSmrgThen, COMMAND is executed, with ARGS as arguments." 393349dc963fSmrg ;; 39344b0ead49Smrg 393549dc963fSmrg finish) 393649dc963fSmrg $ECHO \ 393749dc963fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39384b0ead49Smrg 393949dc963fSmrgComplete the installation of libtool libraries. 39404b0ead49Smrg 394149dc963fSmrgEach LIBDIR is a directory that contains libtool libraries. 39424b0ead49Smrg 394349dc963fSmrgThe commands that this mode executes may require superuser privileges. Use 394426372658Smrgthe '--dry-run' option if you just want to see what would be executed." 394549dc963fSmrg ;; 39464b0ead49Smrg 394749dc963fSmrg install) 394849dc963fSmrg $ECHO \ 394949dc963fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39504b0ead49Smrg 395149dc963fSmrgInstall executables or libraries. 39524b0ead49Smrg 395349dc963fSmrgINSTALL-COMMAND is the installation command. The first component should be 395426372658Smrgeither the 'install' or 'cp' program. 39554b0ead49Smrg 395649dc963fSmrgThe following components of INSTALL-COMMAND are treated specially: 39574b0ead49Smrg 39587aa89044Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39594b0ead49Smrg 396049dc963fSmrgThe rest of the components are interpreted as arguments to that command (only 396149dc963fSmrgBSD-compatible install options are recognized)." 396249dc963fSmrg ;; 39634b0ead49Smrg 396449dc963fSmrg link) 396549dc963fSmrg $ECHO \ 396649dc963fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39674b0ead49Smrg 396849dc963fSmrgLink object files or libraries together to form another library, or to 396949dc963fSmrgcreate an executable program. 39704b0ead49Smrg 397149dc963fSmrgLINK-COMMAND is a command using the C compiler that you would use to create 397249dc963fSmrga program from several object files. 39734b0ead49Smrg 397449dc963fSmrgThe following components of LINK-COMMAND are treated specially: 39754b0ead49Smrg 397649dc963fSmrg -all-static do not do any dynamic linking at all 397749dc963fSmrg -avoid-version do not add a version suffix if possible 39787aa89044Smrg -bindir BINDIR specify path to binaries directory (for systems where 39797aa89044Smrg libraries must be found in the PATH setting at runtime) 398026372658Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 398149dc963fSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 398249dc963fSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 398349dc963fSmrg -export-symbols SYMFILE 398449dc963fSmrg try to export only the symbols listed in SYMFILE 398549dc963fSmrg -export-symbols-regex REGEX 398649dc963fSmrg try to export only the symbols matching REGEX 398749dc963fSmrg -LLIBDIR search LIBDIR for required installed libraries 398849dc963fSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 398949dc963fSmrg -module build a library that can dlopened 399049dc963fSmrg -no-fast-install disable the fast-install mode 399149dc963fSmrg -no-install link a not-installable executable 399249dc963fSmrg -no-undefined declare that a library does not refer to external symbols 399349dc963fSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 399426372658Smrg -objectlist FILE use a list of object files found in FILE to specify objects 399526372658Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 399649dc963fSmrg -precious-files-regex REGEX 399749dc963fSmrg don't remove output files matching REGEX 399849dc963fSmrg -release RELEASE specify package release information 399949dc963fSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 400049dc963fSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 400149dc963fSmrg -shared only do dynamic linking of libtool libraries 400249dc963fSmrg -shrext SUFFIX override the standard shared library file extension 400349dc963fSmrg -static do not do any dynamic linking of uninstalled libtool libraries 400449dc963fSmrg -static-libtool-libs 400549dc963fSmrg do not do any dynamic linking of libtool libraries 400649dc963fSmrg -version-info CURRENT[:REVISION[:AGE]] 400749dc963fSmrg specify library version info [each variable defaults to 0] 400849dc963fSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 40097aa89044Smrg -Wc,FLAG 40107aa89044Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011c3e29c03Smrg -Wa,FLAG 4012c3e29c03Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40137aa89044Smrg -Wl,FLAG 40147aa89044Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40157aa89044Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40164b0ead49Smrg 401726372658SmrgAll other options (arguments beginning with '-') are ignored. 40184b0ead49Smrg 401926372658SmrgEvery other argument is treated as a filename. Files ending in '.la' are 402049dc963fSmrgtreated as uninstalled libtool libraries, other files are standard or library 402149dc963fSmrgobject files. 402252b01e16Smrg 402326372658SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 402426372658Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 402549dc963fSmrgrequired, except when creating a convenience library. 40264b0ead49Smrg 402726372658SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 402826372658Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40294b0ead49Smrg 403026372658SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 403149dc963fSmrgis created, otherwise an executable program is created." 40324b0ead49Smrg ;; 40334b0ead49Smrg 403449dc963fSmrg uninstall) 403549dc963fSmrg $ECHO \ 403649dc963fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40374b0ead49Smrg 403849dc963fSmrgRemove libraries from an installation directory. 40394b0ead49Smrg 404049dc963fSmrgRM is the name of the program to use to delete files associated with each FILE 404126372658Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 404249dc963fSmrgto RM. 40434b0ead49Smrg 404449dc963fSmrgIf FILE is a libtool library, all the files associated with it are deleted. 404549dc963fSmrgOtherwise, only FILE itself is deleted using RM." 404649dc963fSmrg ;; 40474b0ead49Smrg 404849dc963fSmrg *) 404926372658Smrg func_fatal_help "invalid operation mode '$opt_mode'" 405049dc963fSmrg ;; 405149dc963fSmrg esac 40524b0ead49Smrg 40537aa89044Smrg echo 405426372658Smrg $ECHO "Try '$progname --help' for more information about other modes." 405549dc963fSmrg} 40564b0ead49Smrg 40577aa89044Smrg# Now that we've collected a possible --mode arg, show help if necessary 40587aa89044Smrgif $opt_help; then 405926372658Smrg if test : = "$opt_help"; then 40607aa89044Smrg func_mode_help 40617aa89044Smrg else 40627aa89044Smrg { 40637aa89044Smrg func_help noexit 40644e7590efSmrg for opt_mode in compile link execute install finish uninstall clean; do 40657aa89044Smrg func_mode_help 40667aa89044Smrg done 406726372658Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40687aa89044Smrg { 40697aa89044Smrg func_help noexit 40704e7590efSmrg for opt_mode in compile link execute install finish uninstall clean; do 40717aa89044Smrg echo 40727aa89044Smrg func_mode_help 40737aa89044Smrg done 40747aa89044Smrg } | 407526372658Smrg $SED '1d 40767aa89044Smrg /^When reporting/,/^Report/{ 40777aa89044Smrg H 40787aa89044Smrg d 40797aa89044Smrg } 40807aa89044Smrg $x 40817aa89044Smrg /information about other modes/d 40827aa89044Smrg /more detailed .*MODE/d 40837aa89044Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40847aa89044Smrg fi 40857aa89044Smrg exit $? 40867aa89044Smrgfi 40874b0ead49Smrg 40884b0ead49Smrg 408949dc963fSmrg# func_mode_execute arg... 409049dc963fSmrgfunc_mode_execute () 409149dc963fSmrg{ 409226372658Smrg $debug_cmd 409326372658Smrg 409449dc963fSmrg # The first argument is the command name. 409526372658Smrg cmd=$nonopt 409649dc963fSmrg test -z "$cmd" && \ 409749dc963fSmrg func_fatal_help "you must specify a COMMAND" 40984b0ead49Smrg 409949dc963fSmrg # Handle -dlopen flags immediately. 41004e7590efSmrg for file in $opt_dlopen; do 410149dc963fSmrg test -f "$file" \ 410226372658Smrg || func_fatal_help "'$file' is not a file" 41034b0ead49Smrg 410449dc963fSmrg dir= 410549dc963fSmrg case $file in 410649dc963fSmrg *.la) 41074e7590efSmrg func_resolve_sysroot "$file" 41084e7590efSmrg file=$func_resolve_sysroot_result 41094e7590efSmrg 411049dc963fSmrg # Check to see that this really is a libtool archive. 411149dc963fSmrg func_lalib_unsafe_p "$file" \ 411226372658Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 41134b0ead49Smrg 411449dc963fSmrg # Read the libtool library. 411549dc963fSmrg dlname= 411649dc963fSmrg library_names= 411749dc963fSmrg func_source "$file" 41184b0ead49Smrg 411949dc963fSmrg # Skip this library if it cannot be dlopened. 412049dc963fSmrg if test -z "$dlname"; then 412149dc963fSmrg # Warn if it was a shared library. 412249dc963fSmrg test -n "$library_names" && \ 412326372658Smrg func_warning "'$file' was not linked with '-export-dynamic'" 412449dc963fSmrg continue 412549dc963fSmrg fi 41264b0ead49Smrg 412749dc963fSmrg func_dirname "$file" "" "." 412826372658Smrg dir=$func_dirname_result 41294b0ead49Smrg 413049dc963fSmrg if test -f "$dir/$objdir/$dlname"; then 41314e7590efSmrg func_append dir "/$objdir" 413249dc963fSmrg else 413349dc963fSmrg if test ! -f "$dir/$dlname"; then 413426372658Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 413549dc963fSmrg fi 413649dc963fSmrg fi 41374b0ead49Smrg ;; 41384b0ead49Smrg 413949dc963fSmrg *.lo) 414049dc963fSmrg # Just add the directory containing the .lo file. 414149dc963fSmrg func_dirname "$file" "" "." 414226372658Smrg dir=$func_dirname_result 41434b0ead49Smrg ;; 41444b0ead49Smrg 414549dc963fSmrg *) 414626372658Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41474b0ead49Smrg continue 41484b0ead49Smrg ;; 414949dc963fSmrg esac 41504b0ead49Smrg 415149dc963fSmrg # Get the absolute pathname. 415249dc963fSmrg absdir=`cd "$dir" && pwd` 415326372658Smrg test -n "$absdir" && dir=$absdir 41544b0ead49Smrg 415549dc963fSmrg # Now add the directory to shlibpath_var. 415649dc963fSmrg if eval "test -z \"\$$shlibpath_var\""; then 415749dc963fSmrg eval "$shlibpath_var=\"\$dir\"" 415849dc963fSmrg else 415949dc963fSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 416049dc963fSmrg fi 416149dc963fSmrg done 41624b0ead49Smrg 416349dc963fSmrg # This variable tells wrapper scripts just to set shlibpath_var 416449dc963fSmrg # rather than running their programs. 416526372658Smrg libtool_execute_magic=$magic 41664b0ead49Smrg 416749dc963fSmrg # Check if any of the arguments is a wrapper script. 416849dc963fSmrg args= 416949dc963fSmrg for file 417049dc963fSmrg do 417149dc963fSmrg case $file in 41727aa89044Smrg -* | *.la | *.lo ) ;; 417349dc963fSmrg *) 417449dc963fSmrg # Do a test to see if this is really a libtool program. 417549dc963fSmrg if func_ltwrapper_script_p "$file"; then 417649dc963fSmrg func_source "$file" 417749dc963fSmrg # Transform arg to wrapped name. 417826372658Smrg file=$progdir/$program 417949dc963fSmrg elif func_ltwrapper_executable_p "$file"; then 418049dc963fSmrg func_ltwrapper_scriptname "$file" 418149dc963fSmrg func_source "$func_ltwrapper_scriptname_result" 418249dc963fSmrg # Transform arg to wrapped name. 418326372658Smrg file=$progdir/$program 418449dc963fSmrg fi 418549dc963fSmrg ;; 418649dc963fSmrg esac 418749dc963fSmrg # Quote arguments (to preserve shell metacharacters). 41884e7590efSmrg func_append_quoted args "$file" 418949dc963fSmrg done 41904b0ead49Smrg 419126372658Smrg if $opt_dry_run; then 419226372658Smrg # Display what would be done. 419326372658Smrg if test -n "$shlibpath_var"; then 419426372658Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 419526372658Smrg echo "export $shlibpath_var" 419626372658Smrg fi 419726372658Smrg $ECHO "$cmd$args" 419826372658Smrg exit $EXIT_SUCCESS 419926372658Smrg else 420049dc963fSmrg if test -n "$shlibpath_var"; then 420149dc963fSmrg # Export the shlibpath_var. 420249dc963fSmrg eval "export $shlibpath_var" 420349dc963fSmrg fi 42044b0ead49Smrg 420549dc963fSmrg # Restore saved environment variables 420649dc963fSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 420749dc963fSmrg do 420849dc963fSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 420949dc963fSmrg $lt_var=\$save_$lt_var; export $lt_var 42104b0ead49Smrg else 421149dc963fSmrg $lt_unset $lt_var 421249dc963fSmrg fi" 421349dc963fSmrg done 42144b0ead49Smrg 421549dc963fSmrg # Now prepare to actually exec the command. 421626372658Smrg exec_cmd=\$cmd$args 421749dc963fSmrg fi 421849dc963fSmrg} 42194b0ead49Smrg 422026372658Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42214b0ead49Smrg 42224b0ead49Smrg 422349dc963fSmrg# func_mode_finish arg... 422449dc963fSmrgfunc_mode_finish () 422549dc963fSmrg{ 422626372658Smrg $debug_cmd 422726372658Smrg 42284e7590efSmrg libs= 42294e7590efSmrg libdirs= 423049dc963fSmrg admincmds= 42314b0ead49Smrg 42324e7590efSmrg for opt in "$nonopt" ${1+"$@"} 42334e7590efSmrg do 42344e7590efSmrg if test -d "$opt"; then 42354e7590efSmrg func_append libdirs " $opt" 42364e7590efSmrg 42374e7590efSmrg elif test -f "$opt"; then 42384e7590efSmrg if func_lalib_unsafe_p "$opt"; then 42394e7590efSmrg func_append libs " $opt" 42404e7590efSmrg else 424126372658Smrg func_warning "'$opt' is not a valid libtool archive" 42424e7590efSmrg fi 42434e7590efSmrg 42444e7590efSmrg else 424526372658Smrg func_fatal_error "invalid argument '$opt'" 42464e7590efSmrg fi 42474e7590efSmrg done 42484e7590efSmrg 42494e7590efSmrg if test -n "$libs"; then 42504e7590efSmrg if test -n "$lt_sysroot"; then 42514e7590efSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42524e7590efSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42534e7590efSmrg else 42544e7590efSmrg sysroot_cmd= 42554e7590efSmrg fi 42564e7590efSmrg 42574e7590efSmrg # Remove sysroot references 42584e7590efSmrg if $opt_dry_run; then 42594e7590efSmrg for lib in $libs; do 426026372658Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42614e7590efSmrg done 42624e7590efSmrg else 42634e7590efSmrg tmpdir=`func_mktempdir` 42644e7590efSmrg for lib in $libs; do 426526372658Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42664e7590efSmrg > $tmpdir/tmp-la 42674e7590efSmrg mv -f $tmpdir/tmp-la $lib 42684e7590efSmrg done 42694e7590efSmrg ${RM}r "$tmpdir" 42704e7590efSmrg fi 42714e7590efSmrg fi 42724b0ead49Smrg 42734e7590efSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 427449dc963fSmrg for libdir in $libdirs; do 427549dc963fSmrg if test -n "$finish_cmds"; then 427649dc963fSmrg # Do each command in the finish commands. 427749dc963fSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 427849dc963fSmrg'"$cmd"'"' 42794b0ead49Smrg fi 428049dc963fSmrg if test -n "$finish_eval"; then 428149dc963fSmrg # Do the single finish_eval. 428249dc963fSmrg eval cmds=\"$finish_eval\" 42834e7590efSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 428449dc963fSmrg $cmds" 428549dc963fSmrg fi 428649dc963fSmrg done 428749dc963fSmrg fi 42884b0ead49Smrg 428949dc963fSmrg # Exit here if they wanted silent mode. 429026372658Smrg $opt_quiet && exit $EXIT_SUCCESS 42914b0ead49Smrg 42924e7590efSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42934e7590efSmrg echo "----------------------------------------------------------------------" 42944e7590efSmrg echo "Libraries have been installed in:" 42954e7590efSmrg for libdir in $libdirs; do 42964e7590efSmrg $ECHO " $libdir" 42974e7590efSmrg done 42984e7590efSmrg echo 42994e7590efSmrg echo "If you ever happen to want to link against installed libraries" 43004e7590efSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 430126372658Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43024e7590efSmrg echo "flag during linking and do at least one of the following:" 43034e7590efSmrg if test -n "$shlibpath_var"; then 430426372658Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43054e7590efSmrg echo " during execution" 43064e7590efSmrg fi 43074e7590efSmrg if test -n "$runpath_var"; then 430826372658Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43094e7590efSmrg echo " during linking" 43104e7590efSmrg fi 43114e7590efSmrg if test -n "$hardcode_libdir_flag_spec"; then 43124e7590efSmrg libdir=LIBDIR 43134e7590efSmrg eval flag=\"$hardcode_libdir_flag_spec\" 431449dc963fSmrg 431526372658Smrg $ECHO " - use the '$flag' linker flag" 43164e7590efSmrg fi 43174e7590efSmrg if test -n "$admincmds"; then 43184e7590efSmrg $ECHO " - have your system administrator run these commands:$admincmds" 43194e7590efSmrg fi 43204e7590efSmrg if test -f /etc/ld.so.conf; then 432126372658Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43224e7590efSmrg fi 43234e7590efSmrg echo 432449dc963fSmrg 43254e7590efSmrg echo "See any operating system documentation about shared libraries for" 43264e7590efSmrg case $host in 43274e7590efSmrg solaris2.[6789]|solaris2.1[0-9]) 43284e7590efSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43294e7590efSmrg echo "pages." 43304e7590efSmrg ;; 43314e7590efSmrg *) 43324e7590efSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43334e7590efSmrg ;; 43344e7590efSmrg esac 43354e7590efSmrg echo "----------------------------------------------------------------------" 43364e7590efSmrg fi 433749dc963fSmrg exit $EXIT_SUCCESS 433849dc963fSmrg} 433949dc963fSmrg 434026372658Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 434149dc963fSmrg 434249dc963fSmrg 434349dc963fSmrg# func_mode_install arg... 434449dc963fSmrgfunc_mode_install () 434549dc963fSmrg{ 434626372658Smrg $debug_cmd 434726372658Smrg 434849dc963fSmrg # There may be an optional sh(1) argument at the beginning of 434949dc963fSmrg # install_prog (especially on Windows NT). 435026372658Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 435149dc963fSmrg # Allow the use of GNU shtool's install command. 435226372658Smrg case $nonopt in *shtool*) :;; *) false;; esac 435326372658Smrg then 435449dc963fSmrg # Aesthetically quote it. 4355c3e29c03Smrg func_quote_arg pretty "$nonopt" 4356c3e29c03Smrg install_prog="$func_quote_arg_result " 435749dc963fSmrg arg=$1 435849dc963fSmrg shift 435949dc963fSmrg else 436049dc963fSmrg install_prog= 436149dc963fSmrg arg=$nonopt 436249dc963fSmrg fi 436349dc963fSmrg 436449dc963fSmrg # The real first argument should be the name of the installation program. 436549dc963fSmrg # Aesthetically quote it. 4366c3e29c03Smrg func_quote_arg pretty "$arg" 4367c3e29c03Smrg func_append install_prog "$func_quote_arg_result" 43687aa89044Smrg install_shared_prog=$install_prog 43697aa89044Smrg case " $install_prog " in 43707aa89044Smrg *[\\\ /]cp\ *) install_cp=: ;; 43717aa89044Smrg *) install_cp=false ;; 43727aa89044Smrg esac 437349dc963fSmrg 437449dc963fSmrg # We need to accept at least all the BSD install flags. 437549dc963fSmrg dest= 437649dc963fSmrg files= 437749dc963fSmrg opts= 437849dc963fSmrg prev= 437949dc963fSmrg install_type= 438026372658Smrg isdir=false 438149dc963fSmrg stripme= 43827aa89044Smrg no_mode=: 438349dc963fSmrg for arg 438449dc963fSmrg do 43857aa89044Smrg arg2= 438649dc963fSmrg if test -n "$dest"; then 43874e7590efSmrg func_append files " $dest" 438849dc963fSmrg dest=$arg 438949dc963fSmrg continue 439049dc963fSmrg fi 439149dc963fSmrg 439249dc963fSmrg case $arg in 439326372658Smrg -d) isdir=: ;; 439449dc963fSmrg -f) 43957aa89044Smrg if $install_cp; then :; else 43967aa89044Smrg prev=$arg 43977aa89044Smrg fi 439849dc963fSmrg ;; 439949dc963fSmrg -g | -m | -o) 440049dc963fSmrg prev=$arg 440149dc963fSmrg ;; 440249dc963fSmrg -s) 440349dc963fSmrg stripme=" -s" 440449dc963fSmrg continue 440549dc963fSmrg ;; 440649dc963fSmrg -*) 440749dc963fSmrg ;; 440849dc963fSmrg *) 440949dc963fSmrg # If the previous option needed an argument, then skip it. 441049dc963fSmrg if test -n "$prev"; then 441126372658Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44127aa89044Smrg arg2=$install_override_mode 44137aa89044Smrg no_mode=false 44147aa89044Smrg fi 44154b0ead49Smrg prev= 44164b0ead49Smrg else 441749dc963fSmrg dest=$arg 441849dc963fSmrg continue 44194b0ead49Smrg fi 44204b0ead49Smrg ;; 442149dc963fSmrg esac 44224b0ead49Smrg 442349dc963fSmrg # Aesthetically quote the argument. 4424c3e29c03Smrg func_quote_arg pretty "$arg" 4425c3e29c03Smrg func_append install_prog " $func_quote_arg_result" 44267aa89044Smrg if test -n "$arg2"; then 4427c3e29c03Smrg func_quote_arg pretty "$arg2" 44287aa89044Smrg fi 4429c3e29c03Smrg func_append install_shared_prog " $func_quote_arg_result" 443049dc963fSmrg done 44314b0ead49Smrg 443249dc963fSmrg test -z "$install_prog" && \ 443349dc963fSmrg func_fatal_help "you must specify an install program" 44344b0ead49Smrg 443549dc963fSmrg test -n "$prev" && \ 443626372658Smrg func_fatal_help "the '$prev' option requires an argument" 44374b0ead49Smrg 44387aa89044Smrg if test -n "$install_override_mode" && $no_mode; then 44397aa89044Smrg if $install_cp; then :; else 4440c3e29c03Smrg func_quote_arg pretty "$install_override_mode" 4441c3e29c03Smrg func_append install_shared_prog " -m $func_quote_arg_result" 44427aa89044Smrg fi 44437aa89044Smrg fi 44447aa89044Smrg 444549dc963fSmrg if test -z "$files"; then 444649dc963fSmrg if test -z "$dest"; then 444749dc963fSmrg func_fatal_help "no file or destination specified" 444849dc963fSmrg else 444949dc963fSmrg func_fatal_help "you must specify a destination" 445049dc963fSmrg fi 44514b0ead49Smrg fi 44524b0ead49Smrg 445349dc963fSmrg # Strip any trailing slash from the destination. 445449dc963fSmrg func_stripname '' '/' "$dest" 445549dc963fSmrg dest=$func_stripname_result 44564b0ead49Smrg 445749dc963fSmrg # Check to see that the destination is a directory. 445826372658Smrg test -d "$dest" && isdir=: 445926372658Smrg if $isdir; then 446026372658Smrg destdir=$dest 446149dc963fSmrg destname= 44624b0ead49Smrg else 446349dc963fSmrg func_dirname_and_basename "$dest" "" "." 446426372658Smrg destdir=$func_dirname_result 446526372658Smrg destname=$func_basename_result 44664b0ead49Smrg 446749dc963fSmrg # Not a directory, so check to see that there is only one file specified. 446849dc963fSmrg set dummy $files; shift 446949dc963fSmrg test "$#" -gt 1 && \ 447026372658Smrg func_fatal_help "'$dest' is not a directory" 44714b0ead49Smrg fi 447249dc963fSmrg case $destdir in 447349dc963fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44744b0ead49Smrg *) 447549dc963fSmrg for file in $files; do 447649dc963fSmrg case $file in 447749dc963fSmrg *.lo) ;; 447849dc963fSmrg *) 447926372658Smrg func_fatal_help "'$destdir' must be an absolute directory name" 448049dc963fSmrg ;; 448149dc963fSmrg esac 448249dc963fSmrg done 44834b0ead49Smrg ;; 44844b0ead49Smrg esac 44854b0ead49Smrg 448649dc963fSmrg # This variable tells wrapper scripts just to set variables rather 448749dc963fSmrg # than running their programs. 448826372658Smrg libtool_install_magic=$magic 44894b0ead49Smrg 449049dc963fSmrg staticlibs= 449149dc963fSmrg future_libdirs= 449249dc963fSmrg current_libdirs= 449349dc963fSmrg for file in $files; do 44944b0ead49Smrg 449549dc963fSmrg # Do each installation. 449649dc963fSmrg case $file in 449749dc963fSmrg *.$libext) 449849dc963fSmrg # Do the static libraries later. 44994e7590efSmrg func_append staticlibs " $file" 450049dc963fSmrg ;; 450149dc963fSmrg 450249dc963fSmrg *.la) 45034e7590efSmrg func_resolve_sysroot "$file" 45044e7590efSmrg file=$func_resolve_sysroot_result 45054e7590efSmrg 450649dc963fSmrg # Check to see that this really is a libtool archive. 450749dc963fSmrg func_lalib_unsafe_p "$file" \ 450826372658Smrg || func_fatal_help "'$file' is not a valid libtool archive" 450949dc963fSmrg 451049dc963fSmrg library_names= 451149dc963fSmrg old_library= 451249dc963fSmrg relink_command= 451349dc963fSmrg func_source "$file" 451449dc963fSmrg 451549dc963fSmrg # Add the libdir to current_libdirs if it is the destination. 451649dc963fSmrg if test "X$destdir" = "X$libdir"; then 451749dc963fSmrg case "$current_libdirs " in 451849dc963fSmrg *" $libdir "*) ;; 45194e7590efSmrg *) func_append current_libdirs " $libdir" ;; 45204b0ead49Smrg esac 452149dc963fSmrg else 452249dc963fSmrg # Note the libdir as a future libdir. 452349dc963fSmrg case "$future_libdirs " in 452449dc963fSmrg *" $libdir "*) ;; 45254e7590efSmrg *) func_append future_libdirs " $libdir" ;; 452649dc963fSmrg esac 452749dc963fSmrg fi 45284b0ead49Smrg 452949dc963fSmrg func_dirname "$file" "/" "" 453026372658Smrg dir=$func_dirname_result 45314e7590efSmrg func_append dir "$objdir" 453249dc963fSmrg 453349dc963fSmrg if test -n "$relink_command"; then 453449dc963fSmrg # Determine the prefix the user has applied to our future dir. 45357aa89044Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 453649dc963fSmrg 453749dc963fSmrg # Don't allow the user to place us outside of our expected 453849dc963fSmrg # location b/c this prevents finding dependent libraries that 453949dc963fSmrg # are installed to the same prefix. 454049dc963fSmrg # At present, this check doesn't affect windows .dll's that 454149dc963fSmrg # are installed into $libdir/../bin (currently, that works fine) 454249dc963fSmrg # but it's something to keep an eye on. 454349dc963fSmrg test "$inst_prefix_dir" = "$destdir" && \ 454426372658Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 454549dc963fSmrg 454649dc963fSmrg if test -n "$inst_prefix_dir"; then 454749dc963fSmrg # Stick the inst_prefix_dir data into the link command. 45487aa89044Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 454949dc963fSmrg else 45507aa89044Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 455149dc963fSmrg fi 455249dc963fSmrg 455326372658Smrg func_warning "relinking '$file'" 455449dc963fSmrg func_show_eval "$relink_command" \ 455526372658Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 455649dc963fSmrg fi 455749dc963fSmrg 455849dc963fSmrg # See the names of the shared library. 455949dc963fSmrg set dummy $library_names; shift 456049dc963fSmrg if test -n "$1"; then 456126372658Smrg realname=$1 456249dc963fSmrg shift 456349dc963fSmrg 456426372658Smrg srcname=$realname 456526372658Smrg test -n "$relink_command" && srcname=${realname}T 456649dc963fSmrg 456749dc963fSmrg # Install the shared library and build the symlinks. 45687aa89044Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 456949dc963fSmrg 'exit $?' 457026372658Smrg tstripme=$stripme 457149dc963fSmrg case $host_os in 457249dc963fSmrg cygwin* | mingw* | pw32* | cegcc*) 457349dc963fSmrg case $realname in 457449dc963fSmrg *.dll.a) 457526372658Smrg tstripme= 457626372658Smrg ;; 457726372658Smrg esac 457826372658Smrg ;; 457926372658Smrg os2*) 458026372658Smrg case $realname in 458126372658Smrg *_dll.a) 458226372658Smrg tstripme= 458349dc963fSmrg ;; 458449dc963fSmrg esac 45854b0ead49Smrg ;; 45864b0ead49Smrg esac 458749dc963fSmrg if test -n "$tstripme" && test -n "$striplib"; then 458849dc963fSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45894b0ead49Smrg fi 459049dc963fSmrg 459149dc963fSmrg if test "$#" -gt 0; then 459249dc963fSmrg # Delete the old symlinks, and create new ones. 459326372658Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 459449dc963fSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 459549dc963fSmrg # so we also need to try rm && ln -s. 459649dc963fSmrg for linkname 459749dc963fSmrg do 459849dc963fSmrg test "$linkname" != "$realname" \ 459949dc963fSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46004b0ead49Smrg done 46014b0ead49Smrg fi 46024b0ead49Smrg 460349dc963fSmrg # Do each command in the postinstall commands. 460426372658Smrg lib=$destdir/$realname 460549dc963fSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 46064b0ead49Smrg fi 46074b0ead49Smrg 460849dc963fSmrg # Install the pseudo-library for information purposes. 460949dc963fSmrg func_basename "$file" 461026372658Smrg name=$func_basename_result 461126372658Smrg instname=$dir/${name}i 461249dc963fSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46134b0ead49Smrg 461449dc963fSmrg # Maybe install the static library, too. 46154e7590efSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 461649dc963fSmrg ;; 46174b0ead49Smrg 461849dc963fSmrg *.lo) 461949dc963fSmrg # Install (i.e. copy) a libtool object. 46204b0ead49Smrg 462149dc963fSmrg # Figure out destination file name, if it wasn't already specified. 462249dc963fSmrg if test -n "$destname"; then 462326372658Smrg destfile=$destdir/$destname 462449dc963fSmrg else 462549dc963fSmrg func_basename "$file" 462626372658Smrg destfile=$func_basename_result 462726372658Smrg destfile=$destdir/$destfile 46284b0ead49Smrg fi 46294b0ead49Smrg 463049dc963fSmrg # Deduce the name of the destination old-style object file. 463149dc963fSmrg case $destfile in 463249dc963fSmrg *.lo) 463349dc963fSmrg func_lo2o "$destfile" 463449dc963fSmrg staticdest=$func_lo2o_result 463549dc963fSmrg ;; 463649dc963fSmrg *.$objext) 463726372658Smrg staticdest=$destfile 463849dc963fSmrg destfile= 463949dc963fSmrg ;; 464049dc963fSmrg *) 464126372658Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 464249dc963fSmrg ;; 464349dc963fSmrg esac 46444b0ead49Smrg 464549dc963fSmrg # Install the libtool object if requested. 464649dc963fSmrg test -n "$destfile" && \ 464749dc963fSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46484b0ead49Smrg 464949dc963fSmrg # Install the old object if enabled. 465026372658Smrg if test yes = "$build_old_libs"; then 465149dc963fSmrg # Deduce the name of the old-style object file. 465249dc963fSmrg func_lo2o "$file" 465349dc963fSmrg staticobj=$func_lo2o_result 465449dc963fSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46554b0ead49Smrg fi 465649dc963fSmrg exit $EXIT_SUCCESS 465749dc963fSmrg ;; 46584b0ead49Smrg 465949dc963fSmrg *) 466049dc963fSmrg # Figure out destination file name, if it wasn't already specified. 466149dc963fSmrg if test -n "$destname"; then 466226372658Smrg destfile=$destdir/$destname 466349dc963fSmrg else 466449dc963fSmrg func_basename "$file" 466526372658Smrg destfile=$func_basename_result 466626372658Smrg destfile=$destdir/$destfile 466749dc963fSmrg fi 46684b0ead49Smrg 466949dc963fSmrg # If the file is missing, and there is a .exe on the end, strip it 467049dc963fSmrg # because it is most likely a libtool script we actually want to 467149dc963fSmrg # install 467226372658Smrg stripped_ext= 467349dc963fSmrg case $file in 467449dc963fSmrg *.exe) 467549dc963fSmrg if test ! -f "$file"; then 467649dc963fSmrg func_stripname '' '.exe' "$file" 467749dc963fSmrg file=$func_stripname_result 467826372658Smrg stripped_ext=.exe 467949dc963fSmrg fi 468049dc963fSmrg ;; 468149dc963fSmrg esac 468249dc963fSmrg 468349dc963fSmrg # Do a test to see if this is really a libtool program. 468449dc963fSmrg case $host in 468549dc963fSmrg *cygwin* | *mingw*) 468649dc963fSmrg if func_ltwrapper_executable_p "$file"; then 468749dc963fSmrg func_ltwrapper_scriptname "$file" 468849dc963fSmrg wrapper=$func_ltwrapper_scriptname_result 468949dc963fSmrg else 469049dc963fSmrg func_stripname '' '.exe' "$file" 469149dc963fSmrg wrapper=$func_stripname_result 469249dc963fSmrg fi 469349dc963fSmrg ;; 46944b0ead49Smrg *) 469549dc963fSmrg wrapper=$file 469649dc963fSmrg ;; 469749dc963fSmrg esac 469849dc963fSmrg if func_ltwrapper_script_p "$wrapper"; then 469949dc963fSmrg notinst_deplibs= 470049dc963fSmrg relink_command= 470149dc963fSmrg 470249dc963fSmrg func_source "$wrapper" 470349dc963fSmrg 470449dc963fSmrg # Check the variables that should have been set. 470549dc963fSmrg test -z "$generated_by_libtool_version" && \ 470626372658Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 470749dc963fSmrg 470826372658Smrg finalize=: 470949dc963fSmrg for lib in $notinst_deplibs; do 471049dc963fSmrg # Check to see that each library is installed. 471149dc963fSmrg libdir= 471249dc963fSmrg if test -f "$lib"; then 471349dc963fSmrg func_source "$lib" 471449dc963fSmrg fi 471526372658Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 471649dc963fSmrg if test -n "$libdir" && test ! -f "$libfile"; then 471726372658Smrg func_warning "'$lib' has not been installed in '$libdir'" 471826372658Smrg finalize=false 471949dc963fSmrg fi 472049dc963fSmrg done 472149dc963fSmrg 472249dc963fSmrg relink_command= 472349dc963fSmrg func_source "$wrapper" 472449dc963fSmrg 472549dc963fSmrg outputname= 472626372658Smrg if test no = "$fast_install" && test -n "$relink_command"; then 472749dc963fSmrg $opt_dry_run || { 472826372658Smrg if $finalize; then 472949dc963fSmrg tmpdir=`func_mktempdir` 473049dc963fSmrg func_basename "$file$stripped_ext" 473126372658Smrg file=$func_basename_result 473226372658Smrg outputname=$tmpdir/$file 473349dc963fSmrg # Replace the output file specification. 47347aa89044Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 473549dc963fSmrg 473626372658Smrg $opt_quiet || { 4737c3e29c03Smrg func_quote_arg expand,pretty "$relink_command" 4738c3e29c03Smrg eval "func_echo $func_quote_arg_result" 473949dc963fSmrg } 474049dc963fSmrg if eval "$relink_command"; then : 474149dc963fSmrg else 474226372658Smrg func_error "error: relink '$file' with the above command before installing it" 474349dc963fSmrg $opt_dry_run || ${RM}r "$tmpdir" 474449dc963fSmrg continue 474549dc963fSmrg fi 474626372658Smrg file=$outputname 474749dc963fSmrg else 474826372658Smrg func_warning "cannot relink '$file'" 474949dc963fSmrg fi 475049dc963fSmrg } 475149dc963fSmrg else 475249dc963fSmrg # Install the binary that we compiled earlier. 47537aa89044Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47544b0ead49Smrg fi 475549dc963fSmrg fi 475649dc963fSmrg 475749dc963fSmrg # remove .exe since cygwin /usr/bin/install will append another 475849dc963fSmrg # one anyway 475949dc963fSmrg case $install_prog,$host in 476049dc963fSmrg */usr/bin/install*,*cygwin*) 476149dc963fSmrg case $file:$destfile in 476249dc963fSmrg *.exe:*.exe) 476349dc963fSmrg # this is ok 476449dc963fSmrg ;; 476549dc963fSmrg *.exe:*) 476649dc963fSmrg destfile=$destfile.exe 476749dc963fSmrg ;; 476849dc963fSmrg *:*.exe) 476949dc963fSmrg func_stripname '' '.exe' "$destfile" 477049dc963fSmrg destfile=$func_stripname_result 477149dc963fSmrg ;; 477249dc963fSmrg esac 47734b0ead49Smrg ;; 47744b0ead49Smrg esac 477549dc963fSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 477649dc963fSmrg $opt_dry_run || if test -n "$outputname"; then 477749dc963fSmrg ${RM}r "$tmpdir" 477849dc963fSmrg fi 477949dc963fSmrg ;; 478049dc963fSmrg esac 478149dc963fSmrg done 47824b0ead49Smrg 478349dc963fSmrg for file in $staticlibs; do 478449dc963fSmrg func_basename "$file" 478526372658Smrg name=$func_basename_result 478649dc963fSmrg 478749dc963fSmrg # Set up the ranlib parameters. 478826372658Smrg oldlib=$destdir/$name 47894e7590efSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47904e7590efSmrg tool_oldlib=$func_to_tool_file_result 479149dc963fSmrg 479249dc963fSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 479349dc963fSmrg 479449dc963fSmrg if test -n "$stripme" && test -n "$old_striplib"; then 47954e7590efSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 479649dc963fSmrg fi 479749dc963fSmrg 479849dc963fSmrg # Do each command in the postinstall commands. 479949dc963fSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 480049dc963fSmrg done 480149dc963fSmrg 480249dc963fSmrg test -n "$future_libdirs" && \ 480326372658Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 480449dc963fSmrg 480549dc963fSmrg if test -n "$current_libdirs"; then 480649dc963fSmrg # Maybe just do a dry run. 480749dc963fSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 480826372658Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 480949dc963fSmrg else 481049dc963fSmrg exit $EXIT_SUCCESS 481149dc963fSmrg fi 481249dc963fSmrg} 481349dc963fSmrg 481426372658Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 481549dc963fSmrg 481649dc963fSmrg 481749dc963fSmrg# func_generate_dlsyms outputname originator pic_p 481849dc963fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 481949dc963fSmrg# a dlpreopen symbol table. 482049dc963fSmrgfunc_generate_dlsyms () 482149dc963fSmrg{ 482226372658Smrg $debug_cmd 482326372658Smrg 482426372658Smrg my_outputname=$1 482526372658Smrg my_originator=$2 482626372658Smrg my_pic_p=${3-false} 482726372658Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 482849dc963fSmrg my_dlsyms= 482949dc963fSmrg 483026372658Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 483149dc963fSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 483226372658Smrg my_dlsyms=${my_outputname}S.c 483349dc963fSmrg else 483449dc963fSmrg func_error "not configured to extract global symbols from dlpreopened files" 483549dc963fSmrg fi 483649dc963fSmrg fi 483749dc963fSmrg 483849dc963fSmrg if test -n "$my_dlsyms"; then 483949dc963fSmrg case $my_dlsyms in 484049dc963fSmrg "") ;; 484149dc963fSmrg *.c) 484249dc963fSmrg # Discover the nlist of each of the dlfiles. 484326372658Smrg nlist=$output_objdir/$my_outputname.nm 484449dc963fSmrg 484549dc963fSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 484649dc963fSmrg 484749dc963fSmrg # Parse the name list into a source file. 484849dc963fSmrg func_verbose "creating $output_objdir/$my_dlsyms" 484949dc963fSmrg 485049dc963fSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 485126372658Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 485226372658Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 485349dc963fSmrg 485449dc963fSmrg#ifdef __cplusplus 485549dc963fSmrgextern \"C\" { 485649dc963fSmrg#endif 485749dc963fSmrg 485826372658Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48597aa89044Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48607aa89044Smrg#endif 48617aa89044Smrg 48624e7590efSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 486326372658Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 486426372658Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48654e7590efSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48664e7590efSmrg# define LT_DLSYM_CONST 486726372658Smrg#elif defined __osf__ 48684e7590efSmrg/* This system does not cope well with relocations in const data. */ 48694e7590efSmrg# define LT_DLSYM_CONST 48704e7590efSmrg#else 48714e7590efSmrg# define LT_DLSYM_CONST const 48724e7590efSmrg#endif 48734e7590efSmrg 487426372658Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 487526372658Smrg 487649dc963fSmrg/* External symbol declarations for the compiler. */\ 487749dc963fSmrg" 487849dc963fSmrg 487926372658Smrg if test yes = "$dlself"; then 488026372658Smrg func_verbose "generating symbol list for '$output'" 488149dc963fSmrg 488249dc963fSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 488349dc963fSmrg 488449dc963fSmrg # Add our own program objects to the symbol list. 48857aa89044Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 488649dc963fSmrg for progfile in $progfiles; do 48874e7590efSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 488826372658Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48894e7590efSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 489049dc963fSmrg done 489149dc963fSmrg 489249dc963fSmrg if test -n "$exclude_expsyms"; then 489349dc963fSmrg $opt_dry_run || { 489449dc963fSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 489549dc963fSmrg eval '$MV "$nlist"T "$nlist"' 489649dc963fSmrg } 48974b0ead49Smrg fi 489849dc963fSmrg 489949dc963fSmrg if test -n "$export_symbols_regex"; then 490049dc963fSmrg $opt_dry_run || { 490149dc963fSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 490249dc963fSmrg eval '$MV "$nlist"T "$nlist"' 490349dc963fSmrg } 490449dc963fSmrg fi 490549dc963fSmrg 490649dc963fSmrg # Prepare the list of exported symbols 490749dc963fSmrg if test -z "$export_symbols"; then 490826372658Smrg export_symbols=$output_objdir/$outputname.exp 490949dc963fSmrg $opt_dry_run || { 491049dc963fSmrg $RM $export_symbols 491126372658Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 491249dc963fSmrg case $host in 491349dc963fSmrg *cygwin* | *mingw* | *cegcc* ) 491449dc963fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 491549dc963fSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 491649dc963fSmrg ;; 491749dc963fSmrg esac 491849dc963fSmrg } 49194b0ead49Smrg else 492049dc963fSmrg $opt_dry_run || { 492126372658Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 492249dc963fSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 492349dc963fSmrg eval '$MV "$nlist"T "$nlist"' 492449dc963fSmrg case $host in 49257aa89044Smrg *cygwin* | *mingw* | *cegcc* ) 492649dc963fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 492749dc963fSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 492849dc963fSmrg ;; 492949dc963fSmrg esac 493049dc963fSmrg } 49314b0ead49Smrg fi 493249dc963fSmrg fi 49334b0ead49Smrg 493449dc963fSmrg for dlprefile in $dlprefiles; do 493526372658Smrg func_verbose "extracting global C symbols from '$dlprefile'" 493649dc963fSmrg func_basename "$dlprefile" 493726372658Smrg name=$func_basename_result 49384e7590efSmrg case $host in 49394e7590efSmrg *cygwin* | *mingw* | *cegcc* ) 49404e7590efSmrg # if an import library, we need to obtain dlname 49414e7590efSmrg if func_win32_import_lib_p "$dlprefile"; then 49424e7590efSmrg func_tr_sh "$dlprefile" 49434e7590efSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 494426372658Smrg dlprefile_dlbasename= 49454e7590efSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49464e7590efSmrg # Use subshell, to avoid clobbering current variable values 49474e7590efSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 494826372658Smrg if test -n "$dlprefile_dlname"; then 49494e7590efSmrg func_basename "$dlprefile_dlname" 495026372658Smrg dlprefile_dlbasename=$func_basename_result 49514e7590efSmrg else 49524e7590efSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 49534e7590efSmrg $sharedlib_from_linklib_cmd "$dlprefile" 49544e7590efSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49554e7590efSmrg fi 49564e7590efSmrg fi 49574e7590efSmrg $opt_dry_run || { 495826372658Smrg if test -n "$dlprefile_dlbasename"; then 49594e7590efSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49604e7590efSmrg else 49614e7590efSmrg func_warning "Could not compute DLL name from $name" 49624e7590efSmrg eval '$ECHO ": $name " >> "$nlist"' 49634e7590efSmrg fi 49644e7590efSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49654e7590efSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49664e7590efSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49674e7590efSmrg } 49684e7590efSmrg else # not an import lib 49694e7590efSmrg $opt_dry_run || { 49704e7590efSmrg eval '$ECHO ": $name " >> "$nlist"' 49714e7590efSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49724e7590efSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49734e7590efSmrg } 49744e7590efSmrg fi 49754e7590efSmrg ;; 49764e7590efSmrg *) 49774e7590efSmrg $opt_dry_run || { 49784e7590efSmrg eval '$ECHO ": $name " >> "$nlist"' 49794e7590efSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49804e7590efSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49814e7590efSmrg } 49824e7590efSmrg ;; 49834e7590efSmrg esac 498449dc963fSmrg done 498549dc963fSmrg 498649dc963fSmrg $opt_dry_run || { 498749dc963fSmrg # Make sure we have at least an empty file. 498849dc963fSmrg test -f "$nlist" || : > "$nlist" 498949dc963fSmrg 499049dc963fSmrg if test -n "$exclude_expsyms"; then 499149dc963fSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 499249dc963fSmrg $MV "$nlist"T "$nlist" 49934b0ead49Smrg fi 499449dc963fSmrg 499549dc963fSmrg # Try sorting and uniquifying the output. 499649dc963fSmrg if $GREP -v "^: " < "$nlist" | 499749dc963fSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 499849dc963fSmrg sort -k 3 499949dc963fSmrg else 500049dc963fSmrg sort +2 500149dc963fSmrg fi | 500249dc963fSmrg uniq > "$nlist"S; then 500349dc963fSmrg : 50044b0ead49Smrg else 500549dc963fSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 50064b0ead49Smrg fi 50074b0ead49Smrg 500849dc963fSmrg if test -f "$nlist"S; then 500949dc963fSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50104b0ead49Smrg else 50117aa89044Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50124b0ead49Smrg fi 50134b0ead49Smrg 501426372658Smrg func_show_eval '$RM "${nlist}I"' 501526372658Smrg if test -n "$global_symbol_to_import"; then 501626372658Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 501726372658Smrg fi 501826372658Smrg 50197aa89044Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50204b0ead49Smrg 502149dc963fSmrg/* The mapping between symbol names and symbols. */ 502249dc963fSmrgtypedef struct { 502349dc963fSmrg const char *name; 502449dc963fSmrg void *address; 502549dc963fSmrg} lt_dlsymlist; 50264e7590efSmrgextern LT_DLSYM_CONST lt_dlsymlist 502726372658Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 502826372658Smrg" 502926372658Smrg 503026372658Smrg if test -s "$nlist"I; then 503126372658Smrg echo >> "$output_objdir/$my_dlsyms" "\ 503226372658Smrgstatic void lt_syminit(void) 503326372658Smrg{ 503426372658Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 503526372658Smrg for (; symbol->name; ++symbol) 503626372658Smrg {" 503726372658Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 503826372658Smrg echo >> "$output_objdir/$my_dlsyms" "\ 503926372658Smrg } 504026372658Smrg}" 504126372658Smrg fi 504226372658Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50434e7590efSmrgLT_DLSYM_CONST lt_dlsymlist 504449dc963fSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 504526372658Smrg{ {\"$my_originator\", (void *) 0}," 504626372658Smrg 504726372658Smrg if test -s "$nlist"I; then 504826372658Smrg echo >> "$output_objdir/$my_dlsyms" "\ 504926372658Smrg {\"@INIT@\", (void *) <_syminit}," 505026372658Smrg fi 50514b0ead49Smrg 505249dc963fSmrg case $need_lib_prefix in 505349dc963fSmrg no) 505449dc963fSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 505549dc963fSmrg ;; 505649dc963fSmrg *) 505749dc963fSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 505849dc963fSmrg ;; 505949dc963fSmrg esac 50607aa89044Smrg echo >> "$output_objdir/$my_dlsyms" "\ 506149dc963fSmrg {0, (void *) 0} 506249dc963fSmrg}; 50634b0ead49Smrg 506449dc963fSmrg/* This works around a problem in FreeBSD linker */ 506549dc963fSmrg#ifdef FREEBSD_WORKAROUND 506649dc963fSmrgstatic const void *lt_preloaded_setup() { 506749dc963fSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 506849dc963fSmrg} 506949dc963fSmrg#endif 507049dc963fSmrg 507149dc963fSmrg#ifdef __cplusplus 507249dc963fSmrg} 507349dc963fSmrg#endif\ 507449dc963fSmrg" 507549dc963fSmrg } # !$opt_dry_run 507649dc963fSmrg 507749dc963fSmrg pic_flag_for_symtable= 507849dc963fSmrg case "$compile_command " in 507949dc963fSmrg *" -static "*) ;; 508049dc963fSmrg *) 508149dc963fSmrg case $host in 508249dc963fSmrg # compiling the symbol table file with pic_flag works around 508349dc963fSmrg # a FreeBSD bug that causes programs to crash when -lm is 508449dc963fSmrg # linked before any other PIC object. But we must not use 508549dc963fSmrg # pic_flag when linking with -static. The problem exists in 508649dc963fSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50874e7590efSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 508849dc963fSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 508949dc963fSmrg *-*-hpux*) 509049dc963fSmrg pic_flag_for_symtable=" $pic_flag" ;; 509149dc963fSmrg *) 509226372658Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 509349dc963fSmrg ;; 509449dc963fSmrg esac 509549dc963fSmrg ;; 509649dc963fSmrg esac 509749dc963fSmrg symtab_cflags= 509849dc963fSmrg for arg in $LTCFLAGS; do 509949dc963fSmrg case $arg in 510049dc963fSmrg -pie | -fpie | -fPIE) ;; 51014e7590efSmrg *) func_append symtab_cflags " $arg" ;; 510249dc963fSmrg esac 510349dc963fSmrg done 51044b0ead49Smrg 510549dc963fSmrg # Now compile the dynamic symbol file. 510649dc963fSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51074b0ead49Smrg 510849dc963fSmrg # Clean up the generated files. 510926372658Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51104b0ead49Smrg 511149dc963fSmrg # Transform the symbol file into the correct name. 511226372658Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 511349dc963fSmrg case $host in 511449dc963fSmrg *cygwin* | *mingw* | *cegcc* ) 511549dc963fSmrg if test -f "$output_objdir/$my_outputname.def"; then 51167aa89044Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51177aa89044Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511849dc963fSmrg else 51197aa89044Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51207aa89044Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51214b0ead49Smrg fi 512249dc963fSmrg ;; 512349dc963fSmrg *) 51247aa89044Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51257aa89044Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512649dc963fSmrg ;; 512749dc963fSmrg esac 512849dc963fSmrg ;; 512949dc963fSmrg *) 513026372658Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 513149dc963fSmrg ;; 513249dc963fSmrg esac 513349dc963fSmrg else 513449dc963fSmrg # We keep going just in case the user didn't refer to 513549dc963fSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 513649dc963fSmrg # really was required. 51374b0ead49Smrg 513849dc963fSmrg # Nullify the symbol file. 51397aa89044Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51407aa89044Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 514149dc963fSmrg fi 514249dc963fSmrg} 51434b0ead49Smrg 514426372658Smrg# func_cygming_gnu_implib_p ARG 514526372658Smrg# This predicate returns with zero status (TRUE) if 514626372658Smrg# ARG is a GNU/binutils-style import library. Returns 514726372658Smrg# with nonzero status (FALSE) otherwise. 514826372658Smrgfunc_cygming_gnu_implib_p () 514926372658Smrg{ 515026372658Smrg $debug_cmd 515126372658Smrg 515226372658Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 515326372658Smrg 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)$'` 515426372658Smrg test -n "$func_cygming_gnu_implib_tmp" 515526372658Smrg} 515626372658Smrg 515726372658Smrg# func_cygming_ms_implib_p ARG 515826372658Smrg# This predicate returns with zero status (TRUE) if 515926372658Smrg# ARG is an MS-style import library. Returns 516026372658Smrg# with nonzero status (FALSE) otherwise. 516126372658Smrgfunc_cygming_ms_implib_p () 516226372658Smrg{ 516326372658Smrg $debug_cmd 516426372658Smrg 516526372658Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 516626372658Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 516726372658Smrg test -n "$func_cygming_ms_implib_tmp" 516826372658Smrg} 516926372658Smrg 517049dc963fSmrg# func_win32_libid arg 517149dc963fSmrg# return the library type of file 'arg' 517249dc963fSmrg# 517349dc963fSmrg# Need a lot of goo to handle *both* DLLs and import libs 517449dc963fSmrg# Has to be a shell function in order to 'eat' the argument 517549dc963fSmrg# that is supplied when $file_magic_command is called. 51767aa89044Smrg# Despite the name, also deal with 64 bit binaries. 517749dc963fSmrgfunc_win32_libid () 517849dc963fSmrg{ 517926372658Smrg $debug_cmd 518026372658Smrg 518126372658Smrg win32_libid_type=unknown 518249dc963fSmrg win32_fileres=`file -L $1 2>/dev/null` 518349dc963fSmrg case $win32_fileres in 518449dc963fSmrg *ar\ archive\ import\ library*) # definitely import 518549dc963fSmrg win32_libid_type="x86 archive import" 518649dc963fSmrg ;; 518749dc963fSmrg *ar\ archive*) # could be an import, or static 51887aa89044Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 518949dc963fSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51907aa89044Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 519126372658Smrg case $nm_interface in 519226372658Smrg "MS dumpbin") 519326372658Smrg if func_cygming_ms_implib_p "$1" || 519426372658Smrg func_cygming_gnu_implib_p "$1" 519526372658Smrg then 519626372658Smrg win32_nmres=import 519726372658Smrg else 519826372658Smrg win32_nmres= 519926372658Smrg fi 520026372658Smrg ;; 520126372658Smrg *) 520226372658Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 520326372658Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 520426372658Smrg $SED -n -e ' 520549dc963fSmrg 1,100{ 520649dc963fSmrg / I /{ 520726372658Smrg s|.*|import| 520849dc963fSmrg p 520949dc963fSmrg q 521049dc963fSmrg } 521149dc963fSmrg }'` 521226372658Smrg ;; 521326372658Smrg esac 521449dc963fSmrg case $win32_nmres in 521549dc963fSmrg import*) win32_libid_type="x86 archive import";; 521649dc963fSmrg *) win32_libid_type="x86 archive static";; 521749dc963fSmrg esac 521849dc963fSmrg fi 521949dc963fSmrg ;; 522049dc963fSmrg *DLL*) 522149dc963fSmrg win32_libid_type="x86 DLL" 522249dc963fSmrg ;; 522349dc963fSmrg *executable*) # but shell scripts are "executable" too... 522449dc963fSmrg case $win32_fileres in 522549dc963fSmrg *MS\ Windows\ PE\ Intel*) 522649dc963fSmrg win32_libid_type="x86 DLL" 522749dc963fSmrg ;; 522849dc963fSmrg esac 522949dc963fSmrg ;; 523049dc963fSmrg esac 523149dc963fSmrg $ECHO "$win32_libid_type" 523249dc963fSmrg} 52334b0ead49Smrg 52344e7590efSmrg# func_cygming_dll_for_implib ARG 52354e7590efSmrg# 52364e7590efSmrg# Platform-specific function to extract the 52374e7590efSmrg# name of the DLL associated with the specified 52384e7590efSmrg# import library ARG. 52394e7590efSmrg# Invoked by eval'ing the libtool variable 52404e7590efSmrg# $sharedlib_from_linklib_cmd 52414e7590efSmrg# Result is available in the variable 52424e7590efSmrg# $sharedlib_from_linklib_result 52434e7590efSmrgfunc_cygming_dll_for_implib () 52444e7590efSmrg{ 524526372658Smrg $debug_cmd 524626372658Smrg 52474e7590efSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52484e7590efSmrg} 52494e7590efSmrg 52504e7590efSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52514e7590efSmrg# 52524e7590efSmrg# The is the core of a fallback implementation of a 52534e7590efSmrg# platform-specific function to extract the name of the 52544e7590efSmrg# DLL associated with the specified import library LIBNAME. 52554e7590efSmrg# 52564e7590efSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52574e7590efSmrg# on the platform and compiler that created the implib. 52584e7590efSmrg# 52594e7590efSmrg# Echos the name of the DLL associated with the 52604e7590efSmrg# specified import library. 52614e7590efSmrgfunc_cygming_dll_for_implib_fallback_core () 52624e7590efSmrg{ 526326372658Smrg $debug_cmd 526426372658Smrg 52654e7590efSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52664e7590efSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52674e7590efSmrg $SED '/^Contents of section '"$match_literal"':/{ 52684e7590efSmrg # Place marker at beginning of archive member dllname section 52694e7590efSmrg s/.*/====MARK====/ 52704e7590efSmrg p 52714e7590efSmrg d 52724e7590efSmrg } 52734e7590efSmrg # These lines can sometimes be longer than 43 characters, but 52744e7590efSmrg # are always uninteresting 52754e7590efSmrg /:[ ]*file format pe[i]\{,1\}-/d 52764e7590efSmrg /^In archive [^:]*:/d 52774e7590efSmrg # Ensure marker is printed 52784e7590efSmrg /^====MARK====/p 52794e7590efSmrg # Remove all lines with less than 43 characters 52804e7590efSmrg /^.\{43\}/!d 52814e7590efSmrg # From remaining lines, remove first 43 characters 52824e7590efSmrg s/^.\{43\}//' | 52834e7590efSmrg $SED -n ' 52844e7590efSmrg # Join marker and all lines until next marker into a single line 52854e7590efSmrg /^====MARK====/ b para 52864e7590efSmrg H 52874e7590efSmrg $ b para 52884e7590efSmrg b 52894e7590efSmrg :para 52904e7590efSmrg x 52914e7590efSmrg s/\n//g 52924e7590efSmrg # Remove the marker 52934e7590efSmrg s/^====MARK====// 52944e7590efSmrg # Remove trailing dots and whitespace 52954e7590efSmrg s/[\. \t]*$// 52964e7590efSmrg # Print 52974e7590efSmrg /./p' | 52984e7590efSmrg # we now have a list, one entry per line, of the stringified 52994e7590efSmrg # contents of the appropriate section of all members of the 530026372658Smrg # archive that possess that section. Heuristic: eliminate 530126372658Smrg # all those that have a first or second character that is 53024e7590efSmrg # a '.' (that is, objdump's representation of an unprintable 53034e7590efSmrg # character.) This should work for all archives with less than 53044e7590efSmrg # 0x302f exports -- but will fail for DLLs whose name actually 53054e7590efSmrg # begins with a literal '.' or a single character followed by 53064e7590efSmrg # a '.'. 53074e7590efSmrg # 53084e7590efSmrg # Of those that remain, print the first one. 53094e7590efSmrg $SED -e '/^\./d;/^.\./d;q' 53104e7590efSmrg} 53114e7590efSmrg 53124e7590efSmrg# func_cygming_dll_for_implib_fallback ARG 53134e7590efSmrg# Platform-specific function to extract the 53144e7590efSmrg# name of the DLL associated with the specified 53154e7590efSmrg# import library ARG. 53164e7590efSmrg# 53174e7590efSmrg# This fallback implementation is for use when $DLLTOOL 53184e7590efSmrg# does not support the --identify-strict option. 53194e7590efSmrg# Invoked by eval'ing the libtool variable 53204e7590efSmrg# $sharedlib_from_linklib_cmd 53214e7590efSmrg# Result is available in the variable 53224e7590efSmrg# $sharedlib_from_linklib_result 53234e7590efSmrgfunc_cygming_dll_for_implib_fallback () 53244e7590efSmrg{ 532526372658Smrg $debug_cmd 532626372658Smrg 532726372658Smrg if func_cygming_gnu_implib_p "$1"; then 53284e7590efSmrg # binutils import library 53294e7590efSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 533026372658Smrg elif func_cygming_ms_implib_p "$1"; then 53314e7590efSmrg # ms-generated import library 53324e7590efSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53334e7590efSmrg else 53344e7590efSmrg # unknown 533526372658Smrg sharedlib_from_linklib_result= 53364e7590efSmrg fi 53374e7590efSmrg} 53384b0ead49Smrg 53394b0ead49Smrg 534049dc963fSmrg# func_extract_an_archive dir oldlib 534149dc963fSmrgfunc_extract_an_archive () 534249dc963fSmrg{ 534326372658Smrg $debug_cmd 534426372658Smrg 534526372658Smrg f_ex_an_ar_dir=$1; shift 534626372658Smrg f_ex_an_ar_oldlib=$1 534726372658Smrg if test yes = "$lock_old_archive_extraction"; then 53487aa89044Smrg lockfile=$f_ex_an_ar_oldlib.lock 53497aa89044Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53507aa89044Smrg func_echo "Waiting for $lockfile to be removed" 53517aa89044Smrg sleep 2 53527aa89044Smrg done 53537aa89044Smrg fi 53547aa89044Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53557aa89044Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 535626372658Smrg if test yes = "$lock_old_archive_extraction"; then 53577aa89044Smrg $opt_dry_run || rm -f "$lockfile" 53587aa89044Smrg fi 535949dc963fSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 536049dc963fSmrg : 536149dc963fSmrg else 536249dc963fSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 536349dc963fSmrg fi 536449dc963fSmrg} 53654b0ead49Smrg 53664b0ead49Smrg 536749dc963fSmrg# func_extract_archives gentop oldlib ... 536849dc963fSmrgfunc_extract_archives () 536949dc963fSmrg{ 537026372658Smrg $debug_cmd 537126372658Smrg 537226372658Smrg my_gentop=$1; shift 537349dc963fSmrg my_oldlibs=${1+"$@"} 537426372658Smrg my_oldobjs= 537526372658Smrg my_xlib= 537626372658Smrg my_xabs= 537726372658Smrg my_xdir= 53784b0ead49Smrg 537949dc963fSmrg for my_xlib in $my_oldlibs; do 538049dc963fSmrg # Extract the objects. 538149dc963fSmrg case $my_xlib in 538226372658Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 538349dc963fSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 538449dc963fSmrg esac 538549dc963fSmrg func_basename "$my_xlib" 538626372658Smrg my_xlib=$func_basename_result 538749dc963fSmrg my_xlib_u=$my_xlib 538849dc963fSmrg while :; do 538949dc963fSmrg case " $extracted_archives " in 539049dc963fSmrg *" $my_xlib_u "*) 539149dc963fSmrg func_arith $extracted_serial + 1 539249dc963fSmrg extracted_serial=$func_arith_result 539349dc963fSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 539449dc963fSmrg *) break ;; 539549dc963fSmrg esac 539649dc963fSmrg done 539749dc963fSmrg extracted_archives="$extracted_archives $my_xlib_u" 539826372658Smrg my_xdir=$my_gentop/$my_xlib_u 53994b0ead49Smrg 540049dc963fSmrg func_mkdir_p "$my_xdir" 54014b0ead49Smrg 540249dc963fSmrg case $host in 540349dc963fSmrg *-darwin*) 540449dc963fSmrg func_verbose "Extracting $my_xabs" 540549dc963fSmrg # Do not bother doing anything if just a dry run 540649dc963fSmrg $opt_dry_run || { 540749dc963fSmrg darwin_orig_dir=`pwd` 540849dc963fSmrg cd $my_xdir || exit $? 540949dc963fSmrg darwin_archive=$my_xabs 541049dc963fSmrg darwin_curdir=`pwd` 541126372658Smrg func_basename "$darwin_archive" 541226372658Smrg darwin_base_archive=$func_basename_result 541349dc963fSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 541449dc963fSmrg if test -n "$darwin_arches"; then 541549dc963fSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 541649dc963fSmrg darwin_arch= 541749dc963fSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 541826372658Smrg for darwin_arch in $darwin_arches; do 541926372658Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 542026372658Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 542126372658Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 542226372658Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 542349dc963fSmrg cd "$darwin_curdir" 542426372658Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 542549dc963fSmrg done # $darwin_arches 542649dc963fSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 542726372658Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 542849dc963fSmrg darwin_file= 542949dc963fSmrg darwin_files= 543049dc963fSmrg for darwin_file in $darwin_filelist; do 54317aa89044Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 543249dc963fSmrg $LIPO -create -output "$darwin_file" $darwin_files 543349dc963fSmrg done # $darwin_filelist 543449dc963fSmrg $RM -rf unfat-$$ 543549dc963fSmrg cd "$darwin_orig_dir" 54364b0ead49Smrg else 543749dc963fSmrg cd $darwin_orig_dir 543849dc963fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 543949dc963fSmrg fi # $darwin_arches 544049dc963fSmrg } # !$opt_dry_run 544149dc963fSmrg ;; 544249dc963fSmrg *) 544349dc963fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 544449dc963fSmrg ;; 544549dc963fSmrg esac 54467aa89044Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 544749dc963fSmrg done 54484b0ead49Smrg 544926372658Smrg func_extract_archives_result=$my_oldobjs 545049dc963fSmrg} 54514b0ead49Smrg 54524b0ead49Smrg 54537aa89044Smrg# func_emit_wrapper [arg=no] 54547aa89044Smrg# 54557aa89044Smrg# Emit a libtool wrapper script on stdout. 54567aa89044Smrg# Don't directly open a file because we may want to 54577aa89044Smrg# incorporate the script contents within a cygwin/mingw 54587aa89044Smrg# wrapper executable. Must ONLY be called from within 54597aa89044Smrg# func_mode_link because it depends on a number of variables 54607aa89044Smrg# set therein. 546149dc963fSmrg# 54627aa89044Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54637aa89044Smrg# variable will take. If 'yes', then the emitted script 546426372658Smrg# will assume that the directory where it is stored is 54657aa89044Smrg# the $objdir directory. This is a cygwin/mingw-specific 54667aa89044Smrg# behavior. 54677aa89044Smrgfunc_emit_wrapper () 546849dc963fSmrg{ 54697aa89044Smrg func_emit_wrapper_arg1=${1-no} 54704b0ead49Smrg 547149dc963fSmrg $ECHO "\ 547249dc963fSmrg#! $SHELL 54734b0ead49Smrg 547449dc963fSmrg# $output - temporary wrapper script for $objdir/$outputname 547526372658Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 547649dc963fSmrg# 547749dc963fSmrg# The $output program cannot be directly executed until all the libtool 547849dc963fSmrg# libraries that it depends on are installed. 547949dc963fSmrg# 548049dc963fSmrg# This wrapper script should never be moved out of the build directory. 548149dc963fSmrg# If it is, it will not operate correctly. 54824b0ead49Smrg 548349dc963fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 548449dc963fSmrg# metacharacters that are still active within double-quoted strings. 548549dc963fSmrgsed_quote_subst='$sed_quote_subst' 54864b0ead49Smrg 548749dc963fSmrg# Be Bourne compatible 548849dc963fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 548949dc963fSmrg emulate sh 549049dc963fSmrg NULLCMD=: 549149dc963fSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 549249dc963fSmrg # is contrary to our usage. Disable this feature. 549349dc963fSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 549449dc963fSmrg setopt NO_GLOB_SUBST 549549dc963fSmrgelse 549649dc963fSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 549749dc963fSmrgfi 549849dc963fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 549949dc963fSmrgDUALCASE=1; export DUALCASE # for MKS sh 55004b0ead49Smrg 550149dc963fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 550249dc963fSmrg# if CDPATH is set. 550349dc963fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55044b0ead49Smrg 550549dc963fSmrgrelink_command=\"$relink_command\" 55064b0ead49Smrg 550749dc963fSmrg# This environment variable determines our operation mode. 550849dc963fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 550949dc963fSmrg # install mode needs the following variables: 551049dc963fSmrg generated_by_libtool_version='$macro_version' 551149dc963fSmrg notinst_deplibs='$notinst_deplibs' 551249dc963fSmrgelse 551349dc963fSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 551449dc963fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55157aa89044Smrg file=\"\$0\"" 55167aa89044Smrg 5517c3e29c03Smrg func_quote_arg pretty "$ECHO" 5518c3e29c03Smrg qECHO=$func_quote_arg_result 55197aa89044Smrg $ECHO "\ 55207aa89044Smrg 55217aa89044Smrg# A function that is used when there is no print builtin or printf. 55227aa89044Smrgfunc_fallback_echo () 55237aa89044Smrg{ 55247aa89044Smrg eval 'cat <<_LTECHO_EOF 55257aa89044Smrg\$1 55267aa89044Smrg_LTECHO_EOF' 55277aa89044Smrg} 5528c3e29c03Smrg ECHO=$qECHO 55297aa89044Smrg fi 55307aa89044Smrg 55317aa89044Smrg# Very basic option parsing. These options are (a) specific to 55327aa89044Smrg# the libtool wrapper, (b) are identical between the wrapper 553326372658Smrg# /script/ and the wrapper /executable/ that is used only on 55347aa89044Smrg# windows platforms, and (c) all begin with the string "--lt-" 553526372658Smrg# (application programs are unlikely to have options that match 55367aa89044Smrg# this pattern). 55377aa89044Smrg# 55387aa89044Smrg# There are only two supported options: --lt-debug and 55397aa89044Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 55407aa89044Smrg# 55417aa89044Smrg# The first argument to this parsing function should be the 55427aa89044Smrg# script's $0 value, followed by "$@". 55437aa89044Smrglt_option_debug= 55447aa89044Smrgfunc_parse_lt_options () 55457aa89044Smrg{ 55467aa89044Smrg lt_script_arg0=\$0 55477aa89044Smrg shift 55487aa89044Smrg for lt_opt 55497aa89044Smrg do 55507aa89044Smrg case \"\$lt_opt\" in 55517aa89044Smrg --lt-debug) lt_option_debug=1 ;; 55527aa89044Smrg --lt-dump-script) 55537aa89044Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55547aa89044Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55557aa89044Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55567aa89044Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 55577aa89044Smrg exit 0 55587aa89044Smrg ;; 55597aa89044Smrg --lt-*) 55607aa89044Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55617aa89044Smrg exit 1 55627aa89044Smrg ;; 55637aa89044Smrg esac 55647aa89044Smrg done 55657aa89044Smrg 55667aa89044Smrg # Print the debug banner immediately: 55677aa89044Smrg if test -n \"\$lt_option_debug\"; then 556826372658Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55697aa89044Smrg fi 55707aa89044Smrg} 55717aa89044Smrg 55727aa89044Smrg# Used when --lt-debug. Prints its arguments to stdout 55737aa89044Smrg# (redirection is the responsibility of the caller) 55747aa89044Smrgfunc_lt_dump_args () 55757aa89044Smrg{ 55767aa89044Smrg lt_dump_args_N=1; 55777aa89044Smrg for lt_arg 55787aa89044Smrg do 557926372658Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55807aa89044Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55817aa89044Smrg done 55827aa89044Smrg} 55837aa89044Smrg 55847aa89044Smrg# Core function for launching the target application 55857aa89044Smrgfunc_exec_program_core () 55867aa89044Smrg{ 558749dc963fSmrg" 55887aa89044Smrg case $host in 55897aa89044Smrg # Backslashes separate directories on plain windows 55907aa89044Smrg *-*-mingw | *-*-os2* | *-cegcc*) 55917aa89044Smrg $ECHO "\ 55927aa89044Smrg if test -n \"\$lt_option_debug\"; then 559326372658Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55947aa89044Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55957aa89044Smrg fi 55967aa89044Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55977aa89044Smrg" 55987aa89044Smrg ;; 55997aa89044Smrg 56007aa89044Smrg *) 56017aa89044Smrg $ECHO "\ 56027aa89044Smrg if test -n \"\$lt_option_debug\"; then 560326372658Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 56047aa89044Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56057aa89044Smrg fi 56067aa89044Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56077aa89044Smrg" 56087aa89044Smrg ;; 56097aa89044Smrg esac 56107aa89044Smrg $ECHO "\ 56117aa89044Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56127aa89044Smrg exit 1 56137aa89044Smrg} 56147aa89044Smrg 56157aa89044Smrg# A function to encapsulate launching the target application 56167aa89044Smrg# Strips options in the --lt-* namespace from \$@ and 56177aa89044Smrg# launches target application with the remaining arguments. 56187aa89044Smrgfunc_exec_program () 56197aa89044Smrg{ 56204e7590efSmrg case \" \$* \" in 56214e7590efSmrg *\\ --lt-*) 56224e7590efSmrg for lt_wr_arg 56234e7590efSmrg do 56244e7590efSmrg case \$lt_wr_arg in 56254e7590efSmrg --lt-*) ;; 56264e7590efSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56274e7590efSmrg esac 56284e7590efSmrg shift 56294e7590efSmrg done ;; 56304e7590efSmrg esac 56317aa89044Smrg func_exec_program_core \${1+\"\$@\"} 56327aa89044Smrg} 56337aa89044Smrg 56347aa89044Smrg # Parse options 56357aa89044Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56364b0ead49Smrg 563749dc963fSmrg # Find the directory that this script lives in. 56387aa89044Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 563949dc963fSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56404b0ead49Smrg 564149dc963fSmrg # Follow symbolic links until we get to the real thisdir. 56427aa89044Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 564349dc963fSmrg while test -n \"\$file\"; do 56447aa89044Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56454b0ead49Smrg 564649dc963fSmrg # If there was a directory component, then change thisdir. 564749dc963fSmrg if test \"x\$destdir\" != \"x\$file\"; then 564849dc963fSmrg case \"\$destdir\" in 564949dc963fSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 565049dc963fSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 56514b0ead49Smrg esac 565249dc963fSmrg fi 56534b0ead49Smrg 56547aa89044Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56557aa89044Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 565649dc963fSmrg done 56574b0ead49Smrg 565849dc963fSmrg # Usually 'no', except on cygwin/mingw when embedded into 565949dc963fSmrg # the cwrapper. 56607aa89044Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 566149dc963fSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 566249dc963fSmrg # special case for '.' 566349dc963fSmrg if test \"\$thisdir\" = \".\"; then 566449dc963fSmrg thisdir=\`pwd\` 566549dc963fSmrg fi 566649dc963fSmrg # remove .libs from thisdir 566749dc963fSmrg case \"\$thisdir\" in 56687aa89044Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 566949dc963fSmrg $objdir ) thisdir=. ;; 567049dc963fSmrg esac 567149dc963fSmrg fi 567249dc963fSmrg 567349dc963fSmrg # Try to get the absolute directory name. 567449dc963fSmrg absdir=\`cd \"\$thisdir\" && pwd\` 567549dc963fSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 567649dc963fSmrg" 567749dc963fSmrg 567826372658Smrg if test yes = "$fast_install"; then 567949dc963fSmrg $ECHO "\ 568049dc963fSmrg program=lt-'$outputname'$exeext 568149dc963fSmrg progdir=\"\$thisdir/$objdir\" 568249dc963fSmrg 568349dc963fSmrg if test ! -f \"\$progdir/\$program\" || 568426372658Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 568549dc963fSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 568649dc963fSmrg 568749dc963fSmrg file=\"\$\$-\$program\" 568849dc963fSmrg 568949dc963fSmrg if test ! -d \"\$progdir\"; then 569049dc963fSmrg $MKDIR \"\$progdir\" 569149dc963fSmrg else 569249dc963fSmrg $RM \"\$progdir/\$file\" 569349dc963fSmrg fi" 569449dc963fSmrg 569549dc963fSmrg $ECHO "\ 569649dc963fSmrg 569749dc963fSmrg # relink executable if necessary 569849dc963fSmrg if test -n \"\$relink_command\"; then 569949dc963fSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 570049dc963fSmrg else 570126372658Smrg \$ECHO \"\$relink_command_output\" >&2 570249dc963fSmrg $RM \"\$progdir/\$file\" 570349dc963fSmrg exit 1 57044b0ead49Smrg fi 570549dc963fSmrg fi 57064b0ead49Smrg 570749dc963fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 570849dc963fSmrg { $RM \"\$progdir/\$program\"; 570949dc963fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 571049dc963fSmrg $RM \"\$progdir/\$file\" 571149dc963fSmrg fi" 571249dc963fSmrg else 571349dc963fSmrg $ECHO "\ 571449dc963fSmrg program='$outputname' 571549dc963fSmrg progdir=\"\$thisdir/$objdir\" 571649dc963fSmrg" 57174b0ead49Smrg fi 57184b0ead49Smrg 571949dc963fSmrg $ECHO "\ 57204b0ead49Smrg 572149dc963fSmrg if test -f \"\$progdir/\$program\"; then" 57224b0ead49Smrg 57234e7590efSmrg # fixup the dll searchpath if we need to. 57244e7590efSmrg # 57254e7590efSmrg # Fix the DLL searchpath if we need to. Do this before prepending 57264e7590efSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 57274e7590efSmrg # libraries must come first. 57284e7590efSmrg if test -n "$dllsearchpath"; then 57294e7590efSmrg $ECHO "\ 57304e7590efSmrg # Add the dll search path components to the executable PATH 57314e7590efSmrg PATH=$dllsearchpath:\$PATH 57324e7590efSmrg" 57334e7590efSmrg fi 57344e7590efSmrg 573549dc963fSmrg # Export our shlibpath_var if we have one. 573626372658Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 573749dc963fSmrg $ECHO "\ 573849dc963fSmrg # Add our own library path to $shlibpath_var 573949dc963fSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 574049dc963fSmrg 574149dc963fSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 574249dc963fSmrg # The second colon is a workaround for a bug in BeOS R4 sed 57437aa89044Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57444b0ead49Smrg 574549dc963fSmrg export $shlibpath_var 574649dc963fSmrg" 57474b0ead49Smrg fi 57484b0ead49Smrg 574949dc963fSmrg $ECHO "\ 575049dc963fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 575149dc963fSmrg # Run the actual program with our arguments. 57527aa89044Smrg func_exec_program \${1+\"\$@\"} 575349dc963fSmrg fi 575449dc963fSmrg else 575549dc963fSmrg # The program doesn't exist. 575626372658Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 575749dc963fSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57587aa89044Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 575949dc963fSmrg exit 1 576049dc963fSmrg fi 576149dc963fSmrgfi\ 576249dc963fSmrg" 576349dc963fSmrg} 57644b0ead49Smrg 57654b0ead49Smrg 576649dc963fSmrg# func_emit_cwrapperexe_src 576749dc963fSmrg# emit the source code for a wrapper executable on stdout 576849dc963fSmrg# Must ONLY be called from within func_mode_link because 576949dc963fSmrg# it depends on a number of variable set therein. 577049dc963fSmrgfunc_emit_cwrapperexe_src () 577149dc963fSmrg{ 577249dc963fSmrg cat <<EOF 57734b0ead49Smrg 577449dc963fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 577526372658Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57764b0ead49Smrg 577749dc963fSmrg The $output program cannot be directly executed until all the libtool 577849dc963fSmrg libraries that it depends on are installed. 57794b0ead49Smrg 578049dc963fSmrg This wrapper executable should never be moved out of the build directory. 578149dc963fSmrg If it is, it will not operate correctly. 578249dc963fSmrg*/ 578349dc963fSmrgEOF 578449dc963fSmrg cat <<"EOF" 57857aa89044Smrg#ifdef _MSC_VER 57867aa89044Smrg# define _CRT_SECURE_NO_DEPRECATE 1 57877aa89044Smrg#endif 578849dc963fSmrg#include <stdio.h> 578949dc963fSmrg#include <stdlib.h> 579049dc963fSmrg#ifdef _MSC_VER 579149dc963fSmrg# include <direct.h> 579249dc963fSmrg# include <process.h> 579349dc963fSmrg# include <io.h> 579449dc963fSmrg#else 579549dc963fSmrg# include <unistd.h> 579649dc963fSmrg# include <stdint.h> 579749dc963fSmrg# ifdef __CYGWIN__ 579849dc963fSmrg# include <io.h> 579949dc963fSmrg# endif 580049dc963fSmrg#endif 580149dc963fSmrg#include <malloc.h> 580249dc963fSmrg#include <stdarg.h> 580349dc963fSmrg#include <assert.h> 580449dc963fSmrg#include <string.h> 580549dc963fSmrg#include <ctype.h> 580649dc963fSmrg#include <errno.h> 580749dc963fSmrg#include <fcntl.h> 580849dc963fSmrg#include <sys/stat.h> 58094b0ead49Smrg 581026372658Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 581126372658Smrg 58127aa89044Smrg/* declarations of non-ANSI functions */ 581326372658Smrg#if defined __MINGW32__ 58147aa89044Smrg# ifdef __STRICT_ANSI__ 58157aa89044Smrgint _putenv (const char *); 58167aa89044Smrg# endif 581726372658Smrg#elif defined __CYGWIN__ 58187aa89044Smrg# ifdef __STRICT_ANSI__ 58197aa89044Smrgchar *realpath (const char *, char *); 58207aa89044Smrgint putenv (char *); 58217aa89044Smrgint setenv (const char *, const char *, int); 58227aa89044Smrg# endif 582326372658Smrg/* #elif defined other_platform || defined ... */ 58247aa89044Smrg#endif 58257aa89044Smrg 58267aa89044Smrg/* portability defines, excluding path handling macros */ 582726372658Smrg#if defined _MSC_VER 58287aa89044Smrg# define setmode _setmode 58297aa89044Smrg# define stat _stat 58307aa89044Smrg# define chmod _chmod 58317aa89044Smrg# define getcwd _getcwd 58327aa89044Smrg# define putenv _putenv 58337aa89044Smrg# define S_IXUSR _S_IEXEC 583426372658Smrg#elif defined __MINGW32__ 58357aa89044Smrg# define setmode _setmode 58367aa89044Smrg# define stat _stat 58377aa89044Smrg# define chmod _chmod 58387aa89044Smrg# define getcwd _getcwd 58397aa89044Smrg# define putenv _putenv 584026372658Smrg#elif defined __CYGWIN__ 58417aa89044Smrg# define HAVE_SETENV 58427aa89044Smrg# define FOPEN_WB "wb" 584326372658Smrg/* #elif defined other platforms ... */ 58447aa89044Smrg#endif 58457aa89044Smrg 584626372658Smrg#if defined PATH_MAX 584749dc963fSmrg# define LT_PATHMAX PATH_MAX 584826372658Smrg#elif defined MAXPATHLEN 584949dc963fSmrg# define LT_PATHMAX MAXPATHLEN 585049dc963fSmrg#else 585149dc963fSmrg# define LT_PATHMAX 1024 585249dc963fSmrg#endif 58534b0ead49Smrg 585449dc963fSmrg#ifndef S_IXOTH 585549dc963fSmrg# define S_IXOTH 0 585649dc963fSmrg#endif 585749dc963fSmrg#ifndef S_IXGRP 585849dc963fSmrg# define S_IXGRP 0 585949dc963fSmrg#endif 58604b0ead49Smrg 58617aa89044Smrg/* path handling portability macros */ 586249dc963fSmrg#ifndef DIR_SEPARATOR 586349dc963fSmrg# define DIR_SEPARATOR '/' 586449dc963fSmrg# define PATH_SEPARATOR ':' 586549dc963fSmrg#endif 58664b0ead49Smrg 586726372658Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 586826372658Smrg defined __OS2__ 586949dc963fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 587049dc963fSmrg# define FOPEN_WB "wb" 587149dc963fSmrg# ifndef DIR_SEPARATOR_2 587249dc963fSmrg# define DIR_SEPARATOR_2 '\\' 587349dc963fSmrg# endif 587449dc963fSmrg# ifndef PATH_SEPARATOR_2 587549dc963fSmrg# define PATH_SEPARATOR_2 ';' 587649dc963fSmrg# endif 587749dc963fSmrg#endif 58784b0ead49Smrg 587949dc963fSmrg#ifndef DIR_SEPARATOR_2 588049dc963fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 588149dc963fSmrg#else /* DIR_SEPARATOR_2 */ 588249dc963fSmrg# define IS_DIR_SEPARATOR(ch) \ 588349dc963fSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 588449dc963fSmrg#endif /* DIR_SEPARATOR_2 */ 58854b0ead49Smrg 588649dc963fSmrg#ifndef PATH_SEPARATOR_2 588749dc963fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 588849dc963fSmrg#else /* PATH_SEPARATOR_2 */ 588949dc963fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 589049dc963fSmrg#endif /* PATH_SEPARATOR_2 */ 58914b0ead49Smrg 589249dc963fSmrg#ifndef FOPEN_WB 589349dc963fSmrg# define FOPEN_WB "w" 589449dc963fSmrg#endif 589549dc963fSmrg#ifndef _O_BINARY 589649dc963fSmrg# define _O_BINARY 0 589749dc963fSmrg#endif 58984b0ead49Smrg 589949dc963fSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 590049dc963fSmrg#define XFREE(stale) do { \ 590126372658Smrg if (stale) { free (stale); stale = 0; } \ 590249dc963fSmrg} while (0) 59034b0ead49Smrg 590426372658Smrg#if defined LT_DEBUGWRAPPER 59057aa89044Smrgstatic int lt_debug = 1; 590649dc963fSmrg#else 59077aa89044Smrgstatic int lt_debug = 0; 590849dc963fSmrg#endif 59094b0ead49Smrg 59107aa89044Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 59114b0ead49Smrg 591249dc963fSmrgvoid *xmalloc (size_t num); 591349dc963fSmrgchar *xstrdup (const char *string); 591449dc963fSmrgconst char *base_name (const char *name); 591549dc963fSmrgchar *find_executable (const char *wrapper); 591649dc963fSmrgchar *chase_symlinks (const char *pathspec); 591749dc963fSmrgint make_executable (const char *path); 591849dc963fSmrgint check_executable (const char *path); 591949dc963fSmrgchar *strendzap (char *str, const char *pat); 59207aa89044Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59217aa89044Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59227aa89044Smrgstatic const char *nonnull (const char *s); 59237aa89044Smrgstatic const char *nonempty (const char *s); 592449dc963fSmrgvoid lt_setenv (const char *name, const char *value); 592549dc963fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 592649dc963fSmrgvoid lt_update_exe_path (const char *name, const char *value); 592749dc963fSmrgvoid lt_update_lib_path (const char *name, const char *value); 59287aa89044Smrgchar **prepare_spawn (char **argv); 59297aa89044Smrgvoid lt_dump_script (FILE *f); 593049dc963fSmrgEOF 593149dc963fSmrg 593249dc963fSmrg cat <<EOF 593326372658Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 593426372658Smrg# define externally_visible volatile 593526372658Smrg#else 593626372658Smrg# define externally_visible __attribute__((externally_visible)) volatile 593726372658Smrg#endif 593826372658Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 593949dc963fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 594049dc963fSmrgEOF 59414b0ead49Smrg 594226372658Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59434e7590efSmrg func_to_host_path "$temp_rpath" 594449dc963fSmrg cat <<EOF 59454e7590efSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 594649dc963fSmrgEOF 594749dc963fSmrg else 594849dc963fSmrg cat <<"EOF" 594949dc963fSmrgconst char * LIB_PATH_VALUE = ""; 595049dc963fSmrgEOF 59514b0ead49Smrg fi 59524b0ead49Smrg 595349dc963fSmrg if test -n "$dllsearchpath"; then 59544e7590efSmrg func_to_host_path "$dllsearchpath:" 595549dc963fSmrg cat <<EOF 595649dc963fSmrgconst char * EXE_PATH_VARNAME = "PATH"; 59574e7590efSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 59584b0ead49SmrgEOF 59594b0ead49Smrg else 596049dc963fSmrg cat <<"EOF" 596149dc963fSmrgconst char * EXE_PATH_VARNAME = ""; 596249dc963fSmrgconst char * EXE_PATH_VALUE = ""; 596349dc963fSmrgEOF 59644b0ead49Smrg fi 596549dc963fSmrg 596626372658Smrg if test yes = "$fast_install"; then 596749dc963fSmrg cat <<EOF 596849dc963fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 596949dc963fSmrgEOF 59704b0ead49Smrg else 597149dc963fSmrg cat <<EOF 597249dc963fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 597349dc963fSmrgEOF 59744b0ead49Smrg fi 59754b0ead49Smrg 59764b0ead49Smrg 597749dc963fSmrg cat <<"EOF" 59784b0ead49Smrg 597949dc963fSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59804b0ead49Smrg 598149dc963fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 598249dc963fSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59837aa89044Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59844b0ead49Smrg 598549dc963fSmrgint 598649dc963fSmrgmain (int argc, char *argv[]) 598749dc963fSmrg{ 598849dc963fSmrg char **newargz; 598949dc963fSmrg int newargc; 599049dc963fSmrg char *tmp_pathspec; 599149dc963fSmrg char *actual_cwrapper_path; 599249dc963fSmrg char *actual_cwrapper_name; 599349dc963fSmrg char *target_name; 599449dc963fSmrg char *lt_argv_zero; 599526372658Smrg int rval = 127; 59964b0ead49Smrg 599749dc963fSmrg int i; 59984b0ead49Smrg 599949dc963fSmrg program_name = (char *) xstrdup (base_name (argv[0])); 600026372658Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 60014b0ead49Smrg 60027aa89044Smrg /* very simple arg parsing; don't want to rely on getopt 60037aa89044Smrg * also, copy all non cwrapper options to newargz, except 60047aa89044Smrg * argz[0], which is handled differently 60057aa89044Smrg */ 60067aa89044Smrg newargc=0; 600749dc963fSmrg for (i = 1; i < argc; i++) 600849dc963fSmrg { 600926372658Smrg if (STREQ (argv[i], dumpscript_opt)) 601049dc963fSmrg { 601149dc963fSmrgEOF 601226372658Smrg case $host in 601349dc963fSmrg *mingw* | *cygwin* ) 601449dc963fSmrg # make stdout use "unix" line endings 601549dc963fSmrg echo " setmode(1,_O_BINARY);" 601649dc963fSmrg ;; 601749dc963fSmrg esac 60184b0ead49Smrg 601949dc963fSmrg cat <<"EOF" 60207aa89044Smrg lt_dump_script (stdout); 602149dc963fSmrg return 0; 602249dc963fSmrg } 602326372658Smrg if (STREQ (argv[i], debug_opt)) 60247aa89044Smrg { 60257aa89044Smrg lt_debug = 1; 60267aa89044Smrg continue; 60277aa89044Smrg } 602826372658Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60297aa89044Smrg { 60307aa89044Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60317aa89044Smrg namespace, but it is not one of the ones we know about and 60327aa89044Smrg have already dealt with, above (inluding dump-script), then 60337aa89044Smrg report an error. Otherwise, targets might begin to believe 60347aa89044Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60357aa89044Smrg namespace. The first time any user complains about this, we'll 60367aa89044Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60377aa89044Smrg or a configure.ac-settable value. 60387aa89044Smrg */ 60397aa89044Smrg lt_fatal (__FILE__, __LINE__, 60407aa89044Smrg "unrecognized %s option: '%s'", 60417aa89044Smrg ltwrapper_option_prefix, argv[i]); 60427aa89044Smrg } 60437aa89044Smrg /* otherwise ... */ 60447aa89044Smrg newargz[++newargc] = xstrdup (argv[i]); 604549dc963fSmrg } 60467aa89044Smrg newargz[++newargc] = NULL; 60477aa89044Smrg 60487aa89044SmrgEOF 60497aa89044Smrg cat <<EOF 60507aa89044Smrg /* The GNU banner must be the first non-error debug message */ 605126372658Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60527aa89044SmrgEOF 60537aa89044Smrg cat <<"EOF" 60547aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60557aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 60564b0ead49Smrg 605749dc963fSmrg tmp_pathspec = find_executable (argv[0]); 605849dc963fSmrg if (tmp_pathspec == NULL) 60597aa89044Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60607aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 60617aa89044Smrg "(main) found exe (before symlink chase) at: %s\n", 60627aa89044Smrg tmp_pathspec); 606349dc963fSmrg 606449dc963fSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60657aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 60667aa89044Smrg "(main) found exe (after symlink chase) at: %s\n", 60677aa89044Smrg actual_cwrapper_path); 606849dc963fSmrg XFREE (tmp_pathspec); 606949dc963fSmrg 60707aa89044Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 607149dc963fSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 607249dc963fSmrg 607349dc963fSmrg /* wrapper name transforms */ 607449dc963fSmrg strendzap (actual_cwrapper_name, ".exe"); 607549dc963fSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 607649dc963fSmrg XFREE (actual_cwrapper_name); 607749dc963fSmrg actual_cwrapper_name = tmp_pathspec; 607849dc963fSmrg tmp_pathspec = 0; 607949dc963fSmrg 608049dc963fSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 608149dc963fSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 608249dc963fSmrg strendzap (target_name, ".exe"); 608349dc963fSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 608449dc963fSmrg XFREE (target_name); 608549dc963fSmrg target_name = tmp_pathspec; 608649dc963fSmrg tmp_pathspec = 0; 608749dc963fSmrg 60887aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 60897aa89044Smrg "(main) libtool target name: %s\n", 60907aa89044Smrg target_name); 609149dc963fSmrgEOF 60924b0ead49Smrg 609349dc963fSmrg cat <<EOF 609449dc963fSmrg newargz[0] = 609549dc963fSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 609649dc963fSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 609749dc963fSmrg strcpy (newargz[0], actual_cwrapper_path); 609849dc963fSmrg strcat (newargz[0], "$objdir"); 609949dc963fSmrg strcat (newargz[0], "/"); 610049dc963fSmrgEOF 61014b0ead49Smrg 610249dc963fSmrg cat <<"EOF" 610349dc963fSmrg /* stop here, and copy so we don't have to do this twice */ 610449dc963fSmrg tmp_pathspec = xstrdup (newargz[0]); 61054b0ead49Smrg 610649dc963fSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 610749dc963fSmrg strcat (newargz[0], actual_cwrapper_name); 61084b0ead49Smrg 610949dc963fSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 611049dc963fSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 611149dc963fSmrg XFREE (tmp_pathspec); 611249dc963fSmrg tmp_pathspec = NULL; 611349dc963fSmrgEOF 61144b0ead49Smrg 611549dc963fSmrg case $host_os in 611649dc963fSmrg mingw*) 611749dc963fSmrg cat <<"EOF" 611849dc963fSmrg { 611949dc963fSmrg char* p; 612049dc963fSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 612149dc963fSmrg { 612249dc963fSmrg *p = '/'; 612349dc963fSmrg } 612449dc963fSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 612549dc963fSmrg { 612649dc963fSmrg *p = '/'; 612749dc963fSmrg } 612849dc963fSmrg } 612949dc963fSmrgEOF 613049dc963fSmrg ;; 613149dc963fSmrg esac 61324b0ead49Smrg 613349dc963fSmrg cat <<"EOF" 613449dc963fSmrg XFREE (target_name); 613549dc963fSmrg XFREE (actual_cwrapper_path); 613649dc963fSmrg XFREE (actual_cwrapper_name); 61374b0ead49Smrg 613849dc963fSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 613949dc963fSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61404e7590efSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61414e7590efSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61424e7590efSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61434e7590efSmrg libraries must come first. */ 614449dc963fSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61454e7590efSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61464b0ead49Smrg 61477aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61487aa89044Smrg nonnull (lt_argv_zero)); 614949dc963fSmrg for (i = 0; i < newargc; i++) 615049dc963fSmrg { 61517aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61527aa89044Smrg i, nonnull (newargz[i])); 615349dc963fSmrg } 61544b0ead49Smrg 615549dc963fSmrgEOF 61564b0ead49Smrg 615749dc963fSmrg case $host_os in 615849dc963fSmrg mingw*) 615949dc963fSmrg cat <<"EOF" 616049dc963fSmrg /* execv doesn't actually work on mingw as expected on unix */ 61617aa89044Smrg newargz = prepare_spawn (newargz); 616226372658Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 616349dc963fSmrg if (rval == -1) 616449dc963fSmrg { 616549dc963fSmrg /* failed to start process */ 61667aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 61677aa89044Smrg "(main) failed to launch target \"%s\": %s\n", 61687aa89044Smrg lt_argv_zero, nonnull (strerror (errno))); 616949dc963fSmrg return 127; 617049dc963fSmrg } 617149dc963fSmrg return rval; 617249dc963fSmrgEOF 617349dc963fSmrg ;; 617449dc963fSmrg *) 617549dc963fSmrg cat <<"EOF" 617649dc963fSmrg execv (lt_argv_zero, newargz); 617749dc963fSmrg return rval; /* =127, but avoids unused variable warning */ 617849dc963fSmrgEOF 617949dc963fSmrg ;; 618049dc963fSmrg esac 61814b0ead49Smrg 618249dc963fSmrg cat <<"EOF" 618349dc963fSmrg} 61844b0ead49Smrg 618549dc963fSmrgvoid * 618649dc963fSmrgxmalloc (size_t num) 618749dc963fSmrg{ 618849dc963fSmrg void *p = (void *) malloc (num); 618949dc963fSmrg if (!p) 61907aa89044Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61914b0ead49Smrg 619249dc963fSmrg return p; 619349dc963fSmrg} 61944b0ead49Smrg 619549dc963fSmrgchar * 619649dc963fSmrgxstrdup (const char *string) 619749dc963fSmrg{ 619849dc963fSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 619949dc963fSmrg string) : NULL; 620049dc963fSmrg} 62014b0ead49Smrg 620249dc963fSmrgconst char * 620349dc963fSmrgbase_name (const char *name) 620449dc963fSmrg{ 620549dc963fSmrg const char *base; 62064b0ead49Smrg 620726372658Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 620849dc963fSmrg /* Skip over the disk name in MSDOS pathnames. */ 620949dc963fSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 621049dc963fSmrg name += 2; 621149dc963fSmrg#endif 62124b0ead49Smrg 621349dc963fSmrg for (base = name; *name; name++) 621449dc963fSmrg if (IS_DIR_SEPARATOR (*name)) 621549dc963fSmrg base = name + 1; 621649dc963fSmrg return base; 621749dc963fSmrg} 62184b0ead49Smrg 621949dc963fSmrgint 622049dc963fSmrgcheck_executable (const char *path) 622149dc963fSmrg{ 622249dc963fSmrg struct stat st; 62234b0ead49Smrg 62247aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62257aa89044Smrg nonempty (path)); 622649dc963fSmrg if ((!path) || (!*path)) 622749dc963fSmrg return 0; 62284b0ead49Smrg 622949dc963fSmrg if ((stat (path, &st) >= 0) 623049dc963fSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 623149dc963fSmrg return 1; 623249dc963fSmrg else 623349dc963fSmrg return 0; 623449dc963fSmrg} 62354b0ead49Smrg 623649dc963fSmrgint 623749dc963fSmrgmake_executable (const char *path) 623849dc963fSmrg{ 623949dc963fSmrg int rval = 0; 624049dc963fSmrg struct stat st; 62414b0ead49Smrg 62427aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62437aa89044Smrg nonempty (path)); 624449dc963fSmrg if ((!path) || (!*path)) 624549dc963fSmrg return 0; 62464b0ead49Smrg 624749dc963fSmrg if (stat (path, &st) >= 0) 624849dc963fSmrg { 624949dc963fSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 625049dc963fSmrg } 625149dc963fSmrg return rval; 625249dc963fSmrg} 62534b0ead49Smrg 625449dc963fSmrg/* Searches for the full path of the wrapper. Returns 625549dc963fSmrg newly allocated full path name if found, NULL otherwise 625649dc963fSmrg Does not chase symlinks, even on platforms that support them. 625749dc963fSmrg*/ 625849dc963fSmrgchar * 625949dc963fSmrgfind_executable (const char *wrapper) 626049dc963fSmrg{ 626149dc963fSmrg int has_slash = 0; 626249dc963fSmrg const char *p; 626349dc963fSmrg const char *p_next; 626449dc963fSmrg /* static buffer for getcwd */ 626549dc963fSmrg char tmp[LT_PATHMAX + 1]; 626626372658Smrg size_t tmp_len; 626749dc963fSmrg char *concat_name; 62684b0ead49Smrg 62697aa89044Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62707aa89044Smrg nonempty (wrapper)); 62714b0ead49Smrg 627249dc963fSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 627349dc963fSmrg return NULL; 62744b0ead49Smrg 627549dc963fSmrg /* Absolute path? */ 627626372658Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 627749dc963fSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 627849dc963fSmrg { 627949dc963fSmrg concat_name = xstrdup (wrapper); 628049dc963fSmrg if (check_executable (concat_name)) 628149dc963fSmrg return concat_name; 628249dc963fSmrg XFREE (concat_name); 628349dc963fSmrg } 628449dc963fSmrg else 628549dc963fSmrg { 628649dc963fSmrg#endif 628749dc963fSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 628849dc963fSmrg { 628949dc963fSmrg concat_name = xstrdup (wrapper); 629049dc963fSmrg if (check_executable (concat_name)) 629149dc963fSmrg return concat_name; 629249dc963fSmrg XFREE (concat_name); 629349dc963fSmrg } 629426372658Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 629549dc963fSmrg } 629649dc963fSmrg#endif 62974b0ead49Smrg 629849dc963fSmrg for (p = wrapper; *p; p++) 629949dc963fSmrg if (*p == '/') 630049dc963fSmrg { 630149dc963fSmrg has_slash = 1; 630249dc963fSmrg break; 630349dc963fSmrg } 630449dc963fSmrg if (!has_slash) 630549dc963fSmrg { 630649dc963fSmrg /* no slashes; search PATH */ 630749dc963fSmrg const char *path = getenv ("PATH"); 630849dc963fSmrg if (path != NULL) 630949dc963fSmrg { 631049dc963fSmrg for (p = path; *p; p = p_next) 631149dc963fSmrg { 631249dc963fSmrg const char *q; 631349dc963fSmrg size_t p_len; 631449dc963fSmrg for (q = p; *q; q++) 631549dc963fSmrg if (IS_PATH_SEPARATOR (*q)) 631649dc963fSmrg break; 631726372658Smrg p_len = (size_t) (q - p); 631849dc963fSmrg p_next = (*q == '\0' ? q : q + 1); 631949dc963fSmrg if (p_len == 0) 632049dc963fSmrg { 632149dc963fSmrg /* empty path: current directory */ 632249dc963fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63237aa89044Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63247aa89044Smrg nonnull (strerror (errno))); 632549dc963fSmrg tmp_len = strlen (tmp); 632649dc963fSmrg concat_name = 632749dc963fSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 632849dc963fSmrg memcpy (concat_name, tmp, tmp_len); 632949dc963fSmrg concat_name[tmp_len] = '/'; 633049dc963fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 633149dc963fSmrg } 633249dc963fSmrg else 633349dc963fSmrg { 633449dc963fSmrg concat_name = 633549dc963fSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 633649dc963fSmrg memcpy (concat_name, p, p_len); 633749dc963fSmrg concat_name[p_len] = '/'; 633849dc963fSmrg strcpy (concat_name + p_len + 1, wrapper); 633949dc963fSmrg } 634049dc963fSmrg if (check_executable (concat_name)) 634149dc963fSmrg return concat_name; 634249dc963fSmrg XFREE (concat_name); 634349dc963fSmrg } 634449dc963fSmrg } 634549dc963fSmrg /* not found in PATH; assume curdir */ 634649dc963fSmrg } 634749dc963fSmrg /* Relative path | not found in path: prepend cwd */ 634849dc963fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63497aa89044Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63507aa89044Smrg nonnull (strerror (errno))); 635149dc963fSmrg tmp_len = strlen (tmp); 635249dc963fSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 635349dc963fSmrg memcpy (concat_name, tmp, tmp_len); 635449dc963fSmrg concat_name[tmp_len] = '/'; 635549dc963fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 63564b0ead49Smrg 635749dc963fSmrg if (check_executable (concat_name)) 635849dc963fSmrg return concat_name; 635949dc963fSmrg XFREE (concat_name); 636049dc963fSmrg return NULL; 636149dc963fSmrg} 63624b0ead49Smrg 636349dc963fSmrgchar * 636449dc963fSmrgchase_symlinks (const char *pathspec) 636549dc963fSmrg{ 636649dc963fSmrg#ifndef S_ISLNK 636749dc963fSmrg return xstrdup (pathspec); 636849dc963fSmrg#else 636949dc963fSmrg char buf[LT_PATHMAX]; 637049dc963fSmrg struct stat s; 637149dc963fSmrg char *tmp_pathspec = xstrdup (pathspec); 637249dc963fSmrg char *p; 637349dc963fSmrg int has_symlinks = 0; 637449dc963fSmrg while (strlen (tmp_pathspec) && !has_symlinks) 637549dc963fSmrg { 63767aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 63777aa89044Smrg "checking path component for symlinks: %s\n", 63787aa89044Smrg tmp_pathspec); 637949dc963fSmrg if (lstat (tmp_pathspec, &s) == 0) 638049dc963fSmrg { 638149dc963fSmrg if (S_ISLNK (s.st_mode) != 0) 638249dc963fSmrg { 638349dc963fSmrg has_symlinks = 1; 638449dc963fSmrg break; 638549dc963fSmrg } 63864b0ead49Smrg 638749dc963fSmrg /* search backwards for last DIR_SEPARATOR */ 638849dc963fSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 638949dc963fSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639049dc963fSmrg p--; 639149dc963fSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639249dc963fSmrg { 639349dc963fSmrg /* no more DIR_SEPARATORS left */ 639449dc963fSmrg break; 639549dc963fSmrg } 639649dc963fSmrg *p = '\0'; 639749dc963fSmrg } 639849dc963fSmrg else 639949dc963fSmrg { 64007aa89044Smrg lt_fatal (__FILE__, __LINE__, 64017aa89044Smrg "error accessing file \"%s\": %s", 64027aa89044Smrg tmp_pathspec, nonnull (strerror (errno))); 640349dc963fSmrg } 640449dc963fSmrg } 640549dc963fSmrg XFREE (tmp_pathspec); 64064b0ead49Smrg 640749dc963fSmrg if (!has_symlinks) 640849dc963fSmrg { 640949dc963fSmrg return xstrdup (pathspec); 641049dc963fSmrg } 64114b0ead49Smrg 641249dc963fSmrg tmp_pathspec = realpath (pathspec, buf); 641349dc963fSmrg if (tmp_pathspec == 0) 641449dc963fSmrg { 64157aa89044Smrg lt_fatal (__FILE__, __LINE__, 64167aa89044Smrg "could not follow symlinks for %s", pathspec); 641749dc963fSmrg } 641849dc963fSmrg return xstrdup (tmp_pathspec); 641949dc963fSmrg#endif 642049dc963fSmrg} 64214b0ead49Smrg 642249dc963fSmrgchar * 642349dc963fSmrgstrendzap (char *str, const char *pat) 642449dc963fSmrg{ 642549dc963fSmrg size_t len, patlen; 64264b0ead49Smrg 642749dc963fSmrg assert (str != NULL); 642849dc963fSmrg assert (pat != NULL); 64294b0ead49Smrg 643049dc963fSmrg len = strlen (str); 643149dc963fSmrg patlen = strlen (pat); 64324b0ead49Smrg 643349dc963fSmrg if (patlen <= len) 643449dc963fSmrg { 643549dc963fSmrg str += len - patlen; 643626372658Smrg if (STREQ (str, pat)) 643749dc963fSmrg *str = '\0'; 643849dc963fSmrg } 643949dc963fSmrg return str; 644049dc963fSmrg} 64414b0ead49Smrg 64427aa89044Smrgvoid 64437aa89044Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64447aa89044Smrg{ 64457aa89044Smrg va_list args; 64467aa89044Smrg if (lt_debug) 64477aa89044Smrg { 64487aa89044Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64497aa89044Smrg va_start (args, fmt); 64507aa89044Smrg (void) vfprintf (stderr, fmt, args); 64517aa89044Smrg va_end (args); 64527aa89044Smrg } 64537aa89044Smrg} 64547aa89044Smrg 645549dc963fSmrgstatic void 64567aa89044Smrglt_error_core (int exit_status, const char *file, 64577aa89044Smrg int line, const char *mode, 645849dc963fSmrg const char *message, va_list ap) 645949dc963fSmrg{ 64607aa89044Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 646149dc963fSmrg vfprintf (stderr, message, ap); 646249dc963fSmrg fprintf (stderr, ".\n"); 64634b0ead49Smrg 646449dc963fSmrg if (exit_status >= 0) 646549dc963fSmrg exit (exit_status); 646649dc963fSmrg} 64674b0ead49Smrg 646849dc963fSmrgvoid 64697aa89044Smrglt_fatal (const char *file, int line, const char *message, ...) 647049dc963fSmrg{ 647149dc963fSmrg va_list ap; 647249dc963fSmrg va_start (ap, message); 64737aa89044Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 647449dc963fSmrg va_end (ap); 647549dc963fSmrg} 64764b0ead49Smrg 64777aa89044Smrgstatic const char * 64787aa89044Smrgnonnull (const char *s) 64797aa89044Smrg{ 64807aa89044Smrg return s ? s : "(null)"; 64817aa89044Smrg} 64827aa89044Smrg 64837aa89044Smrgstatic const char * 64847aa89044Smrgnonempty (const char *s) 64857aa89044Smrg{ 64867aa89044Smrg return (s && !*s) ? "(empty)" : nonnull (s); 64877aa89044Smrg} 64887aa89044Smrg 648949dc963fSmrgvoid 649049dc963fSmrglt_setenv (const char *name, const char *value) 649149dc963fSmrg{ 64927aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 64937aa89044Smrg "(lt_setenv) setting '%s' to '%s'\n", 64947aa89044Smrg nonnull (name), nonnull (value)); 649549dc963fSmrg { 649649dc963fSmrg#ifdef HAVE_SETENV 649749dc963fSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 649849dc963fSmrg char *str = xstrdup (value); 649949dc963fSmrg setenv (name, str, 1); 650049dc963fSmrg#else 650126372658Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 650249dc963fSmrg char *str = XMALLOC (char, len); 650349dc963fSmrg sprintf (str, "%s=%s", name, value); 650449dc963fSmrg if (putenv (str) != EXIT_SUCCESS) 650549dc963fSmrg { 650649dc963fSmrg XFREE (str); 650749dc963fSmrg } 650849dc963fSmrg#endif 650949dc963fSmrg } 651049dc963fSmrg} 65114b0ead49Smrg 651249dc963fSmrgchar * 651349dc963fSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 651449dc963fSmrg{ 651549dc963fSmrg char *new_value; 651649dc963fSmrg if (orig_value && *orig_value) 651749dc963fSmrg { 651826372658Smrg size_t orig_value_len = strlen (orig_value); 651926372658Smrg size_t add_len = strlen (add); 652049dc963fSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 652149dc963fSmrg if (to_end) 652249dc963fSmrg { 652349dc963fSmrg strcpy (new_value, orig_value); 652449dc963fSmrg strcpy (new_value + orig_value_len, add); 652549dc963fSmrg } 652649dc963fSmrg else 652749dc963fSmrg { 652849dc963fSmrg strcpy (new_value, add); 652949dc963fSmrg strcpy (new_value + add_len, orig_value); 653049dc963fSmrg } 653149dc963fSmrg } 653249dc963fSmrg else 653349dc963fSmrg { 653449dc963fSmrg new_value = xstrdup (add); 653549dc963fSmrg } 653649dc963fSmrg return new_value; 653749dc963fSmrg} 65384b0ead49Smrg 653949dc963fSmrgvoid 654049dc963fSmrglt_update_exe_path (const char *name, const char *value) 654149dc963fSmrg{ 65427aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 65437aa89044Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65447aa89044Smrg nonnull (name), nonnull (value)); 65454b0ead49Smrg 654649dc963fSmrg if (name && *name && value && *value) 654749dc963fSmrg { 654849dc963fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 654949dc963fSmrg /* some systems can't cope with a ':'-terminated path #' */ 655026372658Smrg size_t len = strlen (new_value); 655126372658Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 655249dc963fSmrg { 655326372658Smrg new_value[--len] = '\0'; 655449dc963fSmrg } 655549dc963fSmrg lt_setenv (name, new_value); 655649dc963fSmrg XFREE (new_value); 655749dc963fSmrg } 655849dc963fSmrg} 65594b0ead49Smrg 656049dc963fSmrgvoid 656149dc963fSmrglt_update_lib_path (const char *name, const char *value) 656249dc963fSmrg{ 65637aa89044Smrg lt_debugprintf (__FILE__, __LINE__, 65647aa89044Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65657aa89044Smrg nonnull (name), nonnull (value)); 65664b0ead49Smrg 656749dc963fSmrg if (name && *name && value && *value) 656849dc963fSmrg { 656949dc963fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 657049dc963fSmrg lt_setenv (name, new_value); 657149dc963fSmrg XFREE (new_value); 657249dc963fSmrg } 657349dc963fSmrg} 65744b0ead49Smrg 65757aa89044SmrgEOF 65767aa89044Smrg case $host_os in 65777aa89044Smrg mingw*) 65787aa89044Smrg cat <<"EOF" 65797aa89044Smrg 65807aa89044Smrg/* Prepares an argument vector before calling spawn(). 65817aa89044Smrg Note that spawn() does not by itself call the command interpreter 65827aa89044Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65837aa89044Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65847aa89044Smrg GetVersionEx(&v); 65857aa89044Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65867aa89044Smrg }) ? "cmd.exe" : "command.com"). 65877aa89044Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 65887aa89044Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65897aa89044Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65907aa89044Smrg special way: 65917aa89044Smrg - Space and tab are interpreted as delimiters. They are not treated as 65927aa89044Smrg delimiters if they are surrounded by double quotes: "...". 65937aa89044Smrg - Unescaped double quotes are removed from the input. Their only effect is 65947aa89044Smrg that within double quotes, space and tab are treated like normal 65957aa89044Smrg characters. 65967aa89044Smrg - Backslashes not followed by double quotes are not special. 65977aa89044Smrg - But 2*n+1 backslashes followed by a double quote become 65987aa89044Smrg n backslashes followed by a double quote (n >= 0): 65997aa89044Smrg \" -> " 66007aa89044Smrg \\\" -> \" 66017aa89044Smrg \\\\\" -> \\" 66027aa89044Smrg */ 66037aa89044Smrg#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" 66047aa89044Smrg#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" 66057aa89044Smrgchar ** 66067aa89044Smrgprepare_spawn (char **argv) 66077aa89044Smrg{ 66087aa89044Smrg size_t argc; 66097aa89044Smrg char **new_argv; 66107aa89044Smrg size_t i; 66117aa89044Smrg 66127aa89044Smrg /* Count number of arguments. */ 66137aa89044Smrg for (argc = 0; argv[argc] != NULL; argc++) 66147aa89044Smrg ; 66157aa89044Smrg 66167aa89044Smrg /* Allocate new argument vector. */ 66177aa89044Smrg new_argv = XMALLOC (char *, argc + 1); 66187aa89044Smrg 66197aa89044Smrg /* Put quoted arguments into the new argument vector. */ 66207aa89044Smrg for (i = 0; i < argc; i++) 66217aa89044Smrg { 66227aa89044Smrg const char *string = argv[i]; 66237aa89044Smrg 66247aa89044Smrg if (string[0] == '\0') 66257aa89044Smrg new_argv[i] = xstrdup ("\"\""); 66267aa89044Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66277aa89044Smrg { 66287aa89044Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66297aa89044Smrg size_t length; 66307aa89044Smrg unsigned int backslashes; 66317aa89044Smrg const char *s; 66327aa89044Smrg char *quoted_string; 66337aa89044Smrg char *p; 66347aa89044Smrg 66357aa89044Smrg length = 0; 66367aa89044Smrg backslashes = 0; 66377aa89044Smrg if (quote_around) 66387aa89044Smrg length++; 66397aa89044Smrg for (s = string; *s != '\0'; s++) 66407aa89044Smrg { 66417aa89044Smrg char c = *s; 66427aa89044Smrg if (c == '"') 66437aa89044Smrg length += backslashes + 1; 66447aa89044Smrg length++; 66457aa89044Smrg if (c == '\\') 66467aa89044Smrg backslashes++; 66477aa89044Smrg else 66487aa89044Smrg backslashes = 0; 66497aa89044Smrg } 66507aa89044Smrg if (quote_around) 66517aa89044Smrg length += backslashes + 1; 66527aa89044Smrg 66537aa89044Smrg quoted_string = XMALLOC (char, length + 1); 66547aa89044Smrg 66557aa89044Smrg p = quoted_string; 66567aa89044Smrg backslashes = 0; 66577aa89044Smrg if (quote_around) 66587aa89044Smrg *p++ = '"'; 66597aa89044Smrg for (s = string; *s != '\0'; s++) 66607aa89044Smrg { 66617aa89044Smrg char c = *s; 66627aa89044Smrg if (c == '"') 66637aa89044Smrg { 66647aa89044Smrg unsigned int j; 66657aa89044Smrg for (j = backslashes + 1; j > 0; j--) 66667aa89044Smrg *p++ = '\\'; 66677aa89044Smrg } 66687aa89044Smrg *p++ = c; 66697aa89044Smrg if (c == '\\') 66707aa89044Smrg backslashes++; 66717aa89044Smrg else 66727aa89044Smrg backslashes = 0; 66737aa89044Smrg } 66747aa89044Smrg if (quote_around) 66757aa89044Smrg { 66767aa89044Smrg unsigned int j; 66777aa89044Smrg for (j = backslashes; j > 0; j--) 66787aa89044Smrg *p++ = '\\'; 66797aa89044Smrg *p++ = '"'; 66807aa89044Smrg } 66817aa89044Smrg *p = '\0'; 66827aa89044Smrg 66837aa89044Smrg new_argv[i] = quoted_string; 66847aa89044Smrg } 66857aa89044Smrg else 66867aa89044Smrg new_argv[i] = (char *) string; 66877aa89044Smrg } 66887aa89044Smrg new_argv[argc] = NULL; 66897aa89044Smrg 66907aa89044Smrg return new_argv; 66917aa89044Smrg} 66927aa89044SmrgEOF 66937aa89044Smrg ;; 66947aa89044Smrg esac 66957aa89044Smrg 66967aa89044Smrg cat <<"EOF" 66977aa89044Smrgvoid lt_dump_script (FILE* f) 66987aa89044Smrg{ 66997aa89044SmrgEOF 67007aa89044Smrg func_emit_wrapper yes | 67014e7590efSmrg $SED -n -e ' 67024e7590efSmrgs/^\(.\{79\}\)\(..*\)/\1\ 67034e7590efSmrg\2/ 67044e7590efSmrgh 67054e7590efSmrgs/\([\\"]\)/\\\1/g 67064e7590efSmrgs/$/\\n/ 67074e7590efSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67084e7590efSmrgg 67094e7590efSmrgD' 67107aa89044Smrg cat <<"EOF" 67117aa89044Smrg} 671249dc963fSmrgEOF 671349dc963fSmrg} 671449dc963fSmrg# end: func_emit_cwrapperexe_src 67154b0ead49Smrg 67167aa89044Smrg# func_win32_import_lib_p ARG 67177aa89044Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67187aa89044Smrgfunc_win32_import_lib_p () 67197aa89044Smrg{ 672026372658Smrg $debug_cmd 672126372658Smrg 67227aa89044Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67237aa89044Smrg *import*) : ;; 67247aa89044Smrg *) false ;; 67257aa89044Smrg esac 67267aa89044Smrg} 67277aa89044Smrg 672826372658Smrg# func_suncc_cstd_abi 672926372658Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 673026372658Smrg# Several compiler flags select an ABI that is incompatible with the 673126372658Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 673226372658Smrgfunc_suncc_cstd_abi () 673326372658Smrg{ 673426372658Smrg $debug_cmd 673526372658Smrg 673626372658Smrg case " $compile_command " in 673726372658Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 673826372658Smrg suncc_use_cstd_abi=no 673926372658Smrg ;; 674026372658Smrg *) 674126372658Smrg suncc_use_cstd_abi=yes 674226372658Smrg ;; 674326372658Smrg esac 674426372658Smrg} 674526372658Smrg 674649dc963fSmrg# func_mode_link arg... 674749dc963fSmrgfunc_mode_link () 674849dc963fSmrg{ 674926372658Smrg $debug_cmd 675026372658Smrg 675149dc963fSmrg case $host in 675249dc963fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 675349dc963fSmrg # It is impossible to link a dll without this setting, and 675449dc963fSmrg # we shouldn't force the makefile maintainer to figure out 675526372658Smrg # what system we are compiling for in order to pass an extra 675649dc963fSmrg # flag for every libtool invocation. 675749dc963fSmrg # allow_undefined=no 67584b0ead49Smrg 675949dc963fSmrg # FIXME: Unfortunately, there are problems with the above when trying 676026372658Smrg # to make a dll that has undefined symbols, in which case not 676149dc963fSmrg # even a static library is built. For now, we need to specify 676249dc963fSmrg # -no-undefined on the libtool link line when we can be certain 676349dc963fSmrg # that all symbols are satisfied, otherwise we get a static library. 676449dc963fSmrg allow_undefined=yes 676549dc963fSmrg ;; 676649dc963fSmrg *) 676749dc963fSmrg allow_undefined=yes 676849dc963fSmrg ;; 676949dc963fSmrg esac 677049dc963fSmrg libtool_args=$nonopt 677149dc963fSmrg base_compile="$nonopt $@" 677249dc963fSmrg compile_command=$nonopt 677349dc963fSmrg finalize_command=$nonopt 67744b0ead49Smrg 677549dc963fSmrg compile_rpath= 677649dc963fSmrg finalize_rpath= 677749dc963fSmrg compile_shlibpath= 677849dc963fSmrg finalize_shlibpath= 677949dc963fSmrg convenience= 678049dc963fSmrg old_convenience= 678149dc963fSmrg deplibs= 678249dc963fSmrg old_deplibs= 678349dc963fSmrg compiler_flags= 678449dc963fSmrg linker_flags= 678549dc963fSmrg dllsearchpath= 678649dc963fSmrg lib_search_path=`pwd` 678749dc963fSmrg inst_prefix_dir= 678849dc963fSmrg new_inherited_linker_flags= 67894b0ead49Smrg 679049dc963fSmrg avoid_version=no 67917aa89044Smrg bindir= 679249dc963fSmrg dlfiles= 679349dc963fSmrg dlprefiles= 679449dc963fSmrg dlself=no 679549dc963fSmrg export_dynamic=no 679649dc963fSmrg export_symbols= 679749dc963fSmrg export_symbols_regex= 679849dc963fSmrg generated= 679949dc963fSmrg libobjs= 680049dc963fSmrg ltlibs= 680149dc963fSmrg module=no 680249dc963fSmrg no_install=no 680349dc963fSmrg objs= 680426372658Smrg os2dllname= 680549dc963fSmrg non_pic_objects= 680649dc963fSmrg precious_files_regex= 680749dc963fSmrg prefer_static_libs=no 680826372658Smrg preload=false 680949dc963fSmrg prev= 681049dc963fSmrg prevarg= 681149dc963fSmrg release= 681249dc963fSmrg rpath= 681349dc963fSmrg xrpath= 681449dc963fSmrg perm_rpath= 681549dc963fSmrg temp_rpath= 681649dc963fSmrg thread_safe=no 681749dc963fSmrg vinfo= 681849dc963fSmrg vinfo_number=no 681949dc963fSmrg weak_libs= 682026372658Smrg single_module=$wl-single_module 682149dc963fSmrg func_infer_tag $base_compile 682249dc963fSmrg 682349dc963fSmrg # We need to know -static, to get the right output filenames. 682449dc963fSmrg for arg 682549dc963fSmrg do 682649dc963fSmrg case $arg in 682749dc963fSmrg -shared) 682826372658Smrg test yes != "$build_libtool_libs" \ 682926372658Smrg && func_fatal_configuration "cannot build a shared library" 683049dc963fSmrg build_old_libs=no 683149dc963fSmrg break 683249dc963fSmrg ;; 683349dc963fSmrg -all-static | -static | -static-libtool-libs) 683449dc963fSmrg case $arg in 683549dc963fSmrg -all-static) 683626372658Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 683749dc963fSmrg func_warning "complete static linking is impossible in this configuration" 683849dc963fSmrg fi 683949dc963fSmrg if test -n "$link_static_flag"; then 684049dc963fSmrg dlopen_self=$dlopen_self_static 684149dc963fSmrg fi 684249dc963fSmrg prefer_static_libs=yes 684349dc963fSmrg ;; 684449dc963fSmrg -static) 684549dc963fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 684649dc963fSmrg dlopen_self=$dlopen_self_static 684749dc963fSmrg fi 684849dc963fSmrg prefer_static_libs=built 684949dc963fSmrg ;; 685049dc963fSmrg -static-libtool-libs) 685149dc963fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 685249dc963fSmrg dlopen_self=$dlopen_self_static 68534b0ead49Smrg fi 685449dc963fSmrg prefer_static_libs=yes 685549dc963fSmrg ;; 685649dc963fSmrg esac 685749dc963fSmrg build_libtool_libs=no 685849dc963fSmrg build_old_libs=yes 685949dc963fSmrg break 686049dc963fSmrg ;; 686149dc963fSmrg esac 686249dc963fSmrg done 68634b0ead49Smrg 686449dc963fSmrg # See if our shared archives depend on static archives. 686549dc963fSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68664b0ead49Smrg 686749dc963fSmrg # Go through the arguments, transforming them on the way. 686849dc963fSmrg while test "$#" -gt 0; do 686926372658Smrg arg=$1 687049dc963fSmrg shift 6871c3e29c03Smrg func_quote_arg pretty,unquoted "$arg" 6872c3e29c03Smrg qarg=$func_quote_arg_unquoted_result 6873c3e29c03Smrg func_append libtool_args " $func_quote_arg_result" 68744b0ead49Smrg 687549dc963fSmrg # If the previous option needs an argument, assign it. 687649dc963fSmrg if test -n "$prev"; then 687749dc963fSmrg case $prev in 687849dc963fSmrg output) 687949dc963fSmrg func_append compile_command " @OUTPUT@" 688049dc963fSmrg func_append finalize_command " @OUTPUT@" 688149dc963fSmrg ;; 688249dc963fSmrg esac 68834b0ead49Smrg 688449dc963fSmrg case $prev in 68857aa89044Smrg bindir) 688626372658Smrg bindir=$arg 68877aa89044Smrg prev= 68887aa89044Smrg continue 68897aa89044Smrg ;; 689049dc963fSmrg dlfiles|dlprefiles) 689126372658Smrg $preload || { 689249dc963fSmrg # Add the symbol object into the linking commands. 689349dc963fSmrg func_append compile_command " @SYMFILE@" 689449dc963fSmrg func_append finalize_command " @SYMFILE@" 689526372658Smrg preload=: 689626372658Smrg } 689749dc963fSmrg case $arg in 689849dc963fSmrg *.la | *.lo) ;; # We handle these cases below. 689949dc963fSmrg force) 690026372658Smrg if test no = "$dlself"; then 690149dc963fSmrg dlself=needless 690249dc963fSmrg export_dynamic=yes 690349dc963fSmrg fi 690449dc963fSmrg prev= 690549dc963fSmrg continue 690649dc963fSmrg ;; 690749dc963fSmrg self) 690826372658Smrg if test dlprefiles = "$prev"; then 690949dc963fSmrg dlself=yes 691026372658Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 691149dc963fSmrg dlself=yes 69124b0ead49Smrg else 691349dc963fSmrg dlself=needless 691449dc963fSmrg export_dynamic=yes 69154b0ead49Smrg fi 691649dc963fSmrg prev= 691749dc963fSmrg continue 691849dc963fSmrg ;; 691949dc963fSmrg *) 692026372658Smrg if test dlfiles = "$prev"; then 69214e7590efSmrg func_append dlfiles " $arg" 69224b0ead49Smrg else 69234e7590efSmrg func_append dlprefiles " $arg" 69244b0ead49Smrg fi 692549dc963fSmrg prev= 692649dc963fSmrg continue 692749dc963fSmrg ;; 692849dc963fSmrg esac 692949dc963fSmrg ;; 693049dc963fSmrg expsyms) 693126372658Smrg export_symbols=$arg 693249dc963fSmrg test -f "$arg" \ 693326372658Smrg || func_fatal_error "symbol file '$arg' does not exist" 693449dc963fSmrg prev= 693549dc963fSmrg continue 693649dc963fSmrg ;; 693749dc963fSmrg expsyms_regex) 693826372658Smrg export_symbols_regex=$arg 693949dc963fSmrg prev= 694049dc963fSmrg continue 694149dc963fSmrg ;; 694249dc963fSmrg framework) 69434b0ead49Smrg case $host in 694449dc963fSmrg *-*-darwin*) 694549dc963fSmrg case "$deplibs " in 694649dc963fSmrg *" $qarg.ltframework "*) ;; 69474e7590efSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 694849dc963fSmrg ;; 694949dc963fSmrg esac 695049dc963fSmrg ;; 69514b0ead49Smrg esac 695249dc963fSmrg prev= 695349dc963fSmrg continue 69544b0ead49Smrg ;; 695549dc963fSmrg inst_prefix) 695626372658Smrg inst_prefix_dir=$arg 695726372658Smrg prev= 695826372658Smrg continue 695926372658Smrg ;; 696026372658Smrg mllvm) 696126372658Smrg # Clang does not use LLVM to link, so we can simply discard any 696226372658Smrg # '-mllvm $arg' options when doing the link step. 696349dc963fSmrg prev= 696449dc963fSmrg continue 69654b0ead49Smrg ;; 696649dc963fSmrg objectlist) 696749dc963fSmrg if test -f "$arg"; then 696849dc963fSmrg save_arg=$arg 696949dc963fSmrg moreargs= 697049dc963fSmrg for fil in `cat "$save_arg"` 697149dc963fSmrg do 69724e7590efSmrg# func_append moreargs " $fil" 697349dc963fSmrg arg=$fil 697449dc963fSmrg # A libtool-controlled object. 69754b0ead49Smrg 697649dc963fSmrg # Check to see that this really is a libtool object. 697749dc963fSmrg if func_lalib_unsafe_p "$arg"; then 697849dc963fSmrg pic_object= 697949dc963fSmrg non_pic_object= 69804b0ead49Smrg 698149dc963fSmrg # Read the .lo file 698249dc963fSmrg func_source "$arg" 69834b0ead49Smrg 698449dc963fSmrg if test -z "$pic_object" || 698549dc963fSmrg test -z "$non_pic_object" || 698626372658Smrg test none = "$pic_object" && 698726372658Smrg test none = "$non_pic_object"; then 698826372658Smrg func_fatal_error "cannot find name of object for '$arg'" 698949dc963fSmrg fi 69904b0ead49Smrg 699149dc963fSmrg # Extract subdirectory from the argument. 699249dc963fSmrg func_dirname "$arg" "/" "" 699326372658Smrg xdir=$func_dirname_result 69944b0ead49Smrg 699526372658Smrg if test none != "$pic_object"; then 699649dc963fSmrg # Prepend the subdirectory the object is found in. 699726372658Smrg pic_object=$xdir$pic_object 69984b0ead49Smrg 699926372658Smrg if test dlfiles = "$prev"; then 700026372658Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70014e7590efSmrg func_append dlfiles " $pic_object" 700249dc963fSmrg prev= 700349dc963fSmrg continue 700449dc963fSmrg else 700549dc963fSmrg # If libtool objects are unsupported, then we need to preload. 700649dc963fSmrg prev=dlprefiles 700749dc963fSmrg fi 700849dc963fSmrg fi 70094b0ead49Smrg 701049dc963fSmrg # CHECK ME: I think I busted this. -Ossama 701126372658Smrg if test dlprefiles = "$prev"; then 701249dc963fSmrg # Preload the old-style object. 70134e7590efSmrg func_append dlprefiles " $pic_object" 701449dc963fSmrg prev= 701549dc963fSmrg fi 70164b0ead49Smrg 701749dc963fSmrg # A PIC object. 701849dc963fSmrg func_append libobjs " $pic_object" 701926372658Smrg arg=$pic_object 702049dc963fSmrg fi 70214b0ead49Smrg 702249dc963fSmrg # Non-PIC object. 702326372658Smrg if test none != "$non_pic_object"; then 702449dc963fSmrg # Prepend the subdirectory the object is found in. 702526372658Smrg non_pic_object=$xdir$non_pic_object 70264b0ead49Smrg 702749dc963fSmrg # A standard non-PIC object 702849dc963fSmrg func_append non_pic_objects " $non_pic_object" 702926372658Smrg if test -z "$pic_object" || test none = "$pic_object"; then 703026372658Smrg arg=$non_pic_object 703149dc963fSmrg fi 703249dc963fSmrg else 703349dc963fSmrg # If the PIC object exists, use it instead. 703449dc963fSmrg # $xdir was prepended to $pic_object above. 703526372658Smrg non_pic_object=$pic_object 703649dc963fSmrg func_append non_pic_objects " $non_pic_object" 703749dc963fSmrg fi 703849dc963fSmrg else 703949dc963fSmrg # Only an error if not doing a dry-run. 704049dc963fSmrg if $opt_dry_run; then 704149dc963fSmrg # Extract subdirectory from the argument. 704249dc963fSmrg func_dirname "$arg" "/" "" 704326372658Smrg xdir=$func_dirname_result 704449dc963fSmrg 704549dc963fSmrg func_lo2o "$arg" 704649dc963fSmrg pic_object=$xdir$objdir/$func_lo2o_result 704749dc963fSmrg non_pic_object=$xdir$func_lo2o_result 704849dc963fSmrg func_append libobjs " $pic_object" 704949dc963fSmrg func_append non_pic_objects " $non_pic_object" 705049dc963fSmrg else 705126372658Smrg func_fatal_error "'$arg' is not a valid libtool object" 705249dc963fSmrg fi 705349dc963fSmrg fi 705449dc963fSmrg done 70554b0ead49Smrg else 705626372658Smrg func_fatal_error "link input file '$arg' does not exist" 70574b0ead49Smrg fi 705849dc963fSmrg arg=$save_arg 705949dc963fSmrg prev= 706049dc963fSmrg continue 706149dc963fSmrg ;; 706226372658Smrg os2dllname) 706326372658Smrg os2dllname=$arg 706426372658Smrg prev= 706526372658Smrg continue 706626372658Smrg ;; 706749dc963fSmrg precious_regex) 706826372658Smrg precious_files_regex=$arg 706949dc963fSmrg prev= 707049dc963fSmrg continue 707149dc963fSmrg ;; 707249dc963fSmrg release) 707326372658Smrg release=-$arg 707449dc963fSmrg prev= 707549dc963fSmrg continue 707649dc963fSmrg ;; 707749dc963fSmrg rpath | xrpath) 707849dc963fSmrg # We need an absolute path. 707949dc963fSmrg case $arg in 708049dc963fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 708149dc963fSmrg *) 708249dc963fSmrg func_fatal_error "only absolute run-paths are allowed" 708349dc963fSmrg ;; 708449dc963fSmrg esac 708526372658Smrg if test rpath = "$prev"; then 708649dc963fSmrg case "$rpath " in 708749dc963fSmrg *" $arg "*) ;; 70884e7590efSmrg *) func_append rpath " $arg" ;; 708949dc963fSmrg esac 70904b0ead49Smrg else 709149dc963fSmrg case "$xrpath " in 709249dc963fSmrg *" $arg "*) ;; 70934e7590efSmrg *) func_append xrpath " $arg" ;; 709449dc963fSmrg esac 70954b0ead49Smrg fi 709649dc963fSmrg prev= 709749dc963fSmrg continue 709849dc963fSmrg ;; 709949dc963fSmrg shrext) 710026372658Smrg shrext_cmds=$arg 710149dc963fSmrg prev= 710249dc963fSmrg continue 710349dc963fSmrg ;; 710449dc963fSmrg weak) 71054e7590efSmrg func_append weak_libs " $arg" 710649dc963fSmrg prev= 710749dc963fSmrg continue 710849dc963fSmrg ;; 7109c3e29c03Smrg xassembler) 7110c3e29c03Smrg func_append compiler_flags " -Xassembler $qarg" 7111c3e29c03Smrg prev= 7112c3e29c03Smrg func_append compile_command " -Xassembler $qarg" 7113c3e29c03Smrg func_append finalize_command " -Xassembler $qarg" 7114c3e29c03Smrg continue 7115c3e29c03Smrg ;; 711649dc963fSmrg xcclinker) 71174e7590efSmrg func_append linker_flags " $qarg" 71184e7590efSmrg func_append compiler_flags " $qarg" 711949dc963fSmrg prev= 712049dc963fSmrg func_append compile_command " $qarg" 712149dc963fSmrg func_append finalize_command " $qarg" 712249dc963fSmrg continue 712349dc963fSmrg ;; 712449dc963fSmrg xcompiler) 71254e7590efSmrg func_append compiler_flags " $qarg" 712649dc963fSmrg prev= 712749dc963fSmrg func_append compile_command " $qarg" 712849dc963fSmrg func_append finalize_command " $qarg" 712949dc963fSmrg continue 713049dc963fSmrg ;; 713149dc963fSmrg xlinker) 71324e7590efSmrg func_append linker_flags " $qarg" 71334e7590efSmrg func_append compiler_flags " $wl$qarg" 713449dc963fSmrg prev= 713549dc963fSmrg func_append compile_command " $wl$qarg" 713649dc963fSmrg func_append finalize_command " $wl$qarg" 713749dc963fSmrg continue 713849dc963fSmrg ;; 713949dc963fSmrg *) 714049dc963fSmrg eval "$prev=\"\$arg\"" 714149dc963fSmrg prev= 714249dc963fSmrg continue 714349dc963fSmrg ;; 71444b0ead49Smrg esac 714549dc963fSmrg fi # test -n "$prev" 71464b0ead49Smrg 714726372658Smrg prevarg=$arg 71484b0ead49Smrg 714949dc963fSmrg case $arg in 715049dc963fSmrg -all-static) 715149dc963fSmrg if test -n "$link_static_flag"; then 715249dc963fSmrg # See comment for -static flag below, for more details. 715349dc963fSmrg func_append compile_command " $link_static_flag" 715449dc963fSmrg func_append finalize_command " $link_static_flag" 715549dc963fSmrg fi 715649dc963fSmrg continue 715749dc963fSmrg ;; 71584b0ead49Smrg 715949dc963fSmrg -allow-undefined) 716049dc963fSmrg # FIXME: remove this flag sometime in the future. 716126372658Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 716249dc963fSmrg ;; 71634b0ead49Smrg 716449dc963fSmrg -avoid-version) 716549dc963fSmrg avoid_version=yes 716649dc963fSmrg continue 716749dc963fSmrg ;; 71684b0ead49Smrg 71697aa89044Smrg -bindir) 71707aa89044Smrg prev=bindir 71717aa89044Smrg continue 71727aa89044Smrg ;; 71737aa89044Smrg 717449dc963fSmrg -dlopen) 717549dc963fSmrg prev=dlfiles 717649dc963fSmrg continue 717749dc963fSmrg ;; 71784b0ead49Smrg 717949dc963fSmrg -dlpreopen) 718049dc963fSmrg prev=dlprefiles 718149dc963fSmrg continue 718249dc963fSmrg ;; 71834b0ead49Smrg 718449dc963fSmrg -export-dynamic) 718549dc963fSmrg export_dynamic=yes 718649dc963fSmrg continue 718749dc963fSmrg ;; 71884b0ead49Smrg 718949dc963fSmrg -export-symbols | -export-symbols-regex) 719049dc963fSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 719149dc963fSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 719249dc963fSmrg fi 719326372658Smrg if test X-export-symbols = "X$arg"; then 719449dc963fSmrg prev=expsyms 719549dc963fSmrg else 719649dc963fSmrg prev=expsyms_regex 719749dc963fSmrg fi 719849dc963fSmrg continue 719949dc963fSmrg ;; 72004b0ead49Smrg 720149dc963fSmrg -framework) 720249dc963fSmrg prev=framework 720349dc963fSmrg continue 720449dc963fSmrg ;; 72054b0ead49Smrg 720649dc963fSmrg -inst-prefix-dir) 720749dc963fSmrg prev=inst_prefix 720849dc963fSmrg continue 720949dc963fSmrg ;; 72104b0ead49Smrg 721149dc963fSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 721249dc963fSmrg # so, if we see these flags be careful not to treat them like -L 721349dc963fSmrg -L[A-Z][A-Z]*:*) 721449dc963fSmrg case $with_gcc/$host in 721549dc963fSmrg no/*-*-irix* | /*-*-irix*) 721649dc963fSmrg func_append compile_command " $arg" 721749dc963fSmrg func_append finalize_command " $arg" 721849dc963fSmrg ;; 721949dc963fSmrg esac 722049dc963fSmrg continue 722149dc963fSmrg ;; 72224b0ead49Smrg 722349dc963fSmrg -L*) 72244e7590efSmrg func_stripname "-L" '' "$arg" 72254e7590efSmrg if test -z "$func_stripname_result"; then 722649dc963fSmrg if test "$#" -gt 0; then 722726372658Smrg func_fatal_error "require no space between '-L' and '$1'" 722849dc963fSmrg else 722926372658Smrg func_fatal_error "need path for '-L' option" 723049dc963fSmrg fi 723149dc963fSmrg fi 72324e7590efSmrg func_resolve_sysroot "$func_stripname_result" 72334e7590efSmrg dir=$func_resolve_sysroot_result 723449dc963fSmrg # We need an absolute path. 723549dc963fSmrg case $dir in 723649dc963fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 723749dc963fSmrg *) 723849dc963fSmrg absdir=`cd "$dir" && pwd` 723949dc963fSmrg test -z "$absdir" && \ 724026372658Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 724126372658Smrg dir=$absdir 724249dc963fSmrg ;; 724349dc963fSmrg esac 724449dc963fSmrg case "$deplibs " in 72454e7590efSmrg *" -L$dir "* | *" $arg "*) 72464e7590efSmrg # Will only happen for absolute or sysroot arguments 72474e7590efSmrg ;; 724849dc963fSmrg *) 72494e7590efSmrg # Preserve sysroot, but never include relative directories 72504e7590efSmrg case $dir in 72514e7590efSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72524e7590efSmrg *) func_append deplibs " -L$dir" ;; 72534e7590efSmrg esac 72544e7590efSmrg func_append lib_search_path " $dir" 725549dc963fSmrg ;; 725649dc963fSmrg esac 725749dc963fSmrg case $host in 725849dc963fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72597aa89044Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 726049dc963fSmrg case :$dllsearchpath: in 726149dc963fSmrg *":$dir:"*) ;; 726249dc963fSmrg ::) dllsearchpath=$dir;; 72634e7590efSmrg *) func_append dllsearchpath ":$dir";; 726449dc963fSmrg esac 726549dc963fSmrg case :$dllsearchpath: in 726649dc963fSmrg *":$testbindir:"*) ;; 726749dc963fSmrg ::) dllsearchpath=$testbindir;; 72684e7590efSmrg *) func_append dllsearchpath ":$testbindir";; 726949dc963fSmrg esac 727049dc963fSmrg ;; 727149dc963fSmrg esac 727249dc963fSmrg continue 727349dc963fSmrg ;; 72744b0ead49Smrg 727549dc963fSmrg -l*) 727626372658Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 727749dc963fSmrg case $host in 72787aa89044Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 727949dc963fSmrg # These systems don't actually have a C or math library (as such) 728049dc963fSmrg continue 728149dc963fSmrg ;; 728249dc963fSmrg *-*-os2*) 728349dc963fSmrg # These systems don't actually have a C library (as such) 728426372658Smrg test X-lc = "X$arg" && continue 728549dc963fSmrg ;; 7286c3e29c03Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 728749dc963fSmrg # Do not include libc due to us having libc/libc_r. 728826372658Smrg test X-lc = "X$arg" && continue 728949dc963fSmrg ;; 729049dc963fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 729149dc963fSmrg # Rhapsody C and math libraries are in the System framework 72924e7590efSmrg func_append deplibs " System.ltframework" 729349dc963fSmrg continue 729449dc963fSmrg ;; 729549dc963fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 729649dc963fSmrg # Causes problems with __ctype 729726372658Smrg test X-lc = "X$arg" && continue 729849dc963fSmrg ;; 729949dc963fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 730049dc963fSmrg # Compiler inserts libc in the correct place for threads to work 730126372658Smrg test X-lc = "X$arg" && continue 730249dc963fSmrg ;; 730349dc963fSmrg esac 730426372658Smrg elif test X-lc_r = "X$arg"; then 730549dc963fSmrg case $host in 7306c3e29c03Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 730749dc963fSmrg # Do not include libc_r directly, use -pthread flag. 730849dc963fSmrg continue 730949dc963fSmrg ;; 731049dc963fSmrg esac 731149dc963fSmrg fi 73124e7590efSmrg func_append deplibs " $arg" 731349dc963fSmrg continue 731449dc963fSmrg ;; 73154b0ead49Smrg 731626372658Smrg -mllvm) 731726372658Smrg prev=mllvm 731826372658Smrg continue 731926372658Smrg ;; 732026372658Smrg 732149dc963fSmrg -module) 732249dc963fSmrg module=yes 732349dc963fSmrg continue 732449dc963fSmrg ;; 73254b0ead49Smrg 732649dc963fSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 732749dc963fSmrg # classes, name mangling, and exception handling. 732849dc963fSmrg # Darwin uses the -arch flag to determine output architecture. 73294e7590efSmrg -model|-arch|-isysroot|--sysroot) 73304e7590efSmrg func_append compiler_flags " $arg" 733149dc963fSmrg func_append compile_command " $arg" 733249dc963fSmrg func_append finalize_command " $arg" 733349dc963fSmrg prev=xcompiler 733449dc963fSmrg continue 733549dc963fSmrg ;; 7336c3e29c03Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337c3e29c03Smrg -pthread) 7338c3e29c03Smrg case $host in 7339c3e29c03Smrg *solaris2*) ;; 7340c3e29c03Smrg *) 7341c3e29c03Smrg case "$new_inherited_linker_flags " in 7342c3e29c03Smrg *" $arg "*) ;; 7343c3e29c03Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344c3e29c03Smrg esac 7345c3e29c03Smrg ;; 7346c3e29c03Smrg esac 7347c3e29c03Smrg continue 7348c3e29c03Smrg ;; 7349c3e29c03Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73504e7590efSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73514e7590efSmrg func_append compiler_flags " $arg" 735249dc963fSmrg func_append compile_command " $arg" 735349dc963fSmrg func_append finalize_command " $arg" 735449dc963fSmrg case "$new_inherited_linker_flags " in 735549dc963fSmrg *" $arg "*) ;; 73564e7590efSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 735749dc963fSmrg esac 735849dc963fSmrg continue 735949dc963fSmrg ;; 73604b0ead49Smrg 736149dc963fSmrg -multi_module) 736226372658Smrg single_module=$wl-multi_module 736349dc963fSmrg continue 736449dc963fSmrg ;; 73654b0ead49Smrg 736649dc963fSmrg -no-fast-install) 736749dc963fSmrg fast_install=no 736849dc963fSmrg continue 736949dc963fSmrg ;; 73704b0ead49Smrg 737149dc963fSmrg -no-install) 737249dc963fSmrg case $host in 737349dc963fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 737449dc963fSmrg # The PATH hackery in wrapper scripts is required on Windows 737549dc963fSmrg # and Darwin in order for the loader to find any dlls it needs. 737626372658Smrg func_warning "'-no-install' is ignored for $host" 737726372658Smrg func_warning "assuming '-no-fast-install' instead" 737849dc963fSmrg fast_install=no 737949dc963fSmrg ;; 738049dc963fSmrg *) no_install=yes ;; 738149dc963fSmrg esac 738249dc963fSmrg continue 738349dc963fSmrg ;; 73844b0ead49Smrg 738549dc963fSmrg -no-undefined) 738649dc963fSmrg allow_undefined=no 738749dc963fSmrg continue 738849dc963fSmrg ;; 73894b0ead49Smrg 739049dc963fSmrg -objectlist) 739149dc963fSmrg prev=objectlist 739249dc963fSmrg continue 739349dc963fSmrg ;; 73944b0ead49Smrg 739526372658Smrg -os2dllname) 739626372658Smrg prev=os2dllname 739726372658Smrg continue 739826372658Smrg ;; 739926372658Smrg 740049dc963fSmrg -o) prev=output ;; 74014b0ead49Smrg 740249dc963fSmrg -precious-files-regex) 740349dc963fSmrg prev=precious_regex 740449dc963fSmrg continue 740549dc963fSmrg ;; 74064b0ead49Smrg 740749dc963fSmrg -release) 740849dc963fSmrg prev=release 740949dc963fSmrg continue 741049dc963fSmrg ;; 74114b0ead49Smrg 741249dc963fSmrg -rpath) 741349dc963fSmrg prev=rpath 741449dc963fSmrg continue 741549dc963fSmrg ;; 74164b0ead49Smrg 741749dc963fSmrg -R) 741849dc963fSmrg prev=xrpath 741949dc963fSmrg continue 742049dc963fSmrg ;; 74214b0ead49Smrg 742249dc963fSmrg -R*) 742349dc963fSmrg func_stripname '-R' '' "$arg" 742449dc963fSmrg dir=$func_stripname_result 742549dc963fSmrg # We need an absolute path. 742649dc963fSmrg case $dir in 742749dc963fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74284e7590efSmrg =*) 74294e7590efSmrg func_stripname '=' '' "$dir" 74304e7590efSmrg dir=$lt_sysroot$func_stripname_result 74314e7590efSmrg ;; 743249dc963fSmrg *) 743349dc963fSmrg func_fatal_error "only absolute run-paths are allowed" 743449dc963fSmrg ;; 743549dc963fSmrg esac 743649dc963fSmrg case "$xrpath " in 743749dc963fSmrg *" $dir "*) ;; 74384e7590efSmrg *) func_append xrpath " $dir" ;; 743949dc963fSmrg esac 744049dc963fSmrg continue 744149dc963fSmrg ;; 74424b0ead49Smrg 744349dc963fSmrg -shared) 744449dc963fSmrg # The effects of -shared are defined in a previous loop. 744549dc963fSmrg continue 744649dc963fSmrg ;; 74474b0ead49Smrg 744849dc963fSmrg -shrext) 744949dc963fSmrg prev=shrext 745049dc963fSmrg continue 745149dc963fSmrg ;; 74524b0ead49Smrg 745349dc963fSmrg -static | -static-libtool-libs) 745449dc963fSmrg # The effects of -static are defined in a previous loop. 745549dc963fSmrg # We used to do the same as -all-static on platforms that 745649dc963fSmrg # didn't have a PIC flag, but the assumption that the effects 745749dc963fSmrg # would be equivalent was wrong. It would break on at least 745849dc963fSmrg # Digital Unix and AIX. 745949dc963fSmrg continue 746049dc963fSmrg ;; 74614b0ead49Smrg 746249dc963fSmrg -thread-safe) 746349dc963fSmrg thread_safe=yes 746449dc963fSmrg continue 746549dc963fSmrg ;; 74664b0ead49Smrg 746749dc963fSmrg -version-info) 746849dc963fSmrg prev=vinfo 746949dc963fSmrg continue 747049dc963fSmrg ;; 74714b0ead49Smrg 747249dc963fSmrg -version-number) 747349dc963fSmrg prev=vinfo 747449dc963fSmrg vinfo_number=yes 747549dc963fSmrg continue 747649dc963fSmrg ;; 74774b0ead49Smrg 747849dc963fSmrg -weak) 747949dc963fSmrg prev=weak 748049dc963fSmrg continue 748149dc963fSmrg ;; 74824b0ead49Smrg 748349dc963fSmrg -Wc,*) 748449dc963fSmrg func_stripname '-Wc,' '' "$arg" 748549dc963fSmrg args=$func_stripname_result 748649dc963fSmrg arg= 748726372658Smrg save_ifs=$IFS; IFS=, 748849dc963fSmrg for flag in $args; do 748926372658Smrg IFS=$save_ifs 7490c3e29c03Smrg func_quote_arg pretty "$flag" 7491c3e29c03Smrg func_append arg " $func_quote_arg_result" 7492c3e29c03Smrg func_append compiler_flags " $func_quote_arg_result" 749349dc963fSmrg done 749426372658Smrg IFS=$save_ifs 749549dc963fSmrg func_stripname ' ' '' "$arg" 749649dc963fSmrg arg=$func_stripname_result 749749dc963fSmrg ;; 74984b0ead49Smrg 749949dc963fSmrg -Wl,*) 750049dc963fSmrg func_stripname '-Wl,' '' "$arg" 750149dc963fSmrg args=$func_stripname_result 750249dc963fSmrg arg= 750326372658Smrg save_ifs=$IFS; IFS=, 750449dc963fSmrg for flag in $args; do 750526372658Smrg IFS=$save_ifs 7506c3e29c03Smrg func_quote_arg pretty "$flag" 7507c3e29c03Smrg func_append arg " $wl$func_quote_arg_result" 7508c3e29c03Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7509c3e29c03Smrg func_append linker_flags " $func_quote_arg_result" 751049dc963fSmrg done 751126372658Smrg IFS=$save_ifs 751249dc963fSmrg func_stripname ' ' '' "$arg" 751349dc963fSmrg arg=$func_stripname_result 751449dc963fSmrg ;; 75154b0ead49Smrg 7516c3e29c03Smrg -Xassembler) 7517c3e29c03Smrg prev=xassembler 7518c3e29c03Smrg continue 7519c3e29c03Smrg ;; 7520c3e29c03Smrg 752149dc963fSmrg -Xcompiler) 752249dc963fSmrg prev=xcompiler 752349dc963fSmrg continue 752449dc963fSmrg ;; 75254b0ead49Smrg 752649dc963fSmrg -Xlinker) 752749dc963fSmrg prev=xlinker 752849dc963fSmrg continue 752949dc963fSmrg ;; 75304b0ead49Smrg 753149dc963fSmrg -XCClinker) 753249dc963fSmrg prev=xcclinker 753349dc963fSmrg continue 753449dc963fSmrg ;; 75354b0ead49Smrg 753649dc963fSmrg # -msg_* for osf cc 753749dc963fSmrg -msg_*) 7538c3e29c03Smrg func_quote_arg pretty "$arg" 7539c3e29c03Smrg arg=$func_quote_arg_result 754049dc963fSmrg ;; 75414b0ead49Smrg 75427aa89044Smrg # Flags to be passed through unchanged, with rationale: 75437aa89044Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75447aa89044Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 75457aa89044Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75467aa89044Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75477aa89044Smrg # -q* compiler args for the IBM compiler 75487aa89044Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75497aa89044Smrg # -F/path path to uninstalled frameworks, gcc on darwin 75507aa89044Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 755126372658Smrg # -fstack-protector* stack protector flags for GCC 75527aa89044Smrg # @file GCC response files 75537aa89044Smrg # -tp=* Portland pgcc target processor selection 75544e7590efSmrg # --sysroot=* for sysroot support 755526372658Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556c3e29c03Smrg # -specs=* GCC specs files 755726372658Smrg # -stdlib=* select c++ std lib with clang 7558c3e29c03Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559c3e29c03Smrg # -fuse-ld=* Linker select flags for GCC 7560c3e29c03Smrg # -Wa,* Pass flags directly to the assembler 756149dc963fSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75624e7590efSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563c3e29c03Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564c3e29c03Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565c3e29c03Smrg func_quote_arg pretty "$arg" 7566c3e29c03Smrg arg=$func_quote_arg_result 756749dc963fSmrg func_append compile_command " $arg" 756849dc963fSmrg func_append finalize_command " $arg" 75694e7590efSmrg func_append compiler_flags " $arg" 757049dc963fSmrg continue 757149dc963fSmrg ;; 75724b0ead49Smrg 757326372658Smrg -Z*) 757426372658Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 757526372658Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 757626372658Smrg compiler_flags="$compiler_flags $arg" 757726372658Smrg func_append compile_command " $arg" 757826372658Smrg func_append finalize_command " $arg" 757926372658Smrg case $arg in 758026372658Smrg -Zlinker | -Zstack) 758126372658Smrg prev=xcompiler 758226372658Smrg ;; 758326372658Smrg esac 758426372658Smrg continue 758526372658Smrg else 758626372658Smrg # Otherwise treat like 'Some other compiler flag' below 7587c3e29c03Smrg func_quote_arg pretty "$arg" 7588c3e29c03Smrg arg=$func_quote_arg_result 758926372658Smrg fi 759026372658Smrg ;; 759126372658Smrg 759249dc963fSmrg # Some other compiler flag. 759349dc963fSmrg -* | +*) 7594c3e29c03Smrg func_quote_arg pretty "$arg" 7595c3e29c03Smrg arg=$func_quote_arg_result 759649dc963fSmrg ;; 75974b0ead49Smrg 759849dc963fSmrg *.$objext) 759949dc963fSmrg # A standard object. 76004e7590efSmrg func_append objs " $arg" 760149dc963fSmrg ;; 76024b0ead49Smrg 760349dc963fSmrg *.lo) 760449dc963fSmrg # A libtool-controlled object. 76054b0ead49Smrg 760649dc963fSmrg # Check to see that this really is a libtool object. 760749dc963fSmrg if func_lalib_unsafe_p "$arg"; then 760849dc963fSmrg pic_object= 760949dc963fSmrg non_pic_object= 76104b0ead49Smrg 761149dc963fSmrg # Read the .lo file 761249dc963fSmrg func_source "$arg" 76134b0ead49Smrg 761449dc963fSmrg if test -z "$pic_object" || 761549dc963fSmrg test -z "$non_pic_object" || 761626372658Smrg test none = "$pic_object" && 761726372658Smrg test none = "$non_pic_object"; then 761826372658Smrg func_fatal_error "cannot find name of object for '$arg'" 761949dc963fSmrg fi 76204b0ead49Smrg 762149dc963fSmrg # Extract subdirectory from the argument. 762249dc963fSmrg func_dirname "$arg" "/" "" 762326372658Smrg xdir=$func_dirname_result 762452b01e16Smrg 762526372658Smrg test none = "$pic_object" || { 762649dc963fSmrg # Prepend the subdirectory the object is found in. 762726372658Smrg pic_object=$xdir$pic_object 76284b0ead49Smrg 762926372658Smrg if test dlfiles = "$prev"; then 763026372658Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76314e7590efSmrg func_append dlfiles " $pic_object" 763249dc963fSmrg prev= 763349dc963fSmrg continue 763449dc963fSmrg else 763549dc963fSmrg # If libtool objects are unsupported, then we need to preload. 763649dc963fSmrg prev=dlprefiles 763749dc963fSmrg fi 763849dc963fSmrg fi 76394b0ead49Smrg 764049dc963fSmrg # CHECK ME: I think I busted this. -Ossama 764126372658Smrg if test dlprefiles = "$prev"; then 764249dc963fSmrg # Preload the old-style object. 76434e7590efSmrg func_append dlprefiles " $pic_object" 764449dc963fSmrg prev= 764549dc963fSmrg fi 76464b0ead49Smrg 764749dc963fSmrg # A PIC object. 764849dc963fSmrg func_append libobjs " $pic_object" 764926372658Smrg arg=$pic_object 765026372658Smrg } 76514b0ead49Smrg 765249dc963fSmrg # Non-PIC object. 765326372658Smrg if test none != "$non_pic_object"; then 765449dc963fSmrg # Prepend the subdirectory the object is found in. 765526372658Smrg non_pic_object=$xdir$non_pic_object 76564b0ead49Smrg 765749dc963fSmrg # A standard non-PIC object 765849dc963fSmrg func_append non_pic_objects " $non_pic_object" 765926372658Smrg if test -z "$pic_object" || test none = "$pic_object"; then 766026372658Smrg arg=$non_pic_object 766149dc963fSmrg fi 766249dc963fSmrg else 766349dc963fSmrg # If the PIC object exists, use it instead. 766449dc963fSmrg # $xdir was prepended to $pic_object above. 766526372658Smrg non_pic_object=$pic_object 766649dc963fSmrg func_append non_pic_objects " $non_pic_object" 766749dc963fSmrg fi 766849dc963fSmrg else 766949dc963fSmrg # Only an error if not doing a dry-run. 767049dc963fSmrg if $opt_dry_run; then 767149dc963fSmrg # Extract subdirectory from the argument. 767249dc963fSmrg func_dirname "$arg" "/" "" 767326372658Smrg xdir=$func_dirname_result 767449dc963fSmrg 767549dc963fSmrg func_lo2o "$arg" 767649dc963fSmrg pic_object=$xdir$objdir/$func_lo2o_result 767749dc963fSmrg non_pic_object=$xdir$func_lo2o_result 767849dc963fSmrg func_append libobjs " $pic_object" 767949dc963fSmrg func_append non_pic_objects " $non_pic_object" 768049dc963fSmrg else 768126372658Smrg func_fatal_error "'$arg' is not a valid libtool object" 768249dc963fSmrg fi 768349dc963fSmrg fi 768449dc963fSmrg ;; 76854b0ead49Smrg 768649dc963fSmrg *.$libext) 768749dc963fSmrg # An archive. 76884e7590efSmrg func_append deplibs " $arg" 76894e7590efSmrg func_append old_deplibs " $arg" 769049dc963fSmrg continue 769149dc963fSmrg ;; 769249dc963fSmrg 769349dc963fSmrg *.la) 769449dc963fSmrg # A libtool-controlled library. 769549dc963fSmrg 76964e7590efSmrg func_resolve_sysroot "$arg" 769726372658Smrg if test dlfiles = "$prev"; then 769849dc963fSmrg # This library was specified with -dlopen. 76994e7590efSmrg func_append dlfiles " $func_resolve_sysroot_result" 770049dc963fSmrg prev= 770126372658Smrg elif test dlprefiles = "$prev"; then 770249dc963fSmrg # The library was specified with -dlpreopen. 77034e7590efSmrg func_append dlprefiles " $func_resolve_sysroot_result" 770449dc963fSmrg prev= 770549dc963fSmrg else 77064e7590efSmrg func_append deplibs " $func_resolve_sysroot_result" 770749dc963fSmrg fi 770849dc963fSmrg continue 770949dc963fSmrg ;; 771049dc963fSmrg 771149dc963fSmrg # Some other compiler argument. 771249dc963fSmrg *) 771349dc963fSmrg # Unknown arguments in both finalize_command and compile_command need 771449dc963fSmrg # to be aesthetically quoted because they are evaled later. 7715c3e29c03Smrg func_quote_arg pretty "$arg" 7716c3e29c03Smrg arg=$func_quote_arg_result 771749dc963fSmrg ;; 771849dc963fSmrg esac # arg 771949dc963fSmrg 772049dc963fSmrg # Now actually substitute the argument into the commands. 772149dc963fSmrg if test -n "$arg"; then 772249dc963fSmrg func_append compile_command " $arg" 772349dc963fSmrg func_append finalize_command " $arg" 772449dc963fSmrg fi 772549dc963fSmrg done # argument parsing loop 772649dc963fSmrg 772749dc963fSmrg test -n "$prev" && \ 772826372658Smrg func_fatal_help "the '$prevarg' option requires an argument" 772949dc963fSmrg 773026372658Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 773149dc963fSmrg eval arg=\"$export_dynamic_flag_spec\" 773249dc963fSmrg func_append compile_command " $arg" 773349dc963fSmrg func_append finalize_command " $arg" 773449dc963fSmrg fi 773549dc963fSmrg 773649dc963fSmrg oldlibs= 773749dc963fSmrg # calculate the name of the file, without its directory 773849dc963fSmrg func_basename "$output" 773926372658Smrg outputname=$func_basename_result 774026372658Smrg libobjs_save=$libobjs 774149dc963fSmrg 774249dc963fSmrg if test -n "$shlibpath_var"; then 774349dc963fSmrg # get the directories listed in $shlibpath_var 774426372658Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 774549dc963fSmrg else 774649dc963fSmrg shlib_search_path= 774749dc963fSmrg fi 774849dc963fSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 774949dc963fSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 775049dc963fSmrg 775126372658Smrg # Definition is injected by LT_CONFIG during libtool generation. 775226372658Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 775326372658Smrg 775449dc963fSmrg func_dirname "$output" "/" "" 775526372658Smrg output_objdir=$func_dirname_result$objdir 77564e7590efSmrg func_to_tool_file "$output_objdir/" 77574e7590efSmrg tool_output_objdir=$func_to_tool_file_result 775849dc963fSmrg # Create the object directory. 775949dc963fSmrg func_mkdir_p "$output_objdir" 776049dc963fSmrg 776149dc963fSmrg # Determine the type of output 776249dc963fSmrg case $output in 776349dc963fSmrg "") 776449dc963fSmrg func_fatal_help "you must specify an output file" 776549dc963fSmrg ;; 776649dc963fSmrg *.$libext) linkmode=oldlib ;; 776749dc963fSmrg *.lo | *.$objext) linkmode=obj ;; 776849dc963fSmrg *.la) linkmode=lib ;; 776949dc963fSmrg *) linkmode=prog ;; # Anything else should be a program. 777049dc963fSmrg esac 777149dc963fSmrg 777249dc963fSmrg specialdeplibs= 777349dc963fSmrg 777449dc963fSmrg libs= 777549dc963fSmrg # Find all interdependent deplibs by searching for libraries 777649dc963fSmrg # that are linked more than once (e.g. -la -lb -la) 777749dc963fSmrg for deplib in $deplibs; do 777826372658Smrg if $opt_preserve_dup_deps; then 777949dc963fSmrg case "$libs " in 77804e7590efSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 778149dc963fSmrg esac 778249dc963fSmrg fi 77834e7590efSmrg func_append libs " $deplib" 778449dc963fSmrg done 778549dc963fSmrg 778626372658Smrg if test lib = "$linkmode"; then 778749dc963fSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 778849dc963fSmrg 778949dc963fSmrg # Compute libraries that are listed more than once in $predeps 779049dc963fSmrg # $postdeps and mark them as special (i.e., whose duplicates are 779149dc963fSmrg # not to be eliminated). 779249dc963fSmrg pre_post_deps= 779349dc963fSmrg if $opt_duplicate_compiler_generated_deps; then 779449dc963fSmrg for pre_post_dep in $predeps $postdeps; do 779549dc963fSmrg case "$pre_post_deps " in 77964e7590efSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 779749dc963fSmrg esac 77984e7590efSmrg func_append pre_post_deps " $pre_post_dep" 779949dc963fSmrg done 780049dc963fSmrg fi 780149dc963fSmrg pre_post_deps= 780249dc963fSmrg fi 780349dc963fSmrg 780449dc963fSmrg deplibs= 780549dc963fSmrg newdependency_libs= 780649dc963fSmrg newlib_search_path= 780749dc963fSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 780849dc963fSmrg notinst_deplibs= # not-installed libtool libraries 780949dc963fSmrg notinst_path= # paths that contain not-installed libtool libraries 781049dc963fSmrg 781149dc963fSmrg case $linkmode in 781249dc963fSmrg lib) 781349dc963fSmrg passes="conv dlpreopen link" 781449dc963fSmrg for file in $dlfiles $dlprefiles; do 781549dc963fSmrg case $file in 781649dc963fSmrg *.la) ;; 781749dc963fSmrg *) 781826372658Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 781949dc963fSmrg ;; 782049dc963fSmrg esac 782149dc963fSmrg done 782249dc963fSmrg ;; 782349dc963fSmrg prog) 782449dc963fSmrg compile_deplibs= 782549dc963fSmrg finalize_deplibs= 782626372658Smrg alldeplibs=false 782749dc963fSmrg newdlfiles= 782849dc963fSmrg newdlprefiles= 782949dc963fSmrg passes="conv scan dlopen dlpreopen link" 783049dc963fSmrg ;; 783149dc963fSmrg *) passes="conv" 783249dc963fSmrg ;; 783349dc963fSmrg esac 783449dc963fSmrg 783549dc963fSmrg for pass in $passes; do 783649dc963fSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 783749dc963fSmrg # so that -L comes before libs that need it for instance... 783826372658Smrg if test lib,link = "$linkmode,$pass"; then 783949dc963fSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 784049dc963fSmrg ## order, and fix it there properly 784149dc963fSmrg tmp_deplibs= 784249dc963fSmrg for deplib in $deplibs; do 784349dc963fSmrg tmp_deplibs="$deplib $tmp_deplibs" 784449dc963fSmrg done 784526372658Smrg deplibs=$tmp_deplibs 784649dc963fSmrg fi 784749dc963fSmrg 784826372658Smrg if test lib,link = "$linkmode,$pass" || 784926372658Smrg test prog,scan = "$linkmode,$pass"; then 785026372658Smrg libs=$deplibs 785149dc963fSmrg deplibs= 785249dc963fSmrg fi 785326372658Smrg if test prog = "$linkmode"; then 785449dc963fSmrg case $pass in 785526372658Smrg dlopen) libs=$dlfiles ;; 785626372658Smrg dlpreopen) libs=$dlprefiles ;; 785749dc963fSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 785849dc963fSmrg esac 785949dc963fSmrg fi 786026372658Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 786149dc963fSmrg # Collect and forward deplibs of preopened libtool libs 786249dc963fSmrg for lib in $dlprefiles; do 786349dc963fSmrg # Ignore non-libtool-libs 786449dc963fSmrg dependency_libs= 78654e7590efSmrg func_resolve_sysroot "$lib" 786649dc963fSmrg case $lib in 78674e7590efSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 786849dc963fSmrg esac 786949dc963fSmrg 787049dc963fSmrg # Collect preopened libtool deplibs, except any this library 787149dc963fSmrg # has declared as weak libs 787249dc963fSmrg for deplib in $dependency_libs; do 78737aa89044Smrg func_basename "$deplib" 78747aa89044Smrg deplib_base=$func_basename_result 787549dc963fSmrg case " $weak_libs " in 787649dc963fSmrg *" $deplib_base "*) ;; 78774e7590efSmrg *) func_append deplibs " $deplib" ;; 787849dc963fSmrg esac 787949dc963fSmrg done 788049dc963fSmrg done 788126372658Smrg libs=$dlprefiles 788249dc963fSmrg fi 788326372658Smrg if test dlopen = "$pass"; then 788449dc963fSmrg # Collect dlpreopened libraries 788526372658Smrg save_deplibs=$deplibs 788649dc963fSmrg deplibs= 788749dc963fSmrg fi 788849dc963fSmrg 788949dc963fSmrg for deplib in $libs; do 789049dc963fSmrg lib= 789126372658Smrg found=false 789249dc963fSmrg case $deplib in 78934e7590efSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78944e7590efSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 789526372658Smrg if test prog,link = "$linkmode,$pass"; then 789649dc963fSmrg compile_deplibs="$deplib $compile_deplibs" 789749dc963fSmrg finalize_deplibs="$deplib $finalize_deplibs" 789849dc963fSmrg else 78994e7590efSmrg func_append compiler_flags " $deplib" 790026372658Smrg if test lib = "$linkmode"; then 790149dc963fSmrg case "$new_inherited_linker_flags " in 790249dc963fSmrg *" $deplib "*) ;; 79034e7590efSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 790449dc963fSmrg esac 790549dc963fSmrg fi 790649dc963fSmrg fi 790749dc963fSmrg continue 790849dc963fSmrg ;; 790949dc963fSmrg -l*) 791026372658Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 791126372658Smrg func_warning "'-l' is ignored for archives/objects" 791249dc963fSmrg continue 791349dc963fSmrg fi 791449dc963fSmrg func_stripname '-l' '' "$deplib" 791549dc963fSmrg name=$func_stripname_result 791626372658Smrg if test lib = "$linkmode"; then 791749dc963fSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 791849dc963fSmrg else 791949dc963fSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 792049dc963fSmrg fi 792149dc963fSmrg for searchdir in $searchdirs; do 792249dc963fSmrg for search_ext in .la $std_shrext .so .a; do 792349dc963fSmrg # Search the libtool library 792426372658Smrg lib=$searchdir/lib$name$search_ext 792549dc963fSmrg if test -f "$lib"; then 792626372658Smrg if test .la = "$search_ext"; then 792726372658Smrg found=: 792849dc963fSmrg else 792926372658Smrg found=false 793049dc963fSmrg fi 793149dc963fSmrg break 2 793249dc963fSmrg fi 793349dc963fSmrg done 793449dc963fSmrg done 793526372658Smrg if $found; then 793626372658Smrg # deplib is a libtool library 793749dc963fSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 793849dc963fSmrg # We need to do some special things here, and not later. 793926372658Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 794049dc963fSmrg case " $predeps $postdeps " in 794149dc963fSmrg *" $deplib "*) 794249dc963fSmrg if func_lalib_p "$lib"; then 794349dc963fSmrg library_names= 794449dc963fSmrg old_library= 794549dc963fSmrg func_source "$lib" 794649dc963fSmrg for l in $old_library $library_names; do 794726372658Smrg ll=$l 794849dc963fSmrg done 794926372658Smrg if test "X$ll" = "X$old_library"; then # only static version available 795026372658Smrg found=false 795149dc963fSmrg func_dirname "$lib" "" "." 795226372658Smrg ladir=$func_dirname_result 795349dc963fSmrg lib=$ladir/$old_library 795426372658Smrg if test prog,link = "$linkmode,$pass"; then 795549dc963fSmrg compile_deplibs="$deplib $compile_deplibs" 795649dc963fSmrg finalize_deplibs="$deplib $finalize_deplibs" 795749dc963fSmrg else 795849dc963fSmrg deplibs="$deplib $deplibs" 795926372658Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 796049dc963fSmrg fi 796149dc963fSmrg continue 796249dc963fSmrg fi 796349dc963fSmrg fi 796449dc963fSmrg ;; 796549dc963fSmrg *) ;; 796649dc963fSmrg esac 796749dc963fSmrg fi 796826372658Smrg else 796926372658Smrg # deplib doesn't seem to be a libtool library 797026372658Smrg if test prog,link = "$linkmode,$pass"; then 797126372658Smrg compile_deplibs="$deplib $compile_deplibs" 797226372658Smrg finalize_deplibs="$deplib $finalize_deplibs" 797326372658Smrg else 797426372658Smrg deplibs="$deplib $deplibs" 797526372658Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 797626372658Smrg fi 797726372658Smrg continue 797849dc963fSmrg fi 797949dc963fSmrg ;; # -l 798049dc963fSmrg *.ltframework) 798126372658Smrg if test prog,link = "$linkmode,$pass"; then 798249dc963fSmrg compile_deplibs="$deplib $compile_deplibs" 798349dc963fSmrg finalize_deplibs="$deplib $finalize_deplibs" 798449dc963fSmrg else 798549dc963fSmrg deplibs="$deplib $deplibs" 798626372658Smrg if test lib = "$linkmode"; then 798749dc963fSmrg case "$new_inherited_linker_flags " in 798849dc963fSmrg *" $deplib "*) ;; 79894e7590efSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 799049dc963fSmrg esac 799149dc963fSmrg fi 799249dc963fSmrg fi 799349dc963fSmrg continue 799449dc963fSmrg ;; 799549dc963fSmrg -L*) 799649dc963fSmrg case $linkmode in 799749dc963fSmrg lib) 799849dc963fSmrg deplibs="$deplib $deplibs" 799926372658Smrg test conv = "$pass" && continue 800049dc963fSmrg newdependency_libs="$deplib $newdependency_libs" 800149dc963fSmrg func_stripname '-L' '' "$deplib" 80024e7590efSmrg func_resolve_sysroot "$func_stripname_result" 80034e7590efSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 800449dc963fSmrg ;; 800549dc963fSmrg prog) 800626372658Smrg if test conv = "$pass"; then 800749dc963fSmrg deplibs="$deplib $deplibs" 800849dc963fSmrg continue 800949dc963fSmrg fi 801026372658Smrg if test scan = "$pass"; then 801149dc963fSmrg deplibs="$deplib $deplibs" 801249dc963fSmrg else 801349dc963fSmrg compile_deplibs="$deplib $compile_deplibs" 801449dc963fSmrg finalize_deplibs="$deplib $finalize_deplibs" 801549dc963fSmrg fi 801649dc963fSmrg func_stripname '-L' '' "$deplib" 80174e7590efSmrg func_resolve_sysroot "$func_stripname_result" 80184e7590efSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 801949dc963fSmrg ;; 802049dc963fSmrg *) 802126372658Smrg func_warning "'-L' is ignored for archives/objects" 802249dc963fSmrg ;; 802349dc963fSmrg esac # linkmode 802449dc963fSmrg continue 802549dc963fSmrg ;; # -L 802649dc963fSmrg -R*) 802726372658Smrg if test link = "$pass"; then 802849dc963fSmrg func_stripname '-R' '' "$deplib" 80294e7590efSmrg func_resolve_sysroot "$func_stripname_result" 80304e7590efSmrg dir=$func_resolve_sysroot_result 803149dc963fSmrg # Make sure the xrpath contains only unique directories. 803249dc963fSmrg case "$xrpath " in 803349dc963fSmrg *" $dir "*) ;; 80344e7590efSmrg *) func_append xrpath " $dir" ;; 803549dc963fSmrg esac 803649dc963fSmrg fi 803749dc963fSmrg deplibs="$deplib $deplibs" 803849dc963fSmrg continue 803949dc963fSmrg ;; 80404e7590efSmrg *.la) 80414e7590efSmrg func_resolve_sysroot "$deplib" 80424e7590efSmrg lib=$func_resolve_sysroot_result 80434e7590efSmrg ;; 804449dc963fSmrg *.$libext) 804526372658Smrg if test conv = "$pass"; then 804649dc963fSmrg deplibs="$deplib $deplibs" 804749dc963fSmrg continue 804849dc963fSmrg fi 804949dc963fSmrg case $linkmode in 805049dc963fSmrg lib) 805149dc963fSmrg # Linking convenience modules into shared libraries is allowed, 805249dc963fSmrg # but linking other static libraries is non-portable. 805349dc963fSmrg case " $dlpreconveniencelibs " in 805449dc963fSmrg *" $deplib "*) ;; 805549dc963fSmrg *) 805626372658Smrg valid_a_lib=false 805749dc963fSmrg case $deplibs_check_method in 805849dc963fSmrg match_pattern*) 805949dc963fSmrg set dummy $deplibs_check_method; shift 806049dc963fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80617aa89044Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 806249dc963fSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 806326372658Smrg valid_a_lib=: 806449dc963fSmrg fi 806549dc963fSmrg ;; 806649dc963fSmrg pass_all) 806726372658Smrg valid_a_lib=: 806849dc963fSmrg ;; 806949dc963fSmrg esac 807026372658Smrg if $valid_a_lib; then 807126372658Smrg echo 807226372658Smrg $ECHO "*** Warning: Linking the shared library $output against the" 807326372658Smrg $ECHO "*** static library $deplib is not portable!" 807426372658Smrg deplibs="$deplib $deplibs" 807526372658Smrg else 80767aa89044Smrg echo 807749dc963fSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80787aa89044Smrg echo "*** I have the capability to make that library automatically link in when" 80797aa89044Smrg echo "*** you link to this library. But I can only do this if you have a" 80807aa89044Smrg echo "*** shared version of the library, which you do not appear to have" 80817aa89044Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 80827aa89044Smrg echo "*** that it is just a static archive that I should not use here." 808349dc963fSmrg fi 808449dc963fSmrg ;; 808549dc963fSmrg esac 808649dc963fSmrg continue 808749dc963fSmrg ;; 808849dc963fSmrg prog) 808926372658Smrg if test link != "$pass"; then 809049dc963fSmrg deplibs="$deplib $deplibs" 809149dc963fSmrg else 809249dc963fSmrg compile_deplibs="$deplib $compile_deplibs" 809349dc963fSmrg finalize_deplibs="$deplib $finalize_deplibs" 809449dc963fSmrg fi 809549dc963fSmrg continue 809649dc963fSmrg ;; 809749dc963fSmrg esac # linkmode 809849dc963fSmrg ;; # *.$libext 809949dc963fSmrg *.lo | *.$objext) 810026372658Smrg if test conv = "$pass"; then 810149dc963fSmrg deplibs="$deplib $deplibs" 810226372658Smrg elif test prog = "$linkmode"; then 810326372658Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 810449dc963fSmrg # If there is no dlopen support or we're linking statically, 810549dc963fSmrg # we need to preload. 81064e7590efSmrg func_append newdlprefiles " $deplib" 810749dc963fSmrg compile_deplibs="$deplib $compile_deplibs" 810849dc963fSmrg finalize_deplibs="$deplib $finalize_deplibs" 810949dc963fSmrg else 81104e7590efSmrg func_append newdlfiles " $deplib" 811149dc963fSmrg fi 811249dc963fSmrg fi 811349dc963fSmrg continue 811449dc963fSmrg ;; 811549dc963fSmrg %DEPLIBS%) 811626372658Smrg alldeplibs=: 811749dc963fSmrg continue 811849dc963fSmrg ;; 811949dc963fSmrg esac # case $deplib 812049dc963fSmrg 812126372658Smrg $found || test -f "$lib" \ 812226372658Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 812349dc963fSmrg 812449dc963fSmrg # Check to see that this really is a libtool archive. 812549dc963fSmrg func_lalib_unsafe_p "$lib" \ 812626372658Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 812749dc963fSmrg 812849dc963fSmrg func_dirname "$lib" "" "." 812926372658Smrg ladir=$func_dirname_result 813049dc963fSmrg 813149dc963fSmrg dlname= 813249dc963fSmrg dlopen= 813349dc963fSmrg dlpreopen= 813449dc963fSmrg libdir= 813549dc963fSmrg library_names= 813649dc963fSmrg old_library= 813749dc963fSmrg inherited_linker_flags= 813849dc963fSmrg # If the library was installed with an old release of libtool, 813949dc963fSmrg # it will not redefine variables installed, or shouldnotlink 814049dc963fSmrg installed=yes 814149dc963fSmrg shouldnotlink=no 814249dc963fSmrg avoidtemprpath= 814349dc963fSmrg 814449dc963fSmrg 814549dc963fSmrg # Read the .la file 814649dc963fSmrg func_source "$lib" 814749dc963fSmrg 814849dc963fSmrg # Convert "-framework foo" to "foo.ltframework" 814949dc963fSmrg if test -n "$inherited_linker_flags"; then 81507aa89044Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 815149dc963fSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 815249dc963fSmrg case " $new_inherited_linker_flags " in 815349dc963fSmrg *" $tmp_inherited_linker_flag "*) ;; 81544e7590efSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 815549dc963fSmrg esac 815649dc963fSmrg done 815749dc963fSmrg fi 81587aa89044Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 815926372658Smrg if test lib,link = "$linkmode,$pass" || 816026372658Smrg test prog,scan = "$linkmode,$pass" || 816126372658Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81624e7590efSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81634e7590efSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 816449dc963fSmrg fi 816549dc963fSmrg 816626372658Smrg if test conv = "$pass"; then 816749dc963fSmrg # Only check for convenience libraries 816849dc963fSmrg deplibs="$lib $deplibs" 816949dc963fSmrg if test -z "$libdir"; then 817049dc963fSmrg if test -z "$old_library"; then 817126372658Smrg func_fatal_error "cannot find name of link library for '$lib'" 817249dc963fSmrg fi 817349dc963fSmrg # It is a libtool convenience library, so add in its objects. 81744e7590efSmrg func_append convenience " $ladir/$objdir/$old_library" 81754e7590efSmrg func_append old_convenience " $ladir/$objdir/$old_library" 817626372658Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 817726372658Smrg func_fatal_error "'$lib' is not a convenience library" 817849dc963fSmrg fi 817949dc963fSmrg tmp_libs= 818049dc963fSmrg for deplib in $dependency_libs; do 818149dc963fSmrg deplibs="$deplib $deplibs" 818226372658Smrg if $opt_preserve_dup_deps; then 818349dc963fSmrg case "$tmp_libs " in 81844e7590efSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 818549dc963fSmrg esac 818649dc963fSmrg fi 81874e7590efSmrg func_append tmp_libs " $deplib" 818849dc963fSmrg done 818949dc963fSmrg continue 819049dc963fSmrg fi # $pass = conv 819149dc963fSmrg 819249dc963fSmrg 819349dc963fSmrg # Get the name of the library we link against. 819449dc963fSmrg linklib= 81954e7590efSmrg if test -n "$old_library" && 819626372658Smrg { test yes = "$prefer_static_libs" || 819726372658Smrg test built,no = "$prefer_static_libs,$installed"; }; then 81984e7590efSmrg linklib=$old_library 81994e7590efSmrg else 82004e7590efSmrg for l in $old_library $library_names; do 820126372658Smrg linklib=$l 82024e7590efSmrg done 82034e7590efSmrg fi 820449dc963fSmrg if test -z "$linklib"; then 820526372658Smrg func_fatal_error "cannot find name of link library for '$lib'" 820649dc963fSmrg fi 820749dc963fSmrg 820849dc963fSmrg # This library was specified with -dlopen. 820926372658Smrg if test dlopen = "$pass"; then 821026372658Smrg test -z "$libdir" \ 821126372658Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 821249dc963fSmrg if test -z "$dlname" || 821326372658Smrg test yes != "$dlopen_support" || 821426372658Smrg test no = "$build_libtool_libs" 821526372658Smrg then 821649dc963fSmrg # If there is no dlname, no dlopen support or we're linking 821749dc963fSmrg # statically, we need to preload. We also need to preload any 821849dc963fSmrg # dependent libraries so libltdl's deplib preloader doesn't 821949dc963fSmrg # bomb out in the load deplibs phase. 82204e7590efSmrg func_append dlprefiles " $lib $dependency_libs" 822149dc963fSmrg else 82224e7590efSmrg func_append newdlfiles " $lib" 822349dc963fSmrg fi 822449dc963fSmrg continue 822549dc963fSmrg fi # $pass = dlopen 822649dc963fSmrg 822749dc963fSmrg # We need an absolute path. 822849dc963fSmrg case $ladir in 822926372658Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 823049dc963fSmrg *) 823149dc963fSmrg abs_ladir=`cd "$ladir" && pwd` 823249dc963fSmrg if test -z "$abs_ladir"; then 823326372658Smrg func_warning "cannot determine absolute directory name of '$ladir'" 823449dc963fSmrg func_warning "passing it literally to the linker, although it might fail" 823526372658Smrg abs_ladir=$ladir 823649dc963fSmrg fi 823749dc963fSmrg ;; 823849dc963fSmrg esac 823949dc963fSmrg func_basename "$lib" 824026372658Smrg laname=$func_basename_result 824149dc963fSmrg 824249dc963fSmrg # Find the relevant object directory and library name. 824326372658Smrg if test yes = "$installed"; then 82444e7590efSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 824526372658Smrg func_warning "library '$lib' was moved." 824626372658Smrg dir=$ladir 824726372658Smrg absdir=$abs_ladir 824826372658Smrg libdir=$abs_ladir 824949dc963fSmrg else 825026372658Smrg dir=$lt_sysroot$libdir 825126372658Smrg absdir=$lt_sysroot$libdir 825249dc963fSmrg fi 825326372658Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 825449dc963fSmrg else 825549dc963fSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 825626372658Smrg dir=$ladir 825726372658Smrg absdir=$abs_ladir 825849dc963fSmrg # Remove this search path later 82594e7590efSmrg func_append notinst_path " $abs_ladir" 826049dc963fSmrg else 826126372658Smrg dir=$ladir/$objdir 826226372658Smrg absdir=$abs_ladir/$objdir 826349dc963fSmrg # Remove this search path later 82644e7590efSmrg func_append notinst_path " $abs_ladir" 826549dc963fSmrg fi 826649dc963fSmrg fi # $installed = yes 826749dc963fSmrg func_stripname 'lib' '.la' "$laname" 826849dc963fSmrg name=$func_stripname_result 826949dc963fSmrg 827049dc963fSmrg # This library was specified with -dlpreopen. 827126372658Smrg if test dlpreopen = "$pass"; then 827226372658Smrg if test -z "$libdir" && test prog = "$linkmode"; then 827326372658Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 827449dc963fSmrg fi 827526372658Smrg case $host in 82764e7590efSmrg # special handling for platforms with PE-DLLs. 82774e7590efSmrg *cygwin* | *mingw* | *cegcc* ) 82784e7590efSmrg # Linker will automatically link against shared library if both 82794e7590efSmrg # static and shared are present. Therefore, ensure we extract 82804e7590efSmrg # symbols from the import library if a shared library is present 82814e7590efSmrg # (otherwise, the dlopen module name will be incorrect). We do 82824e7590efSmrg # this by putting the import library name into $newdlprefiles. 82834e7590efSmrg # We recover the dlopen module name by 'saving' the la file 82844e7590efSmrg # name in a special purpose variable, and (later) extracting the 82854e7590efSmrg # dlname from the la file. 82864e7590efSmrg if test -n "$dlname"; then 82874e7590efSmrg func_tr_sh "$dir/$linklib" 82884e7590efSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 82894e7590efSmrg func_append newdlprefiles " $dir/$linklib" 82904e7590efSmrg else 82914e7590efSmrg func_append newdlprefiles " $dir/$old_library" 82924e7590efSmrg # Keep a list of preopened convenience libraries to check 82934e7590efSmrg # that they are being used correctly in the link pass. 82944e7590efSmrg test -z "$libdir" && \ 82954e7590efSmrg func_append dlpreconveniencelibs " $dir/$old_library" 82964e7590efSmrg fi 82974e7590efSmrg ;; 82984e7590efSmrg * ) 82994e7590efSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83004e7590efSmrg # are required to link). 83014e7590efSmrg if test -n "$old_library"; then 83024e7590efSmrg func_append newdlprefiles " $dir/$old_library" 83034e7590efSmrg # Keep a list of preopened convenience libraries to check 83044e7590efSmrg # that they are being used correctly in the link pass. 83054e7590efSmrg test -z "$libdir" && \ 83064e7590efSmrg func_append dlpreconveniencelibs " $dir/$old_library" 83074e7590efSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83084e7590efSmrg elif test -n "$dlname"; then 83094e7590efSmrg func_append newdlprefiles " $dir/$dlname" 83104e7590efSmrg else 83114e7590efSmrg func_append newdlprefiles " $dir/$linklib" 83124e7590efSmrg fi 83134e7590efSmrg ;; 83144e7590efSmrg esac 831549dc963fSmrg fi # $pass = dlpreopen 831649dc963fSmrg 831749dc963fSmrg if test -z "$libdir"; then 831849dc963fSmrg # Link the convenience library 831926372658Smrg if test lib = "$linkmode"; then 832049dc963fSmrg deplibs="$dir/$old_library $deplibs" 832126372658Smrg elif test prog,link = "$linkmode,$pass"; then 832249dc963fSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 832349dc963fSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 832449dc963fSmrg else 832549dc963fSmrg deplibs="$lib $deplibs" # used for prog,scan pass 832649dc963fSmrg fi 832749dc963fSmrg continue 832849dc963fSmrg fi 832949dc963fSmrg 833049dc963fSmrg 833126372658Smrg if test prog = "$linkmode" && test link != "$pass"; then 83324e7590efSmrg func_append newlib_search_path " $ladir" 833349dc963fSmrg deplibs="$lib $deplibs" 833449dc963fSmrg 833526372658Smrg linkalldeplibs=false 833626372658Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 833726372658Smrg test no = "$build_libtool_libs"; then 833826372658Smrg linkalldeplibs=: 833949dc963fSmrg fi 834049dc963fSmrg 834149dc963fSmrg tmp_libs= 834249dc963fSmrg for deplib in $dependency_libs; do 834349dc963fSmrg case $deplib in 834449dc963fSmrg -L*) func_stripname '-L' '' "$deplib" 83454e7590efSmrg func_resolve_sysroot "$func_stripname_result" 83464e7590efSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 834749dc963fSmrg ;; 834849dc963fSmrg esac 834949dc963fSmrg # Need to link against all dependency_libs? 835026372658Smrg if $linkalldeplibs; then 835149dc963fSmrg deplibs="$deplib $deplibs" 835249dc963fSmrg else 835349dc963fSmrg # Need to hardcode shared library paths 835449dc963fSmrg # or/and link against static libraries 835549dc963fSmrg newdependency_libs="$deplib $newdependency_libs" 835649dc963fSmrg fi 835726372658Smrg if $opt_preserve_dup_deps; then 835849dc963fSmrg case "$tmp_libs " in 83594e7590efSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 836049dc963fSmrg esac 836149dc963fSmrg fi 83624e7590efSmrg func_append tmp_libs " $deplib" 836349dc963fSmrg done # for deplib 836449dc963fSmrg continue 836549dc963fSmrg fi # $linkmode = prog... 836649dc963fSmrg 836726372658Smrg if test prog,link = "$linkmode,$pass"; then 836849dc963fSmrg if test -n "$library_names" && 836926372658Smrg { { test no = "$prefer_static_libs" || 837026372658Smrg test built,yes = "$prefer_static_libs,$installed"; } || 837149dc963fSmrg test -z "$old_library"; }; then 837249dc963fSmrg # We need to hardcode the library path 837326372658Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 837449dc963fSmrg # Make sure the rpath contains only unique directories. 837526372658Smrg case $temp_rpath: in 837649dc963fSmrg *"$absdir:"*) ;; 83774e7590efSmrg *) func_append temp_rpath "$absdir:" ;; 837849dc963fSmrg esac 837949dc963fSmrg fi 838049dc963fSmrg 838149dc963fSmrg # Hardcode the library path. 838249dc963fSmrg # Skip directories that are in the system default run-time 838349dc963fSmrg # search path. 838449dc963fSmrg case " $sys_lib_dlsearch_path " in 838549dc963fSmrg *" $absdir "*) ;; 838649dc963fSmrg *) 838749dc963fSmrg case "$compile_rpath " in 838849dc963fSmrg *" $absdir "*) ;; 83894e7590efSmrg *) func_append compile_rpath " $absdir" ;; 839049dc963fSmrg esac 839149dc963fSmrg ;; 839249dc963fSmrg esac 839349dc963fSmrg case " $sys_lib_dlsearch_path " in 839449dc963fSmrg *" $libdir "*) ;; 839549dc963fSmrg *) 839649dc963fSmrg case "$finalize_rpath " in 839749dc963fSmrg *" $libdir "*) ;; 83984e7590efSmrg *) func_append finalize_rpath " $libdir" ;; 839949dc963fSmrg esac 840049dc963fSmrg ;; 840149dc963fSmrg esac 840249dc963fSmrg fi # $linkmode,$pass = prog,link... 840349dc963fSmrg 840426372658Smrg if $alldeplibs && 840526372658Smrg { test pass_all = "$deplibs_check_method" || 840626372658Smrg { test yes = "$build_libtool_libs" && 840749dc963fSmrg test -n "$library_names"; }; }; then 840849dc963fSmrg # We only need to search for static libraries 840949dc963fSmrg continue 841049dc963fSmrg fi 841149dc963fSmrg fi 841249dc963fSmrg 841349dc963fSmrg link_static=no # Whether the deplib will be linked statically 841449dc963fSmrg use_static_libs=$prefer_static_libs 841526372658Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 841649dc963fSmrg use_static_libs=no 841749dc963fSmrg fi 841849dc963fSmrg if test -n "$library_names" && 841926372658Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 842049dc963fSmrg case $host in 842126372658Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 842249dc963fSmrg # No point in relinking DLLs because paths are not encoded 84234e7590efSmrg func_append notinst_deplibs " $lib" 842449dc963fSmrg need_relink=no 842549dc963fSmrg ;; 842649dc963fSmrg *) 842726372658Smrg if test no = "$installed"; then 84284e7590efSmrg func_append notinst_deplibs " $lib" 842949dc963fSmrg need_relink=yes 843049dc963fSmrg fi 843149dc963fSmrg ;; 843249dc963fSmrg esac 843349dc963fSmrg # This is a shared library 843449dc963fSmrg 843549dc963fSmrg # Warn about portability, can't link against -module's on some 843649dc963fSmrg # systems (darwin). Don't bleat about dlopened modules though! 843726372658Smrg dlopenmodule= 843849dc963fSmrg for dlpremoduletest in $dlprefiles; do 843949dc963fSmrg if test "X$dlpremoduletest" = "X$lib"; then 844026372658Smrg dlopenmodule=$dlpremoduletest 844149dc963fSmrg break 844249dc963fSmrg fi 844349dc963fSmrg done 844426372658Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84457aa89044Smrg echo 844626372658Smrg if test prog = "$linkmode"; then 844749dc963fSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 844849dc963fSmrg else 844949dc963fSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 845049dc963fSmrg fi 845149dc963fSmrg $ECHO "*** $linklib is not portable!" 845249dc963fSmrg fi 845326372658Smrg if test lib = "$linkmode" && 845426372658Smrg test yes = "$hardcode_into_libs"; then 845549dc963fSmrg # Hardcode the library path. 845649dc963fSmrg # Skip directories that are in the system default run-time 845749dc963fSmrg # search path. 845849dc963fSmrg case " $sys_lib_dlsearch_path " in 845949dc963fSmrg *" $absdir "*) ;; 846049dc963fSmrg *) 846149dc963fSmrg case "$compile_rpath " in 846249dc963fSmrg *" $absdir "*) ;; 84634e7590efSmrg *) func_append compile_rpath " $absdir" ;; 846449dc963fSmrg esac 846549dc963fSmrg ;; 846649dc963fSmrg esac 846749dc963fSmrg case " $sys_lib_dlsearch_path " in 846849dc963fSmrg *" $libdir "*) ;; 846949dc963fSmrg *) 847049dc963fSmrg case "$finalize_rpath " in 847149dc963fSmrg *" $libdir "*) ;; 84724e7590efSmrg *) func_append finalize_rpath " $libdir" ;; 847349dc963fSmrg esac 847449dc963fSmrg ;; 847549dc963fSmrg esac 847649dc963fSmrg fi 847749dc963fSmrg 847849dc963fSmrg if test -n "$old_archive_from_expsyms_cmds"; then 847949dc963fSmrg # figure out the soname 848049dc963fSmrg set dummy $library_names 848149dc963fSmrg shift 848226372658Smrg realname=$1 848349dc963fSmrg shift 848449dc963fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 848549dc963fSmrg # use dlname if we got it. it's perfectly good, no? 848649dc963fSmrg if test -n "$dlname"; then 848726372658Smrg soname=$dlname 848849dc963fSmrg elif test -n "$soname_spec"; then 848949dc963fSmrg # bleh windows 849049dc963fSmrg case $host in 849126372658Smrg *cygwin* | mingw* | *cegcc* | *os2*) 849249dc963fSmrg func_arith $current - $age 849349dc963fSmrg major=$func_arith_result 849426372658Smrg versuffix=-$major 849549dc963fSmrg ;; 849649dc963fSmrg esac 849749dc963fSmrg eval soname=\"$soname_spec\" 849849dc963fSmrg else 849926372658Smrg soname=$realname 850049dc963fSmrg fi 850149dc963fSmrg 850249dc963fSmrg # Make a new name for the extract_expsyms_cmds to use 850326372658Smrg soroot=$soname 850449dc963fSmrg func_basename "$soroot" 850526372658Smrg soname=$func_basename_result 850649dc963fSmrg func_stripname 'lib' '.dll' "$soname" 850749dc963fSmrg newlib=libimp-$func_stripname_result.a 850849dc963fSmrg 850949dc963fSmrg # If the library has no export list, then create one now 851049dc963fSmrg if test -f "$output_objdir/$soname-def"; then : 851149dc963fSmrg else 851226372658Smrg func_verbose "extracting exported symbol list from '$soname'" 851349dc963fSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 851449dc963fSmrg fi 851549dc963fSmrg 851649dc963fSmrg # Create $newlib 851749dc963fSmrg if test -f "$output_objdir/$newlib"; then :; else 851826372658Smrg func_verbose "generating import library for '$soname'" 851949dc963fSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 852049dc963fSmrg fi 852149dc963fSmrg # make sure the library variables are pointing to the new library 852249dc963fSmrg dir=$output_objdir 852349dc963fSmrg linklib=$newlib 852449dc963fSmrg fi # test -n "$old_archive_from_expsyms_cmds" 852549dc963fSmrg 852626372658Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 852749dc963fSmrg add_shlibpath= 852849dc963fSmrg add_dir= 852949dc963fSmrg add= 853049dc963fSmrg lib_linked=yes 853149dc963fSmrg case $hardcode_action in 853249dc963fSmrg immediate | unsupported) 853326372658Smrg if test no = "$hardcode_direct"; then 853426372658Smrg add=$dir/$linklib 853549dc963fSmrg case $host in 853626372658Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 853726372658Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 853849dc963fSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 853926372658Smrg *-*-unixware7*) add_dir=-L$dir ;; 854049dc963fSmrg *-*-darwin* ) 854126372658Smrg # if the lib is a (non-dlopened) module then we cannot 854249dc963fSmrg # link against it, someone is ignoring the earlier warnings 854349dc963fSmrg if /usr/bin/file -L $add 2> /dev/null | 854426372658Smrg $GREP ": [^:]* bundle" >/dev/null; then 854549dc963fSmrg if test "X$dlopenmodule" != "X$lib"; then 854649dc963fSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 854726372658Smrg if test -z "$old_library"; then 85487aa89044Smrg echo 85497aa89044Smrg echo "*** And there doesn't seem to be a static archive available" 85507aa89044Smrg echo "*** The link will probably fail, sorry" 855149dc963fSmrg else 855226372658Smrg add=$dir/$old_library 855349dc963fSmrg fi 855449dc963fSmrg elif test -n "$old_library"; then 855526372658Smrg add=$dir/$old_library 855649dc963fSmrg fi 855749dc963fSmrg fi 855849dc963fSmrg esac 855926372658Smrg elif test no = "$hardcode_minus_L"; then 856049dc963fSmrg case $host in 856126372658Smrg *-*-sunos*) add_shlibpath=$dir ;; 856249dc963fSmrg esac 856326372658Smrg add_dir=-L$dir 856426372658Smrg add=-l$name 856526372658Smrg elif test no = "$hardcode_shlibpath_var"; then 856626372658Smrg add_shlibpath=$dir 856726372658Smrg add=-l$name 856849dc963fSmrg else 856949dc963fSmrg lib_linked=no 857049dc963fSmrg fi 857149dc963fSmrg ;; 857249dc963fSmrg relink) 857326372658Smrg if test yes = "$hardcode_direct" && 857426372658Smrg test no = "$hardcode_direct_absolute"; then 857526372658Smrg add=$dir/$linklib 857626372658Smrg elif test yes = "$hardcode_minus_L"; then 857726372658Smrg add_dir=-L$absdir 857849dc963fSmrg # Try looking first in the location we're being installed to. 857949dc963fSmrg if test -n "$inst_prefix_dir"; then 858049dc963fSmrg case $libdir in 858149dc963fSmrg [\\/]*) 85824e7590efSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 858349dc963fSmrg ;; 858449dc963fSmrg esac 858549dc963fSmrg fi 858626372658Smrg add=-l$name 858726372658Smrg elif test yes = "$hardcode_shlibpath_var"; then 858826372658Smrg add_shlibpath=$dir 858926372658Smrg add=-l$name 859049dc963fSmrg else 859149dc963fSmrg lib_linked=no 859249dc963fSmrg fi 859349dc963fSmrg ;; 859449dc963fSmrg *) lib_linked=no ;; 859549dc963fSmrg esac 859649dc963fSmrg 859726372658Smrg if test yes != "$lib_linked"; then 859849dc963fSmrg func_fatal_configuration "unsupported hardcode properties" 859949dc963fSmrg fi 860049dc963fSmrg 860149dc963fSmrg if test -n "$add_shlibpath"; then 860249dc963fSmrg case :$compile_shlibpath: in 860349dc963fSmrg *":$add_shlibpath:"*) ;; 86044e7590efSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 860549dc963fSmrg esac 860649dc963fSmrg fi 860726372658Smrg if test prog = "$linkmode"; then 860849dc963fSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 860949dc963fSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 861049dc963fSmrg else 861149dc963fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 861249dc963fSmrg test -n "$add" && deplibs="$add $deplibs" 861326372658Smrg if test yes != "$hardcode_direct" && 861426372658Smrg test yes != "$hardcode_minus_L" && 861526372658Smrg test yes = "$hardcode_shlibpath_var"; then 861649dc963fSmrg case :$finalize_shlibpath: in 861749dc963fSmrg *":$libdir:"*) ;; 86184e7590efSmrg *) func_append finalize_shlibpath "$libdir:" ;; 861949dc963fSmrg esac 862049dc963fSmrg fi 862149dc963fSmrg fi 862249dc963fSmrg fi 862349dc963fSmrg 862426372658Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 862549dc963fSmrg add_shlibpath= 862649dc963fSmrg add_dir= 862749dc963fSmrg add= 862849dc963fSmrg # Finalize command for both is simple: just hardcode it. 862926372658Smrg if test yes = "$hardcode_direct" && 863026372658Smrg test no = "$hardcode_direct_absolute"; then 863126372658Smrg add=$libdir/$linklib 863226372658Smrg elif test yes = "$hardcode_minus_L"; then 863326372658Smrg add_dir=-L$libdir 863426372658Smrg add=-l$name 863526372658Smrg elif test yes = "$hardcode_shlibpath_var"; then 863649dc963fSmrg case :$finalize_shlibpath: in 863749dc963fSmrg *":$libdir:"*) ;; 86384e7590efSmrg *) func_append finalize_shlibpath "$libdir:" ;; 863949dc963fSmrg esac 864026372658Smrg add=-l$name 864126372658Smrg elif test yes = "$hardcode_automatic"; then 864249dc963fSmrg if test -n "$inst_prefix_dir" && 864326372658Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 864426372658Smrg add=$inst_prefix_dir$libdir/$linklib 864549dc963fSmrg else 864626372658Smrg add=$libdir/$linklib 864749dc963fSmrg fi 864849dc963fSmrg else 864949dc963fSmrg # We cannot seem to hardcode it, guess we'll fake it. 865026372658Smrg add_dir=-L$libdir 865149dc963fSmrg # Try looking first in the location we're being installed to. 865249dc963fSmrg if test -n "$inst_prefix_dir"; then 865349dc963fSmrg case $libdir in 865449dc963fSmrg [\\/]*) 86554e7590efSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 865649dc963fSmrg ;; 865749dc963fSmrg esac 865849dc963fSmrg fi 865926372658Smrg add=-l$name 866049dc963fSmrg fi 866149dc963fSmrg 866226372658Smrg if test prog = "$linkmode"; then 866349dc963fSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 866449dc963fSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 866549dc963fSmrg else 866649dc963fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 866749dc963fSmrg test -n "$add" && deplibs="$add $deplibs" 866849dc963fSmrg fi 866949dc963fSmrg fi 867026372658Smrg elif test prog = "$linkmode"; then 867149dc963fSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 867249dc963fSmrg # is not unsupported. This is valid on all known static and 867349dc963fSmrg # shared platforms. 867426372658Smrg if test unsupported != "$hardcode_direct"; then 867526372658Smrg test -n "$old_library" && linklib=$old_library 867649dc963fSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 867749dc963fSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 867849dc963fSmrg else 867949dc963fSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 868049dc963fSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 868149dc963fSmrg fi 868226372658Smrg elif test yes = "$build_libtool_libs"; then 868349dc963fSmrg # Not a shared library 868426372658Smrg if test pass_all != "$deplibs_check_method"; then 868549dc963fSmrg # We're trying link a shared library against a static one 868649dc963fSmrg # but the system doesn't support it. 868749dc963fSmrg 868849dc963fSmrg # Just print a warning and add the library to dependency_libs so 868949dc963fSmrg # that the program can be linked against the static library. 86907aa89044Smrg echo 869126372658Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 86927aa89044Smrg echo "*** I have the capability to make that library automatically link in when" 86937aa89044Smrg echo "*** you link to this library. But I can only do this if you have a" 86947aa89044Smrg echo "*** shared version of the library, which you do not appear to have." 869526372658Smrg if test yes = "$module"; then 86967aa89044Smrg echo "*** But as you try to build a module library, libtool will still create " 86977aa89044Smrg echo "*** a static module, that should work as long as the dlopening application" 86987aa89044Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 869949dc963fSmrg if test -z "$global_symbol_pipe"; then 87007aa89044Smrg echo 87017aa89044Smrg echo "*** However, this would only work if libtool was able to extract symbol" 870226372658Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 87037aa89044Smrg echo "*** not find such a program. So, this module is probably useless." 870426372658Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 870549dc963fSmrg fi 870626372658Smrg if test no = "$build_old_libs"; then 870749dc963fSmrg build_libtool_libs=module 870849dc963fSmrg build_old_libs=yes 870949dc963fSmrg else 871049dc963fSmrg build_libtool_libs=no 871149dc963fSmrg fi 871249dc963fSmrg fi 871349dc963fSmrg else 871449dc963fSmrg deplibs="$dir/$old_library $deplibs" 871549dc963fSmrg link_static=yes 871649dc963fSmrg fi 871749dc963fSmrg fi # link shared/static library? 871849dc963fSmrg 871926372658Smrg if test lib = "$linkmode"; then 872049dc963fSmrg if test -n "$dependency_libs" && 872126372658Smrg { test yes != "$hardcode_into_libs" || 872226372658Smrg test yes = "$build_old_libs" || 872326372658Smrg test yes = "$link_static"; }; then 872449dc963fSmrg # Extract -R from dependency_libs 872549dc963fSmrg temp_deplibs= 872649dc963fSmrg for libdir in $dependency_libs; do 872749dc963fSmrg case $libdir in 872849dc963fSmrg -R*) func_stripname '-R' '' "$libdir" 872949dc963fSmrg temp_xrpath=$func_stripname_result 873049dc963fSmrg case " $xrpath " in 873149dc963fSmrg *" $temp_xrpath "*) ;; 87324e7590efSmrg *) func_append xrpath " $temp_xrpath";; 873349dc963fSmrg esac;; 87344e7590efSmrg *) func_append temp_deplibs " $libdir";; 873549dc963fSmrg esac 873649dc963fSmrg done 873726372658Smrg dependency_libs=$temp_deplibs 873849dc963fSmrg fi 873949dc963fSmrg 87404e7590efSmrg func_append newlib_search_path " $absdir" 874149dc963fSmrg # Link against this library 874226372658Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 874349dc963fSmrg # ... and its dependency_libs 874449dc963fSmrg tmp_libs= 874549dc963fSmrg for deplib in $dependency_libs; do 874649dc963fSmrg newdependency_libs="$deplib $newdependency_libs" 87474e7590efSmrg case $deplib in 87484e7590efSmrg -L*) func_stripname '-L' '' "$deplib" 87494e7590efSmrg func_resolve_sysroot "$func_stripname_result";; 87504e7590efSmrg *) func_resolve_sysroot "$deplib" ;; 87514e7590efSmrg esac 875226372658Smrg if $opt_preserve_dup_deps; then 875349dc963fSmrg case "$tmp_libs " in 87544e7590efSmrg *" $func_resolve_sysroot_result "*) 87554e7590efSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 875649dc963fSmrg esac 875749dc963fSmrg fi 87584e7590efSmrg func_append tmp_libs " $func_resolve_sysroot_result" 875949dc963fSmrg done 876049dc963fSmrg 876126372658Smrg if test no != "$link_all_deplibs"; then 876249dc963fSmrg # Add the search paths of all dependency libraries 876349dc963fSmrg for deplib in $dependency_libs; do 87647aa89044Smrg path= 876549dc963fSmrg case $deplib in 876626372658Smrg -L*) path=$deplib ;; 876749dc963fSmrg *.la) 87684e7590efSmrg func_resolve_sysroot "$deplib" 87694e7590efSmrg deplib=$func_resolve_sysroot_result 877049dc963fSmrg func_dirname "$deplib" "" "." 87714e7590efSmrg dir=$func_dirname_result 877249dc963fSmrg # We need an absolute path. 877349dc963fSmrg case $dir in 877426372658Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 877549dc963fSmrg *) 877649dc963fSmrg absdir=`cd "$dir" && pwd` 877749dc963fSmrg if test -z "$absdir"; then 877826372658Smrg func_warning "cannot determine absolute directory name of '$dir'" 877926372658Smrg absdir=$dir 878049dc963fSmrg fi 878149dc963fSmrg ;; 878249dc963fSmrg esac 878349dc963fSmrg if $GREP "^installed=no" $deplib > /dev/null; then 878449dc963fSmrg case $host in 878549dc963fSmrg *-*-darwin*) 878649dc963fSmrg depdepl= 878726372658Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 878826372658Smrg if test -n "$deplibrary_names"; then 878926372658Smrg for tmp in $deplibrary_names; do 879049dc963fSmrg depdepl=$tmp 879149dc963fSmrg done 879226372658Smrg if test -f "$absdir/$objdir/$depdepl"; then 879326372658Smrg depdepl=$absdir/$objdir/$depdepl 879426372658Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879549dc963fSmrg if test -z "$darwin_install_name"; then 879626372658Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879749dc963fSmrg fi 879826372658Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 879926372658Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 880049dc963fSmrg path= 880149dc963fSmrg fi 880249dc963fSmrg fi 880349dc963fSmrg ;; 880449dc963fSmrg *) 880526372658Smrg path=-L$absdir/$objdir 880649dc963fSmrg ;; 880749dc963fSmrg esac 880849dc963fSmrg else 880926372658Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 881049dc963fSmrg test -z "$libdir" && \ 881126372658Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 881249dc963fSmrg test "$absdir" != "$libdir" && \ 881326372658Smrg func_warning "'$deplib' seems to be moved" 881449dc963fSmrg 881526372658Smrg path=-L$absdir 881649dc963fSmrg fi 881749dc963fSmrg ;; 881849dc963fSmrg esac 881949dc963fSmrg case " $deplibs " in 882049dc963fSmrg *" $path "*) ;; 882149dc963fSmrg *) deplibs="$path $deplibs" ;; 882249dc963fSmrg esac 882349dc963fSmrg done 882449dc963fSmrg fi # link_all_deplibs != no 882549dc963fSmrg fi # linkmode = lib 882649dc963fSmrg done # for deplib in $libs 882726372658Smrg if test link = "$pass"; then 882826372658Smrg if test prog = "$linkmode"; then 882949dc963fSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 883049dc963fSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 883149dc963fSmrg else 88327aa89044Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 883349dc963fSmrg fi 883449dc963fSmrg fi 883526372658Smrg dependency_libs=$newdependency_libs 883626372658Smrg if test dlpreopen = "$pass"; then 883749dc963fSmrg # Link the dlpreopened libraries before other libraries 883849dc963fSmrg for deplib in $save_deplibs; do 883949dc963fSmrg deplibs="$deplib $deplibs" 884049dc963fSmrg done 884149dc963fSmrg fi 884226372658Smrg if test dlopen != "$pass"; then 884326372658Smrg test conv = "$pass" || { 884449dc963fSmrg # Make sure lib_search_path contains only unique directories. 884549dc963fSmrg lib_search_path= 884649dc963fSmrg for dir in $newlib_search_path; do 884749dc963fSmrg case "$lib_search_path " in 884849dc963fSmrg *" $dir "*) ;; 88494e7590efSmrg *) func_append lib_search_path " $dir" ;; 885049dc963fSmrg esac 885149dc963fSmrg done 885249dc963fSmrg newlib_search_path= 885326372658Smrg } 885449dc963fSmrg 885526372658Smrg if test prog,link = "$linkmode,$pass"; then 885649dc963fSmrg vars="compile_deplibs finalize_deplibs" 885726372658Smrg else 885826372658Smrg vars=deplibs 885949dc963fSmrg fi 886049dc963fSmrg for var in $vars dependency_libs; do 886149dc963fSmrg # Add libraries to $var in reverse order 886249dc963fSmrg eval tmp_libs=\"\$$var\" 886349dc963fSmrg new_libs= 886449dc963fSmrg for deplib in $tmp_libs; do 886549dc963fSmrg # FIXME: Pedantically, this is the right thing to do, so 886649dc963fSmrg # that some nasty dependency loop isn't accidentally 886749dc963fSmrg # broken: 886849dc963fSmrg #new_libs="$deplib $new_libs" 886949dc963fSmrg # Pragmatically, this seems to cause very few problems in 887049dc963fSmrg # practice: 887149dc963fSmrg case $deplib in 887249dc963fSmrg -L*) new_libs="$deplib $new_libs" ;; 887349dc963fSmrg -R*) ;; 887449dc963fSmrg *) 887549dc963fSmrg # And here is the reason: when a library appears more 887649dc963fSmrg # than once as an explicit dependence of a library, or 887749dc963fSmrg # is implicitly linked in more than once by the 887849dc963fSmrg # compiler, it is considered special, and multiple 887949dc963fSmrg # occurrences thereof are not removed. Compare this 888049dc963fSmrg # with having the same library being listed as a 888149dc963fSmrg # dependency of multiple other libraries: in this case, 888249dc963fSmrg # we know (pedantically, we assume) the library does not 888349dc963fSmrg # need to be listed more than once, so we keep only the 888449dc963fSmrg # last copy. This is not always right, but it is rare 888549dc963fSmrg # enough that we require users that really mean to play 888649dc963fSmrg # such unportable linking tricks to link the library 888749dc963fSmrg # using -Wl,-lname, so that libtool does not consider it 888849dc963fSmrg # for duplicate removal. 888949dc963fSmrg case " $specialdeplibs " in 889049dc963fSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 889149dc963fSmrg *) 889249dc963fSmrg case " $new_libs " in 889349dc963fSmrg *" $deplib "*) ;; 889449dc963fSmrg *) new_libs="$deplib $new_libs" ;; 889549dc963fSmrg esac 889649dc963fSmrg ;; 889749dc963fSmrg esac 889849dc963fSmrg ;; 889949dc963fSmrg esac 890049dc963fSmrg done 890149dc963fSmrg tmp_libs= 890249dc963fSmrg for deplib in $new_libs; do 890349dc963fSmrg case $deplib in 890449dc963fSmrg -L*) 890549dc963fSmrg case " $tmp_libs " in 890649dc963fSmrg *" $deplib "*) ;; 89074e7590efSmrg *) func_append tmp_libs " $deplib" ;; 890849dc963fSmrg esac 890949dc963fSmrg ;; 89104e7590efSmrg *) func_append tmp_libs " $deplib" ;; 891149dc963fSmrg esac 891249dc963fSmrg done 891349dc963fSmrg eval $var=\"$tmp_libs\" 891449dc963fSmrg done # for var 891549dc963fSmrg fi 891626372658Smrg 891726372658Smrg # Add Sun CC postdeps if required: 891826372658Smrg test CXX = "$tagname" && { 891926372658Smrg case $host_os in 892026372658Smrg linux*) 8921c3e29c03Smrg case `$CC -V 2>&1 | $SED 5q` in 892226372658Smrg *Sun\ C*) # Sun C++ 5.9 892326372658Smrg func_suncc_cstd_abi 892426372658Smrg 892526372658Smrg if test no != "$suncc_use_cstd_abi"; then 892626372658Smrg func_append postdeps ' -library=Cstd -library=Crun' 892726372658Smrg fi 892826372658Smrg ;; 892926372658Smrg esac 893026372658Smrg ;; 893126372658Smrg 893226372658Smrg solaris*) 893326372658Smrg func_cc_basename "$CC" 893426372658Smrg case $func_cc_basename_result in 893526372658Smrg CC* | sunCC*) 893626372658Smrg func_suncc_cstd_abi 893726372658Smrg 893826372658Smrg if test no != "$suncc_use_cstd_abi"; then 893926372658Smrg func_append postdeps ' -library=Cstd -library=Crun' 894026372658Smrg fi 894126372658Smrg ;; 894226372658Smrg esac 894326372658Smrg ;; 894426372658Smrg esac 894526372658Smrg } 894626372658Smrg 894749dc963fSmrg # Last step: remove runtime libs from dependency_libs 894849dc963fSmrg # (they stay in deplibs) 894949dc963fSmrg tmp_libs= 895026372658Smrg for i in $dependency_libs; do 895149dc963fSmrg case " $predeps $postdeps $compiler_lib_search_path " in 895249dc963fSmrg *" $i "*) 895326372658Smrg i= 895449dc963fSmrg ;; 895549dc963fSmrg esac 895626372658Smrg if test -n "$i"; then 89574e7590efSmrg func_append tmp_libs " $i" 895849dc963fSmrg fi 895949dc963fSmrg done 896049dc963fSmrg dependency_libs=$tmp_libs 896149dc963fSmrg done # for pass 896226372658Smrg if test prog = "$linkmode"; then 896326372658Smrg dlfiles=$newdlfiles 896449dc963fSmrg fi 896526372658Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 896626372658Smrg dlprefiles=$newdlprefiles 896749dc963fSmrg fi 896849dc963fSmrg 896949dc963fSmrg case $linkmode in 897049dc963fSmrg oldlib) 897126372658Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 897226372658Smrg func_warning "'-dlopen' is ignored for archives" 897349dc963fSmrg fi 897449dc963fSmrg 897549dc963fSmrg case " $deplibs" in 897649dc963fSmrg *\ -l* | *\ -L*) 897726372658Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 897849dc963fSmrg esac 897949dc963fSmrg 898049dc963fSmrg test -n "$rpath" && \ 898126372658Smrg func_warning "'-rpath' is ignored for archives" 898249dc963fSmrg 898349dc963fSmrg test -n "$xrpath" && \ 898426372658Smrg func_warning "'-R' is ignored for archives" 898549dc963fSmrg 898649dc963fSmrg test -n "$vinfo" && \ 898726372658Smrg func_warning "'-version-info/-version-number' is ignored for archives" 898849dc963fSmrg 898949dc963fSmrg test -n "$release" && \ 899026372658Smrg func_warning "'-release' is ignored for archives" 899149dc963fSmrg 899249dc963fSmrg test -n "$export_symbols$export_symbols_regex" && \ 899326372658Smrg func_warning "'-export-symbols' is ignored for archives" 899449dc963fSmrg 899549dc963fSmrg # Now set the variables for building old libraries. 899649dc963fSmrg build_libtool_libs=no 899726372658Smrg oldlibs=$output 89984e7590efSmrg func_append objs "$old_deplibs" 899949dc963fSmrg ;; 900049dc963fSmrg 900149dc963fSmrg lib) 900226372658Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 900349dc963fSmrg case $outputname in 900449dc963fSmrg lib*) 900549dc963fSmrg func_stripname 'lib' '.la' "$outputname" 900649dc963fSmrg name=$func_stripname_result 900749dc963fSmrg eval shared_ext=\"$shrext_cmds\" 900849dc963fSmrg eval libname=\"$libname_spec\" 900949dc963fSmrg ;; 901049dc963fSmrg *) 901126372658Smrg test no = "$module" \ 901226372658Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 901349dc963fSmrg 901426372658Smrg if test no != "$need_lib_prefix"; then 901549dc963fSmrg # Add the "lib" prefix for modules if required 901649dc963fSmrg func_stripname '' '.la' "$outputname" 901749dc963fSmrg name=$func_stripname_result 901849dc963fSmrg eval shared_ext=\"$shrext_cmds\" 901949dc963fSmrg eval libname=\"$libname_spec\" 902049dc963fSmrg else 902149dc963fSmrg func_stripname '' '.la' "$outputname" 902249dc963fSmrg libname=$func_stripname_result 902349dc963fSmrg fi 902449dc963fSmrg ;; 902549dc963fSmrg esac 902649dc963fSmrg 902749dc963fSmrg if test -n "$objs"; then 902826372658Smrg if test pass_all != "$deplibs_check_method"; then 902926372658Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 903049dc963fSmrg else 90317aa89044Smrg echo 903249dc963fSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 903349dc963fSmrg $ECHO "*** objects $objs is not portable!" 90344e7590efSmrg func_append libobjs " $objs" 903549dc963fSmrg fi 903649dc963fSmrg fi 903749dc963fSmrg 903826372658Smrg test no = "$dlself" \ 903926372658Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 904049dc963fSmrg 904149dc963fSmrg set dummy $rpath 904249dc963fSmrg shift 904326372658Smrg test 1 -lt "$#" \ 904426372658Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 904549dc963fSmrg 904626372658Smrg install_libdir=$1 904749dc963fSmrg 904849dc963fSmrg oldlibs= 904949dc963fSmrg if test -z "$rpath"; then 905026372658Smrg if test yes = "$build_libtool_libs"; then 905149dc963fSmrg # Building a libtool convenience library. 905226372658Smrg # Some compilers have problems with a '.al' extension so 905349dc963fSmrg # convenience libraries should have the same extension an 905449dc963fSmrg # archive normally would. 905549dc963fSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 905649dc963fSmrg build_libtool_libs=convenience 905749dc963fSmrg build_old_libs=yes 905849dc963fSmrg fi 905949dc963fSmrg 906049dc963fSmrg test -n "$vinfo" && \ 906126372658Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 906249dc963fSmrg 906349dc963fSmrg test -n "$release" && \ 906426372658Smrg func_warning "'-release' is ignored for convenience libraries" 906549dc963fSmrg else 906649dc963fSmrg 906749dc963fSmrg # Parse the version information argument. 906826372658Smrg save_ifs=$IFS; IFS=: 906949dc963fSmrg set dummy $vinfo 0 0 0 907049dc963fSmrg shift 907126372658Smrg IFS=$save_ifs 907249dc963fSmrg 907349dc963fSmrg test -n "$7" && \ 907426372658Smrg func_fatal_help "too many parameters to '-version-info'" 907549dc963fSmrg 907649dc963fSmrg # convert absolute version numbers to libtool ages 907749dc963fSmrg # this retains compatibility with .la files and attempts 907849dc963fSmrg # to make the code below a bit more comprehensible 907949dc963fSmrg 908049dc963fSmrg case $vinfo_number in 908149dc963fSmrg yes) 908226372658Smrg number_major=$1 908326372658Smrg number_minor=$2 908426372658Smrg number_revision=$3 908549dc963fSmrg # 908649dc963fSmrg # There are really only two kinds -- those that 908749dc963fSmrg # use the current revision as the major version 908849dc963fSmrg # and those that subtract age and use age as 908949dc963fSmrg # a minor version. But, then there is irix 909026372658Smrg # that has an extra 1 added just for fun 909149dc963fSmrg # 909249dc963fSmrg case $version_type in 90934e7590efSmrg # correct linux to gnu/linux during the next big refactor 9094c3e29c03Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 909549dc963fSmrg func_arith $number_major + $number_minor 909649dc963fSmrg current=$func_arith_result 909726372658Smrg age=$number_minor 909826372658Smrg revision=$number_revision 909949dc963fSmrg ;; 910026372658Smrg freebsd-aout|qnx|sunos) 910126372658Smrg current=$number_major 910226372658Smrg revision=$number_minor 910326372658Smrg age=0 910449dc963fSmrg ;; 910549dc963fSmrg irix|nonstopux) 910649dc963fSmrg func_arith $number_major + $number_minor 910749dc963fSmrg current=$func_arith_result 910826372658Smrg age=$number_minor 910926372658Smrg revision=$number_minor 911049dc963fSmrg lt_irix_increment=no 911149dc963fSmrg ;; 911249dc963fSmrg esac 911349dc963fSmrg ;; 911449dc963fSmrg no) 911526372658Smrg current=$1 911626372658Smrg revision=$2 911726372658Smrg age=$3 911849dc963fSmrg ;; 911949dc963fSmrg esac 912049dc963fSmrg 912149dc963fSmrg # Check that each of the things are valid numbers. 912249dc963fSmrg case $current in 912349dc963fSmrg 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]) ;; 912449dc963fSmrg *) 912526372658Smrg func_error "CURRENT '$current' must be a nonnegative integer" 912626372658Smrg func_fatal_error "'$vinfo' is not valid version information" 912749dc963fSmrg ;; 912849dc963fSmrg esac 912949dc963fSmrg 913049dc963fSmrg case $revision in 913149dc963fSmrg 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]) ;; 913249dc963fSmrg *) 913326372658Smrg func_error "REVISION '$revision' must be a nonnegative integer" 913426372658Smrg func_fatal_error "'$vinfo' is not valid version information" 913549dc963fSmrg ;; 913649dc963fSmrg esac 913749dc963fSmrg 913849dc963fSmrg case $age in 913949dc963fSmrg 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]) ;; 914049dc963fSmrg *) 914126372658Smrg func_error "AGE '$age' must be a nonnegative integer" 914226372658Smrg func_fatal_error "'$vinfo' is not valid version information" 914349dc963fSmrg ;; 914449dc963fSmrg esac 914549dc963fSmrg 914649dc963fSmrg if test "$age" -gt "$current"; then 914726372658Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 914826372658Smrg func_fatal_error "'$vinfo' is not valid version information" 914949dc963fSmrg fi 915049dc963fSmrg 915149dc963fSmrg # Calculate the version variables. 915249dc963fSmrg major= 915349dc963fSmrg versuffix= 915449dc963fSmrg verstring= 915549dc963fSmrg case $version_type in 915649dc963fSmrg none) ;; 915749dc963fSmrg 915849dc963fSmrg darwin) 915949dc963fSmrg # Like Linux, but with the current version available in 916049dc963fSmrg # verstring for coding it into the library header 916149dc963fSmrg func_arith $current - $age 916249dc963fSmrg major=.$func_arith_result 916326372658Smrg versuffix=$major.$age.$revision 916449dc963fSmrg # Darwin ld doesn't like 0 for these options... 916549dc963fSmrg func_arith $current + 1 916649dc963fSmrg minor_current=$func_arith_result 916726372658Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 916849dc963fSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 916926372658Smrg # On Darwin other compilers 917026372658Smrg case $CC in 917126372658Smrg nagfor*) 917226372658Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 917326372658Smrg ;; 917426372658Smrg *) 917526372658Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 917626372658Smrg ;; 917726372658Smrg esac 917849dc963fSmrg ;; 917949dc963fSmrg 918049dc963fSmrg freebsd-aout) 918126372658Smrg major=.$current 918226372658Smrg versuffix=.$current.$revision 918349dc963fSmrg ;; 918449dc963fSmrg 9185c3e29c03Smrg freebsd-elf | midnightbsd-elf) 918626372658Smrg func_arith $current - $age 918726372658Smrg major=.$func_arith_result 918826372658Smrg versuffix=$major.$age.$revision 918949dc963fSmrg ;; 919049dc963fSmrg 919149dc963fSmrg irix | nonstopux) 919226372658Smrg if test no = "$lt_irix_increment"; then 919349dc963fSmrg func_arith $current - $age 919449dc963fSmrg else 919549dc963fSmrg func_arith $current - $age + 1 919649dc963fSmrg fi 919749dc963fSmrg major=$func_arith_result 919849dc963fSmrg 919949dc963fSmrg case $version_type in 920049dc963fSmrg nonstopux) verstring_prefix=nonstopux ;; 920149dc963fSmrg *) verstring_prefix=sgi ;; 920249dc963fSmrg esac 920326372658Smrg verstring=$verstring_prefix$major.$revision 920449dc963fSmrg 920549dc963fSmrg # Add in all the interfaces that we are compatible with. 920649dc963fSmrg loop=$revision 920726372658Smrg while test 0 -ne "$loop"; do 920849dc963fSmrg func_arith $revision - $loop 920949dc963fSmrg iface=$func_arith_result 921049dc963fSmrg func_arith $loop - 1 921149dc963fSmrg loop=$func_arith_result 921226372658Smrg verstring=$verstring_prefix$major.$iface:$verstring 921349dc963fSmrg done 921449dc963fSmrg 921526372658Smrg # Before this point, $major must not contain '.'. 921649dc963fSmrg major=.$major 921726372658Smrg versuffix=$major.$revision 921849dc963fSmrg ;; 921949dc963fSmrg 92204e7590efSmrg linux) # correct to gnu/linux during the next big refactor 922149dc963fSmrg func_arith $current - $age 922249dc963fSmrg major=.$func_arith_result 922326372658Smrg versuffix=$major.$age.$revision 922449dc963fSmrg ;; 922549dc963fSmrg 922649dc963fSmrg osf) 922749dc963fSmrg func_arith $current - $age 922849dc963fSmrg major=.$func_arith_result 922926372658Smrg versuffix=.$current.$age.$revision 923026372658Smrg verstring=$current.$age.$revision 923149dc963fSmrg 923249dc963fSmrg # Add in all the interfaces that we are compatible with. 923349dc963fSmrg loop=$age 923426372658Smrg while test 0 -ne "$loop"; do 923549dc963fSmrg func_arith $current - $loop 923649dc963fSmrg iface=$func_arith_result 923749dc963fSmrg func_arith $loop - 1 923849dc963fSmrg loop=$func_arith_result 923926372658Smrg verstring=$verstring:$iface.0 924049dc963fSmrg done 924149dc963fSmrg 924249dc963fSmrg # Make executables depend on our current version. 924326372658Smrg func_append verstring ":$current.0" 924449dc963fSmrg ;; 924549dc963fSmrg 924649dc963fSmrg qnx) 924726372658Smrg major=.$current 924826372658Smrg versuffix=.$current 924926372658Smrg ;; 925026372658Smrg 925126372658Smrg sco) 925226372658Smrg major=.$current 925326372658Smrg versuffix=.$current 925449dc963fSmrg ;; 925549dc963fSmrg 925649dc963fSmrg sunos) 925726372658Smrg major=.$current 925826372658Smrg versuffix=.$current.$revision 925949dc963fSmrg ;; 926049dc963fSmrg 926149dc963fSmrg windows) 926249dc963fSmrg # Use '-' rather than '.', since we only want one 926326372658Smrg # extension on DOS 8.3 file systems. 926449dc963fSmrg func_arith $current - $age 926549dc963fSmrg major=$func_arith_result 926626372658Smrg versuffix=-$major 926749dc963fSmrg ;; 926849dc963fSmrg 926949dc963fSmrg *) 927026372658Smrg func_fatal_configuration "unknown library version type '$version_type'" 927149dc963fSmrg ;; 927249dc963fSmrg esac 927349dc963fSmrg 927449dc963fSmrg # Clear the version info if we defaulted, and they specified a release. 927549dc963fSmrg if test -z "$vinfo" && test -n "$release"; then 927649dc963fSmrg major= 927749dc963fSmrg case $version_type in 927849dc963fSmrg darwin) 927949dc963fSmrg # we can't check for "0.0" in archive_cmds due to quoting 928049dc963fSmrg # problems, so we reset it completely 928149dc963fSmrg verstring= 928249dc963fSmrg ;; 928349dc963fSmrg *) 928426372658Smrg verstring=0.0 928549dc963fSmrg ;; 928649dc963fSmrg esac 928726372658Smrg if test no = "$need_version"; then 928849dc963fSmrg versuffix= 928949dc963fSmrg else 929026372658Smrg versuffix=.0.0 929149dc963fSmrg fi 929249dc963fSmrg fi 929349dc963fSmrg 929449dc963fSmrg # Remove version info from name if versioning should be avoided 929526372658Smrg if test yes,no = "$avoid_version,$need_version"; then 929649dc963fSmrg major= 929749dc963fSmrg versuffix= 929826372658Smrg verstring= 929949dc963fSmrg fi 930049dc963fSmrg 930149dc963fSmrg # Check to see if the archive will have undefined symbols. 930226372658Smrg if test yes = "$allow_undefined"; then 930326372658Smrg if test unsupported = "$allow_undefined_flag"; then 930426372658Smrg if test yes = "$build_old_libs"; then 930526372658Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 930626372658Smrg build_libtool_libs=no 930726372658Smrg else 930826372658Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 930926372658Smrg fi 931049dc963fSmrg fi 931149dc963fSmrg else 931249dc963fSmrg # Don't allow undefined symbols. 931326372658Smrg allow_undefined_flag=$no_undefined_flag 931449dc963fSmrg fi 931549dc963fSmrg 931649dc963fSmrg fi 931749dc963fSmrg 931826372658Smrg func_generate_dlsyms "$libname" "$libname" : 93194e7590efSmrg func_append libobjs " $symfileobj" 932026372658Smrg test " " = "$libobjs" && libobjs= 932149dc963fSmrg 932226372658Smrg if test relink != "$opt_mode"; then 932349dc963fSmrg # Remove our outputs, but don't remove object files since they 932449dc963fSmrg # may have been created when compiling PIC objects. 932549dc963fSmrg removelist= 932649dc963fSmrg tempremovelist=`$ECHO "$output_objdir/*"` 932749dc963fSmrg for p in $tempremovelist; do 932849dc963fSmrg case $p in 932949dc963fSmrg *.$objext | *.gcno) 933049dc963fSmrg ;; 933126372658Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 933226372658Smrg if test -n "$precious_files_regex"; then 933349dc963fSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 933449dc963fSmrg then 933549dc963fSmrg continue 933649dc963fSmrg fi 933749dc963fSmrg fi 93384e7590efSmrg func_append removelist " $p" 933949dc963fSmrg ;; 934049dc963fSmrg *) ;; 934149dc963fSmrg esac 934249dc963fSmrg done 934349dc963fSmrg test -n "$removelist" && \ 934449dc963fSmrg func_show_eval "${RM}r \$removelist" 934549dc963fSmrg fi 934649dc963fSmrg 934749dc963fSmrg # Now set the variables for building old libraries. 934826372658Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93494e7590efSmrg func_append oldlibs " $output_objdir/$libname.$libext" 935049dc963fSmrg 935149dc963fSmrg # Transform .lo files to .o files. 935226372658Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 935349dc963fSmrg fi 935449dc963fSmrg 935549dc963fSmrg # Eliminate all temporary directories. 935649dc963fSmrg #for path in $notinst_path; do 93577aa89044Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93587aa89044Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93597aa89044Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 936049dc963fSmrg #done 936149dc963fSmrg 936249dc963fSmrg if test -n "$xrpath"; then 936349dc963fSmrg # If the user specified any rpath flags, then add them. 936449dc963fSmrg temp_xrpath= 936549dc963fSmrg for libdir in $xrpath; do 93664e7590efSmrg func_replace_sysroot "$libdir" 93674e7590efSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 936849dc963fSmrg case "$finalize_rpath " in 936949dc963fSmrg *" $libdir "*) ;; 93704e7590efSmrg *) func_append finalize_rpath " $libdir" ;; 937149dc963fSmrg esac 937249dc963fSmrg done 937326372658Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 937449dc963fSmrg dependency_libs="$temp_xrpath $dependency_libs" 937549dc963fSmrg fi 937649dc963fSmrg fi 937749dc963fSmrg 937849dc963fSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 937926372658Smrg old_dlfiles=$dlfiles 938049dc963fSmrg dlfiles= 938149dc963fSmrg for lib in $old_dlfiles; do 938249dc963fSmrg case " $dlprefiles $dlfiles " in 938349dc963fSmrg *" $lib "*) ;; 93844e7590efSmrg *) func_append dlfiles " $lib" ;; 938549dc963fSmrg esac 938649dc963fSmrg done 938749dc963fSmrg 938849dc963fSmrg # Make sure dlprefiles contains only unique files 938926372658Smrg old_dlprefiles=$dlprefiles 939049dc963fSmrg dlprefiles= 939149dc963fSmrg for lib in $old_dlprefiles; do 939249dc963fSmrg case "$dlprefiles " in 939349dc963fSmrg *" $lib "*) ;; 93944e7590efSmrg *) func_append dlprefiles " $lib" ;; 939549dc963fSmrg esac 939649dc963fSmrg done 939749dc963fSmrg 939826372658Smrg if test yes = "$build_libtool_libs"; then 939949dc963fSmrg if test -n "$rpath"; then 940049dc963fSmrg case $host in 94017aa89044Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 940249dc963fSmrg # these systems don't actually have a c library (as such)! 940349dc963fSmrg ;; 940449dc963fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 940549dc963fSmrg # Rhapsody C library is in the System framework 94064e7590efSmrg func_append deplibs " System.ltframework" 940749dc963fSmrg ;; 940849dc963fSmrg *-*-netbsd*) 940949dc963fSmrg # Don't link with libc until the a.out ld.so is fixed. 941049dc963fSmrg ;; 9411c3e29c03Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 941249dc963fSmrg # Do not include libc due to us having libc/libc_r. 941349dc963fSmrg ;; 941449dc963fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 941549dc963fSmrg # Causes problems with __ctype 941649dc963fSmrg ;; 941749dc963fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 941849dc963fSmrg # Compiler inserts libc in the correct place for threads to work 941949dc963fSmrg ;; 942049dc963fSmrg *) 942149dc963fSmrg # Add libc to deplibs on all other systems if necessary. 942226372658Smrg if test yes = "$build_libtool_need_lc"; then 94234e7590efSmrg func_append deplibs " -lc" 942449dc963fSmrg fi 942549dc963fSmrg ;; 942649dc963fSmrg esac 942749dc963fSmrg fi 942849dc963fSmrg 942949dc963fSmrg # Transform deplibs into only deplibs that can be linked in shared. 943049dc963fSmrg name_save=$name 943149dc963fSmrg libname_save=$libname 943249dc963fSmrg release_save=$release 943349dc963fSmrg versuffix_save=$versuffix 943449dc963fSmrg major_save=$major 943549dc963fSmrg # I'm not sure if I'm treating the release correctly. I think 943649dc963fSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 943749dc963fSmrg # add it in twice. Is that correct? 943826372658Smrg release= 943926372658Smrg versuffix= 944026372658Smrg major= 944149dc963fSmrg newdeplibs= 944249dc963fSmrg droppeddeps=no 944349dc963fSmrg case $deplibs_check_method in 944449dc963fSmrg pass_all) 944549dc963fSmrg # Don't check for shared/static. Everything works. 944649dc963fSmrg # This might be a little naive. We might want to check 944749dc963fSmrg # whether the library exists or not. But this is on 944849dc963fSmrg # osf3 & osf4 and I'm not really sure... Just 944949dc963fSmrg # implementing what was already the behavior. 945049dc963fSmrg newdeplibs=$deplibs 945149dc963fSmrg ;; 945249dc963fSmrg test_compile) 945349dc963fSmrg # This code stresses the "libraries are programs" paradigm to its 945449dc963fSmrg # limits. Maybe even breaks it. We compile a program, linking it 945549dc963fSmrg # against the deplibs as a proxy for the library. Then we can check 945649dc963fSmrg # whether they linked in statically or dynamically with ldd. 945749dc963fSmrg $opt_dry_run || $RM conftest.c 945849dc963fSmrg cat > conftest.c <<EOF 945949dc963fSmrg int main() { return 0; } 946049dc963fSmrgEOF 946149dc963fSmrg $opt_dry_run || $RM conftest 946249dc963fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 946349dc963fSmrg ldd_output=`ldd conftest` 946449dc963fSmrg for i in $deplibs; do 946549dc963fSmrg case $i in 946649dc963fSmrg -l*) 946749dc963fSmrg func_stripname -l '' "$i" 946849dc963fSmrg name=$func_stripname_result 946926372658Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 947049dc963fSmrg case " $predeps $postdeps " in 947149dc963fSmrg *" $i "*) 94724e7590efSmrg func_append newdeplibs " $i" 947326372658Smrg i= 947449dc963fSmrg ;; 947549dc963fSmrg esac 947649dc963fSmrg fi 947726372658Smrg if test -n "$i"; then 947849dc963fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 947949dc963fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 948049dc963fSmrg set dummy $deplib_matches; shift 948149dc963fSmrg deplib_match=$1 948226372658Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94834e7590efSmrg func_append newdeplibs " $i" 948449dc963fSmrg else 948549dc963fSmrg droppeddeps=yes 94867aa89044Smrg echo 948749dc963fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94887aa89044Smrg echo "*** I have the capability to make that library automatically link in when" 94897aa89044Smrg echo "*** you link to this library. But I can only do this if you have a" 94907aa89044Smrg echo "*** shared version of the library, which I believe you do not have" 94917aa89044Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 94927aa89044Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 949349dc963fSmrg fi 949449dc963fSmrg fi 949549dc963fSmrg ;; 949649dc963fSmrg *) 94974e7590efSmrg func_append newdeplibs " $i" 949849dc963fSmrg ;; 949949dc963fSmrg esac 950049dc963fSmrg done 950149dc963fSmrg else 950249dc963fSmrg # Error occurred in the first compile. Let's try to salvage 950349dc963fSmrg # the situation: Compile a separate program for each library. 950449dc963fSmrg for i in $deplibs; do 950549dc963fSmrg case $i in 950649dc963fSmrg -l*) 950749dc963fSmrg func_stripname -l '' "$i" 950849dc963fSmrg name=$func_stripname_result 950949dc963fSmrg $opt_dry_run || $RM conftest 951049dc963fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 951149dc963fSmrg ldd_output=`ldd conftest` 951226372658Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 951349dc963fSmrg case " $predeps $postdeps " in 951449dc963fSmrg *" $i "*) 95154e7590efSmrg func_append newdeplibs " $i" 951626372658Smrg i= 951749dc963fSmrg ;; 951849dc963fSmrg esac 951949dc963fSmrg fi 952026372658Smrg if test -n "$i"; then 952149dc963fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 952249dc963fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 952349dc963fSmrg set dummy $deplib_matches; shift 952449dc963fSmrg deplib_match=$1 952526372658Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95264e7590efSmrg func_append newdeplibs " $i" 952749dc963fSmrg else 952849dc963fSmrg droppeddeps=yes 95297aa89044Smrg echo 953049dc963fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95317aa89044Smrg echo "*** I have the capability to make that library automatically link in when" 95327aa89044Smrg echo "*** you link to this library. But I can only do this if you have a" 95337aa89044Smrg echo "*** shared version of the library, which you do not appear to have" 95347aa89044Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 95357aa89044Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 953649dc963fSmrg fi 953749dc963fSmrg fi 953849dc963fSmrg else 953949dc963fSmrg droppeddeps=yes 95407aa89044Smrg echo 954149dc963fSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95427aa89044Smrg echo "*** make it link in! You will probably need to install it or some" 95437aa89044Smrg echo "*** library that it depends on before this library will be fully" 95447aa89044Smrg echo "*** functional. Installing it before continuing would be even better." 954549dc963fSmrg fi 954649dc963fSmrg ;; 954749dc963fSmrg *) 95484e7590efSmrg func_append newdeplibs " $i" 954949dc963fSmrg ;; 955049dc963fSmrg esac 955149dc963fSmrg done 955249dc963fSmrg fi 955349dc963fSmrg ;; 955449dc963fSmrg file_magic*) 955549dc963fSmrg set dummy $deplibs_check_method; shift 955649dc963fSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 955749dc963fSmrg for a_deplib in $deplibs; do 955849dc963fSmrg case $a_deplib in 955949dc963fSmrg -l*) 956049dc963fSmrg func_stripname -l '' "$a_deplib" 956149dc963fSmrg name=$func_stripname_result 956226372658Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 956349dc963fSmrg case " $predeps $postdeps " in 956449dc963fSmrg *" $a_deplib "*) 95654e7590efSmrg func_append newdeplibs " $a_deplib" 956626372658Smrg a_deplib= 956749dc963fSmrg ;; 956849dc963fSmrg esac 956949dc963fSmrg fi 957026372658Smrg if test -n "$a_deplib"; then 957149dc963fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 95724e7590efSmrg if test -n "$file_magic_glob"; then 95734e7590efSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95744e7590efSmrg else 95754e7590efSmrg libnameglob=$libname 95764e7590efSmrg fi 957726372658Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 957849dc963fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 957926372658Smrg if test yes = "$want_nocaseglob"; then 95804e7590efSmrg shopt -s nocaseglob 95814e7590efSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95824e7590efSmrg $nocaseglob 95834e7590efSmrg else 95844e7590efSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95854e7590efSmrg fi 958649dc963fSmrg for potent_lib in $potential_libs; do 958749dc963fSmrg # Follow soft links. 958849dc963fSmrg if ls -lLd "$potent_lib" 2>/dev/null | 958949dc963fSmrg $GREP " -> " >/dev/null; then 959049dc963fSmrg continue 959149dc963fSmrg fi 959249dc963fSmrg # The statement above tries to avoid entering an 959349dc963fSmrg # endless loop below, in case of cyclic links. 959449dc963fSmrg # We might still enter an endless loop, since a link 959549dc963fSmrg # loop can be closed while we follow links, 959649dc963fSmrg # but so what? 959726372658Smrg potlib=$potent_lib 959849dc963fSmrg while test -h "$potlib" 2>/dev/null; do 959926372658Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 960049dc963fSmrg case $potliblink in 960126372658Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 960226372658Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 960349dc963fSmrg esac 960449dc963fSmrg done 960549dc963fSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 960649dc963fSmrg $SED -e 10q | 960749dc963fSmrg $EGREP "$file_magic_regex" > /dev/null; then 96084e7590efSmrg func_append newdeplibs " $a_deplib" 960926372658Smrg a_deplib= 961049dc963fSmrg break 2 961149dc963fSmrg fi 961249dc963fSmrg done 961349dc963fSmrg done 961449dc963fSmrg fi 961526372658Smrg if test -n "$a_deplib"; then 961649dc963fSmrg droppeddeps=yes 96177aa89044Smrg echo 961849dc963fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96197aa89044Smrg echo "*** I have the capability to make that library automatically link in when" 96207aa89044Smrg echo "*** you link to this library. But I can only do this if you have a" 96217aa89044Smrg echo "*** shared version of the library, which you do not appear to have" 96227aa89044Smrg echo "*** because I did check the linker path looking for a file starting" 962326372658Smrg if test -z "$potlib"; then 962449dc963fSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 962549dc963fSmrg else 962649dc963fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 962749dc963fSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 962849dc963fSmrg fi 962949dc963fSmrg fi 963049dc963fSmrg ;; 963149dc963fSmrg *) 963249dc963fSmrg # Add a -L argument. 96334e7590efSmrg func_append newdeplibs " $a_deplib" 963449dc963fSmrg ;; 963549dc963fSmrg esac 963649dc963fSmrg done # Gone through all deplibs. 963749dc963fSmrg ;; 963849dc963fSmrg match_pattern*) 963949dc963fSmrg set dummy $deplibs_check_method; shift 964049dc963fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 964149dc963fSmrg for a_deplib in $deplibs; do 964249dc963fSmrg case $a_deplib in 964349dc963fSmrg -l*) 964449dc963fSmrg func_stripname -l '' "$a_deplib" 964549dc963fSmrg name=$func_stripname_result 964626372658Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 964749dc963fSmrg case " $predeps $postdeps " in 964849dc963fSmrg *" $a_deplib "*) 96494e7590efSmrg func_append newdeplibs " $a_deplib" 965026372658Smrg a_deplib= 965149dc963fSmrg ;; 965249dc963fSmrg esac 965349dc963fSmrg fi 965426372658Smrg if test -n "$a_deplib"; then 965549dc963fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 965649dc963fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 965749dc963fSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 965849dc963fSmrg for potent_lib in $potential_libs; do 965926372658Smrg potlib=$potent_lib # see symlink-check above in file_magic test 96607aa89044Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 966149dc963fSmrg $EGREP "$match_pattern_regex" > /dev/null; then 96624e7590efSmrg func_append newdeplibs " $a_deplib" 966326372658Smrg a_deplib= 966449dc963fSmrg break 2 966549dc963fSmrg fi 966649dc963fSmrg done 966749dc963fSmrg done 966849dc963fSmrg fi 966926372658Smrg if test -n "$a_deplib"; then 967049dc963fSmrg droppeddeps=yes 96717aa89044Smrg echo 967249dc963fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96737aa89044Smrg echo "*** I have the capability to make that library automatically link in when" 96747aa89044Smrg echo "*** you link to this library. But I can only do this if you have a" 96757aa89044Smrg echo "*** shared version of the library, which you do not appear to have" 96767aa89044Smrg echo "*** because I did check the linker path looking for a file starting" 967726372658Smrg if test -z "$potlib"; then 967849dc963fSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 967949dc963fSmrg else 968049dc963fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 968149dc963fSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 968249dc963fSmrg fi 968349dc963fSmrg fi 968449dc963fSmrg ;; 968549dc963fSmrg *) 968649dc963fSmrg # Add a -L argument. 96874e7590efSmrg func_append newdeplibs " $a_deplib" 968849dc963fSmrg ;; 968949dc963fSmrg esac 969049dc963fSmrg done # Gone through all deplibs. 969149dc963fSmrg ;; 969249dc963fSmrg none | unknown | *) 969326372658Smrg newdeplibs= 96947aa89044Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 969526372658Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 969626372658Smrg for i in $predeps $postdeps; do 969749dc963fSmrg # can't use Xsed below, because $i might contain '/' 969826372658Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 969949dc963fSmrg done 970049dc963fSmrg fi 97017aa89044Smrg case $tmp_deplibs in 97027aa89044Smrg *[!\ \ ]*) 97037aa89044Smrg echo 970426372658Smrg if test none = "$deplibs_check_method"; then 97057aa89044Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 970649dc963fSmrg else 97077aa89044Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 970849dc963fSmrg fi 97097aa89044Smrg echo "*** All declared inter-library dependencies are being dropped." 971049dc963fSmrg droppeddeps=yes 97117aa89044Smrg ;; 97127aa89044Smrg esac 971349dc963fSmrg ;; 971449dc963fSmrg esac 971549dc963fSmrg versuffix=$versuffix_save 971649dc963fSmrg major=$major_save 971749dc963fSmrg release=$release_save 971849dc963fSmrg libname=$libname_save 971949dc963fSmrg name=$name_save 972049dc963fSmrg 972149dc963fSmrg case $host in 972249dc963fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 972349dc963fSmrg # On Rhapsody replace the C library with the System framework 97247aa89044Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 972549dc963fSmrg ;; 972649dc963fSmrg esac 972749dc963fSmrg 972826372658Smrg if test yes = "$droppeddeps"; then 972926372658Smrg if test yes = "$module"; then 97307aa89044Smrg echo 97317aa89044Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 973249dc963fSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97337aa89044Smrg echo "*** a static module, that should work as long as the dlopening" 97347aa89044Smrg echo "*** application is linked with the -dlopen flag." 973549dc963fSmrg if test -z "$global_symbol_pipe"; then 97367aa89044Smrg echo 97377aa89044Smrg echo "*** However, this would only work if libtool was able to extract symbol" 973826372658Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97397aa89044Smrg echo "*** not find such a program. So, this module is probably useless." 974026372658Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 974149dc963fSmrg fi 974226372658Smrg if test no = "$build_old_libs"; then 974326372658Smrg oldlibs=$output_objdir/$libname.$libext 974449dc963fSmrg build_libtool_libs=module 974549dc963fSmrg build_old_libs=yes 974649dc963fSmrg else 974749dc963fSmrg build_libtool_libs=no 974849dc963fSmrg fi 974949dc963fSmrg else 97507aa89044Smrg echo "*** The inter-library dependencies that have been dropped here will be" 97517aa89044Smrg echo "*** automatically added whenever a program is linked with this library" 97527aa89044Smrg echo "*** or is declared to -dlopen it." 975349dc963fSmrg 975426372658Smrg if test no = "$allow_undefined"; then 97557aa89044Smrg echo 97567aa89044Smrg echo "*** Since this library must not contain undefined symbols," 97577aa89044Smrg echo "*** because either the platform does not support them or" 97587aa89044Smrg echo "*** it was explicitly requested with -no-undefined," 97597aa89044Smrg echo "*** libtool will only create a static version of it." 976026372658Smrg if test no = "$build_old_libs"; then 976126372658Smrg oldlibs=$output_objdir/$libname.$libext 976249dc963fSmrg build_libtool_libs=module 976349dc963fSmrg build_old_libs=yes 976449dc963fSmrg else 976549dc963fSmrg build_libtool_libs=no 976649dc963fSmrg fi 976749dc963fSmrg fi 976849dc963fSmrg fi 976949dc963fSmrg fi 977049dc963fSmrg # Done checking deplibs! 977149dc963fSmrg deplibs=$newdeplibs 977249dc963fSmrg fi 977349dc963fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 977449dc963fSmrg case $host in 977549dc963fSmrg *-*-darwin*) 97767aa89044Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97777aa89044Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97787aa89044Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977949dc963fSmrg ;; 978049dc963fSmrg esac 978149dc963fSmrg 978249dc963fSmrg # move library search paths that coincide with paths to not yet 978349dc963fSmrg # installed libraries to the beginning of the library search list 978449dc963fSmrg new_libs= 978549dc963fSmrg for path in $notinst_path; do 978649dc963fSmrg case " $new_libs " in 978749dc963fSmrg *" -L$path/$objdir "*) ;; 978849dc963fSmrg *) 978949dc963fSmrg case " $deplibs " in 979049dc963fSmrg *" -L$path/$objdir "*) 97914e7590efSmrg func_append new_libs " -L$path/$objdir" ;; 979249dc963fSmrg esac 979349dc963fSmrg ;; 979449dc963fSmrg esac 979549dc963fSmrg done 979649dc963fSmrg for deplib in $deplibs; do 979749dc963fSmrg case $deplib in 979849dc963fSmrg -L*) 979949dc963fSmrg case " $new_libs " in 980049dc963fSmrg *" $deplib "*) ;; 98014e7590efSmrg *) func_append new_libs " $deplib" ;; 980249dc963fSmrg esac 980349dc963fSmrg ;; 98044e7590efSmrg *) func_append new_libs " $deplib" ;; 980549dc963fSmrg esac 980649dc963fSmrg done 980726372658Smrg deplibs=$new_libs 980849dc963fSmrg 980949dc963fSmrg # All the library-specific variables (install_libdir is set above). 981049dc963fSmrg library_names= 981149dc963fSmrg old_library= 981249dc963fSmrg dlname= 981349dc963fSmrg 981449dc963fSmrg # Test again, we may have decided not to build it any more 981526372658Smrg if test yes = "$build_libtool_libs"; then 981626372658Smrg # Remove $wl instances when linking with ld. 98174e7590efSmrg # FIXME: should test the right _cmds variable. 98184e7590efSmrg case $archive_cmds in 98194e7590efSmrg *\$LD\ *) wl= ;; 98204e7590efSmrg esac 982126372658Smrg if test yes = "$hardcode_into_libs"; then 982249dc963fSmrg # Hardcode the library paths 982349dc963fSmrg hardcode_libdirs= 982449dc963fSmrg dep_rpath= 982526372658Smrg rpath=$finalize_rpath 982626372658Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 982749dc963fSmrg for libdir in $rpath; do 982849dc963fSmrg if test -n "$hardcode_libdir_flag_spec"; then 982949dc963fSmrg if test -n "$hardcode_libdir_separator"; then 98304e7590efSmrg func_replace_sysroot "$libdir" 98314e7590efSmrg libdir=$func_replace_sysroot_result 983249dc963fSmrg if test -z "$hardcode_libdirs"; then 983326372658Smrg hardcode_libdirs=$libdir 983449dc963fSmrg else 983549dc963fSmrg # Just accumulate the unique libdirs. 983649dc963fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 983749dc963fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 983849dc963fSmrg ;; 983949dc963fSmrg *) 98404e7590efSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 984149dc963fSmrg ;; 984249dc963fSmrg esac 984349dc963fSmrg fi 984449dc963fSmrg else 984549dc963fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 98464e7590efSmrg func_append dep_rpath " $flag" 984749dc963fSmrg fi 984849dc963fSmrg elif test -n "$runpath_var"; then 984949dc963fSmrg case "$perm_rpath " in 985049dc963fSmrg *" $libdir "*) ;; 98514e7590efSmrg *) func_append perm_rpath " $libdir" ;; 985249dc963fSmrg esac 985349dc963fSmrg fi 985449dc963fSmrg done 985549dc963fSmrg # Substitute the hardcoded libdirs into the rpath. 985649dc963fSmrg if test -n "$hardcode_libdir_separator" && 985749dc963fSmrg test -n "$hardcode_libdirs"; then 985826372658Smrg libdir=$hardcode_libdirs 98594e7590efSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 986049dc963fSmrg fi 986149dc963fSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 986249dc963fSmrg # We should set the runpath_var. 986349dc963fSmrg rpath= 986449dc963fSmrg for dir in $perm_rpath; do 98654e7590efSmrg func_append rpath "$dir:" 986649dc963fSmrg done 986749dc963fSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 986849dc963fSmrg fi 986949dc963fSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 987049dc963fSmrg fi 98714b0ead49Smrg 987226372658Smrg shlibpath=$finalize_shlibpath 987326372658Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 987449dc963fSmrg if test -n "$shlibpath"; then 987549dc963fSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 987649dc963fSmrg fi 98774b0ead49Smrg 987849dc963fSmrg # Get the real and link names of the library. 987949dc963fSmrg eval shared_ext=\"$shrext_cmds\" 988049dc963fSmrg eval library_names=\"$library_names_spec\" 988149dc963fSmrg set dummy $library_names 988249dc963fSmrg shift 988326372658Smrg realname=$1 988449dc963fSmrg shift 98854b0ead49Smrg 988649dc963fSmrg if test -n "$soname_spec"; then 988749dc963fSmrg eval soname=\"$soname_spec\" 988849dc963fSmrg else 988926372658Smrg soname=$realname 989049dc963fSmrg fi 989149dc963fSmrg if test -z "$dlname"; then 989249dc963fSmrg dlname=$soname 989349dc963fSmrg fi 98944b0ead49Smrg 989526372658Smrg lib=$output_objdir/$realname 989649dc963fSmrg linknames= 989749dc963fSmrg for link 989849dc963fSmrg do 98994e7590efSmrg func_append linknames " $link" 990049dc963fSmrg done 99014b0ead49Smrg 990249dc963fSmrg # Use standard objects if they are pic 99037aa89044Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 990449dc963fSmrg test "X$libobjs" = "X " && libobjs= 99054b0ead49Smrg 990649dc963fSmrg delfiles= 990749dc963fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 990849dc963fSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 990926372658Smrg export_symbols=$output_objdir/$libname.uexp 99104e7590efSmrg func_append delfiles " $export_symbols" 991149dc963fSmrg fi 99124b0ead49Smrg 991349dc963fSmrg orig_export_symbols= 991449dc963fSmrg case $host_os in 991549dc963fSmrg cygwin* | mingw* | cegcc*) 991649dc963fSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 991749dc963fSmrg # exporting using user supplied symfile 991826372658Smrg func_dll_def_p "$export_symbols" || { 991949dc963fSmrg # and it's NOT already a .def file. Must figure out 992049dc963fSmrg # which of the given symbols are data symbols and tag 992149dc963fSmrg # them as such. So, trigger use of export_symbols_cmds. 992249dc963fSmrg # export_symbols gets reassigned inside the "prepare 992349dc963fSmrg # the list of exported symbols" if statement, so the 992449dc963fSmrg # include_expsyms logic still works. 992526372658Smrg orig_export_symbols=$export_symbols 992649dc963fSmrg export_symbols= 992749dc963fSmrg always_export_symbols=yes 992826372658Smrg } 992949dc963fSmrg fi 993049dc963fSmrg ;; 993149dc963fSmrg esac 99324b0ead49Smrg 993349dc963fSmrg # Prepare the list of exported symbols 993449dc963fSmrg if test -z "$export_symbols"; then 993526372658Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 993626372658Smrg func_verbose "generating symbol list for '$libname.la'" 993726372658Smrg export_symbols=$output_objdir/$libname.exp 993849dc963fSmrg $opt_dry_run || $RM $export_symbols 993949dc963fSmrg cmds=$export_symbols_cmds 994026372658Smrg save_ifs=$IFS; IFS='~' 99414e7590efSmrg for cmd1 in $cmds; do 994226372658Smrg IFS=$save_ifs 99434e7590efSmrg # Take the normal branch if the nm_file_list_spec branch 99444e7590efSmrg # doesn't work or if tool conversion is not needed. 99454e7590efSmrg case $nm_file_list_spec~$to_tool_file_cmd in 99464e7590efSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99474e7590efSmrg try_normal_branch=yes 99484e7590efSmrg eval cmd=\"$cmd1\" 99494e7590efSmrg func_len " $cmd" 99504e7590efSmrg len=$func_len_result 99514e7590efSmrg ;; 99524e7590efSmrg *) 99534e7590efSmrg try_normal_branch=no 99544e7590efSmrg ;; 99554e7590efSmrg esac 995626372658Smrg if test yes = "$try_normal_branch" \ 99574e7590efSmrg && { test "$len" -lt "$max_cmd_len" \ 99584e7590efSmrg || test "$max_cmd_len" -le -1; } 99594e7590efSmrg then 99604e7590efSmrg func_show_eval "$cmd" 'exit $?' 99614e7590efSmrg skipped_export=false 99624e7590efSmrg elif test -n "$nm_file_list_spec"; then 99634e7590efSmrg func_basename "$output" 99644e7590efSmrg output_la=$func_basename_result 99654e7590efSmrg save_libobjs=$libobjs 99664e7590efSmrg save_output=$output 996726372658Smrg output=$output_objdir/$output_la.nm 99684e7590efSmrg func_to_tool_file "$output" 99694e7590efSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99704e7590efSmrg func_append delfiles " $output" 99714e7590efSmrg func_verbose "creating $NM input file list: $output" 99724e7590efSmrg for obj in $save_libobjs; do 99734e7590efSmrg func_to_tool_file "$obj" 99744e7590efSmrg $ECHO "$func_to_tool_file_result" 99754e7590efSmrg done > "$output" 99764e7590efSmrg eval cmd=\"$cmd1\" 997749dc963fSmrg func_show_eval "$cmd" 'exit $?' 99784e7590efSmrg output=$save_output 99794e7590efSmrg libobjs=$save_libobjs 998049dc963fSmrg skipped_export=false 998149dc963fSmrg else 998249dc963fSmrg # The command line is too long to execute in one step. 998349dc963fSmrg func_verbose "using reloadable object file for export list..." 998449dc963fSmrg skipped_export=: 998549dc963fSmrg # Break out early, otherwise skipped_export may be 998649dc963fSmrg # set to false by a later but shorter cmd. 998749dc963fSmrg break 998849dc963fSmrg fi 998949dc963fSmrg done 999026372658Smrg IFS=$save_ifs 999126372658Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 999249dc963fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 999349dc963fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 999449dc963fSmrg fi 999549dc963fSmrg fi 99964b0ead49Smrg fi 99974b0ead49Smrg 999849dc963fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 999926372658Smrg tmp_export_symbols=$export_symbols 1000026372658Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 100017aa89044Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1000249dc963fSmrg fi 100034b0ead49Smrg 1000426372658Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 1000549dc963fSmrg # The given exports_symbols file has to be filtered, so filter it. 1000626372658Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1000749dc963fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1000826372658Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 1000949dc963fSmrg # though. Also, the filter scales superlinearly with the number of 1001049dc963fSmrg # global variables. join(1) would be nice here, but unfortunately 1001149dc963fSmrg # isn't a blessed tool. 1001249dc963fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100134e7590efSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1001449dc963fSmrg export_symbols=$output_objdir/$libname.def 1001549dc963fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1001649dc963fSmrg fi 100174b0ead49Smrg 1001849dc963fSmrg tmp_deplibs= 1001949dc963fSmrg for test_deplib in $deplibs; do 1002049dc963fSmrg case " $convenience " in 1002149dc963fSmrg *" $test_deplib "*) ;; 1002249dc963fSmrg *) 100234e7590efSmrg func_append tmp_deplibs " $test_deplib" 1002449dc963fSmrg ;; 1002549dc963fSmrg esac 1002649dc963fSmrg done 1002726372658Smrg deplibs=$tmp_deplibs 100284b0ead49Smrg 1002949dc963fSmrg if test -n "$convenience"; then 1003049dc963fSmrg if test -n "$whole_archive_flag_spec" && 1003126372658Smrg test yes = "$compiler_needs_object" && 1003249dc963fSmrg test -z "$libobjs"; then 1003349dc963fSmrg # extract the archives, so we have objects to list. 1003449dc963fSmrg # TODO: could optimize this to just extract one archive. 1003549dc963fSmrg whole_archive_flag_spec= 1003649dc963fSmrg fi 1003749dc963fSmrg if test -n "$whole_archive_flag_spec"; then 1003849dc963fSmrg save_libobjs=$libobjs 1003949dc963fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1004049dc963fSmrg test "X$libobjs" = "X " && libobjs= 1004149dc963fSmrg else 1004226372658Smrg gentop=$output_objdir/${outputname}x 100434e7590efSmrg func_append generated " $gentop" 100444b0ead49Smrg 1004549dc963fSmrg func_extract_archives $gentop $convenience 100464e7590efSmrg func_append libobjs " $func_extract_archives_result" 1004749dc963fSmrg test "X$libobjs" = "X " && libobjs= 1004849dc963fSmrg fi 100494b0ead49Smrg fi 100504b0ead49Smrg 1005126372658Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 1005249dc963fSmrg eval flag=\"$thread_safe_flag_spec\" 100534e7590efSmrg func_append linker_flags " $flag" 100544b0ead49Smrg fi 100554b0ead49Smrg 1005649dc963fSmrg # Make a backup of the uninstalled library when relinking 1005726372658Smrg if test relink = "$opt_mode"; then 1005849dc963fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 1005949dc963fSmrg fi 100604b0ead49Smrg 1006149dc963fSmrg # Do each of the archive commands. 1006226372658Smrg if test yes = "$module" && test -n "$module_cmds"; then 1006349dc963fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1006449dc963fSmrg eval test_cmds=\"$module_expsym_cmds\" 1006549dc963fSmrg cmds=$module_expsym_cmds 1006649dc963fSmrg else 1006749dc963fSmrg eval test_cmds=\"$module_cmds\" 1006849dc963fSmrg cmds=$module_cmds 1006949dc963fSmrg fi 100704b0ead49Smrg else 1007149dc963fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1007249dc963fSmrg eval test_cmds=\"$archive_expsym_cmds\" 1007349dc963fSmrg cmds=$archive_expsym_cmds 1007449dc963fSmrg else 1007549dc963fSmrg eval test_cmds=\"$archive_cmds\" 1007649dc963fSmrg cmds=$archive_cmds 1007749dc963fSmrg fi 100784b0ead49Smrg fi 100794b0ead49Smrg 1008026372658Smrg if test : != "$skipped_export" && 1008149dc963fSmrg func_len " $test_cmds" && 1008249dc963fSmrg len=$func_len_result && 1008349dc963fSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1008449dc963fSmrg : 1008549dc963fSmrg else 1008649dc963fSmrg # The command line is too long to link in one step, link piecewise 1008749dc963fSmrg # or, if using GNU ld and skipped_export is not :, use a linker 1008849dc963fSmrg # script. 100894b0ead49Smrg 1009049dc963fSmrg # Save the value of $output and $libobjs because we want to 1009149dc963fSmrg # use them later. If we have whole_archive_flag_spec, we 1009249dc963fSmrg # want to use save_libobjs as it was before 1009349dc963fSmrg # whole_archive_flag_spec was expanded, because we can't 1009449dc963fSmrg # assume the linker understands whole_archive_flag_spec. 1009549dc963fSmrg # This may have to be revisited, in case too many 1009649dc963fSmrg # convenience libraries get linked in and end up exceeding 1009749dc963fSmrg # the spec. 1009849dc963fSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 1009949dc963fSmrg save_libobjs=$libobjs 1010049dc963fSmrg fi 1010149dc963fSmrg save_output=$output 101027aa89044Smrg func_basename "$output" 101037aa89044Smrg output_la=$func_basename_result 101044b0ead49Smrg 1010549dc963fSmrg # Clear the reloadable object creation command queue and 1010649dc963fSmrg # initialize k to one. 1010749dc963fSmrg test_cmds= 1010849dc963fSmrg concat_cmds= 1010949dc963fSmrg objlist= 1011049dc963fSmrg last_robj= 1011149dc963fSmrg k=1 1011249dc963fSmrg 1011326372658Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 1011426372658Smrg output=$output_objdir/$output_la.lnkscript 1011549dc963fSmrg func_verbose "creating GNU ld script: $output" 101167aa89044Smrg echo 'INPUT (' > $output 1011749dc963fSmrg for obj in $save_libobjs 101184b0ead49Smrg do 101194e7590efSmrg func_to_tool_file "$obj" 101204e7590efSmrg $ECHO "$func_to_tool_file_result" >> $output 1012149dc963fSmrg done 101227aa89044Smrg echo ')' >> $output 101234e7590efSmrg func_append delfiles " $output" 101244e7590efSmrg func_to_tool_file "$output" 101254e7590efSmrg output=$func_to_tool_file_result 1012626372658Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 1012726372658Smrg output=$output_objdir/$output_la.lnk 1012849dc963fSmrg func_verbose "creating linker input file list: $output" 1012949dc963fSmrg : > $output 1013049dc963fSmrg set x $save_libobjs 1013149dc963fSmrg shift 1013249dc963fSmrg firstobj= 1013326372658Smrg if test yes = "$compiler_needs_object"; then 1013449dc963fSmrg firstobj="$1 " 1013549dc963fSmrg shift 1013649dc963fSmrg fi 1013749dc963fSmrg for obj 1013849dc963fSmrg do 101394e7590efSmrg func_to_tool_file "$obj" 101404e7590efSmrg $ECHO "$func_to_tool_file_result" >> $output 1014149dc963fSmrg done 101424e7590efSmrg func_append delfiles " $output" 101434e7590efSmrg func_to_tool_file "$output" 101444e7590efSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 1014549dc963fSmrg else 1014649dc963fSmrg if test -n "$save_libobjs"; then 1014749dc963fSmrg func_verbose "creating reloadable object files..." 1014826372658Smrg output=$output_objdir/$output_la-$k.$objext 1014949dc963fSmrg eval test_cmds=\"$reload_cmds\" 1015049dc963fSmrg func_len " $test_cmds" 1015149dc963fSmrg len0=$func_len_result 1015249dc963fSmrg len=$len0 1015349dc963fSmrg 1015449dc963fSmrg # Loop over the list of objects to be linked. 1015549dc963fSmrg for obj in $save_libobjs 1015649dc963fSmrg do 1015749dc963fSmrg func_len " $obj" 1015849dc963fSmrg func_arith $len + $func_len_result 1015949dc963fSmrg len=$func_arith_result 1016026372658Smrg if test -z "$objlist" || 1016149dc963fSmrg test "$len" -lt "$max_cmd_len"; then 1016249dc963fSmrg func_append objlist " $obj" 1016349dc963fSmrg else 1016449dc963fSmrg # The command $test_cmds is almost too long, add a 1016549dc963fSmrg # command to the queue. 1016626372658Smrg if test 1 -eq "$k"; then 1016749dc963fSmrg # The first file doesn't have a previous command to add. 101687aa89044Smrg reload_objs=$objlist 101697aa89044Smrg eval concat_cmds=\"$reload_cmds\" 1017049dc963fSmrg else 1017149dc963fSmrg # All subsequent reloadable object files will link in 1017249dc963fSmrg # the last one created. 101737aa89044Smrg reload_objs="$objlist $last_robj" 101747aa89044Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 1017549dc963fSmrg fi 1017626372658Smrg last_robj=$output_objdir/$output_la-$k.$objext 1017749dc963fSmrg func_arith $k + 1 1017849dc963fSmrg k=$func_arith_result 1017926372658Smrg output=$output_objdir/$output_la-$k.$objext 101807aa89044Smrg objlist=" $obj" 1018149dc963fSmrg func_len " $last_robj" 1018249dc963fSmrg func_arith $len0 + $func_len_result 1018349dc963fSmrg len=$func_arith_result 1018449dc963fSmrg fi 1018549dc963fSmrg done 1018649dc963fSmrg # Handle the remaining objects by creating one last 1018749dc963fSmrg # reloadable object file. All subsequent reloadable object 1018849dc963fSmrg # files will link in the last one created. 1018949dc963fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 101907aa89044Smrg reload_objs="$objlist $last_robj" 1019126372658Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 1019249dc963fSmrg if test -n "$last_robj"; then 1019326372658Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1019449dc963fSmrg fi 101954e7590efSmrg func_append delfiles " $output" 101964b0ead49Smrg 1019749dc963fSmrg else 1019849dc963fSmrg output= 1019949dc963fSmrg fi 102004b0ead49Smrg 1020126372658Smrg ${skipped_export-false} && { 1020226372658Smrg func_verbose "generating symbol list for '$libname.la'" 1020326372658Smrg export_symbols=$output_objdir/$libname.exp 1020449dc963fSmrg $opt_dry_run || $RM $export_symbols 1020549dc963fSmrg libobjs=$output 1020649dc963fSmrg # Append the command to create the export file. 1020749dc963fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1020849dc963fSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 1020949dc963fSmrg if test -n "$last_robj"; then 1021049dc963fSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1021149dc963fSmrg fi 1021226372658Smrg } 102134b0ead49Smrg 1021449dc963fSmrg test -n "$save_libobjs" && 1021549dc963fSmrg func_verbose "creating a temporary reloadable object file: $output" 102164b0ead49Smrg 1021749dc963fSmrg # Loop through the commands generated above and execute them. 1021826372658Smrg save_ifs=$IFS; IFS='~' 1021949dc963fSmrg for cmd in $concat_cmds; do 1022026372658Smrg IFS=$save_ifs 1022126372658Smrg $opt_quiet || { 10222c3e29c03Smrg func_quote_arg expand,pretty "$cmd" 10223c3e29c03Smrg eval "func_echo $func_quote_arg_result" 1022449dc963fSmrg } 1022549dc963fSmrg $opt_dry_run || eval "$cmd" || { 1022649dc963fSmrg lt_exit=$? 1022749dc963fSmrg 1022849dc963fSmrg # Restore the uninstalled library and exit 1022926372658Smrg if test relink = "$opt_mode"; then 1023049dc963fSmrg ( cd "$output_objdir" && \ 1023149dc963fSmrg $RM "${realname}T" && \ 1023249dc963fSmrg $MV "${realname}U" "$realname" ) 1023349dc963fSmrg fi 102344b0ead49Smrg 1023549dc963fSmrg exit $lt_exit 1023649dc963fSmrg } 1023749dc963fSmrg done 1023826372658Smrg IFS=$save_ifs 102394b0ead49Smrg 1024049dc963fSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 1024149dc963fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 1024249dc963fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102434b0ead49Smrg fi 102444b0ead49Smrg fi 102454b0ead49Smrg 1024626372658Smrg ${skipped_export-false} && { 1024749dc963fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1024826372658Smrg tmp_export_symbols=$export_symbols 1024926372658Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102507aa89044Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1025149dc963fSmrg fi 102524b0ead49Smrg 1025349dc963fSmrg if test -n "$orig_export_symbols"; then 1025449dc963fSmrg # The given exports_symbols file has to be filtered, so filter it. 1025526372658Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1025649dc963fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1025726372658Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 1025849dc963fSmrg # though. Also, the filter scales superlinearly with the number of 1025949dc963fSmrg # global variables. join(1) would be nice here, but unfortunately 1026049dc963fSmrg # isn't a blessed tool. 1026149dc963fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102624e7590efSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1026349dc963fSmrg export_symbols=$output_objdir/$libname.def 1026449dc963fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1026549dc963fSmrg fi 1026626372658Smrg } 102674b0ead49Smrg 1026849dc963fSmrg libobjs=$output 1026949dc963fSmrg # Restore the value of output. 1027049dc963fSmrg output=$save_output 102714b0ead49Smrg 1027249dc963fSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 1027349dc963fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1027449dc963fSmrg test "X$libobjs" = "X " && libobjs= 1027549dc963fSmrg fi 1027649dc963fSmrg # Expand the library linking commands again to reset the 1027749dc963fSmrg # value of $libobjs for piecewise linking. 102784b0ead49Smrg 1027949dc963fSmrg # Do each of the archive commands. 1028026372658Smrg if test yes = "$module" && test -n "$module_cmds"; then 1028149dc963fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1028249dc963fSmrg cmds=$module_expsym_cmds 1028349dc963fSmrg else 1028449dc963fSmrg cmds=$module_cmds 102854b0ead49Smrg fi 102864b0ead49Smrg else 1028749dc963fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1028849dc963fSmrg cmds=$archive_expsym_cmds 1028949dc963fSmrg else 1029049dc963fSmrg cmds=$archive_cmds 1029149dc963fSmrg fi 102924b0ead49Smrg fi 1029349dc963fSmrg fi 102944b0ead49Smrg 1029549dc963fSmrg if test -n "$delfiles"; then 1029649dc963fSmrg # Append the command to remove temporary files to $cmds. 1029749dc963fSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 1029849dc963fSmrg fi 102994b0ead49Smrg 1030049dc963fSmrg # Add any objects from preloaded convenience libraries 1030149dc963fSmrg if test -n "$dlprefiles"; then 1030226372658Smrg gentop=$output_objdir/${outputname}x 103034e7590efSmrg func_append generated " $gentop" 103044b0ead49Smrg 1030549dc963fSmrg func_extract_archives $gentop $dlprefiles 103064e7590efSmrg func_append libobjs " $func_extract_archives_result" 1030749dc963fSmrg test "X$libobjs" = "X " && libobjs= 1030849dc963fSmrg fi 103094b0ead49Smrg 1031026372658Smrg save_ifs=$IFS; IFS='~' 1031149dc963fSmrg for cmd in $cmds; do 1031226372658Smrg IFS=$sp$nl 1031349dc963fSmrg eval cmd=\"$cmd\" 1031426372658Smrg IFS=$save_ifs 1031526372658Smrg $opt_quiet || { 10316c3e29c03Smrg func_quote_arg expand,pretty "$cmd" 10317c3e29c03Smrg eval "func_echo $func_quote_arg_result" 1031849dc963fSmrg } 1031949dc963fSmrg $opt_dry_run || eval "$cmd" || { 1032049dc963fSmrg lt_exit=$? 103214b0ead49Smrg 1032249dc963fSmrg # Restore the uninstalled library and exit 1032326372658Smrg if test relink = "$opt_mode"; then 1032449dc963fSmrg ( cd "$output_objdir" && \ 1032549dc963fSmrg $RM "${realname}T" && \ 1032649dc963fSmrg $MV "${realname}U" "$realname" ) 1032749dc963fSmrg fi 103284b0ead49Smrg 1032949dc963fSmrg exit $lt_exit 1033049dc963fSmrg } 1033149dc963fSmrg done 1033226372658Smrg IFS=$save_ifs 103334b0ead49Smrg 1033449dc963fSmrg # Restore the uninstalled library and exit 1033526372658Smrg if test relink = "$opt_mode"; then 1033649dc963fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103374b0ead49Smrg 1033849dc963fSmrg if test -n "$convenience"; then 1033949dc963fSmrg if test -z "$whole_archive_flag_spec"; then 1034049dc963fSmrg func_show_eval '${RM}r "$gentop"' 1034149dc963fSmrg fi 1034249dc963fSmrg fi 103434b0ead49Smrg 1034449dc963fSmrg exit $EXIT_SUCCESS 1034549dc963fSmrg fi 1034649dc963fSmrg 1034749dc963fSmrg # Create links to the real library. 1034849dc963fSmrg for linkname in $linknames; do 1034949dc963fSmrg if test "$realname" != "$linkname"; then 1035049dc963fSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103514b0ead49Smrg fi 103524b0ead49Smrg done 103534b0ead49Smrg 1035449dc963fSmrg # If -module or -export-dynamic was specified, set the dlname. 1035526372658Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 1035649dc963fSmrg # On all known operating systems, these are identical. 1035726372658Smrg dlname=$soname 1035849dc963fSmrg fi 1035949dc963fSmrg fi 103604b0ead49Smrg ;; 103614b0ead49Smrg 1036249dc963fSmrg obj) 1036326372658Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1036426372658Smrg func_warning "'-dlopen' is ignored for objects" 1036549dc963fSmrg fi 103664b0ead49Smrg 1036749dc963fSmrg case " $deplibs" in 1036849dc963fSmrg *\ -l* | *\ -L*) 1036926372658Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 103704b0ead49Smrg esac 103714b0ead49Smrg 1037249dc963fSmrg test -n "$rpath" && \ 1037326372658Smrg func_warning "'-rpath' is ignored for objects" 1037449dc963fSmrg 1037549dc963fSmrg test -n "$xrpath" && \ 1037626372658Smrg func_warning "'-R' is ignored for objects" 103774b0ead49Smrg 1037849dc963fSmrg test -n "$vinfo" && \ 1037926372658Smrg func_warning "'-version-info' is ignored for objects" 103804b0ead49Smrg 1038149dc963fSmrg test -n "$release" && \ 1038226372658Smrg func_warning "'-release' is ignored for objects" 1038349dc963fSmrg 1038449dc963fSmrg case $output in 1038549dc963fSmrg *.lo) 1038649dc963fSmrg test -n "$objs$old_deplibs" && \ 1038726372658Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1038849dc963fSmrg 1038949dc963fSmrg libobj=$output 1039049dc963fSmrg func_lo2o "$libobj" 1039149dc963fSmrg obj=$func_lo2o_result 103924b0ead49Smrg ;; 103934b0ead49Smrg *) 1039449dc963fSmrg libobj= 1039526372658Smrg obj=$output 103964b0ead49Smrg ;; 103974b0ead49Smrg esac 103984b0ead49Smrg 1039949dc963fSmrg # Delete the old objects. 1040049dc963fSmrg $opt_dry_run || $RM $obj $libobj 104014b0ead49Smrg 1040249dc963fSmrg # Objects from convenience libraries. This assumes 1040349dc963fSmrg # single-version convenience libraries. Whenever we create 1040449dc963fSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 1040549dc963fSmrg # the extraction. 1040649dc963fSmrg reload_conv_objs= 1040749dc963fSmrg gentop= 1040826372658Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1040926372658Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1041026372658Smrg # into space. 1041126372658Smrg case $reload_cmds in 1041226372658Smrg *\$LD[\ \$]*) wl= ;; 1041326372658Smrg esac 1041449dc963fSmrg if test -n "$convenience"; then 1041549dc963fSmrg if test -n "$whole_archive_flag_spec"; then 1041649dc963fSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1041726372658Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1041826372658Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1041949dc963fSmrg else 1042026372658Smrg gentop=$output_objdir/${obj}x 104214e7590efSmrg func_append generated " $gentop" 104224b0ead49Smrg 1042349dc963fSmrg func_extract_archives $gentop $convenience 1042449dc963fSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1042549dc963fSmrg fi 104264b0ead49Smrg fi 104274b0ead49Smrg 104284e7590efSmrg # If we're not building shared, we need to use non_pic_objs 1042926372658Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104304e7590efSmrg 1043149dc963fSmrg # Create the old-style object. 1043226372658Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104334b0ead49Smrg 1043426372658Smrg output=$obj 1043549dc963fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 104364b0ead49Smrg 1043749dc963fSmrg # Exit if we aren't doing a library object file. 1043849dc963fSmrg if test -z "$libobj"; then 1043949dc963fSmrg if test -n "$gentop"; then 1044049dc963fSmrg func_show_eval '${RM}r "$gentop"' 1044149dc963fSmrg fi 1044249dc963fSmrg 1044349dc963fSmrg exit $EXIT_SUCCESS 104444b0ead49Smrg fi 1044549dc963fSmrg 1044626372658Smrg test yes = "$build_libtool_libs" || { 1044749dc963fSmrg if test -n "$gentop"; then 1044849dc963fSmrg func_show_eval '${RM}r "$gentop"' 1044949dc963fSmrg fi 1045049dc963fSmrg 1045149dc963fSmrg # Create an invalid libtool object if no PIC, so that we don't 1045249dc963fSmrg # accidentally link it into a program. 1045349dc963fSmrg # $show "echo timestamp > $libobj" 1045449dc963fSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1045549dc963fSmrg exit $EXIT_SUCCESS 1045626372658Smrg } 1045749dc963fSmrg 1045826372658Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1045949dc963fSmrg # Only do commands if we really have different PIC objects. 1046049dc963fSmrg reload_objs="$libobjs $reload_conv_objs" 1046126372658Smrg output=$libobj 1046249dc963fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1046349dc963fSmrg fi 1046449dc963fSmrg 1046549dc963fSmrg if test -n "$gentop"; then 1046649dc963fSmrg func_show_eval '${RM}r "$gentop"' 1046749dc963fSmrg fi 1046849dc963fSmrg 1046949dc963fSmrg exit $EXIT_SUCCESS 104704b0ead49Smrg ;; 104714b0ead49Smrg 1047249dc963fSmrg prog) 1047349dc963fSmrg case $host in 1047449dc963fSmrg *cygwin*) func_stripname '' '.exe' "$output" 1047549dc963fSmrg output=$func_stripname_result.exe;; 1047649dc963fSmrg esac 1047749dc963fSmrg test -n "$vinfo" && \ 1047826372658Smrg func_warning "'-version-info' is ignored for programs" 104794b0ead49Smrg 1048049dc963fSmrg test -n "$release" && \ 1048126372658Smrg func_warning "'-release' is ignored for programs" 104824b0ead49Smrg 1048326372658Smrg $preload \ 1048426372658Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1048526372658Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1048649dc963fSmrg 1048749dc963fSmrg case $host in 1048849dc963fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 1048949dc963fSmrg # On Rhapsody replace the C library is the System framework 104907aa89044Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 104917aa89044Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104924b0ead49Smrg ;; 1049349dc963fSmrg esac 104944b0ead49Smrg 1049549dc963fSmrg case $host in 1049649dc963fSmrg *-*-darwin*) 1049749dc963fSmrg # Don't allow lazy linking, it breaks C++ global constructors 1049849dc963fSmrg # But is supposedly fixed on 10.4 or later (yay!). 1049926372658Smrg if test CXX = "$tagname"; then 1050049dc963fSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1050149dc963fSmrg 10.[0123]) 1050226372658Smrg func_append compile_command " $wl-bind_at_load" 1050326372658Smrg func_append finalize_command " $wl-bind_at_load" 1050449dc963fSmrg ;; 1050549dc963fSmrg esac 105064b0ead49Smrg fi 1050749dc963fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105087aa89044Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105097aa89044Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1051049dc963fSmrg ;; 1051149dc963fSmrg esac 105124b0ead49Smrg 105134b0ead49Smrg 1051449dc963fSmrg # move library search paths that coincide with paths to not yet 1051549dc963fSmrg # installed libraries to the beginning of the library search list 1051649dc963fSmrg new_libs= 1051749dc963fSmrg for path in $notinst_path; do 1051849dc963fSmrg case " $new_libs " in 1051949dc963fSmrg *" -L$path/$objdir "*) ;; 1052049dc963fSmrg *) 1052149dc963fSmrg case " $compile_deplibs " in 1052249dc963fSmrg *" -L$path/$objdir "*) 105234e7590efSmrg func_append new_libs " -L$path/$objdir" ;; 105244b0ead49Smrg esac 1052549dc963fSmrg ;; 1052649dc963fSmrg esac 1052749dc963fSmrg done 1052849dc963fSmrg for deplib in $compile_deplibs; do 1052949dc963fSmrg case $deplib in 1053049dc963fSmrg -L*) 1053149dc963fSmrg case " $new_libs " in 1053249dc963fSmrg *" $deplib "*) ;; 105334e7590efSmrg *) func_append new_libs " $deplib" ;; 105344b0ead49Smrg esac 1053549dc963fSmrg ;; 105364e7590efSmrg *) func_append new_libs " $deplib" ;; 1053749dc963fSmrg esac 1053849dc963fSmrg done 1053926372658Smrg compile_deplibs=$new_libs 105404b0ead49Smrg 105414b0ead49Smrg 105424e7590efSmrg func_append compile_command " $compile_deplibs" 105434e7590efSmrg func_append finalize_command " $finalize_deplibs" 105444b0ead49Smrg 1054549dc963fSmrg if test -n "$rpath$xrpath"; then 1054649dc963fSmrg # If the user specified any rpath flags, then add them. 1054749dc963fSmrg for libdir in $rpath $xrpath; do 1054849dc963fSmrg # This is the magic to use -rpath. 1054949dc963fSmrg case "$finalize_rpath " in 1055049dc963fSmrg *" $libdir "*) ;; 105514e7590efSmrg *) func_append finalize_rpath " $libdir" ;; 1055249dc963fSmrg esac 1055349dc963fSmrg done 1055449dc963fSmrg fi 105554b0ead49Smrg 1055649dc963fSmrg # Now hardcode the library paths 1055749dc963fSmrg rpath= 1055849dc963fSmrg hardcode_libdirs= 1055949dc963fSmrg for libdir in $compile_rpath $finalize_rpath; do 1056049dc963fSmrg if test -n "$hardcode_libdir_flag_spec"; then 1056149dc963fSmrg if test -n "$hardcode_libdir_separator"; then 1056249dc963fSmrg if test -z "$hardcode_libdirs"; then 1056326372658Smrg hardcode_libdirs=$libdir 1056449dc963fSmrg else 1056549dc963fSmrg # Just accumulate the unique libdirs. 1056649dc963fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1056749dc963fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1056849dc963fSmrg ;; 1056949dc963fSmrg *) 105704e7590efSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1057149dc963fSmrg ;; 1057249dc963fSmrg esac 1057349dc963fSmrg fi 105744b0ead49Smrg else 1057549dc963fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 105764e7590efSmrg func_append rpath " $flag" 105774b0ead49Smrg fi 1057849dc963fSmrg elif test -n "$runpath_var"; then 1057949dc963fSmrg case "$perm_rpath " in 1058049dc963fSmrg *" $libdir "*) ;; 105814e7590efSmrg *) func_append perm_rpath " $libdir" ;; 1058249dc963fSmrg esac 1058349dc963fSmrg fi 1058449dc963fSmrg case $host in 1058549dc963fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1058626372658Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1058749dc963fSmrg case :$dllsearchpath: in 1058849dc963fSmrg *":$libdir:"*) ;; 1058949dc963fSmrg ::) dllsearchpath=$libdir;; 105904e7590efSmrg *) func_append dllsearchpath ":$libdir";; 1059149dc963fSmrg esac 1059249dc963fSmrg case :$dllsearchpath: in 1059349dc963fSmrg *":$testbindir:"*) ;; 1059449dc963fSmrg ::) dllsearchpath=$testbindir;; 105954e7590efSmrg *) func_append dllsearchpath ":$testbindir";; 1059649dc963fSmrg esac 1059749dc963fSmrg ;; 1059849dc963fSmrg esac 1059949dc963fSmrg done 1060049dc963fSmrg # Substitute the hardcoded libdirs into the rpath. 1060149dc963fSmrg if test -n "$hardcode_libdir_separator" && 1060249dc963fSmrg test -n "$hardcode_libdirs"; then 1060326372658Smrg libdir=$hardcode_libdirs 1060449dc963fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1060549dc963fSmrg fi 1060626372658Smrg compile_rpath=$rpath 106074b0ead49Smrg 1060849dc963fSmrg rpath= 1060949dc963fSmrg hardcode_libdirs= 1061049dc963fSmrg for libdir in $finalize_rpath; do 1061149dc963fSmrg if test -n "$hardcode_libdir_flag_spec"; then 1061249dc963fSmrg if test -n "$hardcode_libdir_separator"; then 1061349dc963fSmrg if test -z "$hardcode_libdirs"; then 1061426372658Smrg hardcode_libdirs=$libdir 1061549dc963fSmrg else 1061649dc963fSmrg # Just accumulate the unique libdirs. 1061749dc963fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1061849dc963fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1061949dc963fSmrg ;; 1062049dc963fSmrg *) 106214e7590efSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1062249dc963fSmrg ;; 1062349dc963fSmrg esac 1062449dc963fSmrg fi 106254b0ead49Smrg else 1062649dc963fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 106274e7590efSmrg func_append rpath " $flag" 106284b0ead49Smrg fi 1062949dc963fSmrg elif test -n "$runpath_var"; then 1063049dc963fSmrg case "$finalize_perm_rpath " in 1063149dc963fSmrg *" $libdir "*) ;; 106324e7590efSmrg *) func_append finalize_perm_rpath " $libdir" ;; 1063349dc963fSmrg esac 106344b0ead49Smrg fi 1063549dc963fSmrg done 1063649dc963fSmrg # Substitute the hardcoded libdirs into the rpath. 1063749dc963fSmrg if test -n "$hardcode_libdir_separator" && 1063849dc963fSmrg test -n "$hardcode_libdirs"; then 1063926372658Smrg libdir=$hardcode_libdirs 1064049dc963fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1064149dc963fSmrg fi 1064226372658Smrg finalize_rpath=$rpath 106434b0ead49Smrg 1064426372658Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1064549dc963fSmrg # Transform all the library objects into standard objects. 106467aa89044Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106477aa89044Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064849dc963fSmrg fi 106494b0ead49Smrg 1065026372658Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106514b0ead49Smrg 1065249dc963fSmrg # template prelinking step 1065349dc963fSmrg if test -n "$prelink_cmds"; then 1065449dc963fSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 1065549dc963fSmrg fi 106564b0ead49Smrg 1065726372658Smrg wrappers_required=: 1065849dc963fSmrg case $host in 106597aa89044Smrg *cegcc* | *mingw32ce*) 106607aa89044Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1066126372658Smrg wrappers_required=false 106627aa89044Smrg ;; 1066349dc963fSmrg *cygwin* | *mingw* ) 1066426372658Smrg test yes = "$build_libtool_libs" || wrappers_required=false 1066549dc963fSmrg ;; 1066649dc963fSmrg *) 1066726372658Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1066826372658Smrg wrappers_required=false 1066949dc963fSmrg fi 1067049dc963fSmrg ;; 1067149dc963fSmrg esac 1067226372658Smrg $wrappers_required || { 1067349dc963fSmrg # Replace the output file specification. 106747aa89044Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1067526372658Smrg link_command=$compile_command$compile_rpath 106764b0ead49Smrg 1067749dc963fSmrg # We have no uninstalled library dependencies, so finalize right now. 1067849dc963fSmrg exit_status=0 1067949dc963fSmrg func_show_eval "$link_command" 'exit_status=$?' 106804b0ead49Smrg 106814e7590efSmrg if test -n "$postlink_cmds"; then 106824e7590efSmrg func_to_tool_file "$output" 106834e7590efSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106844e7590efSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 106854e7590efSmrg fi 106864e7590efSmrg 1068749dc963fSmrg # Delete the generated files. 1068826372658Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1068926372658Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 106904b0ead49Smrg fi 106914b0ead49Smrg 1069249dc963fSmrg exit $exit_status 1069326372658Smrg } 106944b0ead49Smrg 1069549dc963fSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1069649dc963fSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1069749dc963fSmrg fi 1069849dc963fSmrg if test -n "$finalize_shlibpath"; then 1069949dc963fSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1070049dc963fSmrg fi 107014b0ead49Smrg 1070249dc963fSmrg compile_var= 1070349dc963fSmrg finalize_var= 1070449dc963fSmrg if test -n "$runpath_var"; then 1070549dc963fSmrg if test -n "$perm_rpath"; then 1070649dc963fSmrg # We should set the runpath_var. 1070749dc963fSmrg rpath= 1070849dc963fSmrg for dir in $perm_rpath; do 107094e7590efSmrg func_append rpath "$dir:" 1071049dc963fSmrg done 1071149dc963fSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107124b0ead49Smrg fi 1071349dc963fSmrg if test -n "$finalize_perm_rpath"; then 1071449dc963fSmrg # We should set the runpath_var. 1071549dc963fSmrg rpath= 1071649dc963fSmrg for dir in $finalize_perm_rpath; do 107174e7590efSmrg func_append rpath "$dir:" 1071849dc963fSmrg done 1071949dc963fSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107204b0ead49Smrg fi 1072149dc963fSmrg fi 107224b0ead49Smrg 1072326372658Smrg if test yes = "$no_install"; then 1072449dc963fSmrg # We don't need to create a wrapper script. 1072526372658Smrg link_command=$compile_var$compile_command$compile_rpath 1072649dc963fSmrg # Replace the output file specification. 107277aa89044Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1072849dc963fSmrg # Delete the old output file. 1072949dc963fSmrg $opt_dry_run || $RM $output 1073049dc963fSmrg # Link the executable and exit 1073149dc963fSmrg func_show_eval "$link_command" 'exit $?' 107324e7590efSmrg 107334e7590efSmrg if test -n "$postlink_cmds"; then 107344e7590efSmrg func_to_tool_file "$output" 107354e7590efSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107364e7590efSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107374e7590efSmrg fi 107384e7590efSmrg 107394b0ead49Smrg exit $EXIT_SUCCESS 1074049dc963fSmrg fi 107414b0ead49Smrg 1074226372658Smrg case $hardcode_action,$fast_install in 1074326372658Smrg relink,*) 1074426372658Smrg # Fast installation is not supported 1074526372658Smrg link_command=$compile_var$compile_command$compile_rpath 1074626372658Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1074749dc963fSmrg 1074826372658Smrg func_warning "this platform does not like uninstalled shared libraries" 1074926372658Smrg func_warning "'$output' will be relinked during installation" 1075026372658Smrg ;; 1075126372658Smrg *,yes) 1075226372658Smrg link_command=$finalize_var$compile_command$finalize_rpath 1075326372658Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1075426372658Smrg ;; 1075526372658Smrg *,no) 1075626372658Smrg link_command=$compile_var$compile_command$compile_rpath 1075726372658Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1075826372658Smrg ;; 1075926372658Smrg *,needless) 1076026372658Smrg link_command=$finalize_var$compile_command$finalize_rpath 1076126372658Smrg relink_command= 1076226372658Smrg ;; 1076326372658Smrg esac 107644b0ead49Smrg 1076549dc963fSmrg # Replace the output file specification. 107667aa89044Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107674b0ead49Smrg 1076849dc963fSmrg # Delete the old output files. 1076949dc963fSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107704b0ead49Smrg 1077149dc963fSmrg func_show_eval "$link_command" 'exit $?' 107724b0ead49Smrg 107734e7590efSmrg if test -n "$postlink_cmds"; then 107744e7590efSmrg func_to_tool_file "$output_objdir/$outputname" 107754e7590efSmrg 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'` 107764e7590efSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107774e7590efSmrg fi 107784e7590efSmrg 1077949dc963fSmrg # Now create the wrapper script. 1078049dc963fSmrg func_verbose "creating $output" 107814b0ead49Smrg 1078249dc963fSmrg # Quote the relink command for shipping. 1078349dc963fSmrg if test -n "$relink_command"; then 1078449dc963fSmrg # Preserve any variables that may affect compiler behavior 1078549dc963fSmrg for var in $variables_saved_for_relink; do 1078649dc963fSmrg if eval test -z \"\${$var+set}\"; then 1078749dc963fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1078849dc963fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1078949dc963fSmrg relink_command="$var=; export $var; $relink_command" 107904b0ead49Smrg else 10791c3e29c03Smrg func_quote_arg pretty "$var_value" 10792c3e29c03Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107934b0ead49Smrg fi 1079449dc963fSmrg done 10795c3e29c03Smrg func_quote eval cd "`pwd`" 10796c3e29c03Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797c3e29c03Smrg relink_command=$func_quote_arg_unquoted_result 1079849dc963fSmrg fi 1079949dc963fSmrg 1080049dc963fSmrg # Only actually do things if not in dry run mode. 1080149dc963fSmrg $opt_dry_run || { 1080249dc963fSmrg # win32 will think the script is a binary if it has 1080349dc963fSmrg # a .exe suffix, so we strip it off here. 1080449dc963fSmrg case $output in 1080549dc963fSmrg *.exe) func_stripname '' '.exe' "$output" 1080649dc963fSmrg output=$func_stripname_result ;; 1080749dc963fSmrg esac 1080849dc963fSmrg # test for cygwin because mv fails w/o .exe extensions 1080949dc963fSmrg case $host in 1081049dc963fSmrg *cygwin*) 1081149dc963fSmrg exeext=.exe 1081249dc963fSmrg func_stripname '' '.exe' "$outputname" 1081349dc963fSmrg outputname=$func_stripname_result ;; 1081449dc963fSmrg *) exeext= ;; 108154b0ead49Smrg esac 1081649dc963fSmrg case $host in 1081749dc963fSmrg *cygwin* | *mingw* ) 1081849dc963fSmrg func_dirname_and_basename "$output" "" "." 1081949dc963fSmrg output_name=$func_basename_result 1082049dc963fSmrg output_path=$func_dirname_result 1082126372658Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1082226372658Smrg cwrapper=$output_path/$output_name.exe 1082349dc963fSmrg $RM $cwrappersource $cwrapper 1082449dc963fSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1082549dc963fSmrg 1082649dc963fSmrg func_emit_cwrapperexe_src > $cwrappersource 1082749dc963fSmrg 1082849dc963fSmrg # The wrapper executable is built using the $host compiler, 1082949dc963fSmrg # because it contains $host paths and files. If cross- 1083049dc963fSmrg # compiling, it, like the target executable, must be 1083149dc963fSmrg # executed on the $host or under an emulation environment. 1083249dc963fSmrg $opt_dry_run || { 1083349dc963fSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1083449dc963fSmrg $STRIP $cwrapper 1083549dc963fSmrg } 108364b0ead49Smrg 1083749dc963fSmrg # Now, create the wrapper script for func_source use: 1083849dc963fSmrg func_ltwrapper_scriptname $cwrapper 1083949dc963fSmrg $RM $func_ltwrapper_scriptname_result 1084049dc963fSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1084149dc963fSmrg $opt_dry_run || { 1084249dc963fSmrg # note: this script will not be executed, so do not chmod. 1084326372658Smrg if test "x$build" = "x$host"; then 1084449dc963fSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1084549dc963fSmrg else 1084649dc963fSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1084749dc963fSmrg fi 1084849dc963fSmrg } 1084949dc963fSmrg ;; 1085049dc963fSmrg * ) 1085149dc963fSmrg $RM $output 1085249dc963fSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108534b0ead49Smrg 1085449dc963fSmrg func_emit_wrapper no > $output 1085549dc963fSmrg chmod +x $output 1085649dc963fSmrg ;; 1085749dc963fSmrg esac 1085849dc963fSmrg } 1085949dc963fSmrg exit $EXIT_SUCCESS 1086049dc963fSmrg ;; 1086149dc963fSmrg esac 108624b0ead49Smrg 1086349dc963fSmrg # See if we need to build an old-fashioned archive. 1086449dc963fSmrg for oldlib in $oldlibs; do 108654b0ead49Smrg 1086626372658Smrg case $build_libtool_libs in 1086726372658Smrg convenience) 1086826372658Smrg oldobjs="$libobjs_save $symfileobj" 1086926372658Smrg addlibs=$convenience 1087049dc963fSmrg build_libtool_libs=no 1087126372658Smrg ;; 1087226372658Smrg module) 1087326372658Smrg oldobjs=$libobjs_save 1087426372658Smrg addlibs=$old_convenience 1087526372658Smrg build_libtool_libs=no 1087626372658Smrg ;; 1087726372658Smrg *) 1087849dc963fSmrg oldobjs="$old_deplibs $non_pic_objects" 1087926372658Smrg $preload && test -f "$symfileobj" \ 1088026372658Smrg && func_append oldobjs " $symfileobj" 1088126372658Smrg addlibs=$old_convenience 1088226372658Smrg ;; 1088326372658Smrg esac 108844b0ead49Smrg 1088549dc963fSmrg if test -n "$addlibs"; then 1088626372658Smrg gentop=$output_objdir/${outputname}x 108874e7590efSmrg func_append generated " $gentop" 108884b0ead49Smrg 1088949dc963fSmrg func_extract_archives $gentop $addlibs 108904e7590efSmrg func_append oldobjs " $func_extract_archives_result" 1089149dc963fSmrg fi 108924b0ead49Smrg 1089349dc963fSmrg # Do each command in the archive commands. 1089426372658Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1089549dc963fSmrg cmds=$old_archive_from_new_cmds 1089649dc963fSmrg else 108974b0ead49Smrg 1089849dc963fSmrg # Add any objects from preloaded convenience libraries 1089949dc963fSmrg if test -n "$dlprefiles"; then 1090026372658Smrg gentop=$output_objdir/${outputname}x 109014e7590efSmrg func_append generated " $gentop" 109024b0ead49Smrg 1090349dc963fSmrg func_extract_archives $gentop $dlprefiles 109044e7590efSmrg func_append oldobjs " $func_extract_archives_result" 1090549dc963fSmrg fi 109064b0ead49Smrg 1090749dc963fSmrg # POSIX demands no paths to be encoded in archives. We have 1090849dc963fSmrg # to avoid creating archives with duplicate basenames if we 1090949dc963fSmrg # might have to extract them afterwards, e.g., when creating a 1091049dc963fSmrg # static archive out of a convenience library, or when linking 1091149dc963fSmrg # the entirety of a libtool archive into another (currently 1091249dc963fSmrg # not supported by libtool). 1091349dc963fSmrg if (for obj in $oldobjs 1091449dc963fSmrg do 1091549dc963fSmrg func_basename "$obj" 1091649dc963fSmrg $ECHO "$func_basename_result" 1091749dc963fSmrg done | sort | sort -uc >/dev/null 2>&1); then 1091849dc963fSmrg : 1091949dc963fSmrg else 109207aa89044Smrg echo "copying selected object files to avoid basename conflicts..." 1092126372658Smrg gentop=$output_objdir/${outputname}x 109224e7590efSmrg func_append generated " $gentop" 1092349dc963fSmrg func_mkdir_p "$gentop" 1092449dc963fSmrg save_oldobjs=$oldobjs 1092549dc963fSmrg oldobjs= 1092649dc963fSmrg counter=1 1092749dc963fSmrg for obj in $save_oldobjs 1092849dc963fSmrg do 1092949dc963fSmrg func_basename "$obj" 1093026372658Smrg objbase=$func_basename_result 1093149dc963fSmrg case " $oldobjs " in 1093249dc963fSmrg " ") oldobjs=$obj ;; 1093349dc963fSmrg *[\ /]"$objbase "*) 1093449dc963fSmrg while :; do 1093549dc963fSmrg # Make sure we don't pick an alternate name that also 1093649dc963fSmrg # overlaps. 1093749dc963fSmrg newobj=lt$counter-$objbase 1093849dc963fSmrg func_arith $counter + 1 1093949dc963fSmrg counter=$func_arith_result 1094049dc963fSmrg case " $oldobjs " in 1094149dc963fSmrg *[\ /]"$newobj "*) ;; 1094249dc963fSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1094349dc963fSmrg esac 1094449dc963fSmrg done 1094549dc963fSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109464e7590efSmrg func_append oldobjs " $gentop/$newobj" 1094749dc963fSmrg ;; 109484e7590efSmrg *) func_append oldobjs " $obj" ;; 1094949dc963fSmrg esac 109504b0ead49Smrg done 109514b0ead49Smrg fi 109524e7590efSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109534e7590efSmrg tool_oldlib=$func_to_tool_file_result 1095449dc963fSmrg eval cmds=\"$old_archive_cmds\" 109554b0ead49Smrg 1095649dc963fSmrg func_len " $cmds" 1095749dc963fSmrg len=$func_len_result 1095849dc963fSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1095949dc963fSmrg cmds=$old_archive_cmds 109604e7590efSmrg elif test -n "$archiver_list_spec"; then 109614e7590efSmrg func_verbose "using command file archive linking..." 109624e7590efSmrg for obj in $oldobjs 109634e7590efSmrg do 109644e7590efSmrg func_to_tool_file "$obj" 109654e7590efSmrg $ECHO "$func_to_tool_file_result" 109664e7590efSmrg done > $output_objdir/$libname.libcmd 109674e7590efSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 109684e7590efSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109694e7590efSmrg cmds=$old_archive_cmds 1097049dc963fSmrg else 1097149dc963fSmrg # the command line is too long to link in one step, link in parts 1097249dc963fSmrg func_verbose "using piecewise archive linking..." 1097349dc963fSmrg save_RANLIB=$RANLIB 1097449dc963fSmrg RANLIB=: 1097549dc963fSmrg objlist= 1097649dc963fSmrg concat_cmds= 1097749dc963fSmrg save_oldobjs=$oldobjs 1097849dc963fSmrg oldobjs= 1097949dc963fSmrg # Is there a better way of finding the last object in the list? 1098049dc963fSmrg for obj in $save_oldobjs 1098149dc963fSmrg do 1098249dc963fSmrg last_oldobj=$obj 1098349dc963fSmrg done 1098449dc963fSmrg eval test_cmds=\"$old_archive_cmds\" 1098549dc963fSmrg func_len " $test_cmds" 1098649dc963fSmrg len0=$func_len_result 1098749dc963fSmrg len=$len0 1098849dc963fSmrg for obj in $save_oldobjs 1098949dc963fSmrg do 1099049dc963fSmrg func_len " $obj" 1099149dc963fSmrg func_arith $len + $func_len_result 1099249dc963fSmrg len=$func_arith_result 1099349dc963fSmrg func_append objlist " $obj" 1099449dc963fSmrg if test "$len" -lt "$max_cmd_len"; then 1099549dc963fSmrg : 1099649dc963fSmrg else 1099749dc963fSmrg # the above command should be used before it gets too long 1099849dc963fSmrg oldobjs=$objlist 1099926372658Smrg if test "$obj" = "$last_oldobj"; then 1100049dc963fSmrg RANLIB=$save_RANLIB 1100149dc963fSmrg fi 1100249dc963fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1100326372658Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1100449dc963fSmrg objlist= 1100549dc963fSmrg len=$len0 1100649dc963fSmrg fi 1100749dc963fSmrg done 1100849dc963fSmrg RANLIB=$save_RANLIB 1100949dc963fSmrg oldobjs=$objlist 1101026372658Smrg if test -z "$oldobjs"; then 1101149dc963fSmrg eval cmds=\"\$concat_cmds\" 1101249dc963fSmrg else 1101349dc963fSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1101449dc963fSmrg fi 1101549dc963fSmrg fi 1101649dc963fSmrg fi 1101749dc963fSmrg func_execute_cmds "$cmds" 'exit $?' 110184b0ead49Smrg done 110194b0ead49Smrg 1102049dc963fSmrg test -n "$generated" && \ 1102149dc963fSmrg func_show_eval "${RM}r$generated" 110224b0ead49Smrg 1102349dc963fSmrg # Now create the libtool archive. 1102449dc963fSmrg case $output in 1102549dc963fSmrg *.la) 1102649dc963fSmrg old_library= 1102726372658Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 1102849dc963fSmrg func_verbose "creating $output" 110294b0ead49Smrg 1103049dc963fSmrg # Preserve any variables that may affect compiler behavior 1103149dc963fSmrg for var in $variables_saved_for_relink; do 1103249dc963fSmrg if eval test -z \"\${$var+set}\"; then 1103349dc963fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1103449dc963fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1103549dc963fSmrg relink_command="$var=; export $var; $relink_command" 110364b0ead49Smrg else 11037c3e29c03Smrg func_quote_arg pretty,unquoted "$var_value" 11038c3e29c03Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110394b0ead49Smrg fi 1104049dc963fSmrg done 1104149dc963fSmrg # Quote the link command for shipping. 11042c3e29c03Smrg func_quote eval cd "`pwd`" 11043c3e29c03Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044c3e29c03Smrg func_quote_arg pretty,unquoted "$relink_command" 11045c3e29c03Smrg relink_command=$func_quote_arg_unquoted_result 1104626372658Smrg if test yes = "$hardcode_automatic"; then 1104749dc963fSmrg relink_command= 1104849dc963fSmrg fi 110494b0ead49Smrg 1105049dc963fSmrg # Only create the output if not a dry run. 1105149dc963fSmrg $opt_dry_run || { 1105249dc963fSmrg for installed in no yes; do 1105326372658Smrg if test yes = "$installed"; then 1105449dc963fSmrg if test -z "$install_libdir"; then 1105549dc963fSmrg break 1105649dc963fSmrg fi 1105726372658Smrg output=$output_objdir/${outputname}i 1105849dc963fSmrg # Replace all uninstalled libtool libraries with the installed ones 1105949dc963fSmrg newdependency_libs= 1106049dc963fSmrg for deplib in $dependency_libs; do 1106149dc963fSmrg case $deplib in 1106249dc963fSmrg *.la) 1106349dc963fSmrg func_basename "$deplib" 1106426372658Smrg name=$func_basename_result 110654e7590efSmrg func_resolve_sysroot "$deplib" 1106626372658Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1106749dc963fSmrg test -z "$libdir" && \ 1106826372658Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 110694e7590efSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110704e7590efSmrg ;; 110714e7590efSmrg -L*) 110724e7590efSmrg func_stripname -L '' "$deplib" 110734e7590efSmrg func_replace_sysroot "$func_stripname_result" 110744e7590efSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 110754e7590efSmrg ;; 110764e7590efSmrg -R*) 110774e7590efSmrg func_stripname -R '' "$deplib" 110784e7590efSmrg func_replace_sysroot "$func_stripname_result" 110794e7590efSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1108049dc963fSmrg ;; 110814e7590efSmrg *) func_append newdependency_libs " $deplib" ;; 1108249dc963fSmrg esac 1108349dc963fSmrg done 1108426372658Smrg dependency_libs=$newdependency_libs 1108549dc963fSmrg newdlfiles= 1108649dc963fSmrg 1108749dc963fSmrg for lib in $dlfiles; do 1108849dc963fSmrg case $lib in 1108949dc963fSmrg *.la) 1109049dc963fSmrg func_basename "$lib" 1109126372658Smrg name=$func_basename_result 1109226372658Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1109349dc963fSmrg test -z "$libdir" && \ 1109426372658Smrg func_fatal_error "'$lib' is not a valid libtool archive" 110954e7590efSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1109649dc963fSmrg ;; 110974e7590efSmrg *) func_append newdlfiles " $lib" ;; 1109849dc963fSmrg esac 1109949dc963fSmrg done 1110026372658Smrg dlfiles=$newdlfiles 1110149dc963fSmrg newdlprefiles= 1110249dc963fSmrg for lib in $dlprefiles; do 1110349dc963fSmrg case $lib in 1110449dc963fSmrg *.la) 1110549dc963fSmrg # Only pass preopened files to the pseudo-archive (for 1110649dc963fSmrg # eventual linking with the app. that links it) if we 1110749dc963fSmrg # didn't already link the preopened objects directly into 1110849dc963fSmrg # the library: 1110949dc963fSmrg func_basename "$lib" 1111026372658Smrg name=$func_basename_result 1111126372658Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1111249dc963fSmrg test -z "$libdir" && \ 1111326372658Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111144e7590efSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1111549dc963fSmrg ;; 1111649dc963fSmrg esac 1111749dc963fSmrg done 1111826372658Smrg dlprefiles=$newdlprefiles 1111949dc963fSmrg else 1112049dc963fSmrg newdlfiles= 1112149dc963fSmrg for lib in $dlfiles; do 1112249dc963fSmrg case $lib in 1112326372658Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1112449dc963fSmrg *) abs=`pwd`"/$lib" ;; 1112549dc963fSmrg esac 111264e7590efSmrg func_append newdlfiles " $abs" 1112749dc963fSmrg done 1112826372658Smrg dlfiles=$newdlfiles 1112949dc963fSmrg newdlprefiles= 1113049dc963fSmrg for lib in $dlprefiles; do 1113149dc963fSmrg case $lib in 1113226372658Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1113349dc963fSmrg *) abs=`pwd`"/$lib" ;; 1113449dc963fSmrg esac 111354e7590efSmrg func_append newdlprefiles " $abs" 1113649dc963fSmrg done 1113726372658Smrg dlprefiles=$newdlprefiles 1113849dc963fSmrg fi 1113949dc963fSmrg $RM $output 1114049dc963fSmrg # place dlname in correct position for cygwin 111417aa89044Smrg # In fact, it would be nice if we could use this code for all target 111427aa89044Smrg # systems that can't hard-code library paths into their executables 111437aa89044Smrg # and that have no shared library path variable independent of PATH, 111447aa89044Smrg # but it turns out we can't easily determine that from inspecting 111457aa89044Smrg # libtool variables, so we have to hard-code the OSs to which it 111467aa89044Smrg # applies here; at the moment, that means platforms that use the PE 111477aa89044Smrg # object format with DLL files. See the long comment at the top of 111487aa89044Smrg # tests/bindir.at for full details. 1114949dc963fSmrg tdlname=$dlname 1115049dc963fSmrg case $host,$output,$installed,$module,$dlname in 111517aa89044Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111527aa89044Smrg # If a -bindir argument was supplied, place the dll there. 1115326372658Smrg if test -n "$bindir"; then 111547aa89044Smrg func_relative_path "$install_libdir" "$bindir" 1115526372658Smrg tdlname=$func_relative_path_result/$dlname 111567aa89044Smrg else 111577aa89044Smrg # Otherwise fall back on heuristic. 111587aa89044Smrg tdlname=../bin/$dlname 111597aa89044Smrg fi 111607aa89044Smrg ;; 1116149dc963fSmrg esac 1116249dc963fSmrg $ECHO > $output "\ 1116349dc963fSmrg# $outputname - a libtool library file 1116426372658Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1116549dc963fSmrg# 1116649dc963fSmrg# Please DO NOT delete this file! 1116749dc963fSmrg# It is necessary for linking the library. 111684b0ead49Smrg 1116949dc963fSmrg# The name that we can dlopen(3). 1117049dc963fSmrgdlname='$tdlname' 111714b0ead49Smrg 1117249dc963fSmrg# Names of this library. 1117349dc963fSmrglibrary_names='$library_names' 111744b0ead49Smrg 1117549dc963fSmrg# The name of the static archive. 1117649dc963fSmrgold_library='$old_library' 111774b0ead49Smrg 1117826372658Smrg# Linker flags that cannot go in dependency_libs. 1117949dc963fSmrginherited_linker_flags='$new_inherited_linker_flags' 111804b0ead49Smrg 1118149dc963fSmrg# Libraries that this one depends upon. 1118249dc963fSmrgdependency_libs='$dependency_libs' 111834b0ead49Smrg 1118449dc963fSmrg# Names of additional weak libraries provided by this library 1118549dc963fSmrgweak_library_names='$weak_libs' 111864b0ead49Smrg 1118749dc963fSmrg# Version information for $libname. 1118849dc963fSmrgcurrent=$current 1118949dc963fSmrgage=$age 1119049dc963fSmrgrevision=$revision 111914b0ead49Smrg 1119249dc963fSmrg# Is this an already installed library? 1119349dc963fSmrginstalled=$installed 111944b0ead49Smrg 1119549dc963fSmrg# Should we warn about portability when linking against -modules? 1119649dc963fSmrgshouldnotlink=$module 111974b0ead49Smrg 1119849dc963fSmrg# Files to dlopen/dlpreopen 1119949dc963fSmrgdlopen='$dlfiles' 1120049dc963fSmrgdlpreopen='$dlprefiles' 112014b0ead49Smrg 1120249dc963fSmrg# Directory that this library needs to be installed in: 1120349dc963fSmrglibdir='$install_libdir'" 1120426372658Smrg if test no,yes = "$installed,$need_relink"; then 1120549dc963fSmrg $ECHO >> $output "\ 1120649dc963fSmrgrelink_command=\"$relink_command\"" 1120749dc963fSmrg fi 1120849dc963fSmrg done 1120949dc963fSmrg } 112104b0ead49Smrg 1121149dc963fSmrg # Do a symbolic link so that the libtool archive can be found in 1121249dc963fSmrg # LD_LIBRARY_PATH before the program is installed. 1121349dc963fSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1121449dc963fSmrg ;; 1121549dc963fSmrg esac 1121649dc963fSmrg exit $EXIT_SUCCESS 1121749dc963fSmrg} 112184b0ead49Smrg 1121926372658Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1122026372658Smrg func_mode_link ${1+"$@"} 1122126372658Smrgfi 112224b0ead49Smrg 112234b0ead49Smrg 1122449dc963fSmrg# func_mode_uninstall arg... 1122549dc963fSmrgfunc_mode_uninstall () 1122649dc963fSmrg{ 1122726372658Smrg $debug_cmd 1122826372658Smrg 1122926372658Smrg RM=$nonopt 112304b0ead49Smrg files= 1123126372658Smrg rmforce=false 112324b0ead49Smrg exit_status=0 112334b0ead49Smrg 112344b0ead49Smrg # This variable tells wrapper scripts just to set variables rather 112354b0ead49Smrg # than running their programs. 1123626372658Smrg libtool_install_magic=$magic 112374b0ead49Smrg 112384b0ead49Smrg for arg 112394b0ead49Smrg do 112404b0ead49Smrg case $arg in 1124126372658Smrg -f) func_append RM " $arg"; rmforce=: ;; 112424e7590efSmrg -*) func_append RM " $arg" ;; 112434e7590efSmrg *) func_append files " $arg" ;; 112444b0ead49Smrg esac 112454b0ead49Smrg done 112464b0ead49Smrg 1124749dc963fSmrg test -z "$RM" && \ 1124849dc963fSmrg func_fatal_help "you must specify an RM program" 112494b0ead49Smrg 112504b0ead49Smrg rmdirs= 112514b0ead49Smrg 112524b0ead49Smrg for file in $files; do 1125349dc963fSmrg func_dirname "$file" "" "." 1125426372658Smrg dir=$func_dirname_result 1125526372658Smrg if test . = "$dir"; then 1125626372658Smrg odir=$objdir 112574b0ead49Smrg else 1125826372658Smrg odir=$dir/$objdir 112594b0ead49Smrg fi 1126049dc963fSmrg func_basename "$file" 1126126372658Smrg name=$func_basename_result 1126226372658Smrg test uninstall = "$opt_mode" && odir=$dir 112634b0ead49Smrg 112644e7590efSmrg # Remember odir for removal later, being careful to avoid duplicates 1126526372658Smrg if test clean = "$opt_mode"; then 112664b0ead49Smrg case " $rmdirs " in 112674e7590efSmrg *" $odir "*) ;; 112684e7590efSmrg *) func_append rmdirs " $odir" ;; 112694b0ead49Smrg esac 112704b0ead49Smrg fi 112714b0ead49Smrg 112724b0ead49Smrg # Don't error if the file doesn't exist and rm -f was used. 1127349dc963fSmrg if { test -L "$file"; } >/dev/null 2>&1 || 1127449dc963fSmrg { test -h "$file"; } >/dev/null 2>&1 || 1127549dc963fSmrg test -f "$file"; then 112764b0ead49Smrg : 112774b0ead49Smrg elif test -d "$file"; then 112784b0ead49Smrg exit_status=1 112794b0ead49Smrg continue 1128026372658Smrg elif $rmforce; then 112814b0ead49Smrg continue 112824b0ead49Smrg fi 112834b0ead49Smrg 1128426372658Smrg rmfiles=$file 112854b0ead49Smrg 112864b0ead49Smrg case $name in 112874b0ead49Smrg *.la) 112884b0ead49Smrg # Possibly a libtool archive, so verify it. 1128949dc963fSmrg if func_lalib_p "$file"; then 1129049dc963fSmrg func_source $dir/$name 112914b0ead49Smrg 112924b0ead49Smrg # Delete the libtool libraries and symlinks. 112934b0ead49Smrg for n in $library_names; do 112944e7590efSmrg func_append rmfiles " $odir/$n" 112954b0ead49Smrg done 112964e7590efSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112974b0ead49Smrg 1129826372658Smrg case $opt_mode in 112994b0ead49Smrg clean) 113004e7590efSmrg case " $library_names " in 113014b0ead49Smrg *" $dlname "*) ;; 113024e7590efSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113034b0ead49Smrg esac 113044e7590efSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113054b0ead49Smrg ;; 113064b0ead49Smrg uninstall) 113074b0ead49Smrg if test -n "$library_names"; then 113084b0ead49Smrg # Do each command in the postuninstall commands. 1130926372658Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113104b0ead49Smrg fi 113114b0ead49Smrg 113124b0ead49Smrg if test -n "$old_library"; then 113134b0ead49Smrg # Do each command in the old_postuninstall commands. 1131426372658Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113154b0ead49Smrg fi 113164b0ead49Smrg # FIXME: should reinstall the best remaining shared library. 113174b0ead49Smrg ;; 113184b0ead49Smrg esac 113194b0ead49Smrg fi 113204b0ead49Smrg ;; 113214b0ead49Smrg 113224b0ead49Smrg *.lo) 113234b0ead49Smrg # Possibly a libtool object, so verify it. 1132449dc963fSmrg if func_lalib_p "$file"; then 113254b0ead49Smrg 113264b0ead49Smrg # Read the .lo file 1132749dc963fSmrg func_source $dir/$name 113284b0ead49Smrg 113294b0ead49Smrg # Add PIC object to the list of files to remove. 1133026372658Smrg if test -n "$pic_object" && test none != "$pic_object"; then 113314e7590efSmrg func_append rmfiles " $dir/$pic_object" 113324b0ead49Smrg fi 113334b0ead49Smrg 113344b0ead49Smrg # Add non-PIC object to the list of files to remove. 1133526372658Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113364e7590efSmrg func_append rmfiles " $dir/$non_pic_object" 113374b0ead49Smrg fi 113384b0ead49Smrg fi 113394b0ead49Smrg ;; 113404b0ead49Smrg 113414b0ead49Smrg *) 1134226372658Smrg if test clean = "$opt_mode"; then 113434b0ead49Smrg noexename=$name 113444b0ead49Smrg case $file in 113454b0ead49Smrg *.exe) 1134649dc963fSmrg func_stripname '' '.exe' "$file" 1134749dc963fSmrg file=$func_stripname_result 1134849dc963fSmrg func_stripname '' '.exe' "$name" 1134949dc963fSmrg noexename=$func_stripname_result 113504b0ead49Smrg # $file with .exe has already been added to rmfiles, 113514b0ead49Smrg # add $file without .exe 113524e7590efSmrg func_append rmfiles " $file" 113534b0ead49Smrg ;; 113544b0ead49Smrg esac 113554b0ead49Smrg # Do a test to see if this is a libtool program. 1135649dc963fSmrg if func_ltwrapper_p "$file"; then 1135749dc963fSmrg if func_ltwrapper_executable_p "$file"; then 1135849dc963fSmrg func_ltwrapper_scriptname "$file" 1135949dc963fSmrg relink_command= 1136049dc963fSmrg func_source $func_ltwrapper_scriptname_result 113614e7590efSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1136249dc963fSmrg else 1136349dc963fSmrg relink_command= 1136449dc963fSmrg func_source $dir/$noexename 1136549dc963fSmrg fi 113664b0ead49Smrg 113674b0ead49Smrg # note $name still contains .exe if it was in $file originally 113684b0ead49Smrg # as does the version of $file that was added into $rmfiles 1136926372658Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1137026372658Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 113714e7590efSmrg func_append rmfiles " $odir/lt-$name" 113724b0ead49Smrg fi 1137326372658Smrg if test "X$noexename" != "X$name"; then 1137426372658Smrg func_append rmfiles " $odir/lt-$noexename.c" 113754b0ead49Smrg fi 113764b0ead49Smrg fi 113774b0ead49Smrg fi 113784b0ead49Smrg ;; 113794b0ead49Smrg esac 1138049dc963fSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113814b0ead49Smrg done 113824b0ead49Smrg 1138326372658Smrg # Try to remove the $objdir's in the directories where we deleted files 113844b0ead49Smrg for dir in $rmdirs; do 113854b0ead49Smrg if test -d "$dir"; then 1138649dc963fSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113874b0ead49Smrg fi 113884b0ead49Smrg done 113894b0ead49Smrg 113904b0ead49Smrg exit $exit_status 1139149dc963fSmrg} 113924b0ead49Smrg 1139326372658Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1139426372658Smrg func_mode_uninstall ${1+"$@"} 1139526372658Smrgfi 113964b0ead49Smrg 113974e7590efSmrgtest -z "$opt_mode" && { 1139826372658Smrg help=$generic_help 1139949dc963fSmrg func_fatal_help "you must specify a MODE" 1140049dc963fSmrg} 1140149dc963fSmrg 1140249dc963fSmrgtest -z "$exec_cmd" && \ 1140326372658Smrg func_fatal_help "invalid operation mode '$opt_mode'" 114044b0ead49Smrg 114054b0ead49Smrgif test -n "$exec_cmd"; then 1140649dc963fSmrg eval exec "$exec_cmd" 114074b0ead49Smrg exit $EXIT_FAILURE 114084b0ead49Smrgfi 114094b0ead49Smrg 1141049dc963fSmrgexit $exit_status 114114b0ead49Smrg 114124b0ead49Smrg 114134b0ead49Smrg# The TAGs below are defined such that we never get into a situation 1141426372658Smrg# where we disable both kinds of libraries. Given conflicting 114154b0ead49Smrg# choices, we go for a static library, that is the most portable, 114164b0ead49Smrg# since we can't tell whether shared libraries were disabled because 114174b0ead49Smrg# the user asked for that or because the platform doesn't support 114184b0ead49Smrg# them. This is particularly important on AIX, because we don't 114194b0ead49Smrg# support having both static and shared libraries enabled at the same 114204b0ead49Smrg# time on that platform, so we default to a shared-only configuration. 114214b0ead49Smrg# If a disable-shared tag is given, we'll fallback to a static-only 114224b0ead49Smrg# configuration. But we'll never go from static-only to shared-only. 114234b0ead49Smrg 114244b0ead49Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1142549dc963fSmrgbuild_libtool_libs=no 1142649dc963fSmrgbuild_old_libs=yes 114274b0ead49Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 114284b0ead49Smrg 114294b0ead49Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1143049dc963fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114314b0ead49Smrg# ### END LIBTOOL TAG CONFIG: disable-static 114324b0ead49Smrg 114334b0ead49Smrg# Local Variables: 114344b0ead49Smrg# mode:shell-script 114354b0ead49Smrg# sh-indentation:2 114364b0ead49Smrg# End: 11437