ltmain.sh revision 44584a44
144584a44Smrg#! /bin/sh 244584a44Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 344584a44Smrg## by inline-source v2014-01-03.01 4c27c18e8Smrg 544584a44Smrg# libtool (GNU libtool) 2.4.6 644584a44Smrg# Provide generalized library-building support services. 7c27c18e8Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8c27c18e8Smrg 944584a44Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10c27c18e8Smrg# This is free software; see the source for copying conditions. There is NO 11c27c18e8Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12c27c18e8Smrg 13c27c18e8Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14c43cc173Smrg# it under the terms of the GNU General Public License as published by 15c43cc173Smrg# the Free Software Foundation; either version 2 of the License, or 16c43cc173Smrg# (at your option) any later version. 17c43cc173Smrg# 18c27c18e8Smrg# As a special exception to the GNU General Public License, 19c27c18e8Smrg# if you distribute this file as part of a program or library that 20c27c18e8Smrg# is built using GNU Libtool, you may include this file under the 21c27c18e8Smrg# same distribution terms that you use for the rest of that program. 22c27c18e8Smrg# 23c27c18e8Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24c43cc173Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25c43cc173Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26c43cc173Smrg# General Public License for more details. 27c43cc173Smrg# 28c43cc173Smrg# You should have received a copy of the GNU General Public License 2944584a44Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30c43cc173Smrg 31c43cc173Smrg 3237eb1ca1SmrgPROGRAM=libtool 33c43cc173SmrgPACKAGE=libtool 3444584a44SmrgVERSION=2.4.6 3544584a44Smrgpackage_revision=2.4.6 3621e67964Smrg 3744584a44Smrg 3844584a44Smrg## ------ ## 3944584a44Smrg## Usage. ## 4044584a44Smrg## ------ ## 4144584a44Smrg 4244584a44Smrg# Run './libtool --help' for help with using this script from the 4344584a44Smrg# command line. 4444584a44Smrg 4544584a44Smrg 4644584a44Smrg## ------------------------------- ## 4744584a44Smrg## User overridable command paths. ## 4844584a44Smrg## ------------------------------- ## 4944584a44Smrg 5044584a44Smrg# After configure completes, it has a better idea of some of the 5144584a44Smrg# shell tools we need than the defaults used by the functions shared 5244584a44Smrg# with bootstrap, so set those here where they can still be over- 5344584a44Smrg# ridden by the user, but otherwise take precedence. 5444584a44Smrg 5544584a44Smrg: ${AUTOCONF="autoconf"} 5644584a44Smrg: ${AUTOMAKE="automake"} 5744584a44Smrg 5844584a44Smrg 5944584a44Smrg## -------------------------- ## 6044584a44Smrg## Source external libraries. ## 6144584a44Smrg## -------------------------- ## 6244584a44Smrg 6344584a44Smrg# Much of our low-level functionality needs to be sourced from external 6444584a44Smrg# libraries, which are installed to $pkgauxdir. 6544584a44Smrg 6644584a44Smrg# Set a version string for this script. 6744584a44Smrgscriptversion=2015-01-20.17; # UTC 6844584a44Smrg 6944584a44Smrg# General shell script boiler plate, and helper functions. 7044584a44Smrg# Written by Gary V. Vaughan, 2004 7144584a44Smrg 7244584a44Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 7344584a44Smrg# This is free software; see the source for copying conditions. There is NO 7444584a44Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 7544584a44Smrg 7644584a44Smrg# This program is free software; you can redistribute it and/or modify 7744584a44Smrg# it under the terms of the GNU General Public License as published by 7844584a44Smrg# the Free Software Foundation; either version 3 of the License, or 7944584a44Smrg# (at your option) any later version. 8044584a44Smrg 8144584a44Smrg# As a special exception to the GNU General Public License, if you distribute 8244584a44Smrg# this file as part of a program or library that is built using GNU Libtool, 8344584a44Smrg# you may include this file under the same distribution terms that you use 8444584a44Smrg# for the rest of that program. 8544584a44Smrg 8644584a44Smrg# This program is distributed in the hope that it will be useful, 8744584a44Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 8844584a44Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 8944584a44Smrg# General Public License for more details. 9044584a44Smrg 9144584a44Smrg# You should have received a copy of the GNU General Public License 9244584a44Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 9344584a44Smrg 9444584a44Smrg# Please report bugs or propose patches to gary@gnu.org. 9544584a44Smrg 9644584a44Smrg 9744584a44Smrg## ------ ## 9844584a44Smrg## Usage. ## 9944584a44Smrg## ------ ## 10044584a44Smrg 10144584a44Smrg# Evaluate this file near the top of your script to gain access to 10244584a44Smrg# the functions and variables defined here: 10344584a44Smrg# 10444584a44Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 10544584a44Smrg# 10644584a44Smrg# If you need to override any of the default environment variable 10744584a44Smrg# settings, do that before evaluating this file. 10844584a44Smrg 10944584a44Smrg 11044584a44Smrg## -------------------- ## 11144584a44Smrg## Shell normalisation. ## 11244584a44Smrg## -------------------- ## 11344584a44Smrg 11444584a44Smrg# Some shells need a little help to be as Bourne compatible as possible. 11544584a44Smrg# Before doing anything else, make sure all that help has been provided! 11644584a44Smrg 11744584a44SmrgDUALCASE=1; export DUALCASE # for MKS sh 11844584a44Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11921e67964Smrg emulate sh 12021e67964Smrg NULLCMD=: 12144584a44Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 12221e67964Smrg # is contrary to our usage. Disable this feature. 12321e67964Smrg alias -g '${1+"$@"}'='"$@"' 124c43cc173Smrg setopt NO_GLOB_SUBST 12521e67964Smrgelse 12644584a44Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127c43cc173Smrgfi 12837eb1ca1Smrg 12944584a44Smrg# NLS nuisances: We save the old values in case they are required later. 13044584a44Smrg_G_user_locale= 13144584a44Smrg_G_safe_locale= 13244584a44Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 13321e67964Smrgdo 13444584a44Smrg eval "if test set = \"\${$_G_var+set}\"; then 13544584a44Smrg save_$_G_var=\$$_G_var 13644584a44Smrg $_G_var=C 13744584a44Smrg export $_G_var 13844584a44Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13944584a44Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 14021e67964Smrg fi" 14121e67964Smrgdone 142c43cc173Smrg 14344584a44Smrg# CDPATH. 14444584a44Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145c27c18e8Smrg 14644584a44Smrg# Make sure IFS has a sensible default 14744584a44Smrgsp=' ' 14844584a44Smrgnl=' 14944584a44Smrg' 15044584a44SmrgIFS="$sp $nl" 15144584a44Smrg 15244584a44Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 15344584a44Smrgif test "${PATH_SEPARATOR+set}" != set; then 15444584a44Smrg PATH_SEPARATOR=: 15544584a44Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15644584a44Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15744584a44Smrg PATH_SEPARATOR=';' 15844584a44Smrg } 15944584a44Smrgfi 160c27c18e8Smrg 161c27c18e8Smrg 162c27c18e8Smrg 16344584a44Smrg## ------------------------- ## 16444584a44Smrg## Locate command utilities. ## 16544584a44Smrg## ------------------------- ## 16644584a44Smrg 16744584a44Smrg 16844584a44Smrg# func_executable_p FILE 16944584a44Smrg# ---------------------- 17044584a44Smrg# Check that FILE is an executable regular file. 17144584a44Smrgfunc_executable_p () 17244584a44Smrg{ 17344584a44Smrg test -f "$1" && test -x "$1" 17444584a44Smrg} 17544584a44Smrg 17644584a44Smrg 17744584a44Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 17844584a44Smrg# -------------------------------------------- 17944584a44Smrg# Search for either a program that responds to --version with output 18044584a44Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 18144584a44Smrg# trying all the directories in PATH with each of the elements of 18244584a44Smrg# PROGS_LIST. 18344584a44Smrg# 18444584a44Smrg# CHECK_FUNC should accept the path to a candidate program, and 18544584a44Smrg# set $func_check_prog_result if it truncates its output less than 18644584a44Smrg# $_G_path_prog_max characters. 18744584a44Smrgfunc_path_progs () 18844584a44Smrg{ 18944584a44Smrg _G_progs_list=$1 19044584a44Smrg _G_check_func=$2 19144584a44Smrg _G_PATH=${3-"$PATH"} 19244584a44Smrg 19344584a44Smrg _G_path_prog_max=0 19444584a44Smrg _G_path_prog_found=false 19544584a44Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 19644584a44Smrg for _G_dir in $_G_PATH; do 19744584a44Smrg IFS=$_G_save_IFS 19844584a44Smrg test -z "$_G_dir" && _G_dir=. 19944584a44Smrg for _G_prog_name in $_G_progs_list; do 20044584a44Smrg for _exeext in '' .EXE; do 20144584a44Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 20244584a44Smrg func_executable_p "$_G_path_prog" || continue 20344584a44Smrg case `"$_G_path_prog" --version 2>&1` in 20444584a44Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 20544584a44Smrg *) $_G_check_func $_G_path_prog 20644584a44Smrg func_path_progs_result=$func_check_prog_result 20744584a44Smrg ;; 20844584a44Smrg esac 20944584a44Smrg $_G_path_prog_found && break 3 21044584a44Smrg done 21144584a44Smrg done 21244584a44Smrg done 21344584a44Smrg IFS=$_G_save_IFS 21444584a44Smrg test -z "$func_path_progs_result" && { 21544584a44Smrg echo "no acceptable sed could be found in \$PATH" >&2 21644584a44Smrg exit 1 21744584a44Smrg } 21844584a44Smrg} 21944584a44Smrg 22044584a44Smrg 22144584a44Smrg# We want to be able to use the functions in this file before configure 22244584a44Smrg# has figured out where the best binaries are kept, which means we have 22344584a44Smrg# to search for them ourselves - except when the results are already set 22444584a44Smrg# where we skip the searches. 22544584a44Smrg 22644584a44Smrg# Unless the user overrides by setting SED, search the path for either GNU 22744584a44Smrg# sed, or the sed that truncates its output the least. 22844584a44Smrgtest -z "$SED" && { 22944584a44Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 23044584a44Smrg for _G_i in 1 2 3 4 5 6 7; do 23144584a44Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 23244584a44Smrg done 23344584a44Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 23444584a44Smrg _G_sed_script= 23544584a44Smrg 23644584a44Smrg func_check_prog_sed () 23744584a44Smrg { 23844584a44Smrg _G_path_prog=$1 23944584a44Smrg 24044584a44Smrg _G_count=0 24144584a44Smrg printf 0123456789 >conftest.in 24244584a44Smrg while : 24344584a44Smrg do 24444584a44Smrg cat conftest.in conftest.in >conftest.tmp 24544584a44Smrg mv conftest.tmp conftest.in 24644584a44Smrg cp conftest.in conftest.nl 24744584a44Smrg echo '' >> conftest.nl 24844584a44Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 24944584a44Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 25044584a44Smrg _G_count=`expr $_G_count + 1` 25144584a44Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 25244584a44Smrg # Best one so far, save it but keep looking for a better one 25344584a44Smrg func_check_prog_result=$_G_path_prog 25444584a44Smrg _G_path_prog_max=$_G_count 25544584a44Smrg fi 25644584a44Smrg # 10*(2^10) chars as input seems more than enough 25744584a44Smrg test 10 -lt "$_G_count" && break 25844584a44Smrg done 25944584a44Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 26044584a44Smrg } 26144584a44Smrg 26244584a44Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 26344584a44Smrg rm -f conftest.sed 26444584a44Smrg SED=$func_path_progs_result 26544584a44Smrg} 26644584a44Smrg 26744584a44Smrg 26844584a44Smrg# Unless the user overrides by setting GREP, search the path for either GNU 26944584a44Smrg# grep, or the grep that truncates its output the least. 27044584a44Smrgtest -z "$GREP" && { 27144584a44Smrg func_check_prog_grep () 27244584a44Smrg { 27344584a44Smrg _G_path_prog=$1 27444584a44Smrg 27544584a44Smrg _G_count=0 27644584a44Smrg _G_path_prog_max=0 27744584a44Smrg printf 0123456789 >conftest.in 27844584a44Smrg while : 27944584a44Smrg do 28044584a44Smrg cat conftest.in conftest.in >conftest.tmp 28144584a44Smrg mv conftest.tmp conftest.in 28244584a44Smrg cp conftest.in conftest.nl 28344584a44Smrg echo 'GREP' >> conftest.nl 28444584a44Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 28544584a44Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 28644584a44Smrg _G_count=`expr $_G_count + 1` 28744584a44Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 28844584a44Smrg # Best one so far, save it but keep looking for a better one 28944584a44Smrg func_check_prog_result=$_G_path_prog 29044584a44Smrg _G_path_prog_max=$_G_count 29144584a44Smrg fi 29244584a44Smrg # 10*(2^10) chars as input seems more than enough 29344584a44Smrg test 10 -lt "$_G_count" && break 29444584a44Smrg done 29544584a44Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 29644584a44Smrg } 29744584a44Smrg 29844584a44Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 29944584a44Smrg GREP=$func_path_progs_result 30044584a44Smrg} 30144584a44Smrg 30244584a44Smrg 30344584a44Smrg## ------------------------------- ## 30444584a44Smrg## User overridable command paths. ## 30544584a44Smrg## ------------------------------- ## 30644584a44Smrg 30744584a44Smrg# All uppercase variable names are used for environment variables. These 30844584a44Smrg# variables can be overridden by the user before calling a script that 30944584a44Smrg# uses them if a suitable command of that name is not already available 31044584a44Smrg# in the command search PATH. 311c27c18e8Smrg 312c27c18e8Smrg: ${CP="cp -f"} 31344584a44Smrg: ${ECHO="printf %s\n"} 31444584a44Smrg: ${EGREP="$GREP -E"} 31544584a44Smrg: ${FGREP="$GREP -F"} 31644584a44Smrg: ${LN_S="ln -s"} 317c27c18e8Smrg: ${MAKE="make"} 318c27c18e8Smrg: ${MKDIR="mkdir"} 319c27c18e8Smrg: ${MV="mv -f"} 320c27c18e8Smrg: ${RM="rm -f"} 321c27c18e8Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322c43cc173Smrg 323c27c18e8Smrg 32444584a44Smrg## -------------------- ## 32544584a44Smrg## Useful sed snippets. ## 32644584a44Smrg## -------------------- ## 327b789ec8aSmrg 32844584a44Smrgsed_dirname='s|/[^/]*$||' 32944584a44Smrgsed_basename='s|^.*/||' 330b789ec8aSmrg 33144584a44Smrg# Sed substitution that helps us do robust quoting. It backslashifies 33244584a44Smrg# metacharacters that are still active within double-quoted strings. 33344584a44Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334b789ec8aSmrg 33544584a44Smrg# Same as above, but do not quote variable references. 33644584a44Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337b789ec8aSmrg 33844584a44Smrg# Sed substitution that turns a string into a regex matching for the 33944584a44Smrg# string literally. 34044584a44Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341b789ec8aSmrg 34244584a44Smrg# Sed substitution that converts a w32 file name or path 34344584a44Smrg# that contains forward slashes, into one that contains 34444584a44Smrg# (escaped) backslashes. A very naive implementation. 34544584a44Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 34644584a44Smrg 34744584a44Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 34844584a44Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 34944584a44Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 35044584a44Smrg# expansion. Since each input '\' is now two '\'s, look for any number 35144584a44Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 35244584a44Smrg_G_bs='\\' 35344584a44Smrg_G_bs2='\\\\' 35444584a44Smrg_G_bs4='\\\\\\\\' 35544584a44Smrg_G_dollar='\$' 35644584a44Smrgsed_double_backslash="\ 35744584a44Smrg s/$_G_bs4/&\\ 35844584a44Smrg/g 35944584a44Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 36044584a44Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 36144584a44Smrg s/\n//g" 362b789ec8aSmrg 363c43cc173Smrg 36444584a44Smrg## ----------------- ## 36544584a44Smrg## Global variables. ## 36644584a44Smrg## ----------------- ## 367c27c18e8Smrg 36844584a44Smrg# Except for the global variables explicitly listed below, the following 36944584a44Smrg# functions in the '^func_' namespace, and the '^require_' namespace 37044584a44Smrg# variables initialised in the 'Resource management' section, sourcing 37144584a44Smrg# this file will not pollute your global namespace with anything 37244584a44Smrg# else. There's no portable way to scope variables in Bourne shell 37344584a44Smrg# though, so actually running these functions will sometimes place 37444584a44Smrg# results into a variable named after the function, and often use 37544584a44Smrg# temporary variables in the '^_G_' namespace. If you are careful to 37644584a44Smrg# avoid using those namespaces casually in your sourcing script, things 37744584a44Smrg# should continue to work as you expect. And, of course, you can freely 37844584a44Smrg# overwrite any of the functions or variables defined here before 37944584a44Smrg# calling anything to customize them. 38037eb1ca1Smrg 38144584a44SmrgEXIT_SUCCESS=0 38244584a44SmrgEXIT_FAILURE=1 38344584a44SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 38444584a44SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38537eb1ca1Smrg 38644584a44Smrg# Allow overriding, eg assuming that you follow the convention of 38744584a44Smrg# putting '$debug_cmd' at the start of all your functions, you can get 38844584a44Smrg# bash to show function call trace with: 38944584a44Smrg# 39044584a44Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 39144584a44Smrgdebug_cmd=${debug_cmd-":"} 39244584a44Smrgexit_cmd=: 39337eb1ca1Smrg 39444584a44Smrg# By convention, finish your script with: 39544584a44Smrg# 39644584a44Smrg# exit $exit_status 39744584a44Smrg# 39844584a44Smrg# so that you can set exit_status to non-zero if you want to indicate 39944584a44Smrg# something went wrong during execution without actually bailing out at 40044584a44Smrg# the point of failure. 40144584a44Smrgexit_status=$EXIT_SUCCESS 40237eb1ca1Smrg 40344584a44Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 40444584a44Smrg# is ksh but when the shell is invoked as "sh" and the current value of 40544584a44Smrg# the _XPG environment variable is not equal to 1 (one), the special 40644584a44Smrg# positional parameter $0, within a function call, is the name of the 40744584a44Smrg# function. 40844584a44Smrgprogpath=$0 409c27c18e8Smrg 41044584a44Smrg# The name of this program. 41144584a44Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412c27c18e8Smrg 41344584a44Smrg# Make sure we have an absolute progpath for reexecution: 414c27c18e8Smrgcase $progpath in 415c27c18e8Smrg [\\/]*|[A-Za-z]:\\*) ;; 416c27c18e8Smrg *[\\/]*) 41744584a44Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418c27c18e8Smrg progdir=`cd "$progdir" && pwd` 41944584a44Smrg progpath=$progdir/$progname 420c27c18e8Smrg ;; 421c27c18e8Smrg *) 42244584a44Smrg _G_IFS=$IFS 423f1ee322dSmrg IFS=${PATH_SEPARATOR-:} 424c27c18e8Smrg for progdir in $PATH; do 42544584a44Smrg IFS=$_G_IFS 426c27c18e8Smrg test -x "$progdir/$progname" && break 427c27c18e8Smrg done 42844584a44Smrg IFS=$_G_IFS 429c27c18e8Smrg test -n "$progdir" || progdir=`pwd` 43044584a44Smrg progpath=$progdir/$progname 431c27c18e8Smrg ;; 432c27c18e8Smrgesac 433c27c18e8Smrg 434c27c18e8Smrg 43544584a44Smrg## ----------------- ## 43644584a44Smrg## Standard options. ## 43744584a44Smrg## ----------------- ## 438b789ec8aSmrg 43944584a44Smrg# The following options affect the operation of the functions defined 44044584a44Smrg# below, and should be set appropriately depending on run-time para- 44144584a44Smrg# meters passed on the command line. 442c27c18e8Smrg 443c27c18e8Smrgopt_dry_run=false 444c27c18e8Smrgopt_quiet=false 445c27c18e8Smrgopt_verbose=false 446c27c18e8Smrg 44744584a44Smrg# Categories 'all' and 'none' are always available. Append any others 44844584a44Smrg# you will pass as the first argument to func_warning from your own 44944584a44Smrg# code. 45044584a44Smrgwarning_categories= 451c27c18e8Smrg 45244584a44Smrg# By default, display warnings according to 'opt_warning_types'. Set 45344584a44Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 45444584a44Smrg# treat the next displayed warning as a fatal error. 45544584a44Smrgwarning_func=func_warn_and_continue 456c27c18e8Smrg 45744584a44Smrg# Set to 'all' to display all warnings, 'none' to suppress all 45844584a44Smrg# warnings, or a space delimited list of some subset of 45944584a44Smrg# 'warning_categories' to display only the listed warnings. 46044584a44Smrgopt_warning_types=all 461c27c18e8Smrg 46237eb1ca1Smrg 46344584a44Smrg## -------------------- ## 46444584a44Smrg## Resource management. ## 46544584a44Smrg## -------------------- ## 466c27c18e8Smrg 46744584a44Smrg# This section contains definitions for functions that each ensure a 46844584a44Smrg# particular resource (a file, or a non-empty configuration variable for 46944584a44Smrg# example) is available, and if appropriate to extract default values 47044584a44Smrg# from pertinent package files. Call them using their associated 47144584a44Smrg# 'require_*' variable to ensure that they are executed, at most, once. 47244584a44Smrg# 47344584a44Smrg# It's entirely deliberate that calling these functions can set 47444584a44Smrg# variables that don't obey the namespace limitations obeyed by the rest 47544584a44Smrg# of this file, in order that that they be as useful as possible to 47644584a44Smrg# callers. 477c27c18e8Smrg 478c27c18e8Smrg 47944584a44Smrg# require_term_colors 48044584a44Smrg# ------------------- 48144584a44Smrg# Allow display of bold text on terminals that support it. 48244584a44Smrgrequire_term_colors=func_require_term_colors 48344584a44Smrgfunc_require_term_colors () 484c27c18e8Smrg{ 48544584a44Smrg $debug_cmd 48644584a44Smrg 48744584a44Smrg test -t 1 && { 48844584a44Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 48944584a44Smrg # precedence, because most terminfo databases neglect to describe 49044584a44Smrg # whether color sequences are supported. 49144584a44Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 49244584a44Smrg 49344584a44Smrg if test 1 = "$USE_ANSI_COLORS"; then 49444584a44Smrg # Standard ANSI escape sequences 49544584a44Smrg tc_reset='[0m' 49644584a44Smrg tc_bold='[1m'; tc_standout='[7m' 49744584a44Smrg tc_red='[31m'; tc_green='[32m' 49844584a44Smrg tc_blue='[34m'; tc_cyan='[36m' 49944584a44Smrg else 50044584a44Smrg # Otherwise trust the terminfo database after all. 50144584a44Smrg test -n "`tput sgr0 2>/dev/null`" && { 50244584a44Smrg tc_reset=`tput sgr0` 50344584a44Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 50444584a44Smrg tc_standout=$tc_bold 50544584a44Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 50644584a44Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 50744584a44Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 50844584a44Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 50944584a44Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 51044584a44Smrg } 51144584a44Smrg fi 51244584a44Smrg } 513c27c18e8Smrg 51444584a44Smrg require_term_colors=: 515c27c18e8Smrg} 516c27c18e8Smrg 517c27c18e8Smrg 51844584a44Smrg## ----------------- ## 51944584a44Smrg## Function library. ## 52044584a44Smrg## ----------------- ## 52144584a44Smrg 52244584a44Smrg# This section contains a variety of useful functions to call in your 52344584a44Smrg# scripts. Take note of the portable wrappers for features provided by 52444584a44Smrg# some modern shells, which will fall back to slower equivalents on 52544584a44Smrg# less featureful shells. 52644584a44Smrg 52744584a44Smrg 52844584a44Smrg# func_append VAR VALUE 52944584a44Smrg# --------------------- 53044584a44Smrg# Append VALUE onto the existing contents of VAR. 53144584a44Smrg 53244584a44Smrg # We should try to minimise forks, especially on Windows where they are 53344584a44Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 53444584a44Smrg # being used: 53544584a44Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 53644584a44Smrg : ${_G_HAVE_ARITH_OP="yes"} 53744584a44Smrg : ${_G_HAVE_XSI_OPS="yes"} 53844584a44Smrg # The += operator was introduced in bash 3.1 53944584a44Smrg case $BASH_VERSION in 54044584a44Smrg [12].* | 3.0 | 3.0*) ;; 54144584a44Smrg *) 54244584a44Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 54344584a44Smrg ;; 54444584a44Smrg esac 54544584a44Smrg fi 54644584a44Smrg 54744584a44Smrg # _G_HAVE_PLUSEQ_OP 54844584a44Smrg # Can be empty, in which case the shell is probed, "yes" if += is 54944584a44Smrg # useable or anything else if it does not work. 55044584a44Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 55144584a44Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 55244584a44Smrg && _G_HAVE_PLUSEQ_OP=yes 55344584a44Smrg 55444584a44Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 55544584a44Smrgthen 55644584a44Smrg # This is an XSI compatible shell, allowing a faster implementation... 55744584a44Smrg eval 'func_append () 55844584a44Smrg { 55944584a44Smrg $debug_cmd 56044584a44Smrg 56144584a44Smrg eval "$1+=\$2" 56244584a44Smrg }' 56344584a44Smrgelse 56444584a44Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 56544584a44Smrg func_append () 56644584a44Smrg { 56744584a44Smrg $debug_cmd 56844584a44Smrg 56944584a44Smrg eval "$1=\$$1\$2" 57044584a44Smrg } 57144584a44Smrgfi 57244584a44Smrg 57344584a44Smrg 57444584a44Smrg# func_append_quoted VAR VALUE 57544584a44Smrg# ---------------------------- 57644584a44Smrg# Quote VALUE and append to the end of shell variable VAR, separated 57744584a44Smrg# by a space. 57844584a44Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 57944584a44Smrg eval 'func_append_quoted () 58044584a44Smrg { 58144584a44Smrg $debug_cmd 58244584a44Smrg 58344584a44Smrg func_quote_for_eval "$2" 58444584a44Smrg eval "$1+=\\ \$func_quote_for_eval_result" 58544584a44Smrg }' 58644584a44Smrgelse 58744584a44Smrg func_append_quoted () 58844584a44Smrg { 58944584a44Smrg $debug_cmd 59044584a44Smrg 59144584a44Smrg func_quote_for_eval "$2" 59244584a44Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 59344584a44Smrg } 59444584a44Smrgfi 59544584a44Smrg 59644584a44Smrg 59744584a44Smrg# func_append_uniq VAR VALUE 59844584a44Smrg# -------------------------- 59944584a44Smrg# Append unique VALUE onto the existing contents of VAR, assuming 60044584a44Smrg# entries are delimited by the first character of VALUE. For example: 60144584a44Smrg# 60244584a44Smrg# func_append_uniq options " --another-option option-argument" 60344584a44Smrg# 60444584a44Smrg# will only append to $options if " --another-option option-argument " 60544584a44Smrg# is not already present somewhere in $options already (note spaces at 60644584a44Smrg# each end implied by leading space in second argument). 60744584a44Smrgfunc_append_uniq () 60844584a44Smrg{ 60944584a44Smrg $debug_cmd 61044584a44Smrg 61144584a44Smrg eval _G_current_value='`$ECHO $'$1'`' 61244584a44Smrg _G_delim=`expr "$2" : '\(.\)'` 61344584a44Smrg 61444584a44Smrg case $_G_delim$_G_current_value$_G_delim in 61544584a44Smrg *"$2$_G_delim"*) ;; 61644584a44Smrg *) func_append "$@" ;; 61744584a44Smrg esac 61844584a44Smrg} 61944584a44Smrg 62044584a44Smrg 62144584a44Smrg# func_arith TERM... 62244584a44Smrg# ------------------ 62344584a44Smrg# Set func_arith_result to the result of evaluating TERMs. 62444584a44Smrg test -z "$_G_HAVE_ARITH_OP" \ 62544584a44Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 62644584a44Smrg && _G_HAVE_ARITH_OP=yes 62744584a44Smrg 62844584a44Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 62944584a44Smrg eval 'func_arith () 63044584a44Smrg { 63144584a44Smrg $debug_cmd 63244584a44Smrg 63344584a44Smrg func_arith_result=$(( $* )) 63444584a44Smrg }' 63544584a44Smrgelse 63644584a44Smrg func_arith () 63744584a44Smrg { 63844584a44Smrg $debug_cmd 63944584a44Smrg 64044584a44Smrg func_arith_result=`expr "$@"` 64144584a44Smrg } 64244584a44Smrgfi 64344584a44Smrg 64444584a44Smrg 64544584a44Smrg# func_basename FILE 64644584a44Smrg# ------------------ 64744584a44Smrg# Set func_basename_result to FILE with everything up to and including 64844584a44Smrg# the last / stripped. 64944584a44Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 65044584a44Smrg # If this shell supports suffix pattern removal, then use it to avoid 65144584a44Smrg # forking. Hide the definitions single quotes in case the shell chokes 65244584a44Smrg # on unsupported syntax... 65344584a44Smrg _b='func_basename_result=${1##*/}' 65444584a44Smrg _d='case $1 in 65544584a44Smrg */*) func_dirname_result=${1%/*}$2 ;; 65644584a44Smrg * ) func_dirname_result=$3 ;; 65744584a44Smrg esac' 65844584a44Smrg 65944584a44Smrgelse 66044584a44Smrg # ...otherwise fall back to using sed. 66144584a44Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 66244584a44Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 66344584a44Smrg if test "X$func_dirname_result" = "X$1"; then 66444584a44Smrg func_dirname_result=$3 66544584a44Smrg else 66644584a44Smrg func_append func_dirname_result "$2" 66744584a44Smrg fi' 66844584a44Smrgfi 66944584a44Smrg 67044584a44Smrgeval 'func_basename () 67144584a44Smrg{ 67244584a44Smrg $debug_cmd 67344584a44Smrg 67444584a44Smrg '"$_b"' 67544584a44Smrg}' 67644584a44Smrg 67744584a44Smrg 67844584a44Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 67944584a44Smrg# ------------------------------------------- 68044584a44Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 68144584a44Smrg# otherwise set result to NONDIR_REPLACEMENT. 68244584a44Smrgeval 'func_dirname () 68344584a44Smrg{ 68444584a44Smrg $debug_cmd 68544584a44Smrg 68644584a44Smrg '"$_d"' 68744584a44Smrg}' 68844584a44Smrg 68944584a44Smrg 69044584a44Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 69144584a44Smrg# -------------------------------------------------------- 69244584a44Smrg# Perform func_basename and func_dirname in a single function 69344584a44Smrg# call: 69444584a44Smrg# dirname: Compute the dirname of FILE. If nonempty, 69544584a44Smrg# add APPEND to the result, otherwise set result 69644584a44Smrg# to NONDIR_REPLACEMENT. 69744584a44Smrg# value returned in "$func_dirname_result" 69844584a44Smrg# basename: Compute filename of FILE. 69944584a44Smrg# value retuned in "$func_basename_result" 70044584a44Smrg# For efficiency, we do not delegate to the functions above but instead 70144584a44Smrg# duplicate the functionality here. 70244584a44Smrgeval 'func_dirname_and_basename () 70344584a44Smrg{ 70444584a44Smrg $debug_cmd 70544584a44Smrg 70644584a44Smrg '"$_b"' 70744584a44Smrg '"$_d"' 70844584a44Smrg}' 70944584a44Smrg 71044584a44Smrg 71144584a44Smrg# func_echo ARG... 71244584a44Smrg# ---------------- 71344584a44Smrg# Echo program name prefixed message. 71444584a44Smrgfunc_echo () 71544584a44Smrg{ 71644584a44Smrg $debug_cmd 71744584a44Smrg 71844584a44Smrg _G_message=$* 71944584a44Smrg 72044584a44Smrg func_echo_IFS=$IFS 72144584a44Smrg IFS=$nl 72244584a44Smrg for _G_line in $_G_message; do 72344584a44Smrg IFS=$func_echo_IFS 72444584a44Smrg $ECHO "$progname: $_G_line" 72544584a44Smrg done 72644584a44Smrg IFS=$func_echo_IFS 72744584a44Smrg} 72844584a44Smrg 72944584a44Smrg 73044584a44Smrg# func_echo_all ARG... 73144584a44Smrg# -------------------- 73244584a44Smrg# Invoke $ECHO with all args, space-separated. 73344584a44Smrgfunc_echo_all () 73444584a44Smrg{ 73544584a44Smrg $ECHO "$*" 73644584a44Smrg} 73744584a44Smrg 73844584a44Smrg 73944584a44Smrg# func_echo_infix_1 INFIX ARG... 74044584a44Smrg# ------------------------------ 74144584a44Smrg# Echo program name, followed by INFIX on the first line, with any 74244584a44Smrg# additional lines not showing INFIX. 74344584a44Smrgfunc_echo_infix_1 () 74444584a44Smrg{ 74544584a44Smrg $debug_cmd 74644584a44Smrg 74744584a44Smrg $require_term_colors 74844584a44Smrg 74944584a44Smrg _G_infix=$1; shift 75044584a44Smrg _G_indent=$_G_infix 75144584a44Smrg _G_prefix="$progname: $_G_infix: " 75244584a44Smrg _G_message=$* 75344584a44Smrg 75444584a44Smrg # Strip color escape sequences before counting printable length 75544584a44Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 75644584a44Smrg do 75744584a44Smrg test -n "$_G_tc" && { 75844584a44Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 75944584a44Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 76044584a44Smrg } 76144584a44Smrg done 76244584a44Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 76344584a44Smrg 76444584a44Smrg func_echo_infix_1_IFS=$IFS 76544584a44Smrg IFS=$nl 76644584a44Smrg for _G_line in $_G_message; do 76744584a44Smrg IFS=$func_echo_infix_1_IFS 76844584a44Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 76944584a44Smrg _G_prefix=$_G_indent 77044584a44Smrg done 77144584a44Smrg IFS=$func_echo_infix_1_IFS 77244584a44Smrg} 77344584a44Smrg 77444584a44Smrg 77544584a44Smrg# func_error ARG... 77644584a44Smrg# ----------------- 77744584a44Smrg# Echo program name prefixed message to standard error. 77844584a44Smrgfunc_error () 77944584a44Smrg{ 78044584a44Smrg $debug_cmd 78144584a44Smrg 78244584a44Smrg $require_term_colors 78344584a44Smrg 78444584a44Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 78544584a44Smrg} 78644584a44Smrg 78744584a44Smrg 78844584a44Smrg# func_fatal_error ARG... 78944584a44Smrg# ----------------------- 79044584a44Smrg# Echo program name prefixed message to standard error, and exit. 79144584a44Smrgfunc_fatal_error () 79244584a44Smrg{ 79344584a44Smrg $debug_cmd 79444584a44Smrg 79544584a44Smrg func_error "$*" 79644584a44Smrg exit $EXIT_FAILURE 79744584a44Smrg} 79844584a44Smrg 79944584a44Smrg 80044584a44Smrg# func_grep EXPRESSION FILENAME 80144584a44Smrg# ----------------------------- 802c27c18e8Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803c27c18e8Smrgfunc_grep () 804c27c18e8Smrg{ 80544584a44Smrg $debug_cmd 80644584a44Smrg 807c27c18e8Smrg $GREP "$1" "$2" >/dev/null 2>&1 808c27c18e8Smrg} 809c27c18e8Smrg 810c27c18e8Smrg 81144584a44Smrg# func_len STRING 81244584a44Smrg# --------------- 81344584a44Smrg# Set func_len_result to the length of STRING. STRING may not 81444584a44Smrg# start with a hyphen. 81544584a44Smrg test -z "$_G_HAVE_XSI_OPS" \ 81644584a44Smrg && (eval 'x=a/b/c; 81744584a44Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 81844584a44Smrg && _G_HAVE_XSI_OPS=yes 81944584a44Smrg 82044584a44Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 82144584a44Smrg eval 'func_len () 82244584a44Smrg { 82344584a44Smrg $debug_cmd 82444584a44Smrg 82544584a44Smrg func_len_result=${#1} 82644584a44Smrg }' 82744584a44Smrgelse 82844584a44Smrg func_len () 82944584a44Smrg { 83044584a44Smrg $debug_cmd 83144584a44Smrg 83244584a44Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 83344584a44Smrg } 83444584a44Smrgfi 83544584a44Smrg 83644584a44Smrg 83744584a44Smrg# func_mkdir_p DIRECTORY-PATH 83844584a44Smrg# --------------------------- 839c27c18e8Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840c27c18e8Smrgfunc_mkdir_p () 841c27c18e8Smrg{ 84244584a44Smrg $debug_cmd 843c27c18e8Smrg 84444584a44Smrg _G_directory_path=$1 84544584a44Smrg _G_dir_list= 846c27c18e8Smrg 84744584a44Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84844584a44Smrg 84944584a44Smrg # Protect directory names starting with '-' 85044584a44Smrg case $_G_directory_path in 85144584a44Smrg -*) _G_directory_path=./$_G_directory_path ;; 852c27c18e8Smrg esac 853c27c18e8Smrg 854c27c18e8Smrg # While some portion of DIR does not yet exist... 85544584a44Smrg while test ! -d "$_G_directory_path"; do 856c27c18e8Smrg # ...make a list in topmost first order. Use a colon delimited 857c27c18e8Smrg # list incase some portion of path contains whitespace. 85844584a44Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 859c27c18e8Smrg 860c27c18e8Smrg # If the last portion added has no slash in it, the list is done 86144584a44Smrg case $_G_directory_path in */*) ;; *) break ;; esac 862c27c18e8Smrg 863c27c18e8Smrg # ...otherwise throw away the child directory and loop 86444584a44Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865c27c18e8Smrg done 86644584a44Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867c27c18e8Smrg 86844584a44Smrg func_mkdir_p_IFS=$IFS; IFS=: 86944584a44Smrg for _G_dir in $_G_dir_list; do 87044584a44Smrg IFS=$func_mkdir_p_IFS 87144584a44Smrg # mkdir can fail with a 'File exist' error if two processes 872c27c18e8Smrg # try to create one of the directories concurrently. Don't 873c27c18e8Smrg # stop in that case! 87444584a44Smrg $MKDIR "$_G_dir" 2>/dev/null || : 875c27c18e8Smrg done 87644584a44Smrg IFS=$func_mkdir_p_IFS 877c27c18e8Smrg 878c27c18e8Smrg # Bail out if we (or some other process) failed to create a directory. 87944584a44Smrg test -d "$_G_directory_path" || \ 88044584a44Smrg func_fatal_error "Failed to create '$1'" 881c27c18e8Smrg fi 882c27c18e8Smrg} 883c43cc173Smrg 884c43cc173Smrg 88544584a44Smrg# func_mktempdir [BASENAME] 88644584a44Smrg# ------------------------- 887c43cc173Smrg# Make a temporary directory that won't clash with other running 888c43cc173Smrg# libtool processes, and avoids race conditions if possible. If 88944584a44Smrg# given, BASENAME is the basename for that directory. 890c43cc173Smrgfunc_mktempdir () 891c43cc173Smrg{ 89244584a44Smrg $debug_cmd 89344584a44Smrg 89444584a44Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895c43cc173Smrg 89644584a44Smrg if test : = "$opt_dry_run"; then 897c43cc173Smrg # Return a directory name, but don't create it in dry-run mode 89844584a44Smrg _G_tmpdir=$_G_template-$$ 899c43cc173Smrg else 900c43cc173Smrg 901c43cc173Smrg # If mktemp works, use that first and foremost 90244584a44Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903c43cc173Smrg 90444584a44Smrg if test ! -d "$_G_tmpdir"; then 905c27c18e8Smrg # Failing that, at least try and use $RANDOM to avoid a race 90644584a44Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907c43cc173Smrg 90844584a44Smrg func_mktempdir_umask=`umask` 909c27c18e8Smrg umask 0077 91044584a44Smrg $MKDIR "$_G_tmpdir" 91144584a44Smrg umask $func_mktempdir_umask 912c43cc173Smrg fi 913c43cc173Smrg 914c43cc173Smrg # If we're not in dry-run mode, bomb out on failure 91544584a44Smrg test -d "$_G_tmpdir" || \ 91644584a44Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 91744584a44Smrg fi 91844584a44Smrg 91944584a44Smrg $ECHO "$_G_tmpdir" 92044584a44Smrg} 92144584a44Smrg 92244584a44Smrg 92344584a44Smrg# func_normal_abspath PATH 92444584a44Smrg# ------------------------ 92544584a44Smrg# Remove doubled-up and trailing slashes, "." path components, 92644584a44Smrg# and cancel out any ".." path components in PATH after making 92744584a44Smrg# it an absolute path. 92844584a44Smrgfunc_normal_abspath () 92944584a44Smrg{ 93044584a44Smrg $debug_cmd 93144584a44Smrg 93244584a44Smrg # These SED scripts presuppose an absolute path with a trailing slash. 93344584a44Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 93444584a44Smrg _G_pathcdr='s|^/[^/]*||' 93544584a44Smrg _G_removedotparts=':dotsl 93644584a44Smrg s|/\./|/|g 93744584a44Smrg t dotsl 93844584a44Smrg s|/\.$|/|' 93944584a44Smrg _G_collapseslashes='s|/\{1,\}|/|g' 94044584a44Smrg _G_finalslash='s|/*$|/|' 94144584a44Smrg 94244584a44Smrg # Start from root dir and reassemble the path. 94344584a44Smrg func_normal_abspath_result= 94444584a44Smrg func_normal_abspath_tpath=$1 94544584a44Smrg func_normal_abspath_altnamespace= 94644584a44Smrg case $func_normal_abspath_tpath in 94744584a44Smrg "") 94844584a44Smrg # Empty path, that just means $cwd. 94944584a44Smrg func_stripname '' '/' "`pwd`" 95044584a44Smrg func_normal_abspath_result=$func_stripname_result 95144584a44Smrg return 95244584a44Smrg ;; 95344584a44Smrg # The next three entries are used to spot a run of precisely 95444584a44Smrg # two leading slashes without using negated character classes; 95544584a44Smrg # we take advantage of case's first-match behaviour. 95644584a44Smrg ///*) 95744584a44Smrg # Unusual form of absolute path, do nothing. 95844584a44Smrg ;; 95944584a44Smrg //*) 96044584a44Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 96144584a44Smrg # and for example Cygwin uses it to access remote file shares 96244584a44Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 96344584a44Smrg func_normal_abspath_altnamespace=/ 96444584a44Smrg ;; 96544584a44Smrg /*) 96644584a44Smrg # Absolute path, do nothing. 96744584a44Smrg ;; 96844584a44Smrg *) 96944584a44Smrg # Relative path, prepend $cwd. 97044584a44Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 97144584a44Smrg ;; 97244584a44Smrg esac 97344584a44Smrg 97444584a44Smrg # Cancel out all the simple stuff to save iterations. We also want 97544584a44Smrg # the path to end with a slash for ease of parsing, so make sure 97644584a44Smrg # there is one (and only one) here. 97744584a44Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 97844584a44Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 97944584a44Smrg while :; do 98044584a44Smrg # Processed it all yet? 98144584a44Smrg if test / = "$func_normal_abspath_tpath"; then 98244584a44Smrg # If we ascended to the root using ".." the result may be empty now. 98344584a44Smrg if test -z "$func_normal_abspath_result"; then 98444584a44Smrg func_normal_abspath_result=/ 98544584a44Smrg fi 98644584a44Smrg break 98744584a44Smrg fi 98844584a44Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 98944584a44Smrg -e "$_G_pathcar"` 99044584a44Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 99144584a44Smrg -e "$_G_pathcdr"` 99244584a44Smrg # Figure out what to do with it 99344584a44Smrg case $func_normal_abspath_tcomponent in 99444584a44Smrg "") 99544584a44Smrg # Trailing empty path component, ignore it. 99644584a44Smrg ;; 99744584a44Smrg ..) 99844584a44Smrg # Parent dir; strip last assembled component from result. 99944584a44Smrg func_dirname "$func_normal_abspath_result" 100044584a44Smrg func_normal_abspath_result=$func_dirname_result 100144584a44Smrg ;; 100244584a44Smrg *) 100344584a44Smrg # Actual path component, append it. 100444584a44Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 100544584a44Smrg ;; 100644584a44Smrg esac 100744584a44Smrg done 100844584a44Smrg # Restore leading double-slash if one was found on entry. 100944584a44Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 101044584a44Smrg} 101144584a44Smrg 101244584a44Smrg 101344584a44Smrg# func_notquiet ARG... 101444584a44Smrg# -------------------- 101544584a44Smrg# Echo program name prefixed message only when not in quiet mode. 101644584a44Smrgfunc_notquiet () 101744584a44Smrg{ 101844584a44Smrg $debug_cmd 101944584a44Smrg 102044584a44Smrg $opt_quiet || func_echo ${1+"$@"} 102144584a44Smrg 102244584a44Smrg # A bug in bash halts the script if the last line of a function 102344584a44Smrg # fails when set -e is in force, so we need another command to 102444584a44Smrg # work around that: 102544584a44Smrg : 102644584a44Smrg} 102744584a44Smrg 102844584a44Smrg 102944584a44Smrg# func_relative_path SRCDIR DSTDIR 103044584a44Smrg# -------------------------------- 103144584a44Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 103244584a44Smrgfunc_relative_path () 103344584a44Smrg{ 103444584a44Smrg $debug_cmd 103544584a44Smrg 103644584a44Smrg func_relative_path_result= 103744584a44Smrg func_normal_abspath "$1" 103844584a44Smrg func_relative_path_tlibdir=$func_normal_abspath_result 103944584a44Smrg func_normal_abspath "$2" 104044584a44Smrg func_relative_path_tbindir=$func_normal_abspath_result 104144584a44Smrg 104244584a44Smrg # Ascend the tree starting from libdir 104344584a44Smrg while :; do 104444584a44Smrg # check if we have found a prefix of bindir 104544584a44Smrg case $func_relative_path_tbindir in 104644584a44Smrg $func_relative_path_tlibdir) 104744584a44Smrg # found an exact match 104844584a44Smrg func_relative_path_tcancelled= 104944584a44Smrg break 105044584a44Smrg ;; 105144584a44Smrg $func_relative_path_tlibdir*) 105244584a44Smrg # found a matching prefix 105344584a44Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 105444584a44Smrg func_relative_path_tcancelled=$func_stripname_result 105544584a44Smrg if test -z "$func_relative_path_result"; then 105644584a44Smrg func_relative_path_result=. 105744584a44Smrg fi 105844584a44Smrg break 105944584a44Smrg ;; 106044584a44Smrg *) 106144584a44Smrg func_dirname $func_relative_path_tlibdir 106244584a44Smrg func_relative_path_tlibdir=$func_dirname_result 106344584a44Smrg if test -z "$func_relative_path_tlibdir"; then 106444584a44Smrg # Have to descend all the way to the root! 106544584a44Smrg func_relative_path_result=../$func_relative_path_result 106644584a44Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 106744584a44Smrg break 106844584a44Smrg fi 106944584a44Smrg func_relative_path_result=../$func_relative_path_result 107044584a44Smrg ;; 107144584a44Smrg esac 107244584a44Smrg done 107344584a44Smrg 107444584a44Smrg # Now calculate path; take care to avoid doubling-up slashes. 107544584a44Smrg func_stripname '' '/' "$func_relative_path_result" 107644584a44Smrg func_relative_path_result=$func_stripname_result 107744584a44Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 107844584a44Smrg if test -n "$func_stripname_result"; then 107944584a44Smrg func_append func_relative_path_result "/$func_stripname_result" 108044584a44Smrg fi 108144584a44Smrg 108244584a44Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 108344584a44Smrg if test -n "$func_relative_path_result"; then 108444584a44Smrg func_stripname './' '' "$func_relative_path_result" 108544584a44Smrg func_relative_path_result=$func_stripname_result 1086c43cc173Smrg fi 1087c43cc173Smrg 108844584a44Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 108944584a44Smrg 109044584a44Smrg : 109144584a44Smrg} 109244584a44Smrg 109344584a44Smrg 109444584a44Smrg# func_quote_for_eval ARG... 109544584a44Smrg# -------------------------- 109644584a44Smrg# Aesthetically quote ARGs to be evaled later. 109744584a44Smrg# This function returns two values: 109844584a44Smrg# i) func_quote_for_eval_result 109944584a44Smrg# double-quoted, suitable for a subsequent eval 110044584a44Smrg# ii) func_quote_for_eval_unquoted_result 110144584a44Smrg# has all characters that are still active within double 110244584a44Smrg# quotes backslashified. 110344584a44Smrgfunc_quote_for_eval () 110444584a44Smrg{ 110544584a44Smrg $debug_cmd 110644584a44Smrg 110744584a44Smrg func_quote_for_eval_unquoted_result= 110844584a44Smrg func_quote_for_eval_result= 110944584a44Smrg while test 0 -lt $#; do 111044584a44Smrg case $1 in 111144584a44Smrg *[\\\`\"\$]*) 111244584a44Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 111344584a44Smrg *) 111444584a44Smrg _G_unquoted_arg=$1 ;; 111544584a44Smrg esac 111644584a44Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 111744584a44Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 111844584a44Smrg else 111944584a44Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 112044584a44Smrg fi 112144584a44Smrg 112244584a44Smrg case $_G_unquoted_arg in 112344584a44Smrg # Double-quote args containing shell metacharacters to delay 112444584a44Smrg # word splitting, command substitution and variable expansion 112544584a44Smrg # for a subsequent eval. 112644584a44Smrg # Many Bourne shells cannot handle close brackets correctly 112744584a44Smrg # in scan sets, so we specify it separately. 112844584a44Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 112944584a44Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 113044584a44Smrg ;; 113144584a44Smrg *) 113244584a44Smrg _G_quoted_arg=$_G_unquoted_arg 113344584a44Smrg ;; 113444584a44Smrg esac 113544584a44Smrg 113644584a44Smrg if test -n "$func_quote_for_eval_result"; then 113744584a44Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 113844584a44Smrg else 113944584a44Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 114044584a44Smrg fi 114144584a44Smrg shift 114244584a44Smrg done 114344584a44Smrg} 114444584a44Smrg 114544584a44Smrg 114644584a44Smrg# func_quote_for_expand ARG 114744584a44Smrg# ------------------------- 114844584a44Smrg# Aesthetically quote ARG to be evaled later; same as above, 114944584a44Smrg# but do not quote variable references. 115044584a44Smrgfunc_quote_for_expand () 115144584a44Smrg{ 115244584a44Smrg $debug_cmd 115344584a44Smrg 115444584a44Smrg case $1 in 115544584a44Smrg *[\\\`\"]*) 115644584a44Smrg _G_arg=`$ECHO "$1" | $SED \ 115744584a44Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115844584a44Smrg *) 115944584a44Smrg _G_arg=$1 ;; 116044584a44Smrg esac 116144584a44Smrg 116244584a44Smrg case $_G_arg in 116344584a44Smrg # Double-quote args containing shell metacharacters to delay 116444584a44Smrg # word splitting and command substitution for a subsequent eval. 116544584a44Smrg # Many Bourne shells cannot handle close brackets correctly 116644584a44Smrg # in scan sets, so we specify it separately. 116744584a44Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 116844584a44Smrg _G_arg=\"$_G_arg\" 116944584a44Smrg ;; 117044584a44Smrg esac 117144584a44Smrg 117244584a44Smrg func_quote_for_expand_result=$_G_arg 117344584a44Smrg} 117444584a44Smrg 117544584a44Smrg 117644584a44Smrg# func_stripname PREFIX SUFFIX NAME 117744584a44Smrg# --------------------------------- 117844584a44Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 117944584a44Smrg# PREFIX and SUFFIX must not contain globbing or regex special 118044584a44Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 118144584a44Smrg# dot (in which case that matches only a dot). 118244584a44Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 118344584a44Smrg eval 'func_stripname () 118444584a44Smrg { 118544584a44Smrg $debug_cmd 118644584a44Smrg 118744584a44Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 118844584a44Smrg # positional parameters, so assign one to ordinary variable first. 118944584a44Smrg func_stripname_result=$3 119044584a44Smrg func_stripname_result=${func_stripname_result#"$1"} 119144584a44Smrg func_stripname_result=${func_stripname_result%"$2"} 119244584a44Smrg }' 119344584a44Smrgelse 119444584a44Smrg func_stripname () 119544584a44Smrg { 119644584a44Smrg $debug_cmd 119744584a44Smrg 119844584a44Smrg case $2 in 119944584a44Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 120044584a44Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 120144584a44Smrg esac 120244584a44Smrg } 120344584a44Smrgfi 120444584a44Smrg 120544584a44Smrg 120644584a44Smrg# func_show_eval CMD [FAIL_EXP] 120744584a44Smrg# ----------------------------- 120844584a44Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 120944584a44Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 121044584a44Smrg# is given, then evaluate it. 121144584a44Smrgfunc_show_eval () 121244584a44Smrg{ 121344584a44Smrg $debug_cmd 121444584a44Smrg 121544584a44Smrg _G_cmd=$1 121644584a44Smrg _G_fail_exp=${2-':'} 121744584a44Smrg 121844584a44Smrg func_quote_for_expand "$_G_cmd" 121944584a44Smrg eval "func_notquiet $func_quote_for_expand_result" 122044584a44Smrg 122144584a44Smrg $opt_dry_run || { 122244584a44Smrg eval "$_G_cmd" 122344584a44Smrg _G_status=$? 122444584a44Smrg if test 0 -ne "$_G_status"; then 122544584a44Smrg eval "(exit $_G_status); $_G_fail_exp" 122644584a44Smrg fi 122744584a44Smrg } 122844584a44Smrg} 122944584a44Smrg 123044584a44Smrg 123144584a44Smrg# func_show_eval_locale CMD [FAIL_EXP] 123244584a44Smrg# ------------------------------------ 123344584a44Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 123444584a44Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 123544584a44Smrg# is given, then evaluate it. Use the saved locale for evaluation. 123644584a44Smrgfunc_show_eval_locale () 123744584a44Smrg{ 123844584a44Smrg $debug_cmd 123944584a44Smrg 124044584a44Smrg _G_cmd=$1 124144584a44Smrg _G_fail_exp=${2-':'} 124244584a44Smrg 124344584a44Smrg $opt_quiet || { 124444584a44Smrg func_quote_for_expand "$_G_cmd" 124544584a44Smrg eval "func_echo $func_quote_for_expand_result" 124644584a44Smrg } 124744584a44Smrg 124844584a44Smrg $opt_dry_run || { 124944584a44Smrg eval "$_G_user_locale 125044584a44Smrg $_G_cmd" 125144584a44Smrg _G_status=$? 125244584a44Smrg eval "$_G_safe_locale" 125344584a44Smrg if test 0 -ne "$_G_status"; then 125444584a44Smrg eval "(exit $_G_status); $_G_fail_exp" 125544584a44Smrg fi 125644584a44Smrg } 125744584a44Smrg} 125844584a44Smrg 125944584a44Smrg 126044584a44Smrg# func_tr_sh 126144584a44Smrg# ---------- 126244584a44Smrg# Turn $1 into a string suitable for a shell variable name. 126344584a44Smrg# Result is stored in $func_tr_sh_result. All characters 126444584a44Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 126544584a44Smrg# if $1 begins with a digit, a '_' is prepended as well. 126644584a44Smrgfunc_tr_sh () 126744584a44Smrg{ 126844584a44Smrg $debug_cmd 126944584a44Smrg 127044584a44Smrg case $1 in 127144584a44Smrg [0-9]* | *[!a-zA-Z0-9_]*) 127244584a44Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 127344584a44Smrg ;; 127444584a44Smrg * ) 127544584a44Smrg func_tr_sh_result=$1 127644584a44Smrg ;; 127744584a44Smrg esac 127844584a44Smrg} 127944584a44Smrg 128044584a44Smrg 128144584a44Smrg# func_verbose ARG... 128244584a44Smrg# ------------------- 128344584a44Smrg# Echo program name prefixed message in verbose mode only. 128444584a44Smrgfunc_verbose () 128544584a44Smrg{ 128644584a44Smrg $debug_cmd 128744584a44Smrg 128844584a44Smrg $opt_verbose && func_echo "$*" 128944584a44Smrg 129044584a44Smrg : 129144584a44Smrg} 129244584a44Smrg 129344584a44Smrg 129444584a44Smrg# func_warn_and_continue ARG... 129544584a44Smrg# ----------------------------- 129644584a44Smrg# Echo program name prefixed warning message to standard error. 129744584a44Smrgfunc_warn_and_continue () 129844584a44Smrg{ 129944584a44Smrg $debug_cmd 130044584a44Smrg 130144584a44Smrg $require_term_colors 130244584a44Smrg 130344584a44Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 130444584a44Smrg} 130544584a44Smrg 130644584a44Smrg 130744584a44Smrg# func_warning CATEGORY ARG... 130844584a44Smrg# ---------------------------- 130944584a44Smrg# Echo program name prefixed warning message to standard error. Warning 131044584a44Smrg# messages can be filtered according to CATEGORY, where this function 131144584a44Smrg# elides messages where CATEGORY is not listed in the global variable 131244584a44Smrg# 'opt_warning_types'. 131344584a44Smrgfunc_warning () 131444584a44Smrg{ 131544584a44Smrg $debug_cmd 131644584a44Smrg 131744584a44Smrg # CATEGORY must be in the warning_categories list! 131844584a44Smrg case " $warning_categories " in 131944584a44Smrg *" $1 "*) ;; 132044584a44Smrg *) func_internal_error "invalid warning category '$1'" ;; 132144584a44Smrg esac 132244584a44Smrg 132344584a44Smrg _G_category=$1 132444584a44Smrg shift 132544584a44Smrg 132644584a44Smrg case " $opt_warning_types " in 132744584a44Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 132844584a44Smrg esac 132944584a44Smrg} 133044584a44Smrg 133144584a44Smrg 133244584a44Smrg# func_sort_ver VER1 VER2 133344584a44Smrg# ----------------------- 133444584a44Smrg# 'sort -V' is not generally available. 133544584a44Smrg# Note this deviates from the version comparison in automake 133644584a44Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 133744584a44Smrg# but this should suffice as we won't be specifying old 133844584a44Smrg# version formats or redundant trailing .0 in bootstrap.conf. 133944584a44Smrg# If we did want full compatibility then we should probably 134044584a44Smrg# use m4_version_compare from autoconf. 134144584a44Smrgfunc_sort_ver () 134244584a44Smrg{ 134344584a44Smrg $debug_cmd 134444584a44Smrg 134544584a44Smrg printf '%s\n%s\n' "$1" "$2" \ 134644584a44Smrg | 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 134744584a44Smrg} 134844584a44Smrg 134944584a44Smrg# func_lt_ver PREV CURR 135044584a44Smrg# --------------------- 135144584a44Smrg# Return true if PREV and CURR are in the correct order according to 135244584a44Smrg# func_sort_ver, otherwise false. Use it like this: 135344584a44Smrg# 135444584a44Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 135544584a44Smrgfunc_lt_ver () 135644584a44Smrg{ 135744584a44Smrg $debug_cmd 135844584a44Smrg 135944584a44Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 136044584a44Smrg} 136144584a44Smrg 136244584a44Smrg 136344584a44Smrg# Local variables: 136444584a44Smrg# mode: shell-script 136544584a44Smrg# sh-indentation: 2 136644584a44Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 136744584a44Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 136844584a44Smrg# time-stamp-time-zone: "UTC" 136944584a44Smrg# End: 137044584a44Smrg#! /bin/sh 137144584a44Smrg 137244584a44Smrg# Set a version string for this script. 137344584a44Smrgscriptversion=2014-01-07.03; # UTC 137444584a44Smrg 137544584a44Smrg# A portable, pluggable option parser for Bourne shell. 137644584a44Smrg# Written by Gary V. Vaughan, 2010 137744584a44Smrg 137844584a44Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 137944584a44Smrg# This is free software; see the source for copying conditions. There is NO 138044584a44Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 138144584a44Smrg 138244584a44Smrg# This program is free software: you can redistribute it and/or modify 138344584a44Smrg# it under the terms of the GNU General Public License as published by 138444584a44Smrg# the Free Software Foundation, either version 3 of the License, or 138544584a44Smrg# (at your option) any later version. 138644584a44Smrg 138744584a44Smrg# This program is distributed in the hope that it will be useful, 138844584a44Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 138944584a44Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 139044584a44Smrg# GNU General Public License for more details. 139144584a44Smrg 139244584a44Smrg# You should have received a copy of the GNU General Public License 139344584a44Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 139444584a44Smrg 139544584a44Smrg# Please report bugs or propose patches to gary@gnu.org. 139644584a44Smrg 139744584a44Smrg 139844584a44Smrg## ------ ## 139944584a44Smrg## Usage. ## 140044584a44Smrg## ------ ## 140144584a44Smrg 140244584a44Smrg# This file is a library for parsing options in your shell scripts along 140344584a44Smrg# with assorted other useful supporting features that you can make use 140444584a44Smrg# of too. 140544584a44Smrg# 140644584a44Smrg# For the simplest scripts you might need only: 140744584a44Smrg# 140844584a44Smrg# #!/bin/sh 140944584a44Smrg# . relative/path/to/funclib.sh 141044584a44Smrg# . relative/path/to/options-parser 141144584a44Smrg# scriptversion=1.0 141244584a44Smrg# func_options ${1+"$@"} 141344584a44Smrg# eval set dummy "$func_options_result"; shift 141444584a44Smrg# ...rest of your script... 141544584a44Smrg# 141644584a44Smrg# In order for the '--version' option to work, you will need to have a 141744584a44Smrg# suitably formatted comment like the one at the top of this file 141844584a44Smrg# starting with '# Written by ' and ending with '# warranty; '. 141944584a44Smrg# 142044584a44Smrg# For '-h' and '--help' to work, you will also need a one line 142144584a44Smrg# description of your script's purpose in a comment directly above the 142244584a44Smrg# '# Written by ' line, like the one at the top of this file. 142344584a44Smrg# 142444584a44Smrg# The default options also support '--debug', which will turn on shell 142544584a44Smrg# execution tracing (see the comment above debug_cmd below for another 142644584a44Smrg# use), and '--verbose' and the func_verbose function to allow your script 142744584a44Smrg# to display verbose messages only when your user has specified 142844584a44Smrg# '--verbose'. 142944584a44Smrg# 143044584a44Smrg# After sourcing this file, you can plug processing for additional 143144584a44Smrg# options by amending the variables from the 'Configuration' section 143244584a44Smrg# below, and following the instructions in the 'Option parsing' 143344584a44Smrg# section further down. 143444584a44Smrg 143544584a44Smrg## -------------- ## 143644584a44Smrg## Configuration. ## 143744584a44Smrg## -------------- ## 143844584a44Smrg 143944584a44Smrg# You should override these variables in your script after sourcing this 144044584a44Smrg# file so that they reflect the customisations you have added to the 144144584a44Smrg# option parser. 144244584a44Smrg 144344584a44Smrg# The usage line for option parsing errors and the start of '-h' and 144444584a44Smrg# '--help' output messages. You can embed shell variables for delayed 144544584a44Smrg# expansion at the time the message is displayed, but you will need to 144644584a44Smrg# quote other shell meta-characters carefully to prevent them being 144744584a44Smrg# expanded when the contents are evaled. 144844584a44Smrgusage='$progpath [OPTION]...' 144944584a44Smrg 145044584a44Smrg# Short help message in response to '-h' and '--help'. Add to this or 145144584a44Smrg# override it after sourcing this library to reflect the full set of 145244584a44Smrg# options your script accepts. 145344584a44Smrgusage_message="\ 145444584a44Smrg --debug enable verbose shell tracing 145544584a44Smrg -W, --warnings=CATEGORY 145644584a44Smrg report the warnings falling in CATEGORY [all] 145744584a44Smrg -v, --verbose verbosely report processing 145844584a44Smrg --version print version information and exit 145944584a44Smrg -h, --help print short or long help message and exit 146044584a44Smrg" 146144584a44Smrg 146244584a44Smrg# Additional text appended to 'usage_message' in response to '--help'. 146344584a44Smrglong_help_message=" 146444584a44SmrgWarning categories include: 146544584a44Smrg 'all' show all warnings 146644584a44Smrg 'none' turn off all the warnings 146744584a44Smrg 'error' warnings are treated as fatal errors" 146844584a44Smrg 146944584a44Smrg# Help message printed before fatal option parsing errors. 147044584a44Smrgfatal_help="Try '\$progname --help' for more information." 147144584a44Smrg 147244584a44Smrg 147344584a44Smrg 147444584a44Smrg## ------------------------- ## 147544584a44Smrg## Hook function management. ## 147644584a44Smrg## ------------------------- ## 147744584a44Smrg 147844584a44Smrg# This section contains functions for adding, removing, and running hooks 147944584a44Smrg# to the main code. A hook is just a named list of of function, that can 148044584a44Smrg# be run in order later on. 148144584a44Smrg 148244584a44Smrg# func_hookable FUNC_NAME 148344584a44Smrg# ----------------------- 148444584a44Smrg# Declare that FUNC_NAME will run hooks added with 148544584a44Smrg# 'func_add_hook FUNC_NAME ...'. 148644584a44Smrgfunc_hookable () 148744584a44Smrg{ 148844584a44Smrg $debug_cmd 148944584a44Smrg 149044584a44Smrg func_append hookable_fns " $1" 149144584a44Smrg} 149244584a44Smrg 149344584a44Smrg 149444584a44Smrg# func_add_hook FUNC_NAME HOOK_FUNC 149544584a44Smrg# --------------------------------- 149644584a44Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 149744584a44Smrg# first have been declared "hookable" by a call to 'func_hookable'. 149844584a44Smrgfunc_add_hook () 149944584a44Smrg{ 150044584a44Smrg $debug_cmd 150144584a44Smrg 150244584a44Smrg case " $hookable_fns " in 150344584a44Smrg *" $1 "*) ;; 150444584a44Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 150544584a44Smrg esac 150644584a44Smrg 150744584a44Smrg eval func_append ${1}_hooks '" $2"' 150844584a44Smrg} 150944584a44Smrg 151044584a44Smrg 151144584a44Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 151244584a44Smrg# ------------------------------------ 151344584a44Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 151444584a44Smrgfunc_remove_hook () 151544584a44Smrg{ 151644584a44Smrg $debug_cmd 151744584a44Smrg 151844584a44Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 151944584a44Smrg} 152044584a44Smrg 152144584a44Smrg 152244584a44Smrg# func_run_hooks FUNC_NAME [ARG]... 152344584a44Smrg# --------------------------------- 152444584a44Smrg# Run all hook functions registered to FUNC_NAME. 152544584a44Smrg# It is assumed that the list of hook functions contains nothing more 152644584a44Smrg# than a whitespace-delimited list of legal shell function names, and 152744584a44Smrg# no effort is wasted trying to catch shell meta-characters or preserve 152844584a44Smrg# whitespace. 152944584a44Smrgfunc_run_hooks () 153044584a44Smrg{ 153144584a44Smrg $debug_cmd 153244584a44Smrg 153344584a44Smrg case " $hookable_fns " in 153444584a44Smrg *" $1 "*) ;; 153544584a44Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 153644584a44Smrg esac 153744584a44Smrg 153844584a44Smrg eval _G_hook_fns=\$$1_hooks; shift 153944584a44Smrg 154044584a44Smrg for _G_hook in $_G_hook_fns; do 154144584a44Smrg eval $_G_hook '"$@"' 154244584a44Smrg 154344584a44Smrg # store returned options list back into positional 154444584a44Smrg # parameters for next 'cmd' execution. 154544584a44Smrg eval _G_hook_result=\$${_G_hook}_result 154644584a44Smrg eval set dummy "$_G_hook_result"; shift 154744584a44Smrg done 154844584a44Smrg 154944584a44Smrg func_quote_for_eval ${1+"$@"} 155044584a44Smrg func_run_hooks_result=$func_quote_for_eval_result 155144584a44Smrg} 155244584a44Smrg 155344584a44Smrg 155444584a44Smrg 155544584a44Smrg## --------------- ## 155644584a44Smrg## Option parsing. ## 155744584a44Smrg## --------------- ## 155844584a44Smrg 155944584a44Smrg# In order to add your own option parsing hooks, you must accept the 156044584a44Smrg# full positional parameter list in your hook function, remove any 156144584a44Smrg# options that you action, and then pass back the remaining unprocessed 156244584a44Smrg# options in '<hooked_function_name>_result', escaped suitably for 156344584a44Smrg# 'eval'. Like this: 156444584a44Smrg# 156544584a44Smrg# my_options_prep () 156644584a44Smrg# { 156744584a44Smrg# $debug_cmd 156844584a44Smrg# 156944584a44Smrg# # Extend the existing usage message. 157044584a44Smrg# usage_message=$usage_message' 157144584a44Smrg# -s, --silent don'\''t print informational messages 157244584a44Smrg# ' 157344584a44Smrg# 157444584a44Smrg# func_quote_for_eval ${1+"$@"} 157544584a44Smrg# my_options_prep_result=$func_quote_for_eval_result 157644584a44Smrg# } 157744584a44Smrg# func_add_hook func_options_prep my_options_prep 157844584a44Smrg# 157944584a44Smrg# 158044584a44Smrg# my_silent_option () 158144584a44Smrg# { 158244584a44Smrg# $debug_cmd 158344584a44Smrg# 158444584a44Smrg# # Note that for efficiency, we parse as many options as we can 158544584a44Smrg# # recognise in a loop before passing the remainder back to the 158644584a44Smrg# # caller on the first unrecognised argument we encounter. 158744584a44Smrg# while test $# -gt 0; do 158844584a44Smrg# opt=$1; shift 158944584a44Smrg# case $opt in 159044584a44Smrg# --silent|-s) opt_silent=: ;; 159144584a44Smrg# # Separate non-argument short options: 159244584a44Smrg# -s*) func_split_short_opt "$_G_opt" 159344584a44Smrg# set dummy "$func_split_short_opt_name" \ 159444584a44Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 159544584a44Smrg# shift 159644584a44Smrg# ;; 159744584a44Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 159844584a44Smrg# esac 159944584a44Smrg# done 160044584a44Smrg# 160144584a44Smrg# func_quote_for_eval ${1+"$@"} 160244584a44Smrg# my_silent_option_result=$func_quote_for_eval_result 160344584a44Smrg# } 160444584a44Smrg# func_add_hook func_parse_options my_silent_option 160544584a44Smrg# 160644584a44Smrg# 160744584a44Smrg# my_option_validation () 160844584a44Smrg# { 160944584a44Smrg# $debug_cmd 161044584a44Smrg# 161144584a44Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 161244584a44Smrg# '--silent' and '--verbose' options are mutually exclusive." 161344584a44Smrg# 161444584a44Smrg# func_quote_for_eval ${1+"$@"} 161544584a44Smrg# my_option_validation_result=$func_quote_for_eval_result 161644584a44Smrg# } 161744584a44Smrg# func_add_hook func_validate_options my_option_validation 161844584a44Smrg# 161944584a44Smrg# You'll alse need to manually amend $usage_message to reflect the extra 162044584a44Smrg# options you parse. It's preferable to append if you can, so that 162144584a44Smrg# multiple option parsing hooks can be added safely. 162244584a44Smrg 162344584a44Smrg 162444584a44Smrg# func_options [ARG]... 162544584a44Smrg# --------------------- 162644584a44Smrg# All the functions called inside func_options are hookable. See the 162744584a44Smrg# individual implementations for details. 162844584a44Smrgfunc_hookable func_options 162944584a44Smrgfunc_options () 163044584a44Smrg{ 163144584a44Smrg $debug_cmd 163244584a44Smrg 163344584a44Smrg func_options_prep ${1+"$@"} 163444584a44Smrg eval func_parse_options \ 163544584a44Smrg ${func_options_prep_result+"$func_options_prep_result"} 163644584a44Smrg eval func_validate_options \ 163744584a44Smrg ${func_parse_options_result+"$func_parse_options_result"} 163844584a44Smrg 163944584a44Smrg eval func_run_hooks func_options \ 164044584a44Smrg ${func_validate_options_result+"$func_validate_options_result"} 164144584a44Smrg 164244584a44Smrg # save modified positional parameters for caller 164344584a44Smrg func_options_result=$func_run_hooks_result 1644c43cc173Smrg} 1645c43cc173Smrg 1646c43cc173Smrg 164744584a44Smrg# func_options_prep [ARG]... 164844584a44Smrg# -------------------------- 164944584a44Smrg# All initialisations required before starting the option parse loop. 165044584a44Smrg# Note that when calling hook functions, we pass through the list of 165144584a44Smrg# positional parameters. If a hook function modifies that list, and 165244584a44Smrg# needs to propogate that back to rest of this script, then the complete 165344584a44Smrg# modified list must be put in 'func_run_hooks_result' before 165444584a44Smrg# returning. 165544584a44Smrgfunc_hookable func_options_prep 165644584a44Smrgfunc_options_prep () 1657c43cc173Smrg{ 165844584a44Smrg $debug_cmd 1659c27c18e8Smrg 166044584a44Smrg # Option defaults: 166144584a44Smrg opt_verbose=false 166244584a44Smrg opt_warning_types= 166344584a44Smrg 166444584a44Smrg func_run_hooks func_options_prep ${1+"$@"} 166544584a44Smrg 166644584a44Smrg # save modified positional parameters for caller 166744584a44Smrg func_options_prep_result=$func_run_hooks_result 1668c43cc173Smrg} 1669c43cc173Smrg 1670c43cc173Smrg 167144584a44Smrg# func_parse_options [ARG]... 167244584a44Smrg# --------------------------- 167344584a44Smrg# The main option parsing loop. 167444584a44Smrgfunc_hookable func_parse_options 167544584a44Smrgfunc_parse_options () 1676c43cc173Smrg{ 167744584a44Smrg $debug_cmd 1678c27c18e8Smrg 167944584a44Smrg func_parse_options_result= 1680c27c18e8Smrg 168144584a44Smrg # this just eases exit handling 168244584a44Smrg while test $# -gt 0; do 168344584a44Smrg # Defer to hook functions for initial option parsing, so they 168444584a44Smrg # get priority in the event of reusing an option name. 168544584a44Smrg func_run_hooks func_parse_options ${1+"$@"} 1686c43cc173Smrg 168744584a44Smrg # Adjust func_parse_options positional parameters to match 168844584a44Smrg eval set dummy "$func_run_hooks_result"; shift 1689c43cc173Smrg 169044584a44Smrg # Break out of the loop if we already parsed every option. 169144584a44Smrg test $# -gt 0 || break 1692c43cc173Smrg 169344584a44Smrg _G_opt=$1 169444584a44Smrg shift 169544584a44Smrg case $_G_opt in 169644584a44Smrg --debug|-x) debug_cmd='set -x' 169744584a44Smrg func_echo "enabling shell trace mode" 169844584a44Smrg $debug_cmd 169944584a44Smrg ;; 170044584a44Smrg 170144584a44Smrg --no-warnings|--no-warning|--no-warn) 170244584a44Smrg set dummy --warnings none ${1+"$@"} 170344584a44Smrg shift 170444584a44Smrg ;; 1705c27c18e8Smrg 170644584a44Smrg --warnings|--warning|-W) 170744584a44Smrg test $# = 0 && func_missing_arg $_G_opt && break 170844584a44Smrg case " $warning_categories $1" in 170944584a44Smrg *" $1 "*) 171044584a44Smrg # trailing space prevents matching last $1 above 171144584a44Smrg func_append_uniq opt_warning_types " $1" 171244584a44Smrg ;; 171344584a44Smrg *all) 171444584a44Smrg opt_warning_types=$warning_categories 171544584a44Smrg ;; 171644584a44Smrg *none) 171744584a44Smrg opt_warning_types=none 171844584a44Smrg warning_func=: 171944584a44Smrg ;; 172044584a44Smrg *error) 172144584a44Smrg opt_warning_types=$warning_categories 172244584a44Smrg warning_func=func_fatal_error 172344584a44Smrg ;; 172444584a44Smrg *) 172544584a44Smrg func_fatal_error \ 172644584a44Smrg "unsupported warning category: '$1'" 172744584a44Smrg ;; 172844584a44Smrg esac 172944584a44Smrg shift 173044584a44Smrg ;; 173144584a44Smrg 173244584a44Smrg --verbose|-v) opt_verbose=: ;; 173344584a44Smrg --version) func_version ;; 173444584a44Smrg -\?|-h) func_usage ;; 173544584a44Smrg --help) func_help ;; 173644584a44Smrg 173744584a44Smrg # Separate optargs to long options (plugins may need this): 173844584a44Smrg --*=*) func_split_equals "$_G_opt" 173944584a44Smrg set dummy "$func_split_equals_lhs" \ 174044584a44Smrg "$func_split_equals_rhs" ${1+"$@"} 174144584a44Smrg shift 174244584a44Smrg ;; 174344584a44Smrg 174444584a44Smrg # Separate optargs to short options: 174544584a44Smrg -W*) 174644584a44Smrg func_split_short_opt "$_G_opt" 174744584a44Smrg set dummy "$func_split_short_opt_name" \ 174844584a44Smrg "$func_split_short_opt_arg" ${1+"$@"} 174944584a44Smrg shift 175044584a44Smrg ;; 175144584a44Smrg 175244584a44Smrg # Separate non-argument short options: 175344584a44Smrg -\?*|-h*|-v*|-x*) 175444584a44Smrg func_split_short_opt "$_G_opt" 175544584a44Smrg set dummy "$func_split_short_opt_name" \ 175644584a44Smrg "-$func_split_short_opt_arg" ${1+"$@"} 175744584a44Smrg shift 175844584a44Smrg ;; 175944584a44Smrg 176044584a44Smrg --) break ;; 176144584a44Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176244584a44Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 176344584a44Smrg esac 176444584a44Smrg done 176544584a44Smrg 176644584a44Smrg # save modified positional parameters for caller 176744584a44Smrg func_quote_for_eval ${1+"$@"} 176844584a44Smrg func_parse_options_result=$func_quote_for_eval_result 1769c43cc173Smrg} 1770c43cc173Smrg 1771c27c18e8Smrg 177244584a44Smrg# func_validate_options [ARG]... 177344584a44Smrg# ------------------------------ 177444584a44Smrg# Perform any sanity checks on option settings and/or unconsumed 177544584a44Smrg# arguments. 177644584a44Smrgfunc_hookable func_validate_options 177744584a44Smrgfunc_validate_options () 1778c43cc173Smrg{ 177944584a44Smrg $debug_cmd 1780c27c18e8Smrg 178144584a44Smrg # Display all warnings if -W was not given. 178244584a44Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783c27c18e8Smrg 178444584a44Smrg func_run_hooks func_validate_options ${1+"$@"} 1785c43cc173Smrg 178644584a44Smrg # Bail if the options were screwed! 178744584a44Smrg $exit_cmd $EXIT_FAILURE 178844584a44Smrg 178944584a44Smrg # save modified positional parameters for caller 179044584a44Smrg func_validate_options_result=$func_run_hooks_result 1791b789ec8aSmrg} 1792b789ec8aSmrg 1793c43cc173Smrg 1794b789ec8aSmrg 179544584a44Smrg## ----------------- ## 179644584a44Smrg## Helper functions. ## 179744584a44Smrg## ----------------- ## 1798c27c18e8Smrg 179944584a44Smrg# This section contains the helper functions used by the rest of the 180044584a44Smrg# hookable option parser framework in ascii-betical order. 180144584a44Smrg 180244584a44Smrg 180344584a44Smrg# func_fatal_help ARG... 180444584a44Smrg# ---------------------- 180544584a44Smrg# Echo program name prefixed message to standard error, followed by 180644584a44Smrg# a help hint, and exit. 180744584a44Smrgfunc_fatal_help () 1808c27c18e8Smrg{ 180944584a44Smrg $debug_cmd 1810b789ec8aSmrg 181144584a44Smrg eval \$ECHO \""Usage: $usage"\" 181244584a44Smrg eval \$ECHO \""$fatal_help"\" 181344584a44Smrg func_error ${1+"$@"} 181444584a44Smrg exit $EXIT_FAILURE 1815c27c18e8Smrg} 1816c27c18e8Smrg 181744584a44Smrg 181844584a44Smrg# func_help 181944584a44Smrg# --------- 182044584a44Smrg# Echo long help message to standard output and exit. 1821c27c18e8Smrgfunc_help () 1822c27c18e8Smrg{ 182344584a44Smrg $debug_cmd 182444584a44Smrg 182544584a44Smrg func_usage_message 182644584a44Smrg $ECHO "$long_help_message" 182744584a44Smrg exit 0 1828c27c18e8Smrg} 1829c27c18e8Smrg 183044584a44Smrg 183144584a44Smrg# func_missing_arg ARGNAME 183244584a44Smrg# ------------------------ 1833c27c18e8Smrg# Echo program name prefixed message to standard error and set global 1834c27c18e8Smrg# exit_cmd. 1835c27c18e8Smrgfunc_missing_arg () 1836c27c18e8Smrg{ 183744584a44Smrg $debug_cmd 1838b789ec8aSmrg 183944584a44Smrg func_error "Missing argument for '$1'." 1840c27c18e8Smrg exit_cmd=exit 1841c43cc173Smrg} 1842c43cc173Smrg 1843c43cc173Smrg 184444584a44Smrg# func_split_equals STRING 184544584a44Smrg# ------------------------ 184644584a44Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 184744584a44Smrg# splitting STRING at the '=' sign. 184844584a44Smrgtest -z "$_G_HAVE_XSI_OPS" \ 184944584a44Smrg && (eval 'x=a/b/c; 185044584a44Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 185144584a44Smrg && _G_HAVE_XSI_OPS=yes 185244584a44Smrg 185344584a44Smrgif test yes = "$_G_HAVE_XSI_OPS" 185444584a44Smrgthen 185544584a44Smrg # This is an XSI compatible shell, allowing a faster implementation... 185644584a44Smrg eval 'func_split_equals () 185744584a44Smrg { 185844584a44Smrg $debug_cmd 185944584a44Smrg 186044584a44Smrg func_split_equals_lhs=${1%%=*} 186144584a44Smrg func_split_equals_rhs=${1#*=} 186244584a44Smrg test "x$func_split_equals_lhs" = "x$1" \ 186344584a44Smrg && func_split_equals_rhs= 186444584a44Smrg }' 186544584a44Smrgelse 186644584a44Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 186744584a44Smrg func_split_equals () 186844584a44Smrg { 186944584a44Smrg $debug_cmd 187044584a44Smrg 187144584a44Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 187244584a44Smrg func_split_equals_rhs= 187344584a44Smrg test "x$func_split_equals_lhs" = "x$1" \ 187444584a44Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 187544584a44Smrg } 187644584a44Smrgfi #func_split_equals 187744584a44Smrg 187844584a44Smrg 187944584a44Smrg# func_split_short_opt SHORTOPT 188044584a44Smrg# ----------------------------- 1881b789ec8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882b789ec8aSmrg# variables after splitting SHORTOPT after the 2nd character. 188344584a44Smrgif test yes = "$_G_HAVE_XSI_OPS" 188444584a44Smrgthen 188544584a44Smrg # This is an XSI compatible shell, allowing a faster implementation... 188644584a44Smrg eval 'func_split_short_opt () 188744584a44Smrg { 188844584a44Smrg $debug_cmd 188944584a44Smrg 189044584a44Smrg func_split_short_opt_arg=${1#??} 189144584a44Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 189244584a44Smrg }' 189344584a44Smrgelse 189444584a44Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 189544584a44Smrg func_split_short_opt () 189644584a44Smrg { 189744584a44Smrg $debug_cmd 189844584a44Smrg 189944584a44Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 190044584a44Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 190144584a44Smrg } 190244584a44Smrgfi #func_split_short_opt 190344584a44Smrg 190444584a44Smrg 190544584a44Smrg# func_usage 190644584a44Smrg# ---------- 190744584a44Smrg# Echo short help message to standard output and exit. 190844584a44Smrgfunc_usage () 1909b789ec8aSmrg{ 191044584a44Smrg $debug_cmd 1911b789ec8aSmrg 191244584a44Smrg func_usage_message 191344584a44Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 191444584a44Smrg exit 0 191544584a44Smrg} 1916b789ec8aSmrg 1917b789ec8aSmrg 191844584a44Smrg# func_usage_message 191944584a44Smrg# ------------------ 192044584a44Smrg# Echo short help message to standard output. 192144584a44Smrgfunc_usage_message () 1922b789ec8aSmrg{ 192344584a44Smrg $debug_cmd 1924b789ec8aSmrg 192544584a44Smrg eval \$ECHO \""Usage: $usage"\" 192644584a44Smrg echo 192744584a44Smrg $SED -n 's|^# || 192844584a44Smrg /^Written by/{ 192944584a44Smrg x;p;x 193044584a44Smrg } 193144584a44Smrg h 193244584a44Smrg /^Written by/q' < "$progpath" 193344584a44Smrg echo 193444584a44Smrg eval \$ECHO \""$usage_message"\" 193544584a44Smrg} 1936b789ec8aSmrg 1937c43cc173Smrg 193844584a44Smrg# func_version 193944584a44Smrg# ------------ 194044584a44Smrg# Echo version message to standard output and exit. 194144584a44Smrgfunc_version () 194244584a44Smrg{ 194344584a44Smrg $debug_cmd 1944c27c18e8Smrg 194544584a44Smrg printf '%s\n' "$progname $scriptversion" 194644584a44Smrg $SED -n ' 194744584a44Smrg /(C)/!b go 194844584a44Smrg :more 194944584a44Smrg /\./!{ 195044584a44Smrg N 195144584a44Smrg s|\n# | | 195244584a44Smrg b more 195344584a44Smrg } 195444584a44Smrg :go 195544584a44Smrg /^# Written by /,/# warranty; / { 195644584a44Smrg s|^# || 195744584a44Smrg s|^# *$|| 195844584a44Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 195944584a44Smrg p 196044584a44Smrg } 196144584a44Smrg /^# Written by / { 196244584a44Smrg s|^# || 196344584a44Smrg p 196444584a44Smrg } 196544584a44Smrg /^warranty; /q' < "$progpath" 1966c27c18e8Smrg 196744584a44Smrg exit $? 196844584a44Smrg} 1969c27c18e8Smrg 1970c43cc173Smrg 197144584a44Smrg# Local variables: 197244584a44Smrg# mode: shell-script 197344584a44Smrg# sh-indentation: 2 197444584a44Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 197544584a44Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 197644584a44Smrg# time-stamp-time-zone: "UTC" 197744584a44Smrg# End: 1978c43cc173Smrg 197944584a44Smrg# Set a version string. 198044584a44Smrgscriptversion='(GNU libtool) 2.4.6' 1981c43cc173Smrg 1982c27c18e8Smrg 198344584a44Smrg# func_echo ARG... 198444584a44Smrg# ---------------- 198544584a44Smrg# Libtool also displays the current mode in messages, so override 198644584a44Smrg# funclib.sh func_echo with this custom definition. 198744584a44Smrgfunc_echo () 1988b789ec8aSmrg{ 198944584a44Smrg $debug_cmd 1990b789ec8aSmrg 199144584a44Smrg _G_message=$* 1992b789ec8aSmrg 199344584a44Smrg func_echo_IFS=$IFS 199444584a44Smrg IFS=$nl 199544584a44Smrg for _G_line in $_G_message; do 199644584a44Smrg IFS=$func_echo_IFS 199744584a44Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 199844584a44Smrg done 199944584a44Smrg IFS=$func_echo_IFS 200044584a44Smrg} 2001b789ec8aSmrg 200244584a44Smrg 200344584a44Smrg# func_warning ARG... 200444584a44Smrg# ------------------- 200544584a44Smrg# Libtool warnings are not categorized, so override funclib.sh 200644584a44Smrg# func_warning with this simpler definition. 200744584a44Smrgfunc_warning () 2008b789ec8aSmrg{ 200944584a44Smrg $debug_cmd 2010b789ec8aSmrg 201144584a44Smrg $warning_func ${1+"$@"} 201244584a44Smrg} 2013b789ec8aSmrg 2014b789ec8aSmrg 201544584a44Smrg## ---------------- ## 201644584a44Smrg## Options parsing. ## 201744584a44Smrg## ---------------- ## 201844584a44Smrg 201944584a44Smrg# Hook in the functions to make sure our own options are parsed during 202044584a44Smrg# the option parsing loop. 202144584a44Smrg 202244584a44Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 202344584a44Smrg 202444584a44Smrg# Short help message in response to '-h'. 202544584a44Smrgusage_message="Options: 202644584a44Smrg --config show all configuration variables 202744584a44Smrg --debug enable verbose shell tracing 202844584a44Smrg -n, --dry-run display commands without modifying any files 202944584a44Smrg --features display basic configuration information and exit 203044584a44Smrg --mode=MODE use operation mode MODE 203144584a44Smrg --no-warnings equivalent to '-Wnone' 203244584a44Smrg --preserve-dup-deps don't remove duplicate dependency libraries 203344584a44Smrg --quiet, --silent don't print informational messages 203444584a44Smrg --tag=TAG use configuration variables from tag TAG 203544584a44Smrg -v, --verbose print more informational messages than default 203644584a44Smrg --version print version information 203744584a44Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 203844584a44Smrg -h, --help, --help-all print short, long, or detailed help message 203944584a44Smrg" 2040b789ec8aSmrg 204144584a44Smrg# Additional text appended to 'usage_message' in response to '--help'. 204244584a44Smrgfunc_help () 2043b789ec8aSmrg{ 204444584a44Smrg $debug_cmd 204544584a44Smrg 204644584a44Smrg func_usage_message 204744584a44Smrg $ECHO "$long_help_message 204844584a44Smrg 204944584a44SmrgMODE must be one of the following: 205044584a44Smrg 205144584a44Smrg clean remove files from the build directory 205244584a44Smrg compile compile a source file into a libtool object 205344584a44Smrg execute automatically set library path, then run a program 205444584a44Smrg finish complete the installation of libtool libraries 205544584a44Smrg install install libraries or executables 205644584a44Smrg link create a library or an executable 205744584a44Smrg uninstall remove libraries from an installed directory 205844584a44Smrg 205944584a44SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 206044584a44Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 206144584a44SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 206244584a44Smrg 206344584a44SmrgWhen reporting a bug, please describe a test case to reproduce it and 206444584a44Smrginclude the following information: 206544584a44Smrg 206644584a44Smrg host-triplet: $host 206744584a44Smrg shell: $SHELL 206844584a44Smrg compiler: $LTCC 206944584a44Smrg compiler flags: $LTCFLAGS 207044584a44Smrg linker: $LD (gnu? $with_gnu_ld) 207144584a44Smrg version: $progname (GNU libtool) 2.4.6 207244584a44Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 207344584a44Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 207444584a44Smrg 207544584a44SmrgReport bugs to <bug-libtool@gnu.org>. 207644584a44SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 207744584a44SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207844584a44Smrg exit 0 207944584a44Smrg} 2080b789ec8aSmrg 2081b789ec8aSmrg 208244584a44Smrg# func_lo2o OBJECT-NAME 208344584a44Smrg# --------------------- 208444584a44Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 208544584a44Smrg# object suffix. 208644584a44Smrg 208744584a44Smrglo2o=s/\\.lo\$/.$objext/ 208844584a44Smrgo2lo=s/\\.$objext\$/.lo/ 208944584a44Smrg 209044584a44Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 209144584a44Smrg eval 'func_lo2o () 209244584a44Smrg { 209344584a44Smrg case $1 in 209444584a44Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 209544584a44Smrg * ) func_lo2o_result=$1 ;; 209644584a44Smrg esac 209744584a44Smrg }' 209844584a44Smrg 209944584a44Smrg # func_xform LIBOBJ-OR-SOURCE 210044584a44Smrg # --------------------------- 210144584a44Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 210244584a44Smrg # suffix to a '.lo' libtool-object suffix. 210344584a44Smrg eval 'func_xform () 210444584a44Smrg { 210544584a44Smrg func_xform_result=${1%.*}.lo 210644584a44Smrg }' 210744584a44Smrgelse 210844584a44Smrg # ...otherwise fall back to using sed. 210944584a44Smrg func_lo2o () 211044584a44Smrg { 211144584a44Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 211244584a44Smrg } 211344584a44Smrg 211444584a44Smrg func_xform () 211544584a44Smrg { 211644584a44Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 211744584a44Smrg } 211844584a44Smrgfi 2119b789ec8aSmrg 2120b789ec8aSmrg 212144584a44Smrg# func_fatal_configuration ARG... 212244584a44Smrg# ------------------------------- 2123c27c18e8Smrg# Echo program name prefixed message to standard error, followed by 2124c27c18e8Smrg# a configuration failure hint, and exit. 2125c27c18e8Smrgfunc_fatal_configuration () 2126c27c18e8Smrg{ 212744584a44Smrg func__fatal_error ${1+"$@"} \ 212844584a44Smrg "See the $PACKAGE documentation for more information." \ 212944584a44Smrg "Fatal configuration error." 2130c27c18e8Smrg} 2131c43cc173Smrg 213221e67964Smrg 2133c27c18e8Smrg# func_config 213444584a44Smrg# ----------- 2135c27c18e8Smrg# Display the configuration for all the tags in this script. 2136c27c18e8Smrgfunc_config () 2137c27c18e8Smrg{ 2138c27c18e8Smrg re_begincf='^# ### BEGIN LIBTOOL' 2139c27c18e8Smrg re_endcf='^# ### END LIBTOOL' 2140c27c18e8Smrg 2141c27c18e8Smrg # Default configuration. 2142c27c18e8Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143c43cc173Smrg 2144c43cc173Smrg # Now print the configurations for the tags. 2145c43cc173Smrg for tagname in $taglist; do 2146c27c18e8Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147c43cc173Smrg done 2148c43cc173Smrg 2149c27c18e8Smrg exit $? 2150c27c18e8Smrg} 2151c43cc173Smrg 215244584a44Smrg 2153c27c18e8Smrg# func_features 215444584a44Smrg# ------------- 2155c27c18e8Smrg# Display the features supported by this script. 2156c27c18e8Smrgfunc_features () 2157c27c18e8Smrg{ 215837eb1ca1Smrg echo "host: $host" 215944584a44Smrg if test yes = "$build_libtool_libs"; then 216037eb1ca1Smrg echo "enable shared libraries" 2161c43cc173Smrg else 216237eb1ca1Smrg echo "disable shared libraries" 2163c43cc173Smrg fi 216444584a44Smrg if test yes = "$build_old_libs"; then 216537eb1ca1Smrg echo "enable static libraries" 2166c43cc173Smrg else 216737eb1ca1Smrg echo "disable static libraries" 2168c43cc173Smrg fi 2169c27c18e8Smrg 2170c43cc173Smrg exit $? 2171c27c18e8Smrg} 2172c43cc173Smrg 217344584a44Smrg 217444584a44Smrg# func_enable_tag TAGNAME 217544584a44Smrg# ----------------------- 2176c27c18e8Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177c27c18e8Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178c27c18e8Smrg# variable here. 2179c27c18e8Smrgfunc_enable_tag () 2180c27c18e8Smrg{ 218144584a44Smrg # Global variable: 218244584a44Smrg tagname=$1 2183c43cc173Smrg 218444584a44Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 218544584a44Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 218644584a44Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187c43cc173Smrg 218844584a44Smrg # Validate tagname. 218944584a44Smrg case $tagname in 219044584a44Smrg *[!-_A-Za-z0-9,/]*) 219144584a44Smrg func_fatal_error "invalid tag name: $tagname" 219244584a44Smrg ;; 219344584a44Smrg esac 2194c43cc173Smrg 219544584a44Smrg # Don't test for the "default" C tag, as we know it's 219644584a44Smrg # there but not specially marked. 219744584a44Smrg case $tagname in 219844584a44Smrg CC) ;; 2199c27c18e8Smrg *) 220044584a44Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 220144584a44Smrg taglist="$taglist $tagname" 220244584a44Smrg 220344584a44Smrg # Evaluate the configuration. Be careful to quote the path 220444584a44Smrg # and the sed script, to avoid splitting on whitespace, but 220544584a44Smrg # also don't use non-portable quotes within backquotes within 220644584a44Smrg # quotes we have to do it in 2 steps: 220744584a44Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 220844584a44Smrg eval "$extractedcf" 220944584a44Smrg else 221044584a44Smrg func_error "ignoring unknown tag $tagname" 221144584a44Smrg fi 221244584a44Smrg ;; 221344584a44Smrg esac 2214c27c18e8Smrg} 2215c27c18e8Smrg 221644584a44Smrg 2217b789ec8aSmrg# func_check_version_match 221844584a44Smrg# ------------------------ 2219b789ec8aSmrg# Ensure that we are using m4 macros, and libtool script from the same 2220b789ec8aSmrg# release of libtool. 2221b789ec8aSmrgfunc_check_version_match () 2222c27c18e8Smrg{ 222344584a44Smrg if test "$package_revision" != "$macro_revision"; then 222444584a44Smrg if test "$VERSION" != "$macro_version"; then 222544584a44Smrg if test -z "$macro_version"; then 222644584a44Smrg cat >&2 <<_LT_EOF 2227b789ec8aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228b789ec8aSmrg$progname: definition of this LT_INIT comes from an older release. 2229b789ec8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230b789ec8aSmrg$progname: and run autoconf again. 2231b789ec8aSmrg_LT_EOF 223244584a44Smrg else 223344584a44Smrg cat >&2 <<_LT_EOF 2234b789ec8aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235b789ec8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236b789ec8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237b789ec8aSmrg$progname: and run autoconf again. 2238b789ec8aSmrg_LT_EOF 223944584a44Smrg fi 224044584a44Smrg else 224144584a44Smrg cat >&2 <<_LT_EOF 2242b789ec8aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243b789ec8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244b789ec8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245b789ec8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246b789ec8aSmrg_LT_EOF 224744584a44Smrg fi 2248c43cc173Smrg 224944584a44Smrg exit $EXIT_MISMATCH 225044584a44Smrg fi 2251b789ec8aSmrg} 2252b789ec8aSmrg 2253b789ec8aSmrg 225444584a44Smrg# libtool_options_prep [ARG]... 225544584a44Smrg# ----------------------------- 225644584a44Smrg# Preparation for options parsed by libtool. 225744584a44Smrglibtool_options_prep () 225844584a44Smrg{ 225944584a44Smrg $debug_mode 2260c43cc173Smrg 226144584a44Smrg # Option defaults: 226244584a44Smrg opt_config=false 226344584a44Smrg opt_dlopen= 226444584a44Smrg opt_dry_run=false 226544584a44Smrg opt_help=false 226644584a44Smrg opt_mode= 226744584a44Smrg opt_preserve_dup_deps=false 226844584a44Smrg opt_quiet=false 2269b789ec8aSmrg 227044584a44Smrg nonopt= 227144584a44Smrg preserve_args= 2272b789ec8aSmrg 227344584a44Smrg # Shorthand for --mode=foo, only valid as the first argument 227444584a44Smrg case $1 in 227544584a44Smrg clean|clea|cle|cl) 227644584a44Smrg shift; set dummy --mode clean ${1+"$@"}; shift 227744584a44Smrg ;; 227844584a44Smrg compile|compil|compi|comp|com|co|c) 227944584a44Smrg shift; set dummy --mode compile ${1+"$@"}; shift 228044584a44Smrg ;; 228144584a44Smrg execute|execut|execu|exec|exe|ex|e) 228244584a44Smrg shift; set dummy --mode execute ${1+"$@"}; shift 228344584a44Smrg ;; 228444584a44Smrg finish|finis|fini|fin|fi|f) 228544584a44Smrg shift; set dummy --mode finish ${1+"$@"}; shift 228644584a44Smrg ;; 228744584a44Smrg install|instal|insta|inst|ins|in|i) 228844584a44Smrg shift; set dummy --mode install ${1+"$@"}; shift 228944584a44Smrg ;; 229044584a44Smrg link|lin|li|l) 229144584a44Smrg shift; set dummy --mode link ${1+"$@"}; shift 229244584a44Smrg ;; 229344584a44Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 229444584a44Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 229544584a44Smrg ;; 229644584a44Smrg esac 229744584a44Smrg 229844584a44Smrg # Pass back the list of options. 229944584a44Smrg func_quote_for_eval ${1+"$@"} 230044584a44Smrg libtool_options_prep_result=$func_quote_for_eval_result 230144584a44Smrg} 230244584a44Smrgfunc_add_hook func_options_prep libtool_options_prep 2303b789ec8aSmrg 2304b789ec8aSmrg 230544584a44Smrg# libtool_parse_options [ARG]... 230644584a44Smrg# --------------------------------- 230744584a44Smrg# Provide handling for libtool specific options. 230844584a44Smrglibtool_parse_options () 2309b789ec8aSmrg{ 231044584a44Smrg $debug_cmd 2311c27c18e8Smrg 231244584a44Smrg # Perform our own loop to consume as many options as possible in 231344584a44Smrg # each iteration. 231444584a44Smrg while test $# -gt 0; do 231544584a44Smrg _G_opt=$1 231644584a44Smrg shift 231744584a44Smrg case $_G_opt in 231844584a44Smrg --dry-run|--dryrun|-n) 231944584a44Smrg opt_dry_run=: 232044584a44Smrg ;; 232144584a44Smrg 232244584a44Smrg --config) func_config ;; 232344584a44Smrg 232444584a44Smrg --dlopen|-dlopen) 232544584a44Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 232644584a44Smrg}$1" 232744584a44Smrg shift 232844584a44Smrg ;; 232944584a44Smrg 233044584a44Smrg --preserve-dup-deps) 233144584a44Smrg opt_preserve_dup_deps=: ;; 233244584a44Smrg 233344584a44Smrg --features) func_features ;; 233444584a44Smrg 233544584a44Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 233644584a44Smrg 233744584a44Smrg --help) opt_help=: ;; 233844584a44Smrg 233944584a44Smrg --help-all) opt_help=': help-all' ;; 234044584a44Smrg 234144584a44Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 234244584a44Smrg opt_mode=$1 234344584a44Smrg case $1 in 234444584a44Smrg # Valid mode arguments: 234544584a44Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 234644584a44Smrg 234744584a44Smrg # Catch anything else as an error 234844584a44Smrg *) func_error "invalid argument for $_G_opt" 234944584a44Smrg exit_cmd=exit 235044584a44Smrg break 235144584a44Smrg ;; 235244584a44Smrg esac 235344584a44Smrg shift 235444584a44Smrg ;; 235544584a44Smrg 235644584a44Smrg --no-silent|--no-quiet) 235744584a44Smrg opt_quiet=false 235844584a44Smrg func_append preserve_args " $_G_opt" 235944584a44Smrg ;; 236044584a44Smrg 236144584a44Smrg --no-warnings|--no-warning|--no-warn) 236244584a44Smrg opt_warning=false 236344584a44Smrg func_append preserve_args " $_G_opt" 236444584a44Smrg ;; 236544584a44Smrg 236644584a44Smrg --no-verbose) 236744584a44Smrg opt_verbose=false 236844584a44Smrg func_append preserve_args " $_G_opt" 236944584a44Smrg ;; 237044584a44Smrg 237144584a44Smrg --silent|--quiet) 237244584a44Smrg opt_quiet=: 237344584a44Smrg opt_verbose=false 237444584a44Smrg func_append preserve_args " $_G_opt" 237544584a44Smrg ;; 237644584a44Smrg 237744584a44Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 237844584a44Smrg opt_tag=$1 237944584a44Smrg func_append preserve_args " $_G_opt $1" 238044584a44Smrg func_enable_tag "$1" 238144584a44Smrg shift 238244584a44Smrg ;; 238344584a44Smrg 238444584a44Smrg --verbose|-v) opt_quiet=false 238544584a44Smrg opt_verbose=: 238644584a44Smrg func_append preserve_args " $_G_opt" 238744584a44Smrg ;; 238844584a44Smrg 238944584a44Smrg # An option not handled by this hook function: 239044584a44Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 239144584a44Smrg esac 239244584a44Smrg done 2393b789ec8aSmrg 2394b789ec8aSmrg 239544584a44Smrg # save modified positional parameters for caller 239644584a44Smrg func_quote_for_eval ${1+"$@"} 239744584a44Smrg libtool_parse_options_result=$func_quote_for_eval_result 239844584a44Smrg} 239944584a44Smrgfunc_add_hook func_parse_options libtool_parse_options 2400c27c18e8Smrg 2401c43cc173Smrg 2402c27c18e8Smrg 240344584a44Smrg# libtool_validate_options [ARG]... 240444584a44Smrg# --------------------------------- 240544584a44Smrg# Perform any sanity checks on option settings and/or unconsumed 240644584a44Smrg# arguments. 240744584a44Smrglibtool_validate_options () 240844584a44Smrg{ 240944584a44Smrg # save first non-option argument 241044584a44Smrg if test 0 -lt $#; then 241144584a44Smrg nonopt=$1 241244584a44Smrg shift 2413c27c18e8Smrg fi 2414c27c18e8Smrg 241544584a44Smrg # preserve --debug 241644584a44Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417c27c18e8Smrg 241844584a44Smrg case $host in 241944584a44Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 242044584a44Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 242144584a44Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 242244584a44Smrg # don't eliminate duplications in $postdeps and $predeps 242344584a44Smrg opt_duplicate_compiler_generated_deps=: 242444584a44Smrg ;; 242544584a44Smrg *) 242644584a44Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 242744584a44Smrg ;; 242844584a44Smrg esac 2429c27c18e8Smrg 243044584a44Smrg $opt_help || { 243144584a44Smrg # Sanity checks first: 243244584a44Smrg func_check_version_match 243344584a44Smrg 243444584a44Smrg test yes != "$build_libtool_libs" \ 243544584a44Smrg && test yes != "$build_old_libs" \ 243644584a44Smrg && func_fatal_configuration "not configured to build any kind of library" 243744584a44Smrg 243844584a44Smrg # Darwin sucks 243944584a44Smrg eval std_shrext=\"$shrext_cmds\" 244044584a44Smrg 244144584a44Smrg # Only execute mode is allowed to have -dlopen flags. 244244584a44Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 244344584a44Smrg func_error "unrecognized option '-dlopen'" 244444584a44Smrg $ECHO "$help" 1>&2 244544584a44Smrg exit $EXIT_FAILURE 244644584a44Smrg fi 2447c27c18e8Smrg 244844584a44Smrg # Change the help message to a mode-specific one. 244944584a44Smrg generic_help=$help 245044584a44Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 245144584a44Smrg } 2452c27c18e8Smrg 245344584a44Smrg # Pass back the unparsed argument list 245444584a44Smrg func_quote_for_eval ${1+"$@"} 245544584a44Smrg libtool_validate_options_result=$func_quote_for_eval_result 2456b789ec8aSmrg} 245744584a44Smrgfunc_add_hook func_validate_options libtool_validate_options 2458c27c18e8Smrg 2459c27c18e8Smrg 246044584a44Smrg# Process options as early as possible so that --help and --version 246144584a44Smrg# can return quickly. 246244584a44Smrgfunc_options ${1+"$@"} 246344584a44Smrgeval set dummy "$func_options_result"; shift 246444584a44Smrg 2465c43cc173Smrg 2466c43cc173Smrg 2467b789ec8aSmrg## ----------- ## 2468b789ec8aSmrg## Main. ## 2469b789ec8aSmrg## ----------- ## 2470c43cc173Smrg 247144584a44Smrgmagic='%%%MAGIC variable%%%' 247244584a44Smrgmagic_exe='%%%MAGIC EXE variable%%%' 247344584a44Smrg 247444584a44Smrg# Global variables. 247544584a44Smrgextracted_archives= 247644584a44Smrgextracted_serial=0 247744584a44Smrg 247844584a44Smrg# If this variable is set in any of the actions, the command in it 247944584a44Smrg# will be execed at the end. This prevents here-documents from being 248044584a44Smrg# left over by shells. 248144584a44Smrgexec_cmd= 248244584a44Smrg 248344584a44Smrg 248444584a44Smrg# A function that is used when there is no print builtin or printf. 248544584a44Smrgfunc_fallback_echo () 248644584a44Smrg{ 248744584a44Smrg eval 'cat <<_LTECHO_EOF 248844584a44Smrg$1 248944584a44Smrg_LTECHO_EOF' 249044584a44Smrg} 249144584a44Smrg 249244584a44Smrg# func_generated_by_libtool 249344584a44Smrg# True iff stdin has been generated by Libtool. This function is only 249444584a44Smrg# a basic sanity check; it will hardly flush out determined imposters. 249544584a44Smrgfunc_generated_by_libtool_p () 249644584a44Smrg{ 249744584a44Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 249844584a44Smrg} 249944584a44Smrg 2500c27c18e8Smrg# func_lalib_p file 250144584a44Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out 2503c27c18e8Smrg# determined imposters. 2504c27c18e8Smrgfunc_lalib_p () 2505c27c18e8Smrg{ 2506c27c18e8Smrg test -f "$1" && 250744584a44Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508c27c18e8Smrg} 2509c43cc173Smrg 2510c27c18e8Smrg# func_lalib_unsafe_p file 251144584a44Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512c27c18e8Smrg# This function implements the same check as func_lalib_p without 2513c27c18e8Smrg# resorting to external programs. To this end, it redirects stdin and 2514c27c18e8Smrg# closes it afterwards, without saving the original file descriptor. 2515c27c18e8Smrg# As a safety measure, use it only where a negative result would be 251644584a44Smrg# fatal anyway. Works if 'file' does not exist. 2517c27c18e8Smrgfunc_lalib_unsafe_p () 2518c27c18e8Smrg{ 2519c27c18e8Smrg lalib_p=no 2520c27c18e8Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521c27c18e8Smrg for lalib_p_l in 1 2 3 4 2522c27c18e8Smrg do 2523c27c18e8Smrg read lalib_p_line 252444584a44Smrg case $lalib_p_line in 2525c27c18e8Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526c27c18e8Smrg esac 2527c27c18e8Smrg done 2528c27c18e8Smrg exec 0<&5 5<&- 2529c27c18e8Smrg fi 253044584a44Smrg test yes = "$lalib_p" 2531c27c18e8Smrg} 2532c43cc173Smrg 2533c27c18e8Smrg# func_ltwrapper_script_p file 2534c27c18e8Smrg# True iff FILE is a libtool wrapper script 2535c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out 2536c27c18e8Smrg# determined imposters. 2537c27c18e8Smrgfunc_ltwrapper_script_p () 2538c27c18e8Smrg{ 253944584a44Smrg test -f "$1" && 254044584a44Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541c27c18e8Smrg} 2542c43cc173Smrg 2543c27c18e8Smrg# func_ltwrapper_executable_p file 2544c27c18e8Smrg# True iff FILE is a libtool wrapper executable 2545c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out 2546c27c18e8Smrg# determined imposters. 2547c27c18e8Smrgfunc_ltwrapper_executable_p () 2548c27c18e8Smrg{ 2549c27c18e8Smrg func_ltwrapper_exec_suffix= 2550c27c18e8Smrg case $1 in 2551c27c18e8Smrg *.exe) ;; 2552c27c18e8Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553c27c18e8Smrg esac 2554c27c18e8Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555c27c18e8Smrg} 2556c43cc173Smrg 2557c27c18e8Smrg# func_ltwrapper_scriptname file 2558c27c18e8Smrg# Assumes file is an ltwrapper_executable 2559c27c18e8Smrg# uses $file to determine the appropriate filename for a 2560c27c18e8Smrg# temporary ltwrapper_script. 2561c27c18e8Smrgfunc_ltwrapper_scriptname () 2562c27c18e8Smrg{ 2563b789ec8aSmrg func_dirname_and_basename "$1" "" "." 2564b789ec8aSmrg func_stripname '' '.exe' "$func_basename_result" 256544584a44Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566c27c18e8Smrg} 2567c27c18e8Smrg 2568c27c18e8Smrg# func_ltwrapper_p file 2569c27c18e8Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2570c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out 2571c27c18e8Smrg# determined imposters. 2572c27c18e8Smrgfunc_ltwrapper_p () 2573c27c18e8Smrg{ 2574c27c18e8Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575c27c18e8Smrg} 2576c27c18e8Smrg 2577c27c18e8Smrg 2578c27c18e8Smrg# func_execute_cmds commands fail_cmd 2579c27c18e8Smrg# Execute tilde-delimited COMMANDS. 2580c27c18e8Smrg# If FAIL_CMD is given, eval that upon failure. 2581c27c18e8Smrg# FAIL_CMD may read-access the current command in variable CMD! 2582c27c18e8Smrgfunc_execute_cmds () 2583c27c18e8Smrg{ 258444584a44Smrg $debug_cmd 258544584a44Smrg 2586c27c18e8Smrg save_ifs=$IFS; IFS='~' 2587c27c18e8Smrg for cmd in $1; do 258844584a44Smrg IFS=$sp$nl 2589c27c18e8Smrg eval cmd=\"$cmd\" 259044584a44Smrg IFS=$save_ifs 2591c27c18e8Smrg func_show_eval "$cmd" "${2-:}" 2592c27c18e8Smrg done 2593c27c18e8Smrg IFS=$save_ifs 2594c27c18e8Smrg} 2595c27c18e8Smrg 2596c27c18e8Smrg 2597c27c18e8Smrg# func_source file 2598c27c18e8Smrg# Source FILE, adding directory component if necessary. 2599c27c18e8Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600c27c18e8Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601c27c18e8Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 260244584a44Smrg# 'FILE.' does not work on cygwin managed mounts. 2603c27c18e8Smrgfunc_source () 2604c27c18e8Smrg{ 260544584a44Smrg $debug_cmd 260644584a44Smrg 2607c27c18e8Smrg case $1 in 2608c27c18e8Smrg */* | *\\*) . "$1" ;; 2609c27c18e8Smrg *) . "./$1" ;; 2610c27c18e8Smrg esac 2611c27c18e8Smrg} 2612c27c18e8Smrg 2613c27c18e8Smrg 2614b789ec8aSmrg# func_resolve_sysroot PATH 2615b789ec8aSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2616b789ec8aSmrg# func_resolve_sysroot_result 2617b789ec8aSmrgfunc_resolve_sysroot () 2618b789ec8aSmrg{ 2619b789ec8aSmrg func_resolve_sysroot_result=$1 2620b789ec8aSmrg case $func_resolve_sysroot_result in 2621b789ec8aSmrg =*) 2622b789ec8aSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623b789ec8aSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624b789ec8aSmrg ;; 2625b789ec8aSmrg esac 2626b789ec8aSmrg} 2627b789ec8aSmrg 2628b789ec8aSmrg# func_replace_sysroot PATH 2629b789ec8aSmrg# If PATH begins with the sysroot, replace it with = and 2630b789ec8aSmrg# store the result into func_replace_sysroot_result. 2631b789ec8aSmrgfunc_replace_sysroot () 2632b789ec8aSmrg{ 263344584a44Smrg case $lt_sysroot:$1 in 2634b789ec8aSmrg ?*:"$lt_sysroot"*) 2635b789ec8aSmrg func_stripname "$lt_sysroot" '' "$1" 263644584a44Smrg func_replace_sysroot_result='='$func_stripname_result 2637b789ec8aSmrg ;; 2638b789ec8aSmrg *) 2639b789ec8aSmrg # Including no sysroot. 2640b789ec8aSmrg func_replace_sysroot_result=$1 2641b789ec8aSmrg ;; 2642b789ec8aSmrg esac 2643b789ec8aSmrg} 2644b789ec8aSmrg 2645c27c18e8Smrg# func_infer_tag arg 2646c27c18e8Smrg# Infer tagged configuration to use if any are available and 2647c27c18e8Smrg# if one wasn't chosen via the "--tag" command line option. 2648c27c18e8Smrg# Only attempt this if the compiler in the base compile 2649c27c18e8Smrg# command doesn't match the default compiler. 2650c27c18e8Smrg# arg is usually of the form 'gcc ...' 2651c27c18e8Smrgfunc_infer_tag () 2652c27c18e8Smrg{ 265344584a44Smrg $debug_cmd 265444584a44Smrg 2655c27c18e8Smrg if test -n "$available_tags" && test -z "$tagname"; then 2656c27c18e8Smrg CC_quoted= 2657c27c18e8Smrg for arg in $CC; do 2658b789ec8aSmrg func_append_quoted CC_quoted "$arg" 2659c27c18e8Smrg done 266037eb1ca1Smrg CC_expanded=`func_echo_all $CC` 266137eb1ca1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662c27c18e8Smrg case $@ in 2663c27c18e8Smrg # Blanks in the command may have been stripped by the calling shell, 2664c27c18e8Smrg # but not from the CC environment variable when configure was run. 266537eb1ca1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266637eb1ca1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667c27c18e8Smrg # Blanks at the start of $base_compile will cause this to fail 2668c27c18e8Smrg # if we don't check for them as well. 2669c27c18e8Smrg *) 2670c27c18e8Smrg for z in $available_tags; do 2671c27c18e8Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672c27c18e8Smrg # Evaluate the configuration. 267344584a44Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674c27c18e8Smrg CC_quoted= 2675c27c18e8Smrg for arg in $CC; do 2676c27c18e8Smrg # Double-quote args containing other shell metacharacters. 2677b789ec8aSmrg func_append_quoted CC_quoted "$arg" 2678c27c18e8Smrg done 267937eb1ca1Smrg CC_expanded=`func_echo_all $CC` 268037eb1ca1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681c27c18e8Smrg case "$@ " in 268237eb1ca1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268337eb1ca1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684c27c18e8Smrg # The compiler in the base compile command matches 2685c27c18e8Smrg # the one in the tagged configuration. 2686c27c18e8Smrg # Assume this is the tagged configuration we want. 2687c27c18e8Smrg tagname=$z 2688c27c18e8Smrg break 2689c27c18e8Smrg ;; 2690c27c18e8Smrg esac 2691c27c18e8Smrg fi 2692c27c18e8Smrg done 2693c27c18e8Smrg # If $tagname still isn't set, then no tagged configuration 2694c27c18e8Smrg # was found and let the user know that the "--tag" command 2695c27c18e8Smrg # line option must be used. 2696c27c18e8Smrg if test -z "$tagname"; then 2697c27c18e8Smrg func_echo "unable to infer tagged configuration" 269844584a44Smrg func_fatal_error "specify a tag with '--tag'" 2699c27c18e8Smrg# else 2700c27c18e8Smrg# func_verbose "using $tagname tagged configuration" 2701c27c18e8Smrg fi 2702c27c18e8Smrg ;; 2703c27c18e8Smrg esac 2704c27c18e8Smrg fi 2705c27c18e8Smrg} 2706c27c18e8Smrg 2707c27c18e8Smrg 2708c27c18e8Smrg 2709b789ec8aSmrg# func_write_libtool_object output_name pic_name nonpic_name 2710b789ec8aSmrg# Create a libtool object file (analogous to a ".la" file), 2711b789ec8aSmrg# but don't create it if we're doing a dry run. 2712b789ec8aSmrgfunc_write_libtool_object () 2713b789ec8aSmrg{ 271444584a44Smrg write_libobj=$1 271544584a44Smrg if test yes = "$build_libtool_libs"; then 271644584a44Smrg write_lobj=\'$2\' 2717b789ec8aSmrg else 2718b789ec8aSmrg write_lobj=none 2719b789ec8aSmrg fi 2720b789ec8aSmrg 272144584a44Smrg if test yes = "$build_old_libs"; then 272244584a44Smrg write_oldobj=\'$3\' 2723b789ec8aSmrg else 2724b789ec8aSmrg write_oldobj=none 2725b789ec8aSmrg fi 2726b789ec8aSmrg 2727b789ec8aSmrg $opt_dry_run || { 2728b789ec8aSmrg cat >${write_libobj}T <<EOF 2729b789ec8aSmrg# $write_libobj - a libtool object file 273044584a44Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731b789ec8aSmrg# 2732b789ec8aSmrg# Please DO NOT delete this file! 2733b789ec8aSmrg# It is necessary for linking the library. 2734b789ec8aSmrg 2735b789ec8aSmrg# Name of the PIC object. 2736b789ec8aSmrgpic_object=$write_lobj 2737b789ec8aSmrg 2738b789ec8aSmrg# Name of the non-PIC object 2739b789ec8aSmrgnon_pic_object=$write_oldobj 2740b789ec8aSmrg 2741b789ec8aSmrgEOF 274244584a44Smrg $MV "${write_libobj}T" "$write_libobj" 2743b789ec8aSmrg } 2744b789ec8aSmrg} 2745b789ec8aSmrg 2746b789ec8aSmrg 2747b789ec8aSmrg################################################## 2748b789ec8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749b789ec8aSmrg################################################## 2750b789ec8aSmrg 2751b789ec8aSmrg# func_convert_core_file_wine_to_w32 ARG 2752b789ec8aSmrg# Helper function used by file name conversion functions when $build is *nix, 2753b789ec8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754b789ec8aSmrg# correctly configured wine environment available, with the winepath program 2755b789ec8aSmrg# in $build's $PATH. 2756b789ec8aSmrg# 2757b789ec8aSmrg# ARG is the $build file name to be converted to w32 format. 2758b789ec8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759b789ec8aSmrg# be empty on error (or when ARG is empty) 2760b789ec8aSmrgfunc_convert_core_file_wine_to_w32 () 2761b789ec8aSmrg{ 276244584a44Smrg $debug_cmd 276344584a44Smrg 276444584a44Smrg func_convert_core_file_wine_to_w32_result=$1 2765b789ec8aSmrg if test -n "$1"; then 2766b789ec8aSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767b789ec8aSmrg # are forced to check the contents of stdout. On the other hand, if the 2768b789ec8aSmrg # command is not found, the shell will set an exit code of 127 and print 2769b789ec8aSmrg # *an error message* to stdout. So we must check for both error code of 2770b789ec8aSmrg # zero AND non-empty stdout, which explains the odd construction: 2771b789ec8aSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 277244584a44Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773b789ec8aSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 277444584a44Smrg $SED -e "$sed_naive_backslashify"` 2775b789ec8aSmrg else 2776b789ec8aSmrg func_convert_core_file_wine_to_w32_result= 2777b789ec8aSmrg fi 2778b789ec8aSmrg fi 2779b789ec8aSmrg} 2780b789ec8aSmrg# end: func_convert_core_file_wine_to_w32 2781b789ec8aSmrg 2782b789ec8aSmrg 2783b789ec8aSmrg# func_convert_core_path_wine_to_w32 ARG 2784b789ec8aSmrg# Helper function used by path conversion functions when $build is *nix, and 2785b789ec8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786b789ec8aSmrg# configured wine environment available, with the winepath program in $build's 2787b789ec8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788b789ec8aSmrg# 2789b789ec8aSmrg# ARG is path to be converted from $build format to win32. 2790b789ec8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791b789ec8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792b789ec8aSmrg# are convertible, then the result may be empty. 2793b789ec8aSmrgfunc_convert_core_path_wine_to_w32 () 2794b789ec8aSmrg{ 279544584a44Smrg $debug_cmd 279644584a44Smrg 2797b789ec8aSmrg # unfortunately, winepath doesn't convert paths, only file names 279844584a44Smrg func_convert_core_path_wine_to_w32_result= 2799b789ec8aSmrg if test -n "$1"; then 2800b789ec8aSmrg oldIFS=$IFS 2801b789ec8aSmrg IFS=: 2802b789ec8aSmrg for func_convert_core_path_wine_to_w32_f in $1; do 2803b789ec8aSmrg IFS=$oldIFS 2804b789ec8aSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 280544584a44Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806b789ec8aSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 280744584a44Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808b789ec8aSmrg else 2809b789ec8aSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810b789ec8aSmrg fi 2811b789ec8aSmrg fi 2812b789ec8aSmrg done 2813b789ec8aSmrg IFS=$oldIFS 2814b789ec8aSmrg fi 2815b789ec8aSmrg} 2816b789ec8aSmrg# end: func_convert_core_path_wine_to_w32 2817b789ec8aSmrg 2818b789ec8aSmrg 2819b789ec8aSmrg# func_cygpath ARGS... 2820b789ec8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821b789ec8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822b789ec8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823b789ec8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824b789ec8aSmrg# file name or path is assumed to be in w32 format, as previously converted 2825b789ec8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826b789ec8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827b789ec8aSmrg# Cygwin format). Returns an empty string on error. 2828b789ec8aSmrg# 2829b789ec8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830b789ec8aSmrg# be converted. 2831b789ec8aSmrg# 2832b789ec8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833b789ec8aSmrg# environment variable; do not put it in $PATH. 2834b789ec8aSmrgfunc_cygpath () 2835b789ec8aSmrg{ 283644584a44Smrg $debug_cmd 283744584a44Smrg 2838b789ec8aSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839b789ec8aSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840b789ec8aSmrg if test "$?" -ne 0; then 2841b789ec8aSmrg # on failure, ensure result is empty 2842b789ec8aSmrg func_cygpath_result= 2843b789ec8aSmrg fi 2844b789ec8aSmrg else 2845b789ec8aSmrg func_cygpath_result= 284644584a44Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847b789ec8aSmrg fi 2848b789ec8aSmrg} 2849b789ec8aSmrg#end: func_cygpath 2850b789ec8aSmrg 2851b789ec8aSmrg 2852b789ec8aSmrg# func_convert_core_msys_to_w32 ARG 2853b789ec8aSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854b789ec8aSmrg# result in func_convert_core_msys_to_w32_result. 2855b789ec8aSmrgfunc_convert_core_msys_to_w32 () 2856b789ec8aSmrg{ 285744584a44Smrg $debug_cmd 285844584a44Smrg 2859b789ec8aSmrg # awkward: cmd appends spaces to result 2860b789ec8aSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 286144584a44Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862b789ec8aSmrg} 2863b789ec8aSmrg#end: func_convert_core_msys_to_w32 2864b789ec8aSmrg 2865b789ec8aSmrg 2866b789ec8aSmrg# func_convert_file_check ARG1 ARG2 2867b789ec8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868b789ec8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869b789ec8aSmrg# func_to_host_file_result to ARG1). 2870b789ec8aSmrgfunc_convert_file_check () 2871b789ec8aSmrg{ 287244584a44Smrg $debug_cmd 287344584a44Smrg 287444584a44Smrg if test -z "$2" && test -n "$1"; then 2875b789ec8aSmrg func_error "Could not determine host file name corresponding to" 287644584a44Smrg func_error " '$1'" 2877b789ec8aSmrg func_error "Continuing, but uninstalled executables may not work." 2878b789ec8aSmrg # Fallback: 287944584a44Smrg func_to_host_file_result=$1 2880b789ec8aSmrg fi 2881b789ec8aSmrg} 2882b789ec8aSmrg# end func_convert_file_check 2883b789ec8aSmrg 2884b789ec8aSmrg 2885b789ec8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886b789ec8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887b789ec8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888b789ec8aSmrg# func_to_host_file_result to a simplistic fallback value (see below). 2889b789ec8aSmrgfunc_convert_path_check () 2890b789ec8aSmrg{ 289144584a44Smrg $debug_cmd 289244584a44Smrg 2893b789ec8aSmrg if test -z "$4" && test -n "$3"; then 2894b789ec8aSmrg func_error "Could not determine the host path corresponding to" 289544584a44Smrg func_error " '$3'" 2896b789ec8aSmrg func_error "Continuing, but uninstalled executables may not work." 2897b789ec8aSmrg # Fallback. This is a deliberately simplistic "conversion" and 2898b789ec8aSmrg # should not be "improved". See libtool.info. 2899b789ec8aSmrg if test "x$1" != "x$2"; then 2900b789ec8aSmrg lt_replace_pathsep_chars="s|$1|$2|g" 2901b789ec8aSmrg func_to_host_path_result=`echo "$3" | 2902b789ec8aSmrg $SED -e "$lt_replace_pathsep_chars"` 2903b789ec8aSmrg else 290444584a44Smrg func_to_host_path_result=$3 2905b789ec8aSmrg fi 2906b789ec8aSmrg fi 2907b789ec8aSmrg} 2908b789ec8aSmrg# end func_convert_path_check 2909b789ec8aSmrg 2910b789ec8aSmrg 2911b789ec8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912b789ec8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913b789ec8aSmrg# and appending REPL if ORIG matches BACKPAT. 2914b789ec8aSmrgfunc_convert_path_front_back_pathsep () 2915b789ec8aSmrg{ 291644584a44Smrg $debug_cmd 291744584a44Smrg 2918b789ec8aSmrg case $4 in 291944584a44Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920b789ec8aSmrg ;; 2921b789ec8aSmrg esac 2922b789ec8aSmrg case $4 in 2923b789ec8aSmrg $2 ) func_append func_to_host_path_result "$3" 2924b789ec8aSmrg ;; 2925b789ec8aSmrg esac 2926b789ec8aSmrg} 2927b789ec8aSmrg# end func_convert_path_front_back_pathsep 2928b789ec8aSmrg 2929b789ec8aSmrg 2930b789ec8aSmrg################################################## 2931b789ec8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932b789ec8aSmrg################################################## 293344584a44Smrg# invoked via '$to_host_file_cmd ARG' 2934b789ec8aSmrg# 2935b789ec8aSmrg# In each case, ARG is the path to be converted from $build to $host format. 2936b789ec8aSmrg# Result will be available in $func_to_host_file_result. 2937b789ec8aSmrg 2938b789ec8aSmrg 2939b789ec8aSmrg# func_to_host_file ARG 2940b789ec8aSmrg# Converts the file name ARG from $build format to $host format. Return result 2941b789ec8aSmrg# in func_to_host_file_result. 2942b789ec8aSmrgfunc_to_host_file () 2943b789ec8aSmrg{ 294444584a44Smrg $debug_cmd 294544584a44Smrg 2946b789ec8aSmrg $to_host_file_cmd "$1" 2947b789ec8aSmrg} 2948b789ec8aSmrg# end func_to_host_file 2949b789ec8aSmrg 2950b789ec8aSmrg 2951b789ec8aSmrg# func_to_tool_file ARG LAZY 2952b789ec8aSmrg# converts the file name ARG from $build format to toolchain format. Return 2953b789ec8aSmrg# result in func_to_tool_file_result. If the conversion in use is listed 2954b789ec8aSmrg# in (the comma separated) LAZY, no conversion takes place. 2955b789ec8aSmrgfunc_to_tool_file () 2956b789ec8aSmrg{ 295744584a44Smrg $debug_cmd 295844584a44Smrg 2959b789ec8aSmrg case ,$2, in 2960b789ec8aSmrg *,"$to_tool_file_cmd",*) 2961b789ec8aSmrg func_to_tool_file_result=$1 2962b789ec8aSmrg ;; 2963b789ec8aSmrg *) 2964b789ec8aSmrg $to_tool_file_cmd "$1" 2965b789ec8aSmrg func_to_tool_file_result=$func_to_host_file_result 2966b789ec8aSmrg ;; 2967b789ec8aSmrg esac 2968b789ec8aSmrg} 2969b789ec8aSmrg# end func_to_tool_file 2970b789ec8aSmrg 2971b789ec8aSmrg 2972b789ec8aSmrg# func_convert_file_noop ARG 2973b789ec8aSmrg# Copy ARG to func_to_host_file_result. 2974b789ec8aSmrgfunc_convert_file_noop () 2975b789ec8aSmrg{ 297644584a44Smrg func_to_host_file_result=$1 2977b789ec8aSmrg} 2978b789ec8aSmrg# end func_convert_file_noop 2979b789ec8aSmrg 2980b789ec8aSmrg 2981b789ec8aSmrg# func_convert_file_msys_to_w32 ARG 2982b789ec8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983b789ec8aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984b789ec8aSmrg# func_to_host_file_result. 2985b789ec8aSmrgfunc_convert_file_msys_to_w32 () 2986b789ec8aSmrg{ 298744584a44Smrg $debug_cmd 298844584a44Smrg 298944584a44Smrg func_to_host_file_result=$1 2990b789ec8aSmrg if test -n "$1"; then 2991b789ec8aSmrg func_convert_core_msys_to_w32 "$1" 299244584a44Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993b789ec8aSmrg fi 2994b789ec8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 2995b789ec8aSmrg} 2996b789ec8aSmrg# end func_convert_file_msys_to_w32 2997b789ec8aSmrg 2998b789ec8aSmrg 2999b789ec8aSmrg# func_convert_file_cygwin_to_w32 ARG 3000b789ec8aSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001b789ec8aSmrg# func_to_host_file_result. 3002b789ec8aSmrgfunc_convert_file_cygwin_to_w32 () 3003b789ec8aSmrg{ 300444584a44Smrg $debug_cmd 300544584a44Smrg 300644584a44Smrg func_to_host_file_result=$1 3007b789ec8aSmrg if test -n "$1"; then 3008b789ec8aSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009b789ec8aSmrg # LT_CYGPATH in this case. 3010b789ec8aSmrg func_to_host_file_result=`cygpath -m "$1"` 3011b789ec8aSmrg fi 3012b789ec8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3013b789ec8aSmrg} 3014b789ec8aSmrg# end func_convert_file_cygwin_to_w32 3015b789ec8aSmrg 3016b789ec8aSmrg 3017b789ec8aSmrg# func_convert_file_nix_to_w32 ARG 3018b789ec8aSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019b789ec8aSmrg# and a working winepath. Returns result in func_to_host_file_result. 3020b789ec8aSmrgfunc_convert_file_nix_to_w32 () 3021b789ec8aSmrg{ 302244584a44Smrg $debug_cmd 302344584a44Smrg 302444584a44Smrg func_to_host_file_result=$1 3025b789ec8aSmrg if test -n "$1"; then 3026b789ec8aSmrg func_convert_core_file_wine_to_w32 "$1" 302744584a44Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028b789ec8aSmrg fi 3029b789ec8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3030b789ec8aSmrg} 3031b789ec8aSmrg# end func_convert_file_nix_to_w32 3032b789ec8aSmrg 3033b789ec8aSmrg 3034b789ec8aSmrg# func_convert_file_msys_to_cygwin ARG 3035b789ec8aSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036b789ec8aSmrg# Returns result in func_to_host_file_result. 3037b789ec8aSmrgfunc_convert_file_msys_to_cygwin () 3038b789ec8aSmrg{ 303944584a44Smrg $debug_cmd 304044584a44Smrg 304144584a44Smrg func_to_host_file_result=$1 3042b789ec8aSmrg if test -n "$1"; then 3043b789ec8aSmrg func_convert_core_msys_to_w32 "$1" 3044b789ec8aSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 304544584a44Smrg func_to_host_file_result=$func_cygpath_result 3046b789ec8aSmrg fi 3047b789ec8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3048b789ec8aSmrg} 3049b789ec8aSmrg# end func_convert_file_msys_to_cygwin 3050b789ec8aSmrg 3051b789ec8aSmrg 3052b789ec8aSmrg# func_convert_file_nix_to_cygwin ARG 3053b789ec8aSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054b789ec8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055b789ec8aSmrg# in func_to_host_file_result. 3056b789ec8aSmrgfunc_convert_file_nix_to_cygwin () 3057b789ec8aSmrg{ 305844584a44Smrg $debug_cmd 305944584a44Smrg 306044584a44Smrg func_to_host_file_result=$1 3061b789ec8aSmrg if test -n "$1"; then 3062b789ec8aSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063b789ec8aSmrg func_convert_core_file_wine_to_w32 "$1" 3064b789ec8aSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 306544584a44Smrg func_to_host_file_result=$func_cygpath_result 3066b789ec8aSmrg fi 3067b789ec8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3068b789ec8aSmrg} 3069b789ec8aSmrg# end func_convert_file_nix_to_cygwin 3070b789ec8aSmrg 3071b789ec8aSmrg 3072b789ec8aSmrg############################################# 3073b789ec8aSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3074b789ec8aSmrg############################################# 307544584a44Smrg# invoked via '$to_host_path_cmd ARG' 3076b789ec8aSmrg# 3077b789ec8aSmrg# In each case, ARG is the path to be converted from $build to $host format. 3078b789ec8aSmrg# The result will be available in $func_to_host_path_result. 3079b789ec8aSmrg# 3080b789ec8aSmrg# Path separators are also converted from $build format to $host format. If 3081b789ec8aSmrg# ARG begins or ends with a path separator character, it is preserved (but 3082b789ec8aSmrg# converted to $host format) on output. 3083b789ec8aSmrg# 3084b789ec8aSmrg# All path conversion functions are named using the following convention: 3085b789ec8aSmrg# file name conversion function : func_convert_file_X_to_Y () 3086b789ec8aSmrg# path conversion function : func_convert_path_X_to_Y () 3087b789ec8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088b789ec8aSmrg# same. If conversion functions are added for new $build/$host combinations, 3089b789ec8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090b789ec8aSmrg# will break. 3091b789ec8aSmrg 3092b789ec8aSmrg 3093b789ec8aSmrg# func_init_to_host_path_cmd 3094b789ec8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095b789ec8aSmrg# appropriate value, based on the value of $to_host_file_cmd. 3096b789ec8aSmrgto_host_path_cmd= 3097b789ec8aSmrgfunc_init_to_host_path_cmd () 3098b789ec8aSmrg{ 309944584a44Smrg $debug_cmd 310044584a44Smrg 3101b789ec8aSmrg if test -z "$to_host_path_cmd"; then 3102b789ec8aSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 310344584a44Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104b789ec8aSmrg fi 3105b789ec8aSmrg} 3106b789ec8aSmrg 3107b789ec8aSmrg 3108b789ec8aSmrg# func_to_host_path ARG 3109b789ec8aSmrg# Converts the path ARG from $build format to $host format. Return result 3110b789ec8aSmrg# in func_to_host_path_result. 3111b789ec8aSmrgfunc_to_host_path () 3112b789ec8aSmrg{ 311344584a44Smrg $debug_cmd 311444584a44Smrg 3115b789ec8aSmrg func_init_to_host_path_cmd 3116b789ec8aSmrg $to_host_path_cmd "$1" 3117b789ec8aSmrg} 3118b789ec8aSmrg# end func_to_host_path 3119b789ec8aSmrg 3120b789ec8aSmrg 3121b789ec8aSmrg# func_convert_path_noop ARG 3122b789ec8aSmrg# Copy ARG to func_to_host_path_result. 3123b789ec8aSmrgfunc_convert_path_noop () 3124b789ec8aSmrg{ 312544584a44Smrg func_to_host_path_result=$1 3126b789ec8aSmrg} 3127b789ec8aSmrg# end func_convert_path_noop 3128b789ec8aSmrg 3129b789ec8aSmrg 3130b789ec8aSmrg# func_convert_path_msys_to_w32 ARG 3131b789ec8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132b789ec8aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133b789ec8aSmrg# func_to_host_path_result. 3134b789ec8aSmrgfunc_convert_path_msys_to_w32 () 3135c27c18e8Smrg{ 313644584a44Smrg $debug_cmd 313744584a44Smrg 313844584a44Smrg func_to_host_path_result=$1 3139b789ec8aSmrg if test -n "$1"; then 3140b789ec8aSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3141b789ec8aSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142b789ec8aSmrg # and winepath ignores them completely. 3143b789ec8aSmrg func_stripname : : "$1" 3144b789ec8aSmrg func_to_host_path_tmp1=$func_stripname_result 3145b789ec8aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 314644584a44Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147b789ec8aSmrg func_convert_path_check : ";" \ 3148b789ec8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149b789ec8aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150b789ec8aSmrg fi 3151b789ec8aSmrg} 3152b789ec8aSmrg# end func_convert_path_msys_to_w32 3153c27c18e8Smrg 3154c27c18e8Smrg 3155b789ec8aSmrg# func_convert_path_cygwin_to_w32 ARG 3156b789ec8aSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157b789ec8aSmrg# func_to_host_file_result. 3158b789ec8aSmrgfunc_convert_path_cygwin_to_w32 () 3159b789ec8aSmrg{ 316044584a44Smrg $debug_cmd 316144584a44Smrg 316244584a44Smrg func_to_host_path_result=$1 3163b789ec8aSmrg if test -n "$1"; then 3164b789ec8aSmrg # See func_convert_path_msys_to_w32: 3165b789ec8aSmrg func_stripname : : "$1" 3166b789ec8aSmrg func_to_host_path_tmp1=$func_stripname_result 3167b789ec8aSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168b789ec8aSmrg func_convert_path_check : ";" \ 3169b789ec8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170b789ec8aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171b789ec8aSmrg fi 3172b789ec8aSmrg} 3173b789ec8aSmrg# end func_convert_path_cygwin_to_w32 3174c27c18e8Smrg 3175c27c18e8Smrg 3176b789ec8aSmrg# func_convert_path_nix_to_w32 ARG 3177b789ec8aSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178b789ec8aSmrg# a working winepath. Returns result in func_to_host_file_result. 3179b789ec8aSmrgfunc_convert_path_nix_to_w32 () 3180b789ec8aSmrg{ 318144584a44Smrg $debug_cmd 318244584a44Smrg 318344584a44Smrg func_to_host_path_result=$1 3184b789ec8aSmrg if test -n "$1"; then 3185b789ec8aSmrg # See func_convert_path_msys_to_w32: 3186b789ec8aSmrg func_stripname : : "$1" 3187b789ec8aSmrg func_to_host_path_tmp1=$func_stripname_result 3188b789ec8aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 318944584a44Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190b789ec8aSmrg func_convert_path_check : ";" \ 3191b789ec8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192b789ec8aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193b789ec8aSmrg fi 3194b789ec8aSmrg} 3195b789ec8aSmrg# end func_convert_path_nix_to_w32 3196c27c18e8Smrg 3197b789ec8aSmrg 3198b789ec8aSmrg# func_convert_path_msys_to_cygwin ARG 3199b789ec8aSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200b789ec8aSmrg# Returns result in func_to_host_file_result. 3201b789ec8aSmrgfunc_convert_path_msys_to_cygwin () 3202b789ec8aSmrg{ 320344584a44Smrg $debug_cmd 320444584a44Smrg 320544584a44Smrg func_to_host_path_result=$1 3206b789ec8aSmrg if test -n "$1"; then 3207b789ec8aSmrg # See func_convert_path_msys_to_w32: 3208b789ec8aSmrg func_stripname : : "$1" 3209b789ec8aSmrg func_to_host_path_tmp1=$func_stripname_result 3210b789ec8aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211b789ec8aSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 321244584a44Smrg func_to_host_path_result=$func_cygpath_result 3213b789ec8aSmrg func_convert_path_check : : \ 3214b789ec8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215b789ec8aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216b789ec8aSmrg fi 3217b789ec8aSmrg} 3218b789ec8aSmrg# end func_convert_path_msys_to_cygwin 3219b789ec8aSmrg 3220b789ec8aSmrg 3221b789ec8aSmrg# func_convert_path_nix_to_cygwin ARG 3222b789ec8aSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223b789ec8aSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224b789ec8aSmrg# func_to_host_file_result. 3225b789ec8aSmrgfunc_convert_path_nix_to_cygwin () 3226b789ec8aSmrg{ 322744584a44Smrg $debug_cmd 322844584a44Smrg 322944584a44Smrg func_to_host_path_result=$1 3230b789ec8aSmrg if test -n "$1"; then 3231b789ec8aSmrg # Remove leading and trailing path separator characters from 3232b789ec8aSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233b789ec8aSmrg # into '.;' and ';.', and winepath ignores them completely. 3234b789ec8aSmrg func_stripname : : "$1" 3235b789ec8aSmrg func_to_host_path_tmp1=$func_stripname_result 3236b789ec8aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237b789ec8aSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 323844584a44Smrg func_to_host_path_result=$func_cygpath_result 3239b789ec8aSmrg func_convert_path_check : : \ 3240b789ec8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241b789ec8aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242b789ec8aSmrg fi 3243c27c18e8Smrg} 3244b789ec8aSmrg# end func_convert_path_nix_to_cygwin 3245b789ec8aSmrg 3246c27c18e8Smrg 324744584a44Smrg# func_dll_def_p FILE 324844584a44Smrg# True iff FILE is a Windows DLL '.def' file. 324944584a44Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 325044584a44Smrgfunc_dll_def_p () 325144584a44Smrg{ 325244584a44Smrg $debug_cmd 325344584a44Smrg 325444584a44Smrg func_dll_def_p_tmp=`$SED -n \ 325544584a44Smrg -e 's/^[ ]*//' \ 325644584a44Smrg -e '/^\(;.*\)*$/d' \ 325744584a44Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 325844584a44Smrg -e q \ 325944584a44Smrg "$1"` 326044584a44Smrg test DEF = "$func_dll_def_p_tmp" 326144584a44Smrg} 326244584a44Smrg 326344584a44Smrg 3264c27c18e8Smrg# func_mode_compile arg... 3265c27c18e8Smrgfunc_mode_compile () 3266c27c18e8Smrg{ 326744584a44Smrg $debug_cmd 326844584a44Smrg 3269c27c18e8Smrg # Get the compilation command and the source file. 3270c27c18e8Smrg base_compile= 327144584a44Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272c27c18e8Smrg suppress_opt=yes 3273c27c18e8Smrg suppress_output= 3274c27c18e8Smrg arg_mode=normal 3275c27c18e8Smrg libobj= 3276c27c18e8Smrg later= 3277c27c18e8Smrg pie_flag= 3278c27c18e8Smrg 3279c27c18e8Smrg for arg 3280c27c18e8Smrg do 3281c27c18e8Smrg case $arg_mode in 3282c27c18e8Smrg arg ) 3283c27c18e8Smrg # do not "continue". Instead, add this to base_compile 328444584a44Smrg lastarg=$arg 3285c27c18e8Smrg arg_mode=normal 3286c27c18e8Smrg ;; 3287c27c18e8Smrg 3288c27c18e8Smrg target ) 328944584a44Smrg libobj=$arg 3290c27c18e8Smrg arg_mode=normal 3291c27c18e8Smrg continue 3292c27c18e8Smrg ;; 3293c27c18e8Smrg 3294c27c18e8Smrg normal ) 3295c27c18e8Smrg # Accept any command-line options. 3296c27c18e8Smrg case $arg in 3297c27c18e8Smrg -o) 3298c27c18e8Smrg test -n "$libobj" && \ 329944584a44Smrg func_fatal_error "you cannot specify '-o' more than once" 3300c27c18e8Smrg arg_mode=target 3301c27c18e8Smrg continue 3302c27c18e8Smrg ;; 3303c27c18e8Smrg 3304c27c18e8Smrg -pie | -fpie | -fPIE) 3305b789ec8aSmrg func_append pie_flag " $arg" 3306c27c18e8Smrg continue 3307c27c18e8Smrg ;; 3308c27c18e8Smrg 3309c27c18e8Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310b789ec8aSmrg func_append later " $arg" 3311c27c18e8Smrg continue 3312c27c18e8Smrg ;; 3313c27c18e8Smrg 3314c27c18e8Smrg -no-suppress) 3315c43cc173Smrg suppress_opt=no 3316c43cc173Smrg continue 3317c43cc173Smrg ;; 3318c43cc173Smrg 3319c43cc173Smrg -Xcompiler) 3320c43cc173Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321c43cc173Smrg continue # The current "srcfile" will either be retained or 3322c43cc173Smrg ;; # replaced later. I would guess that would be a bug. 3323c43cc173Smrg 3324c43cc173Smrg -Wc,*) 3325c27c18e8Smrg func_stripname '-Wc,' '' "$arg" 3326c27c18e8Smrg args=$func_stripname_result 3327c43cc173Smrg lastarg= 332844584a44Smrg save_ifs=$IFS; IFS=, 3329c27c18e8Smrg for arg in $args; do 333044584a44Smrg IFS=$save_ifs 3331b789ec8aSmrg func_append_quoted lastarg "$arg" 3332c43cc173Smrg done 333344584a44Smrg IFS=$save_ifs 3334c27c18e8Smrg func_stripname ' ' '' "$lastarg" 3335c27c18e8Smrg lastarg=$func_stripname_result 3336c43cc173Smrg 3337c43cc173Smrg # Add the arguments to base_compile. 3338b789ec8aSmrg func_append base_compile " $lastarg" 3339c43cc173Smrg continue 3340c43cc173Smrg ;; 3341c43cc173Smrg 3342c27c18e8Smrg *) 3343c43cc173Smrg # Accept the current argument as the source file. 3344c43cc173Smrg # The previous "srcfile" becomes the current argument. 3345c43cc173Smrg # 334644584a44Smrg lastarg=$srcfile 334744584a44Smrg srcfile=$arg 3348c43cc173Smrg ;; 3349c43cc173Smrg esac # case $arg 3350c43cc173Smrg ;; 3351c43cc173Smrg esac # case $arg_mode 3352c43cc173Smrg 3353c43cc173Smrg # Aesthetically quote the previous argument. 3354b789ec8aSmrg func_append_quoted base_compile "$lastarg" 3355c43cc173Smrg done # for arg 3356c43cc173Smrg 3357c43cc173Smrg case $arg_mode in 3358c43cc173Smrg arg) 3359c27c18e8Smrg func_fatal_error "you must specify an argument for -Xcompile" 3360c43cc173Smrg ;; 3361c43cc173Smrg target) 336244584a44Smrg func_fatal_error "you must specify a target with '-o'" 3363c43cc173Smrg ;; 3364c43cc173Smrg *) 3365c43cc173Smrg # Get the name of the library object. 3366c27c18e8Smrg test -z "$libobj" && { 3367c27c18e8Smrg func_basename "$srcfile" 336844584a44Smrg libobj=$func_basename_result 3369c27c18e8Smrg } 3370c43cc173Smrg ;; 3371c43cc173Smrg esac 3372c43cc173Smrg 3373c43cc173Smrg # Recognize several different file suffixes. 3374c43cc173Smrg # If the user specifies -o file.o, it is replaced with file.lo 3375c43cc173Smrg case $libobj in 3376c27c18e8Smrg *.[cCFSifmso] | \ 3377c27c18e8Smrg *.ada | *.adb | *.ads | *.asm | \ 3378c27c18e8Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379f1ee322dSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380c27c18e8Smrg func_xform "$libobj" 3381c27c18e8Smrg libobj=$func_xform_result 3382c27c18e8Smrg ;; 3383c43cc173Smrg esac 3384c43cc173Smrg 3385c43cc173Smrg case $libobj in 3386c27c18e8Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387c43cc173Smrg *) 338844584a44Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389c43cc173Smrg ;; 3390c43cc173Smrg esac 3391c43cc173Smrg 3392c43cc173Smrg func_infer_tag $base_compile 3393c43cc173Smrg 3394c43cc173Smrg for arg in $later; do 3395c43cc173Smrg case $arg in 3396c27c18e8Smrg -shared) 339744584a44Smrg test yes = "$build_libtool_libs" \ 339844584a44Smrg || func_fatal_configuration "cannot build a shared library" 3399c27c18e8Smrg build_old_libs=no 3400c27c18e8Smrg continue 3401c27c18e8Smrg ;; 3402c27c18e8Smrg 3403c43cc173Smrg -static) 3404c27c18e8Smrg build_libtool_libs=no 3405c43cc173Smrg build_old_libs=yes 3406c43cc173Smrg continue 3407c43cc173Smrg ;; 3408c43cc173Smrg 3409c43cc173Smrg -prefer-pic) 3410c43cc173Smrg pic_mode=yes 3411c43cc173Smrg continue 3412c43cc173Smrg ;; 3413c43cc173Smrg 3414c43cc173Smrg -prefer-non-pic) 3415c43cc173Smrg pic_mode=no 3416c43cc173Smrg continue 3417c43cc173Smrg ;; 3418c43cc173Smrg esac 3419c43cc173Smrg done 3420c43cc173Smrg 3421c27c18e8Smrg func_quote_for_eval "$libobj" 3422c27c18e8Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423c27c18e8Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 342444584a44Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425c27c18e8Smrg func_dirname_and_basename "$obj" "/" "" 342644584a44Smrg objname=$func_basename_result 342744584a44Smrg xdir=$func_dirname_result 342844584a44Smrg lobj=$xdir$objdir/$objname 3429c43cc173Smrg 3430c27c18e8Smrg test -z "$base_compile" && \ 3431c27c18e8Smrg func_fatal_help "you must specify a compilation command" 3432c43cc173Smrg 3433c43cc173Smrg # Delete any leftover library objects. 343444584a44Smrg if test yes = "$build_old_libs"; then 3435c43cc173Smrg removelist="$obj $lobj $libobj ${libobj}T" 3436c43cc173Smrg else 3437c43cc173Smrg removelist="$lobj $libobj ${libobj}T" 3438c43cc173Smrg fi 3439c43cc173Smrg 3440c43cc173Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441c43cc173Smrg case $host_os in 3442c27c18e8Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443c43cc173Smrg pic_mode=default 3444c43cc173Smrg ;; 3445c43cc173Smrg esac 344644584a44Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447c43cc173Smrg # non-PIC code in shared libraries is not supported 3448c43cc173Smrg pic_mode=default 3449c43cc173Smrg fi 3450c43cc173Smrg 3451c43cc173Smrg # Calculate the filename of the output object if compiler does 3452c43cc173Smrg # not support -o with -c 345344584a44Smrg if test no = "$compiler_c_o"; then 345444584a44Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 345544584a44Smrg lockfile=$output_obj.lock 3456c43cc173Smrg else 3457c43cc173Smrg output_obj= 3458c43cc173Smrg need_locks=no 3459c43cc173Smrg lockfile= 3460c43cc173Smrg fi 3461c43cc173Smrg 3462c43cc173Smrg # Lock this critical section if it is needed 3463c43cc173Smrg # We use this script file to make the link, it avoids creating a new file 346444584a44Smrg if test yes = "$need_locks"; then 3465c27c18e8Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466c27c18e8Smrg func_echo "Waiting for $lockfile to be removed" 3467c43cc173Smrg sleep 2 3468c43cc173Smrg done 346944584a44Smrg elif test warn = "$need_locks"; then 3470c43cc173Smrg if test -f "$lockfile"; then 3471c27c18e8Smrg $ECHO "\ 3472c43cc173Smrg*** ERROR, $lockfile exists and contains: 3473c43cc173Smrg`cat $lockfile 2>/dev/null` 3474c43cc173Smrg 3475c43cc173SmrgThis indicates that another process is trying to use the same 3476c43cc173Smrgtemporary object file, and libtool could not work around it because 347744584a44Smrgyour compiler does not support '-c' and '-o' together. If you 3478c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better 3479c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better 3480c43cc173Smrgcompiler." 3481c43cc173Smrg 3482c27c18e8Smrg $opt_dry_run || $RM $removelist 3483c43cc173Smrg exit $EXIT_FAILURE 3484c43cc173Smrg fi 3485b789ec8aSmrg func_append removelist " $output_obj" 3486c27c18e8Smrg $ECHO "$srcfile" > "$lockfile" 3487c43cc173Smrg fi 3488c43cc173Smrg 3489c27c18e8Smrg $opt_dry_run || $RM $removelist 3490b789ec8aSmrg func_append removelist " $lockfile" 3491c27c18e8Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492c27c18e8Smrg 3493b789ec8aSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494b789ec8aSmrg srcfile=$func_to_tool_file_result 3495c27c18e8Smrg func_quote_for_eval "$srcfile" 3496c27c18e8Smrg qsrcfile=$func_quote_for_eval_result 3497c43cc173Smrg 3498c43cc173Smrg # Only build a PIC object if we are building libtool libraries. 349944584a44Smrg if test yes = "$build_libtool_libs"; then 3500c43cc173Smrg # Without this assignment, base_compile gets emptied. 3501c43cc173Smrg fbsd_hideous_sh_bug=$base_compile 3502c43cc173Smrg 350344584a44Smrg if test no != "$pic_mode"; then 3504c43cc173Smrg command="$base_compile $qsrcfile $pic_flag" 3505c43cc173Smrg else 3506c43cc173Smrg # Don't build PIC code 3507c43cc173Smrg command="$base_compile $qsrcfile" 3508c43cc173Smrg fi 3509c43cc173Smrg 3510c27c18e8Smrg func_mkdir_p "$xdir$objdir" 3511c43cc173Smrg 3512c43cc173Smrg if test -z "$output_obj"; then 3513c43cc173Smrg # Place PIC objects in $objdir 3514b789ec8aSmrg func_append command " -o $lobj" 3515c43cc173Smrg fi 3516c43cc173Smrg 3517c27c18e8Smrg func_show_eval_locale "$command" \ 3518c27c18e8Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519c43cc173Smrg 352044584a44Smrg if test warn = "$need_locks" && 3521c43cc173Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522c27c18e8Smrg $ECHO "\ 3523c43cc173Smrg*** ERROR, $lockfile contains: 3524c43cc173Smrg`cat $lockfile 2>/dev/null` 3525c43cc173Smrg 3526c43cc173Smrgbut it should contain: 3527c43cc173Smrg$srcfile 3528c43cc173Smrg 3529c43cc173SmrgThis indicates that another process is trying to use the same 3530c43cc173Smrgtemporary object file, and libtool could not work around it because 353144584a44Smrgyour compiler does not support '-c' and '-o' together. If you 3532c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better 3533c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better 3534c43cc173Smrgcompiler." 3535c43cc173Smrg 3536c27c18e8Smrg $opt_dry_run || $RM $removelist 3537c43cc173Smrg exit $EXIT_FAILURE 3538c43cc173Smrg fi 3539c43cc173Smrg 3540c43cc173Smrg # Just move the object if needed, then go on to compile the next one 3541c43cc173Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542c27c18e8Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543c27c18e8Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544c43cc173Smrg fi 3545c43cc173Smrg 3546c43cc173Smrg # Allow error messages only from the first compilation. 354744584a44Smrg if test yes = "$suppress_opt"; then 3548c27c18e8Smrg suppress_output=' >/dev/null 2>&1' 3549c43cc173Smrg fi 3550c43cc173Smrg fi 3551c43cc173Smrg 3552c43cc173Smrg # Only build a position-dependent object if we build old libraries. 355344584a44Smrg if test yes = "$build_old_libs"; then 355444584a44Smrg if test yes != "$pic_mode"; then 3555c43cc173Smrg # Don't build PIC code 3556c27c18e8Smrg command="$base_compile $qsrcfile$pie_flag" 3557c43cc173Smrg else 3558c43cc173Smrg command="$base_compile $qsrcfile $pic_flag" 3559c43cc173Smrg fi 356044584a44Smrg if test yes = "$compiler_c_o"; then 3561b789ec8aSmrg func_append command " -o $obj" 3562c43cc173Smrg fi 3563c43cc173Smrg 3564c43cc173Smrg # Suppress compiler output if we already did a PIC compilation. 3565b789ec8aSmrg func_append command "$suppress_output" 3566c27c18e8Smrg func_show_eval_locale "$command" \ 3567c27c18e8Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568c43cc173Smrg 356944584a44Smrg if test warn = "$need_locks" && 3570c43cc173Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571c27c18e8Smrg $ECHO "\ 3572c43cc173Smrg*** ERROR, $lockfile contains: 3573c43cc173Smrg`cat $lockfile 2>/dev/null` 3574c43cc173Smrg 3575c43cc173Smrgbut it should contain: 3576c43cc173Smrg$srcfile 3577c43cc173Smrg 3578c43cc173SmrgThis indicates that another process is trying to use the same 3579c43cc173Smrgtemporary object file, and libtool could not work around it because 358044584a44Smrgyour compiler does not support '-c' and '-o' together. If you 3581c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better 3582c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better 3583c43cc173Smrgcompiler." 3584c43cc173Smrg 3585c27c18e8Smrg $opt_dry_run || $RM $removelist 3586c43cc173Smrg exit $EXIT_FAILURE 3587c43cc173Smrg fi 3588c43cc173Smrg 3589c43cc173Smrg # Just move the object if needed 3590c43cc173Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591c27c18e8Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592c27c18e8Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593c43cc173Smrg fi 3594c43cc173Smrg fi 3595c43cc173Smrg 3596c27c18e8Smrg $opt_dry_run || { 3597c27c18e8Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598c43cc173Smrg 3599c27c18e8Smrg # Unlock the critical section if it was locked 360044584a44Smrg if test no != "$need_locks"; then 3601c27c18e8Smrg removelist=$lockfile 3602c27c18e8Smrg $RM "$lockfile" 3603c27c18e8Smrg fi 3604c27c18e8Smrg } 3605c43cc173Smrg 3606c43cc173Smrg exit $EXIT_SUCCESS 3607c27c18e8Smrg} 3608c43cc173Smrg 3609c27c18e8Smrg$opt_help || { 361044584a44Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611c27c18e8Smrg} 3612c43cc173Smrg 3613c27c18e8Smrgfunc_mode_help () 3614c27c18e8Smrg{ 3615c27c18e8Smrg # We need to display help for each of the modes. 3616b789ec8aSmrg case $opt_mode in 3617c27c18e8Smrg "") 3618c27c18e8Smrg # Generic help is extracted from the usage comments 3619c27c18e8Smrg # at the start of this file. 3620c27c18e8Smrg func_help 3621c27c18e8Smrg ;; 3622c43cc173Smrg 3623c27c18e8Smrg clean) 3624c27c18e8Smrg $ECHO \ 3625c27c18e8Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626c43cc173Smrg 3627c27c18e8SmrgRemove files from the build directory. 3628c43cc173Smrg 3629c27c18e8SmrgRM is the name of the program to use to delete files associated with each FILE 363044584a44Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631c27c18e8Smrgto RM. 3632c43cc173Smrg 3633c27c18e8SmrgIf FILE is a libtool library, object or program, all the files associated 3634c27c18e8Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635c27c18e8Smrg ;; 3636c43cc173Smrg 3637c27c18e8Smrg compile) 3638c27c18e8Smrg $ECHO \ 3639c27c18e8Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640c43cc173Smrg 3641c27c18e8SmrgCompile a source file into a libtool library object. 3642c43cc173Smrg 3643c27c18e8SmrgThis mode accepts the following additional options: 3644c43cc173Smrg 3645c27c18e8Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646c27c18e8Smrg -no-suppress do not suppress compiler output for multiple passes 364737eb1ca1Smrg -prefer-pic try to build PIC objects only 364837eb1ca1Smrg -prefer-non-pic try to build non-PIC objects only 364944584a44Smrg -shared do not build a '.o' file suitable for static linking 365044584a44Smrg -static only build a '.o' file suitable for static linking 365137eb1ca1Smrg -Wc,FLAG pass FLAG directly to the compiler 3652c43cc173Smrg 365344584a44SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654c27c18e8Smrgfrom the given SOURCEFILE. 3655c43cc173Smrg 3656c27c18e8SmrgThe output file name is determined by removing the directory component from 365744584a44SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 365844584a44Smrglibrary object suffix, '.lo'." 3659c27c18e8Smrg ;; 3660c43cc173Smrg 3661c27c18e8Smrg execute) 3662c27c18e8Smrg $ECHO \ 3663c27c18e8Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664c43cc173Smrg 3665c27c18e8SmrgAutomatically set library path, then run a program. 3666c43cc173Smrg 3667c27c18e8SmrgThis mode accepts the following additional options: 3668c43cc173Smrg 3669c27c18e8Smrg -dlopen FILE add the directory containing FILE to the library path 3670c43cc173Smrg 367144584a44SmrgThis mode sets the library path environment variable according to '-dlopen' 3672c27c18e8Smrgflags. 3673c43cc173Smrg 3674c27c18e8SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675c27c18e8Smrginto their corresponding uninstalled binary, and any of their required library 3676c27c18e8Smrgdirectories are added to the library path. 3677c43cc173Smrg 3678c27c18e8SmrgThen, COMMAND is executed, with ARGS as arguments." 3679c27c18e8Smrg ;; 3680c43cc173Smrg 3681c27c18e8Smrg finish) 3682c27c18e8Smrg $ECHO \ 3683c27c18e8Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684c43cc173Smrg 3685c27c18e8SmrgComplete the installation of libtool libraries. 3686c43cc173Smrg 3687c27c18e8SmrgEach LIBDIR is a directory that contains libtool libraries. 3688c43cc173Smrg 3689c27c18e8SmrgThe commands that this mode executes may require superuser privileges. Use 369044584a44Smrgthe '--dry-run' option if you just want to see what would be executed." 3691c27c18e8Smrg ;; 3692c43cc173Smrg 3693c27c18e8Smrg install) 3694c27c18e8Smrg $ECHO \ 3695c27c18e8Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696c43cc173Smrg 3697c27c18e8SmrgInstall executables or libraries. 3698c43cc173Smrg 3699c27c18e8SmrgINSTALL-COMMAND is the installation command. The first component should be 370044584a44Smrgeither the 'install' or 'cp' program. 3701c43cc173Smrg 3702c27c18e8SmrgThe following components of INSTALL-COMMAND are treated specially: 3703c43cc173Smrg 370437eb1ca1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705c43cc173Smrg 3706c27c18e8SmrgThe rest of the components are interpreted as arguments to that command (only 3707c27c18e8SmrgBSD-compatible install options are recognized)." 3708c27c18e8Smrg ;; 3709c43cc173Smrg 3710c27c18e8Smrg link) 3711c27c18e8Smrg $ECHO \ 3712c27c18e8Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713c43cc173Smrg 3714c27c18e8SmrgLink object files or libraries together to form another library, or to 3715c27c18e8Smrgcreate an executable program. 3716c43cc173Smrg 3717c27c18e8SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718c27c18e8Smrga program from several object files. 3719c43cc173Smrg 3720c27c18e8SmrgThe following components of LINK-COMMAND are treated specially: 3721c43cc173Smrg 3722c27c18e8Smrg -all-static do not do any dynamic linking at all 3723c27c18e8Smrg -avoid-version do not add a version suffix if possible 372437eb1ca1Smrg -bindir BINDIR specify path to binaries directory (for systems where 372537eb1ca1Smrg libraries must be found in the PATH setting at runtime) 372644584a44Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727c27c18e8Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728c27c18e8Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729c27c18e8Smrg -export-symbols SYMFILE 3730c27c18e8Smrg try to export only the symbols listed in SYMFILE 3731c27c18e8Smrg -export-symbols-regex REGEX 3732c27c18e8Smrg try to export only the symbols matching REGEX 3733c27c18e8Smrg -LLIBDIR search LIBDIR for required installed libraries 3734c27c18e8Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735c27c18e8Smrg -module build a library that can dlopened 3736c27c18e8Smrg -no-fast-install disable the fast-install mode 3737c27c18e8Smrg -no-install link a not-installable executable 3738c27c18e8Smrg -no-undefined declare that a library does not refer to external symbols 3739c27c18e8Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 374044584a44Smrg -objectlist FILE use a list of object files found in FILE to specify objects 374144584a44Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742c27c18e8Smrg -precious-files-regex REGEX 3743c27c18e8Smrg don't remove output files matching REGEX 3744c27c18e8Smrg -release RELEASE specify package release information 3745c27c18e8Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746c27c18e8Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747c27c18e8Smrg -shared only do dynamic linking of libtool libraries 3748c27c18e8Smrg -shrext SUFFIX override the standard shared library file extension 3749c27c18e8Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3750c27c18e8Smrg -static-libtool-libs 3751c27c18e8Smrg do not do any dynamic linking of libtool libraries 3752c27c18e8Smrg -version-info CURRENT[:REVISION[:AGE]] 3753c27c18e8Smrg specify library version info [each variable defaults to 0] 3754c27c18e8Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 375537eb1ca1Smrg -Wc,FLAG 375637eb1ca1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375737eb1ca1Smrg -Wl,FLAG 375837eb1ca1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375937eb1ca1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760c43cc173Smrg 376144584a44SmrgAll other options (arguments beginning with '-') are ignored. 3762c43cc173Smrg 376344584a44SmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764c27c18e8Smrgtreated as uninstalled libtool libraries, other files are standard or library 3765c27c18e8Smrgobject files. 3766c43cc173Smrg 376744584a44SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 376844584a44Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769c27c18e8Smrgrequired, except when creating a convenience library. 3770c43cc173Smrg 377144584a44SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 377244584a44Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773c43cc173Smrg 377444584a44SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775c27c18e8Smrgis created, otherwise an executable program is created." 3776c43cc173Smrg ;; 3777c43cc173Smrg 3778c27c18e8Smrg uninstall) 3779c27c18e8Smrg $ECHO \ 3780c27c18e8Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781c43cc173Smrg 3782c27c18e8SmrgRemove libraries from an installation directory. 3783c43cc173Smrg 3784c27c18e8SmrgRM is the name of the program to use to delete files associated with each FILE 378544584a44Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786c27c18e8Smrgto RM. 3787c43cc173Smrg 3788c27c18e8SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789c27c18e8SmrgOtherwise, only FILE itself is deleted using RM." 3790c27c18e8Smrg ;; 3791c43cc173Smrg 3792c27c18e8Smrg *) 379344584a44Smrg func_fatal_help "invalid operation mode '$opt_mode'" 3794c27c18e8Smrg ;; 3795c27c18e8Smrg esac 3796c43cc173Smrg 379737eb1ca1Smrg echo 379844584a44Smrg $ECHO "Try '$progname --help' for more information about other modes." 3799c27c18e8Smrg} 3800c43cc173Smrg 380137eb1ca1Smrg# Now that we've collected a possible --mode arg, show help if necessary 380237eb1ca1Smrgif $opt_help; then 380344584a44Smrg if test : = "$opt_help"; then 380437eb1ca1Smrg func_mode_help 380537eb1ca1Smrg else 380637eb1ca1Smrg { 380737eb1ca1Smrg func_help noexit 3808b789ec8aSmrg for opt_mode in compile link execute install finish uninstall clean; do 380937eb1ca1Smrg func_mode_help 381037eb1ca1Smrg done 381144584a44Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381237eb1ca1Smrg { 381337eb1ca1Smrg func_help noexit 3814b789ec8aSmrg for opt_mode in compile link execute install finish uninstall clean; do 381537eb1ca1Smrg echo 381637eb1ca1Smrg func_mode_help 381737eb1ca1Smrg done 381837eb1ca1Smrg } | 381944584a44Smrg $SED '1d 382037eb1ca1Smrg /^When reporting/,/^Report/{ 382137eb1ca1Smrg H 382237eb1ca1Smrg d 382337eb1ca1Smrg } 382437eb1ca1Smrg $x 382537eb1ca1Smrg /information about other modes/d 382637eb1ca1Smrg /more detailed .*MODE/d 382737eb1ca1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382837eb1ca1Smrg fi 382937eb1ca1Smrg exit $? 383037eb1ca1Smrgfi 3831c43cc173Smrg 3832c43cc173Smrg 3833c27c18e8Smrg# func_mode_execute arg... 3834c27c18e8Smrgfunc_mode_execute () 3835c27c18e8Smrg{ 383644584a44Smrg $debug_cmd 383744584a44Smrg 3838c27c18e8Smrg # The first argument is the command name. 383944584a44Smrg cmd=$nonopt 3840c27c18e8Smrg test -z "$cmd" && \ 3841c27c18e8Smrg func_fatal_help "you must specify a COMMAND" 3842c43cc173Smrg 3843c27c18e8Smrg # Handle -dlopen flags immediately. 3844b789ec8aSmrg for file in $opt_dlopen; do 3845c27c18e8Smrg test -f "$file" \ 384644584a44Smrg || func_fatal_help "'$file' is not a file" 3847c43cc173Smrg 3848c27c18e8Smrg dir= 3849c27c18e8Smrg case $file in 3850c27c18e8Smrg *.la) 3851b789ec8aSmrg func_resolve_sysroot "$file" 3852b789ec8aSmrg file=$func_resolve_sysroot_result 3853b789ec8aSmrg 3854c27c18e8Smrg # Check to see that this really is a libtool archive. 3855c27c18e8Smrg func_lalib_unsafe_p "$file" \ 385644584a44Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857c43cc173Smrg 3858c27c18e8Smrg # Read the libtool library. 3859c27c18e8Smrg dlname= 3860c27c18e8Smrg library_names= 3861c27c18e8Smrg func_source "$file" 3862c43cc173Smrg 3863c27c18e8Smrg # Skip this library if it cannot be dlopened. 3864c27c18e8Smrg if test -z "$dlname"; then 3865c27c18e8Smrg # Warn if it was a shared library. 3866c27c18e8Smrg test -n "$library_names" && \ 386744584a44Smrg func_warning "'$file' was not linked with '-export-dynamic'" 3868c27c18e8Smrg continue 3869c27c18e8Smrg fi 3870c43cc173Smrg 3871c27c18e8Smrg func_dirname "$file" "" "." 387244584a44Smrg dir=$func_dirname_result 3873c43cc173Smrg 3874c27c18e8Smrg if test -f "$dir/$objdir/$dlname"; then 3875b789ec8aSmrg func_append dir "/$objdir" 3876c27c18e8Smrg else 3877c27c18e8Smrg if test ! -f "$dir/$dlname"; then 387844584a44Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879c27c18e8Smrg fi 3880c27c18e8Smrg fi 3881c43cc173Smrg ;; 3882c43cc173Smrg 3883c27c18e8Smrg *.lo) 3884c27c18e8Smrg # Just add the directory containing the .lo file. 3885c27c18e8Smrg func_dirname "$file" "" "." 388644584a44Smrg dir=$func_dirname_result 3887c43cc173Smrg ;; 3888c43cc173Smrg 3889c27c18e8Smrg *) 389044584a44Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891c43cc173Smrg continue 3892c43cc173Smrg ;; 3893c27c18e8Smrg esac 3894c43cc173Smrg 3895c27c18e8Smrg # Get the absolute pathname. 3896c27c18e8Smrg absdir=`cd "$dir" && pwd` 389744584a44Smrg test -n "$absdir" && dir=$absdir 3898c43cc173Smrg 3899c27c18e8Smrg # Now add the directory to shlibpath_var. 3900c27c18e8Smrg if eval "test -z \"\$$shlibpath_var\""; then 3901c27c18e8Smrg eval "$shlibpath_var=\"\$dir\"" 3902c27c18e8Smrg else 3903c27c18e8Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904c27c18e8Smrg fi 3905c27c18e8Smrg done 3906c43cc173Smrg 3907c27c18e8Smrg # This variable tells wrapper scripts just to set shlibpath_var 3908c27c18e8Smrg # rather than running their programs. 390944584a44Smrg libtool_execute_magic=$magic 3910c43cc173Smrg 3911c27c18e8Smrg # Check if any of the arguments is a wrapper script. 3912c27c18e8Smrg args= 3913c27c18e8Smrg for file 3914c27c18e8Smrg do 3915c27c18e8Smrg case $file in 391637eb1ca1Smrg -* | *.la | *.lo ) ;; 3917c27c18e8Smrg *) 3918c27c18e8Smrg # Do a test to see if this is really a libtool program. 3919c27c18e8Smrg if func_ltwrapper_script_p "$file"; then 3920c27c18e8Smrg func_source "$file" 3921c27c18e8Smrg # Transform arg to wrapped name. 392244584a44Smrg file=$progdir/$program 3923c27c18e8Smrg elif func_ltwrapper_executable_p "$file"; then 3924c27c18e8Smrg func_ltwrapper_scriptname "$file" 3925c27c18e8Smrg func_source "$func_ltwrapper_scriptname_result" 3926c27c18e8Smrg # Transform arg to wrapped name. 392744584a44Smrg file=$progdir/$program 3928c27c18e8Smrg fi 3929c27c18e8Smrg ;; 3930c27c18e8Smrg esac 3931c27c18e8Smrg # Quote arguments (to preserve shell metacharacters). 3932b789ec8aSmrg func_append_quoted args "$file" 3933c27c18e8Smrg done 3934c43cc173Smrg 393544584a44Smrg if $opt_dry_run; then 393644584a44Smrg # Display what would be done. 393744584a44Smrg if test -n "$shlibpath_var"; then 393844584a44Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 393944584a44Smrg echo "export $shlibpath_var" 394044584a44Smrg fi 394144584a44Smrg $ECHO "$cmd$args" 394244584a44Smrg exit $EXIT_SUCCESS 394344584a44Smrg else 3944c27c18e8Smrg if test -n "$shlibpath_var"; then 3945c27c18e8Smrg # Export the shlibpath_var. 3946c27c18e8Smrg eval "export $shlibpath_var" 3947c27c18e8Smrg fi 3948c43cc173Smrg 3949c27c18e8Smrg # Restore saved environment variables 3950c27c18e8Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951c27c18e8Smrg do 3952c27c18e8Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953c27c18e8Smrg $lt_var=\$save_$lt_var; export $lt_var 3954c43cc173Smrg else 3955c27c18e8Smrg $lt_unset $lt_var 3956c27c18e8Smrg fi" 3957c27c18e8Smrg done 3958c43cc173Smrg 3959c27c18e8Smrg # Now prepare to actually exec the command. 396044584a44Smrg exec_cmd=\$cmd$args 3961c27c18e8Smrg fi 3962c27c18e8Smrg} 3963c43cc173Smrg 396444584a44Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965c43cc173Smrg 3966c43cc173Smrg 3967c27c18e8Smrg# func_mode_finish arg... 3968c27c18e8Smrgfunc_mode_finish () 3969c27c18e8Smrg{ 397044584a44Smrg $debug_cmd 397144584a44Smrg 3972b789ec8aSmrg libs= 3973b789ec8aSmrg libdirs= 3974c27c18e8Smrg admincmds= 3975c43cc173Smrg 3976b789ec8aSmrg for opt in "$nonopt" ${1+"$@"} 3977b789ec8aSmrg do 3978b789ec8aSmrg if test -d "$opt"; then 3979b789ec8aSmrg func_append libdirs " $opt" 3980b789ec8aSmrg 3981b789ec8aSmrg elif test -f "$opt"; then 3982b789ec8aSmrg if func_lalib_unsafe_p "$opt"; then 3983b789ec8aSmrg func_append libs " $opt" 3984b789ec8aSmrg else 398544584a44Smrg func_warning "'$opt' is not a valid libtool archive" 3986b789ec8aSmrg fi 3987b789ec8aSmrg 3988b789ec8aSmrg else 398944584a44Smrg func_fatal_error "invalid argument '$opt'" 3990b789ec8aSmrg fi 3991b789ec8aSmrg done 3992b789ec8aSmrg 3993b789ec8aSmrg if test -n "$libs"; then 3994b789ec8aSmrg if test -n "$lt_sysroot"; then 3995b789ec8aSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996b789ec8aSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997b789ec8aSmrg else 3998b789ec8aSmrg sysroot_cmd= 3999b789ec8aSmrg fi 4000b789ec8aSmrg 4001b789ec8aSmrg # Remove sysroot references 4002b789ec8aSmrg if $opt_dry_run; then 4003b789ec8aSmrg for lib in $libs; do 400444584a44Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005b789ec8aSmrg done 4006b789ec8aSmrg else 4007b789ec8aSmrg tmpdir=`func_mktempdir` 4008b789ec8aSmrg for lib in $libs; do 400944584a44Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010b789ec8aSmrg > $tmpdir/tmp-la 4011b789ec8aSmrg mv -f $tmpdir/tmp-la $lib 4012b789ec8aSmrg done 4013b789ec8aSmrg ${RM}r "$tmpdir" 4014b789ec8aSmrg fi 4015b789ec8aSmrg fi 4016c43cc173Smrg 4017b789ec8aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018c27c18e8Smrg for libdir in $libdirs; do 4019c27c18e8Smrg if test -n "$finish_cmds"; then 4020c27c18e8Smrg # Do each command in the finish commands. 4021c27c18e8Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022c27c18e8Smrg'"$cmd"'"' 4023c43cc173Smrg fi 4024c27c18e8Smrg if test -n "$finish_eval"; then 4025c27c18e8Smrg # Do the single finish_eval. 4026c27c18e8Smrg eval cmds=\"$finish_eval\" 4027b789ec8aSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028c27c18e8Smrg $cmds" 4029c27c18e8Smrg fi 4030c27c18e8Smrg done 4031c27c18e8Smrg fi 4032c43cc173Smrg 4033c27c18e8Smrg # Exit here if they wanted silent mode. 403444584a44Smrg $opt_quiet && exit $EXIT_SUCCESS 4035c43cc173Smrg 4036b789ec8aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037b789ec8aSmrg echo "----------------------------------------------------------------------" 4038b789ec8aSmrg echo "Libraries have been installed in:" 4039b789ec8aSmrg for libdir in $libdirs; do 4040b789ec8aSmrg $ECHO " $libdir" 4041b789ec8aSmrg done 4042b789ec8aSmrg echo 4043b789ec8aSmrg echo "If you ever happen to want to link against installed libraries" 4044b789ec8aSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 404544584a44Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046b789ec8aSmrg echo "flag during linking and do at least one of the following:" 4047b789ec8aSmrg if test -n "$shlibpath_var"; then 404844584a44Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049b789ec8aSmrg echo " during execution" 4050b789ec8aSmrg fi 4051b789ec8aSmrg if test -n "$runpath_var"; then 405244584a44Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053b789ec8aSmrg echo " during linking" 4054b789ec8aSmrg fi 4055b789ec8aSmrg if test -n "$hardcode_libdir_flag_spec"; then 4056b789ec8aSmrg libdir=LIBDIR 4057b789ec8aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4058c43cc173Smrg 405944584a44Smrg $ECHO " - use the '$flag' linker flag" 4060b789ec8aSmrg fi 4061b789ec8aSmrg if test -n "$admincmds"; then 4062b789ec8aSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4063b789ec8aSmrg fi 4064b789ec8aSmrg if test -f /etc/ld.so.conf; then 406544584a44Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066b789ec8aSmrg fi 4067b789ec8aSmrg echo 4068c27c18e8Smrg 4069b789ec8aSmrg echo "See any operating system documentation about shared libraries for" 4070b789ec8aSmrg case $host in 4071b789ec8aSmrg solaris2.[6789]|solaris2.1[0-9]) 4072b789ec8aSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073b789ec8aSmrg echo "pages." 4074b789ec8aSmrg ;; 4075b789ec8aSmrg *) 4076b789ec8aSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077b789ec8aSmrg ;; 4078b789ec8aSmrg esac 4079b789ec8aSmrg echo "----------------------------------------------------------------------" 4080b789ec8aSmrg fi 4081c27c18e8Smrg exit $EXIT_SUCCESS 4082c27c18e8Smrg} 4083c27c18e8Smrg 408444584a44Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085c27c18e8Smrg 4086c27c18e8Smrg 4087c27c18e8Smrg# func_mode_install arg... 4088c27c18e8Smrgfunc_mode_install () 4089c27c18e8Smrg{ 409044584a44Smrg $debug_cmd 409144584a44Smrg 4092c27c18e8Smrg # There may be an optional sh(1) argument at the beginning of 4093c27c18e8Smrg # install_prog (especially on Windows NT). 409444584a44Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095c27c18e8Smrg # Allow the use of GNU shtool's install command. 409644584a44Smrg case $nonopt in *shtool*) :;; *) false;; esac 409744584a44Smrg then 4098c27c18e8Smrg # Aesthetically quote it. 4099c27c18e8Smrg func_quote_for_eval "$nonopt" 4100c27c18e8Smrg install_prog="$func_quote_for_eval_result " 4101c27c18e8Smrg arg=$1 4102c27c18e8Smrg shift 4103c27c18e8Smrg else 4104c27c18e8Smrg install_prog= 4105c27c18e8Smrg arg=$nonopt 4106c27c18e8Smrg fi 4107c27c18e8Smrg 4108c27c18e8Smrg # The real first argument should be the name of the installation program. 4109c27c18e8Smrg # Aesthetically quote it. 4110c27c18e8Smrg func_quote_for_eval "$arg" 4111b789ec8aSmrg func_append install_prog "$func_quote_for_eval_result" 411237eb1ca1Smrg install_shared_prog=$install_prog 411337eb1ca1Smrg case " $install_prog " in 411437eb1ca1Smrg *[\\\ /]cp\ *) install_cp=: ;; 411537eb1ca1Smrg *) install_cp=false ;; 411637eb1ca1Smrg esac 4117c27c18e8Smrg 4118c27c18e8Smrg # We need to accept at least all the BSD install flags. 4119c27c18e8Smrg dest= 4120c27c18e8Smrg files= 4121c27c18e8Smrg opts= 4122c27c18e8Smrg prev= 4123c27c18e8Smrg install_type= 412444584a44Smrg isdir=false 4125c27c18e8Smrg stripme= 412637eb1ca1Smrg no_mode=: 4127c27c18e8Smrg for arg 4128c27c18e8Smrg do 412937eb1ca1Smrg arg2= 4130c27c18e8Smrg if test -n "$dest"; then 4131b789ec8aSmrg func_append files " $dest" 4132c27c18e8Smrg dest=$arg 4133c27c18e8Smrg continue 4134c27c18e8Smrg fi 4135c27c18e8Smrg 4136c27c18e8Smrg case $arg in 413744584a44Smrg -d) isdir=: ;; 4138c27c18e8Smrg -f) 413937eb1ca1Smrg if $install_cp; then :; else 414037eb1ca1Smrg prev=$arg 414137eb1ca1Smrg fi 4142c27c18e8Smrg ;; 4143c27c18e8Smrg -g | -m | -o) 4144c27c18e8Smrg prev=$arg 4145c27c18e8Smrg ;; 4146c27c18e8Smrg -s) 4147c27c18e8Smrg stripme=" -s" 4148c27c18e8Smrg continue 4149c27c18e8Smrg ;; 4150c27c18e8Smrg -*) 4151c27c18e8Smrg ;; 4152c27c18e8Smrg *) 4153c27c18e8Smrg # If the previous option needed an argument, then skip it. 4154c27c18e8Smrg if test -n "$prev"; then 415544584a44Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415637eb1ca1Smrg arg2=$install_override_mode 415737eb1ca1Smrg no_mode=false 415837eb1ca1Smrg fi 4159c43cc173Smrg prev= 4160c43cc173Smrg else 4161c27c18e8Smrg dest=$arg 4162c27c18e8Smrg continue 4163c43cc173Smrg fi 4164c43cc173Smrg ;; 4165c27c18e8Smrg esac 4166c43cc173Smrg 4167c27c18e8Smrg # Aesthetically quote the argument. 4168c27c18e8Smrg func_quote_for_eval "$arg" 4169b789ec8aSmrg func_append install_prog " $func_quote_for_eval_result" 417037eb1ca1Smrg if test -n "$arg2"; then 417137eb1ca1Smrg func_quote_for_eval "$arg2" 417237eb1ca1Smrg fi 4173b789ec8aSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4174c27c18e8Smrg done 4175c43cc173Smrg 4176c27c18e8Smrg test -z "$install_prog" && \ 4177c27c18e8Smrg func_fatal_help "you must specify an install program" 4178c43cc173Smrg 4179c27c18e8Smrg test -n "$prev" && \ 418044584a44Smrg func_fatal_help "the '$prev' option requires an argument" 4181c43cc173Smrg 418237eb1ca1Smrg if test -n "$install_override_mode" && $no_mode; then 418337eb1ca1Smrg if $install_cp; then :; else 418437eb1ca1Smrg func_quote_for_eval "$install_override_mode" 4185b789ec8aSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418637eb1ca1Smrg fi 418737eb1ca1Smrg fi 418837eb1ca1Smrg 4189c27c18e8Smrg if test -z "$files"; then 4190c27c18e8Smrg if test -z "$dest"; then 4191c27c18e8Smrg func_fatal_help "no file or destination specified" 4192c27c18e8Smrg else 4193c27c18e8Smrg func_fatal_help "you must specify a destination" 4194c27c18e8Smrg fi 4195c43cc173Smrg fi 4196c43cc173Smrg 4197c27c18e8Smrg # Strip any trailing slash from the destination. 4198c27c18e8Smrg func_stripname '' '/' "$dest" 4199c27c18e8Smrg dest=$func_stripname_result 4200c43cc173Smrg 4201c27c18e8Smrg # Check to see that the destination is a directory. 420244584a44Smrg test -d "$dest" && isdir=: 420344584a44Smrg if $isdir; then 420444584a44Smrg destdir=$dest 4205c27c18e8Smrg destname= 4206c43cc173Smrg else 4207c27c18e8Smrg func_dirname_and_basename "$dest" "" "." 420844584a44Smrg destdir=$func_dirname_result 420944584a44Smrg destname=$func_basename_result 4210c43cc173Smrg 4211c27c18e8Smrg # Not a directory, so check to see that there is only one file specified. 4212c27c18e8Smrg set dummy $files; shift 4213c27c18e8Smrg test "$#" -gt 1 && \ 421444584a44Smrg func_fatal_help "'$dest' is not a directory" 4215c43cc173Smrg fi 4216c27c18e8Smrg case $destdir in 4217c27c18e8Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218c43cc173Smrg *) 4219c27c18e8Smrg for file in $files; do 4220c27c18e8Smrg case $file in 4221c27c18e8Smrg *.lo) ;; 4222c27c18e8Smrg *) 422344584a44Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4224c27c18e8Smrg ;; 4225c27c18e8Smrg esac 4226c27c18e8Smrg done 4227c43cc173Smrg ;; 4228c43cc173Smrg esac 4229c43cc173Smrg 4230c27c18e8Smrg # This variable tells wrapper scripts just to set variables rather 4231c27c18e8Smrg # than running their programs. 423244584a44Smrg libtool_install_magic=$magic 4233c43cc173Smrg 4234c27c18e8Smrg staticlibs= 4235c27c18e8Smrg future_libdirs= 4236c27c18e8Smrg current_libdirs= 4237c27c18e8Smrg for file in $files; do 4238c43cc173Smrg 4239c27c18e8Smrg # Do each installation. 4240c27c18e8Smrg case $file in 4241c27c18e8Smrg *.$libext) 4242c27c18e8Smrg # Do the static libraries later. 4243b789ec8aSmrg func_append staticlibs " $file" 4244c27c18e8Smrg ;; 4245c27c18e8Smrg 4246c27c18e8Smrg *.la) 4247b789ec8aSmrg func_resolve_sysroot "$file" 4248b789ec8aSmrg file=$func_resolve_sysroot_result 4249b789ec8aSmrg 4250c27c18e8Smrg # Check to see that this really is a libtool archive. 4251c27c18e8Smrg func_lalib_unsafe_p "$file" \ 425244584a44Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4253c27c18e8Smrg 4254c27c18e8Smrg library_names= 4255c27c18e8Smrg old_library= 4256c27c18e8Smrg relink_command= 4257c27c18e8Smrg func_source "$file" 4258c27c18e8Smrg 4259c27c18e8Smrg # Add the libdir to current_libdirs if it is the destination. 4260c27c18e8Smrg if test "X$destdir" = "X$libdir"; then 4261c27c18e8Smrg case "$current_libdirs " in 4262c27c18e8Smrg *" $libdir "*) ;; 4263b789ec8aSmrg *) func_append current_libdirs " $libdir" ;; 4264c43cc173Smrg esac 4265c27c18e8Smrg else 4266c27c18e8Smrg # Note the libdir as a future libdir. 4267c27c18e8Smrg case "$future_libdirs " in 4268c27c18e8Smrg *" $libdir "*) ;; 4269b789ec8aSmrg *) func_append future_libdirs " $libdir" ;; 4270c27c18e8Smrg esac 4271c27c18e8Smrg fi 4272c43cc173Smrg 4273c27c18e8Smrg func_dirname "$file" "/" "" 427444584a44Smrg dir=$func_dirname_result 4275b789ec8aSmrg func_append dir "$objdir" 4276c27c18e8Smrg 4277c27c18e8Smrg if test -n "$relink_command"; then 4278c27c18e8Smrg # Determine the prefix the user has applied to our future dir. 427937eb1ca1Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280c27c18e8Smrg 4281c27c18e8Smrg # Don't allow the user to place us outside of our expected 4282c27c18e8Smrg # location b/c this prevents finding dependent libraries that 4283c27c18e8Smrg # are installed to the same prefix. 4284c27c18e8Smrg # At present, this check doesn't affect windows .dll's that 4285c27c18e8Smrg # are installed into $libdir/../bin (currently, that works fine) 4286c27c18e8Smrg # but it's something to keep an eye on. 4287c27c18e8Smrg test "$inst_prefix_dir" = "$destdir" && \ 428844584a44Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289c27c18e8Smrg 4290c27c18e8Smrg if test -n "$inst_prefix_dir"; then 4291c27c18e8Smrg # Stick the inst_prefix_dir data into the link command. 429237eb1ca1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293c27c18e8Smrg else 429437eb1ca1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295c27c18e8Smrg fi 4296c27c18e8Smrg 429744584a44Smrg func_warning "relinking '$file'" 4298c27c18e8Smrg func_show_eval "$relink_command" \ 429944584a44Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300c27c18e8Smrg fi 4301c27c18e8Smrg 4302c27c18e8Smrg # See the names of the shared library. 4303c27c18e8Smrg set dummy $library_names; shift 4304c27c18e8Smrg if test -n "$1"; then 430544584a44Smrg realname=$1 4306c27c18e8Smrg shift 4307c27c18e8Smrg 430844584a44Smrg srcname=$realname 430944584a44Smrg test -n "$relink_command" && srcname=${realname}T 4310c27c18e8Smrg 4311c27c18e8Smrg # Install the shared library and build the symlinks. 431237eb1ca1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313c27c18e8Smrg 'exit $?' 431444584a44Smrg tstripme=$stripme 4315c27c18e8Smrg case $host_os in 4316c27c18e8Smrg cygwin* | mingw* | pw32* | cegcc*) 4317c27c18e8Smrg case $realname in 4318c27c18e8Smrg *.dll.a) 431944584a44Smrg tstripme= 432044584a44Smrg ;; 432144584a44Smrg esac 432244584a44Smrg ;; 432344584a44Smrg os2*) 432444584a44Smrg case $realname in 432544584a44Smrg *_dll.a) 432644584a44Smrg tstripme= 4327c27c18e8Smrg ;; 4328c27c18e8Smrg esac 4329c43cc173Smrg ;; 4330c43cc173Smrg esac 4331c27c18e8Smrg if test -n "$tstripme" && test -n "$striplib"; then 4332c27c18e8Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333c43cc173Smrg fi 4334c27c18e8Smrg 4335c27c18e8Smrg if test "$#" -gt 0; then 4336c27c18e8Smrg # Delete the old symlinks, and create new ones. 433744584a44Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338c27c18e8Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339c27c18e8Smrg # so we also need to try rm && ln -s. 4340c27c18e8Smrg for linkname 4341c27c18e8Smrg do 4342c27c18e8Smrg test "$linkname" != "$realname" \ 4343c27c18e8Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344c43cc173Smrg done 4345c43cc173Smrg fi 4346c43cc173Smrg 4347c27c18e8Smrg # Do each command in the postinstall commands. 434844584a44Smrg lib=$destdir/$realname 4349c27c18e8Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350c43cc173Smrg fi 4351c43cc173Smrg 4352c27c18e8Smrg # Install the pseudo-library for information purposes. 4353c27c18e8Smrg func_basename "$file" 435444584a44Smrg name=$func_basename_result 435544584a44Smrg instname=$dir/${name}i 4356c27c18e8Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357c43cc173Smrg 4358c27c18e8Smrg # Maybe install the static library, too. 4359b789ec8aSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360c27c18e8Smrg ;; 4361c43cc173Smrg 4362c27c18e8Smrg *.lo) 4363c27c18e8Smrg # Install (i.e. copy) a libtool object. 4364c43cc173Smrg 4365c27c18e8Smrg # Figure out destination file name, if it wasn't already specified. 4366c27c18e8Smrg if test -n "$destname"; then 436744584a44Smrg destfile=$destdir/$destname 4368c27c18e8Smrg else 4369c27c18e8Smrg func_basename "$file" 437044584a44Smrg destfile=$func_basename_result 437144584a44Smrg destfile=$destdir/$destfile 4372c43cc173Smrg fi 4373c43cc173Smrg 4374c27c18e8Smrg # Deduce the name of the destination old-style object file. 4375c27c18e8Smrg case $destfile in 4376c27c18e8Smrg *.lo) 4377c27c18e8Smrg func_lo2o "$destfile" 4378c27c18e8Smrg staticdest=$func_lo2o_result 4379c27c18e8Smrg ;; 4380c27c18e8Smrg *.$objext) 438144584a44Smrg staticdest=$destfile 4382c27c18e8Smrg destfile= 4383c27c18e8Smrg ;; 4384c27c18e8Smrg *) 438544584a44Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386c27c18e8Smrg ;; 4387c27c18e8Smrg esac 4388c43cc173Smrg 4389c27c18e8Smrg # Install the libtool object if requested. 4390c27c18e8Smrg test -n "$destfile" && \ 4391c27c18e8Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392c43cc173Smrg 4393c27c18e8Smrg # Install the old object if enabled. 439444584a44Smrg if test yes = "$build_old_libs"; then 4395c27c18e8Smrg # Deduce the name of the old-style object file. 4396c27c18e8Smrg func_lo2o "$file" 4397c27c18e8Smrg staticobj=$func_lo2o_result 4398c27c18e8Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399c43cc173Smrg fi 4400c27c18e8Smrg exit $EXIT_SUCCESS 4401c27c18e8Smrg ;; 4402c43cc173Smrg 4403c27c18e8Smrg *) 4404c27c18e8Smrg # Figure out destination file name, if it wasn't already specified. 4405c27c18e8Smrg if test -n "$destname"; then 440644584a44Smrg destfile=$destdir/$destname 4407c27c18e8Smrg else 4408c27c18e8Smrg func_basename "$file" 440944584a44Smrg destfile=$func_basename_result 441044584a44Smrg destfile=$destdir/$destfile 4411c27c18e8Smrg fi 4412c43cc173Smrg 4413c27c18e8Smrg # If the file is missing, and there is a .exe on the end, strip it 4414c27c18e8Smrg # because it is most likely a libtool script we actually want to 4415c27c18e8Smrg # install 441644584a44Smrg stripped_ext= 4417c27c18e8Smrg case $file in 4418c27c18e8Smrg *.exe) 4419c27c18e8Smrg if test ! -f "$file"; then 4420c27c18e8Smrg func_stripname '' '.exe' "$file" 4421c27c18e8Smrg file=$func_stripname_result 442244584a44Smrg stripped_ext=.exe 4423c27c18e8Smrg fi 4424c27c18e8Smrg ;; 4425c27c18e8Smrg esac 4426c27c18e8Smrg 4427c27c18e8Smrg # Do a test to see if this is really a libtool program. 4428c27c18e8Smrg case $host in 4429c27c18e8Smrg *cygwin* | *mingw*) 4430c27c18e8Smrg if func_ltwrapper_executable_p "$file"; then 4431c27c18e8Smrg func_ltwrapper_scriptname "$file" 4432c27c18e8Smrg wrapper=$func_ltwrapper_scriptname_result 4433c27c18e8Smrg else 4434c27c18e8Smrg func_stripname '' '.exe' "$file" 4435c27c18e8Smrg wrapper=$func_stripname_result 4436c27c18e8Smrg fi 4437c27c18e8Smrg ;; 4438c43cc173Smrg *) 4439c27c18e8Smrg wrapper=$file 4440c27c18e8Smrg ;; 4441c27c18e8Smrg esac 4442c27c18e8Smrg if func_ltwrapper_script_p "$wrapper"; then 4443c27c18e8Smrg notinst_deplibs= 4444c27c18e8Smrg relink_command= 4445c27c18e8Smrg 4446c27c18e8Smrg func_source "$wrapper" 4447c27c18e8Smrg 4448c27c18e8Smrg # Check the variables that should have been set. 4449c27c18e8Smrg test -z "$generated_by_libtool_version" && \ 445044584a44Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451c27c18e8Smrg 445244584a44Smrg finalize=: 4453c27c18e8Smrg for lib in $notinst_deplibs; do 4454c27c18e8Smrg # Check to see that each library is installed. 4455c27c18e8Smrg libdir= 4456c27c18e8Smrg if test -f "$lib"; then 4457c27c18e8Smrg func_source "$lib" 4458c27c18e8Smrg fi 445944584a44Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460c27c18e8Smrg if test -n "$libdir" && test ! -f "$libfile"; then 446144584a44Smrg func_warning "'$lib' has not been installed in '$libdir'" 446244584a44Smrg finalize=false 4463c27c18e8Smrg fi 4464c27c18e8Smrg done 4465c27c18e8Smrg 4466c27c18e8Smrg relink_command= 4467c27c18e8Smrg func_source "$wrapper" 4468c27c18e8Smrg 4469c27c18e8Smrg outputname= 447044584a44Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4471c27c18e8Smrg $opt_dry_run || { 447244584a44Smrg if $finalize; then 4473c27c18e8Smrg tmpdir=`func_mktempdir` 4474c27c18e8Smrg func_basename "$file$stripped_ext" 447544584a44Smrg file=$func_basename_result 447644584a44Smrg outputname=$tmpdir/$file 4477c27c18e8Smrg # Replace the output file specification. 447837eb1ca1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479c27c18e8Smrg 448044584a44Smrg $opt_quiet || { 4481c27c18e8Smrg func_quote_for_expand "$relink_command" 4482c27c18e8Smrg eval "func_echo $func_quote_for_expand_result" 4483c27c18e8Smrg } 4484c27c18e8Smrg if eval "$relink_command"; then : 4485c27c18e8Smrg else 448644584a44Smrg func_error "error: relink '$file' with the above command before installing it" 4487c27c18e8Smrg $opt_dry_run || ${RM}r "$tmpdir" 4488c27c18e8Smrg continue 4489c27c18e8Smrg fi 449044584a44Smrg file=$outputname 4491c27c18e8Smrg else 449244584a44Smrg func_warning "cannot relink '$file'" 4493c27c18e8Smrg fi 4494c27c18e8Smrg } 4495c27c18e8Smrg else 4496c27c18e8Smrg # Install the binary that we compiled earlier. 449737eb1ca1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498c43cc173Smrg fi 4499c27c18e8Smrg fi 4500c27c18e8Smrg 4501c27c18e8Smrg # remove .exe since cygwin /usr/bin/install will append another 4502c27c18e8Smrg # one anyway 4503c27c18e8Smrg case $install_prog,$host in 4504c27c18e8Smrg */usr/bin/install*,*cygwin*) 4505c27c18e8Smrg case $file:$destfile in 4506c27c18e8Smrg *.exe:*.exe) 4507c27c18e8Smrg # this is ok 4508c27c18e8Smrg ;; 4509c27c18e8Smrg *.exe:*) 4510c27c18e8Smrg destfile=$destfile.exe 4511c27c18e8Smrg ;; 4512c27c18e8Smrg *:*.exe) 4513c27c18e8Smrg func_stripname '' '.exe' "$destfile" 4514c27c18e8Smrg destfile=$func_stripname_result 4515c27c18e8Smrg ;; 4516c27c18e8Smrg esac 4517c43cc173Smrg ;; 4518c43cc173Smrg esac 4519c27c18e8Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520c27c18e8Smrg $opt_dry_run || if test -n "$outputname"; then 4521c27c18e8Smrg ${RM}r "$tmpdir" 4522c27c18e8Smrg fi 4523c27c18e8Smrg ;; 4524c27c18e8Smrg esac 4525c27c18e8Smrg done 4526c43cc173Smrg 4527c27c18e8Smrg for file in $staticlibs; do 4528c27c18e8Smrg func_basename "$file" 452944584a44Smrg name=$func_basename_result 4530c27c18e8Smrg 4531c27c18e8Smrg # Set up the ranlib parameters. 453244584a44Smrg oldlib=$destdir/$name 4533f1ee322dSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534f1ee322dSmrg tool_oldlib=$func_to_tool_file_result 4535c27c18e8Smrg 4536c27c18e8Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537c27c18e8Smrg 4538c27c18e8Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4539f1ee322dSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540c27c18e8Smrg fi 4541c27c18e8Smrg 4542c27c18e8Smrg # Do each command in the postinstall commands. 4543c27c18e8Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544c27c18e8Smrg done 4545c27c18e8Smrg 4546c27c18e8Smrg test -n "$future_libdirs" && \ 454744584a44Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548c27c18e8Smrg 4549c27c18e8Smrg if test -n "$current_libdirs"; then 4550c27c18e8Smrg # Maybe just do a dry run. 4551c27c18e8Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 455244584a44Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553c27c18e8Smrg else 4554c27c18e8Smrg exit $EXIT_SUCCESS 4555c27c18e8Smrg fi 4556c27c18e8Smrg} 4557c27c18e8Smrg 455844584a44Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559c27c18e8Smrg 4560c27c18e8Smrg 4561c27c18e8Smrg# func_generate_dlsyms outputname originator pic_p 4562c27c18e8Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563c27c18e8Smrg# a dlpreopen symbol table. 4564c27c18e8Smrgfunc_generate_dlsyms () 4565c27c18e8Smrg{ 456644584a44Smrg $debug_cmd 456744584a44Smrg 456844584a44Smrg my_outputname=$1 456944584a44Smrg my_originator=$2 457044584a44Smrg my_pic_p=${3-false} 457144584a44Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572c27c18e8Smrg my_dlsyms= 4573c27c18e8Smrg 457444584a44Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575c27c18e8Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 457644584a44Smrg my_dlsyms=${my_outputname}S.c 4577c27c18e8Smrg else 4578c27c18e8Smrg func_error "not configured to extract global symbols from dlpreopened files" 4579c27c18e8Smrg fi 4580c27c18e8Smrg fi 4581c27c18e8Smrg 4582c27c18e8Smrg if test -n "$my_dlsyms"; then 4583c27c18e8Smrg case $my_dlsyms in 4584c27c18e8Smrg "") ;; 4585c27c18e8Smrg *.c) 4586c27c18e8Smrg # Discover the nlist of each of the dlfiles. 458744584a44Smrg nlist=$output_objdir/$my_outputname.nm 4588c27c18e8Smrg 4589c27c18e8Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590c27c18e8Smrg 4591c27c18e8Smrg # Parse the name list into a source file. 4592c27c18e8Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593c27c18e8Smrg 4594c27c18e8Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 459544584a44Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 459644584a44Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597c27c18e8Smrg 4598c27c18e8Smrg#ifdef __cplusplus 4599c27c18e8Smrgextern \"C\" { 4600c27c18e8Smrg#endif 4601c27c18e8Smrg 460244584a44Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460337eb1ca1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460437eb1ca1Smrg#endif 460537eb1ca1Smrg 4606b789ec8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 460744584a44Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 460844584a44Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609b789ec8aSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610b789ec8aSmrg# define LT_DLSYM_CONST 461144584a44Smrg#elif defined __osf__ 4612b789ec8aSmrg/* This system does not cope well with relocations in const data. */ 4613b789ec8aSmrg# define LT_DLSYM_CONST 4614b789ec8aSmrg#else 4615b789ec8aSmrg# define LT_DLSYM_CONST const 4616b789ec8aSmrg#endif 4617b789ec8aSmrg 461844584a44Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 461944584a44Smrg 4620c27c18e8Smrg/* External symbol declarations for the compiler. */\ 4621c27c18e8Smrg" 4622c27c18e8Smrg 462344584a44Smrg if test yes = "$dlself"; then 462444584a44Smrg func_verbose "generating symbol list for '$output'" 4625c27c18e8Smrg 4626c27c18e8Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627c27c18e8Smrg 4628c27c18e8Smrg # Add our own program objects to the symbol list. 462937eb1ca1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630c27c18e8Smrg for progfile in $progfiles; do 4631b789ec8aSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 463244584a44Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633b789ec8aSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634c27c18e8Smrg done 4635c27c18e8Smrg 4636c27c18e8Smrg if test -n "$exclude_expsyms"; then 4637c27c18e8Smrg $opt_dry_run || { 4638c27c18e8Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639c27c18e8Smrg eval '$MV "$nlist"T "$nlist"' 4640c27c18e8Smrg } 4641c43cc173Smrg fi 4642c27c18e8Smrg 4643c27c18e8Smrg if test -n "$export_symbols_regex"; then 4644c27c18e8Smrg $opt_dry_run || { 4645c27c18e8Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646c27c18e8Smrg eval '$MV "$nlist"T "$nlist"' 4647c27c18e8Smrg } 4648c27c18e8Smrg fi 4649c27c18e8Smrg 4650c27c18e8Smrg # Prepare the list of exported symbols 4651c27c18e8Smrg if test -z "$export_symbols"; then 465244584a44Smrg export_symbols=$output_objdir/$outputname.exp 4653c27c18e8Smrg $opt_dry_run || { 4654c27c18e8Smrg $RM $export_symbols 465544584a44Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656c27c18e8Smrg case $host in 4657c27c18e8Smrg *cygwin* | *mingw* | *cegcc* ) 4658c27c18e8Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659c27c18e8Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660c27c18e8Smrg ;; 4661c27c18e8Smrg esac 4662c27c18e8Smrg } 4663c43cc173Smrg else 4664c27c18e8Smrg $opt_dry_run || { 466544584a44Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666c27c18e8Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667c27c18e8Smrg eval '$MV "$nlist"T "$nlist"' 4668c27c18e8Smrg case $host in 466937eb1ca1Smrg *cygwin* | *mingw* | *cegcc* ) 4670c27c18e8Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671c27c18e8Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672c27c18e8Smrg ;; 4673c27c18e8Smrg esac 4674c27c18e8Smrg } 4675c43cc173Smrg fi 4676c27c18e8Smrg fi 4677c43cc173Smrg 4678c27c18e8Smrg for dlprefile in $dlprefiles; do 467944584a44Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4680c27c18e8Smrg func_basename "$dlprefile" 468144584a44Smrg name=$func_basename_result 4682b789ec8aSmrg case $host in 4683b789ec8aSmrg *cygwin* | *mingw* | *cegcc* ) 4684b789ec8aSmrg # if an import library, we need to obtain dlname 4685b789ec8aSmrg if func_win32_import_lib_p "$dlprefile"; then 4686b789ec8aSmrg func_tr_sh "$dlprefile" 4687b789ec8aSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 468844584a44Smrg dlprefile_dlbasename= 4689b789ec8aSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690b789ec8aSmrg # Use subshell, to avoid clobbering current variable values 4691b789ec8aSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 469244584a44Smrg if test -n "$dlprefile_dlname"; then 4693b789ec8aSmrg func_basename "$dlprefile_dlname" 469444584a44Smrg dlprefile_dlbasename=$func_basename_result 4695b789ec8aSmrg else 4696b789ec8aSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697b789ec8aSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4698b789ec8aSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699b789ec8aSmrg fi 4700b789ec8aSmrg fi 4701b789ec8aSmrg $opt_dry_run || { 470244584a44Smrg if test -n "$dlprefile_dlbasename"; then 4703b789ec8aSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704b789ec8aSmrg else 4705b789ec8aSmrg func_warning "Could not compute DLL name from $name" 4706b789ec8aSmrg eval '$ECHO ": $name " >> "$nlist"' 4707b789ec8aSmrg fi 4708b789ec8aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709b789ec8aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710b789ec8aSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711b789ec8aSmrg } 4712b789ec8aSmrg else # not an import lib 4713b789ec8aSmrg $opt_dry_run || { 4714b789ec8aSmrg eval '$ECHO ": $name " >> "$nlist"' 4715b789ec8aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716b789ec8aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717b789ec8aSmrg } 4718b789ec8aSmrg fi 4719b789ec8aSmrg ;; 4720b789ec8aSmrg *) 4721b789ec8aSmrg $opt_dry_run || { 4722b789ec8aSmrg eval '$ECHO ": $name " >> "$nlist"' 4723b789ec8aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724b789ec8aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725b789ec8aSmrg } 4726b789ec8aSmrg ;; 4727b789ec8aSmrg esac 4728c27c18e8Smrg done 4729c27c18e8Smrg 4730c27c18e8Smrg $opt_dry_run || { 4731c27c18e8Smrg # Make sure we have at least an empty file. 4732c27c18e8Smrg test -f "$nlist" || : > "$nlist" 4733c27c18e8Smrg 4734c27c18e8Smrg if test -n "$exclude_expsyms"; then 4735c27c18e8Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736c27c18e8Smrg $MV "$nlist"T "$nlist" 4737c43cc173Smrg fi 4738c27c18e8Smrg 4739c27c18e8Smrg # Try sorting and uniquifying the output. 4740c27c18e8Smrg if $GREP -v "^: " < "$nlist" | 4741c27c18e8Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742c27c18e8Smrg sort -k 3 4743c27c18e8Smrg else 4744c27c18e8Smrg sort +2 4745c27c18e8Smrg fi | 4746c27c18e8Smrg uniq > "$nlist"S; then 4747c27c18e8Smrg : 4748c43cc173Smrg else 4749c27c18e8Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750c43cc173Smrg fi 4751c43cc173Smrg 4752c27c18e8Smrg if test -f "$nlist"S; then 4753c27c18e8Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754c43cc173Smrg else 475537eb1ca1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756c43cc173Smrg fi 4757c43cc173Smrg 475844584a44Smrg func_show_eval '$RM "${nlist}I"' 475944584a44Smrg if test -n "$global_symbol_to_import"; then 476044584a44Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 476144584a44Smrg fi 476244584a44Smrg 476337eb1ca1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4764c43cc173Smrg 4765c27c18e8Smrg/* The mapping between symbol names and symbols. */ 4766c27c18e8Smrgtypedef struct { 4767c27c18e8Smrg const char *name; 4768c27c18e8Smrg void *address; 4769c27c18e8Smrg} lt_dlsymlist; 4770b789ec8aSmrgextern LT_DLSYM_CONST lt_dlsymlist 477144584a44Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 477244584a44Smrg" 477344584a44Smrg 477444584a44Smrg if test -s "$nlist"I; then 477544584a44Smrg echo >> "$output_objdir/$my_dlsyms" "\ 477644584a44Smrgstatic void lt_syminit(void) 477744584a44Smrg{ 477844584a44Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 477944584a44Smrg for (; symbol->name; ++symbol) 478044584a44Smrg {" 478144584a44Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 478244584a44Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478344584a44Smrg } 478444584a44Smrg}" 478544584a44Smrg fi 478644584a44Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4787b789ec8aSmrgLT_DLSYM_CONST lt_dlsymlist 4788c27c18e8Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 478944584a44Smrg{ {\"$my_originator\", (void *) 0}," 479044584a44Smrg 479144584a44Smrg if test -s "$nlist"I; then 479244584a44Smrg echo >> "$output_objdir/$my_dlsyms" "\ 479344584a44Smrg {\"@INIT@\", (void *) <_syminit}," 479444584a44Smrg fi 4795c43cc173Smrg 4796c27c18e8Smrg case $need_lib_prefix in 4797c27c18e8Smrg no) 4798c27c18e8Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799c27c18e8Smrg ;; 4800c27c18e8Smrg *) 4801c27c18e8Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802c27c18e8Smrg ;; 4803c27c18e8Smrg esac 480437eb1ca1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4805c27c18e8Smrg {0, (void *) 0} 4806c27c18e8Smrg}; 4807c43cc173Smrg 4808c27c18e8Smrg/* This works around a problem in FreeBSD linker */ 4809c27c18e8Smrg#ifdef FREEBSD_WORKAROUND 4810c27c18e8Smrgstatic const void *lt_preloaded_setup() { 4811c27c18e8Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812c27c18e8Smrg} 4813c27c18e8Smrg#endif 4814c43cc173Smrg 4815c27c18e8Smrg#ifdef __cplusplus 4816c27c18e8Smrg} 4817c27c18e8Smrg#endif\ 4818c27c18e8Smrg" 4819c27c18e8Smrg } # !$opt_dry_run 4820c43cc173Smrg 4821c27c18e8Smrg pic_flag_for_symtable= 4822c27c18e8Smrg case "$compile_command " in 4823c27c18e8Smrg *" -static "*) ;; 4824c27c18e8Smrg *) 4825c27c18e8Smrg case $host in 4826c27c18e8Smrg # compiling the symbol table file with pic_flag works around 4827c27c18e8Smrg # a FreeBSD bug that causes programs to crash when -lm is 4828c27c18e8Smrg # linked before any other PIC object. But we must not use 4829c27c18e8Smrg # pic_flag when linking with -static. The problem exists in 4830c27c18e8Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831f1ee322dSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832c27c18e8Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833c27c18e8Smrg *-*-hpux*) 4834c27c18e8Smrg pic_flag_for_symtable=" $pic_flag" ;; 4835c27c18e8Smrg *) 483644584a44Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837c27c18e8Smrg ;; 4838c27c18e8Smrg esac 4839c27c18e8Smrg ;; 4840c27c18e8Smrg esac 4841c27c18e8Smrg symtab_cflags= 4842c27c18e8Smrg for arg in $LTCFLAGS; do 4843c27c18e8Smrg case $arg in 4844c27c18e8Smrg -pie | -fpie | -fPIE) ;; 4845b789ec8aSmrg *) func_append symtab_cflags " $arg" ;; 4846c27c18e8Smrg esac 4847c27c18e8Smrg done 4848c43cc173Smrg 4849c27c18e8Smrg # Now compile the dynamic symbol file. 4850c27c18e8Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851c43cc173Smrg 4852c27c18e8Smrg # Clean up the generated files. 485344584a44Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854c43cc173Smrg 4855c27c18e8Smrg # Transform the symbol file into the correct name. 485644584a44Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857c27c18e8Smrg case $host in 4858c27c18e8Smrg *cygwin* | *mingw* | *cegcc* ) 4859c27c18e8Smrg if test -f "$output_objdir/$my_outputname.def"; then 486037eb1ca1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486137eb1ca1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862c27c18e8Smrg else 486337eb1ca1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486437eb1ca1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865c27c18e8Smrg fi 4866c27c18e8Smrg ;; 4867c27c18e8Smrg *) 486837eb1ca1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486937eb1ca1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870c27c18e8Smrg ;; 4871c27c18e8Smrg esac 4872c27c18e8Smrg ;; 4873c27c18e8Smrg *) 487444584a44Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875c27c18e8Smrg ;; 4876c27c18e8Smrg esac 4877c27c18e8Smrg else 4878c27c18e8Smrg # We keep going just in case the user didn't refer to 4879c27c18e8Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880c27c18e8Smrg # really was required. 4881c43cc173Smrg 4882c27c18e8Smrg # Nullify the symbol file. 488337eb1ca1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488437eb1ca1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885c27c18e8Smrg fi 4886c27c18e8Smrg} 4887c43cc173Smrg 488844584a44Smrg# func_cygming_gnu_implib_p ARG 488944584a44Smrg# This predicate returns with zero status (TRUE) if 489044584a44Smrg# ARG is a GNU/binutils-style import library. Returns 489144584a44Smrg# with nonzero status (FALSE) otherwise. 489244584a44Smrgfunc_cygming_gnu_implib_p () 489344584a44Smrg{ 489444584a44Smrg $debug_cmd 489544584a44Smrg 489644584a44Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 489744584a44Smrg 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)$'` 489844584a44Smrg test -n "$func_cygming_gnu_implib_tmp" 489944584a44Smrg} 490044584a44Smrg 490144584a44Smrg# func_cygming_ms_implib_p ARG 490244584a44Smrg# This predicate returns with zero status (TRUE) if 490344584a44Smrg# ARG is an MS-style import library. Returns 490444584a44Smrg# with nonzero status (FALSE) otherwise. 490544584a44Smrgfunc_cygming_ms_implib_p () 490644584a44Smrg{ 490744584a44Smrg $debug_cmd 490844584a44Smrg 490944584a44Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 491044584a44Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 491144584a44Smrg test -n "$func_cygming_ms_implib_tmp" 491244584a44Smrg} 491344584a44Smrg 4914c27c18e8Smrg# func_win32_libid arg 4915c27c18e8Smrg# return the library type of file 'arg' 4916c27c18e8Smrg# 4917c27c18e8Smrg# Need a lot of goo to handle *both* DLLs and import libs 4918c27c18e8Smrg# Has to be a shell function in order to 'eat' the argument 4919c27c18e8Smrg# that is supplied when $file_magic_command is called. 492037eb1ca1Smrg# Despite the name, also deal with 64 bit binaries. 4921c27c18e8Smrgfunc_win32_libid () 4922c27c18e8Smrg{ 492344584a44Smrg $debug_cmd 492444584a44Smrg 492544584a44Smrg win32_libid_type=unknown 4926c27c18e8Smrg win32_fileres=`file -L $1 2>/dev/null` 4927c27c18e8Smrg case $win32_fileres in 4928c27c18e8Smrg *ar\ archive\ import\ library*) # definitely import 4929c27c18e8Smrg win32_libid_type="x86 archive import" 4930c27c18e8Smrg ;; 4931c27c18e8Smrg *ar\ archive*) # could be an import, or static 493237eb1ca1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933c27c18e8Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493437eb1ca1Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 493544584a44Smrg case $nm_interface in 493644584a44Smrg "MS dumpbin") 493744584a44Smrg if func_cygming_ms_implib_p "$1" || 493844584a44Smrg func_cygming_gnu_implib_p "$1" 493944584a44Smrg then 494044584a44Smrg win32_nmres=import 494144584a44Smrg else 494244584a44Smrg win32_nmres= 494344584a44Smrg fi 494444584a44Smrg ;; 494544584a44Smrg *) 494644584a44Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 494744584a44Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 494844584a44Smrg $SED -n -e ' 4949c27c18e8Smrg 1,100{ 4950c27c18e8Smrg / I /{ 495144584a44Smrg s|.*|import| 4952c27c18e8Smrg p 4953c27c18e8Smrg q 4954c27c18e8Smrg } 4955c27c18e8Smrg }'` 495644584a44Smrg ;; 495744584a44Smrg esac 4958c27c18e8Smrg case $win32_nmres in 4959c27c18e8Smrg import*) win32_libid_type="x86 archive import";; 4960c27c18e8Smrg *) win32_libid_type="x86 archive static";; 4961c27c18e8Smrg esac 4962c27c18e8Smrg fi 4963c27c18e8Smrg ;; 4964c27c18e8Smrg *DLL*) 4965c27c18e8Smrg win32_libid_type="x86 DLL" 4966c27c18e8Smrg ;; 4967c27c18e8Smrg *executable*) # but shell scripts are "executable" too... 4968c27c18e8Smrg case $win32_fileres in 4969c27c18e8Smrg *MS\ Windows\ PE\ Intel*) 4970c27c18e8Smrg win32_libid_type="x86 DLL" 4971c27c18e8Smrg ;; 4972c27c18e8Smrg esac 4973c27c18e8Smrg ;; 4974c27c18e8Smrg esac 4975c27c18e8Smrg $ECHO "$win32_libid_type" 4976c27c18e8Smrg} 4977c43cc173Smrg 4978b789ec8aSmrg# func_cygming_dll_for_implib ARG 4979b789ec8aSmrg# 4980b789ec8aSmrg# Platform-specific function to extract the 4981b789ec8aSmrg# name of the DLL associated with the specified 4982b789ec8aSmrg# import library ARG. 4983b789ec8aSmrg# Invoked by eval'ing the libtool variable 4984b789ec8aSmrg# $sharedlib_from_linklib_cmd 4985b789ec8aSmrg# Result is available in the variable 4986b789ec8aSmrg# $sharedlib_from_linklib_result 4987b789ec8aSmrgfunc_cygming_dll_for_implib () 4988b789ec8aSmrg{ 498944584a44Smrg $debug_cmd 499044584a44Smrg 4991b789ec8aSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992b789ec8aSmrg} 4993b789ec8aSmrg 4994b789ec8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995b789ec8aSmrg# 4996b789ec8aSmrg# The is the core of a fallback implementation of a 4997b789ec8aSmrg# platform-specific function to extract the name of the 4998b789ec8aSmrg# DLL associated with the specified import library LIBNAME. 4999b789ec8aSmrg# 5000b789ec8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001b789ec8aSmrg# on the platform and compiler that created the implib. 5002b789ec8aSmrg# 5003b789ec8aSmrg# Echos the name of the DLL associated with the 5004b789ec8aSmrg# specified import library. 5005b789ec8aSmrgfunc_cygming_dll_for_implib_fallback_core () 5006b789ec8aSmrg{ 500744584a44Smrg $debug_cmd 500844584a44Smrg 5009b789ec8aSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010b789ec8aSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011b789ec8aSmrg $SED '/^Contents of section '"$match_literal"':/{ 5012b789ec8aSmrg # Place marker at beginning of archive member dllname section 5013b789ec8aSmrg s/.*/====MARK====/ 5014b789ec8aSmrg p 5015b789ec8aSmrg d 5016b789ec8aSmrg } 5017b789ec8aSmrg # These lines can sometimes be longer than 43 characters, but 5018b789ec8aSmrg # are always uninteresting 5019b789ec8aSmrg /:[ ]*file format pe[i]\{,1\}-/d 5020b789ec8aSmrg /^In archive [^:]*:/d 5021b789ec8aSmrg # Ensure marker is printed 5022b789ec8aSmrg /^====MARK====/p 5023b789ec8aSmrg # Remove all lines with less than 43 characters 5024b789ec8aSmrg /^.\{43\}/!d 5025b789ec8aSmrg # From remaining lines, remove first 43 characters 5026b789ec8aSmrg s/^.\{43\}//' | 5027b789ec8aSmrg $SED -n ' 5028b789ec8aSmrg # Join marker and all lines until next marker into a single line 5029b789ec8aSmrg /^====MARK====/ b para 5030b789ec8aSmrg H 5031b789ec8aSmrg $ b para 5032b789ec8aSmrg b 5033b789ec8aSmrg :para 5034b789ec8aSmrg x 5035b789ec8aSmrg s/\n//g 5036b789ec8aSmrg # Remove the marker 5037b789ec8aSmrg s/^====MARK====// 5038b789ec8aSmrg # Remove trailing dots and whitespace 5039b789ec8aSmrg s/[\. \t]*$// 5040b789ec8aSmrg # Print 5041b789ec8aSmrg /./p' | 5042b789ec8aSmrg # we now have a list, one entry per line, of the stringified 5043b789ec8aSmrg # contents of the appropriate section of all members of the 504444584a44Smrg # archive that possess that section. Heuristic: eliminate 504544584a44Smrg # all those that have a first or second character that is 5046b789ec8aSmrg # a '.' (that is, objdump's representation of an unprintable 5047b789ec8aSmrg # character.) This should work for all archives with less than 5048b789ec8aSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5049b789ec8aSmrg # begins with a literal '.' or a single character followed by 5050b789ec8aSmrg # a '.'. 5051b789ec8aSmrg # 5052b789ec8aSmrg # Of those that remain, print the first one. 5053b789ec8aSmrg $SED -e '/^\./d;/^.\./d;q' 5054b789ec8aSmrg} 5055b789ec8aSmrg 5056b789ec8aSmrg# func_cygming_dll_for_implib_fallback ARG 5057b789ec8aSmrg# Platform-specific function to extract the 5058b789ec8aSmrg# name of the DLL associated with the specified 5059b789ec8aSmrg# import library ARG. 5060b789ec8aSmrg# 5061b789ec8aSmrg# This fallback implementation is for use when $DLLTOOL 5062b789ec8aSmrg# does not support the --identify-strict option. 5063b789ec8aSmrg# Invoked by eval'ing the libtool variable 5064b789ec8aSmrg# $sharedlib_from_linklib_cmd 5065b789ec8aSmrg# Result is available in the variable 5066b789ec8aSmrg# $sharedlib_from_linklib_result 5067b789ec8aSmrgfunc_cygming_dll_for_implib_fallback () 5068b789ec8aSmrg{ 506944584a44Smrg $debug_cmd 507044584a44Smrg 507144584a44Smrg if func_cygming_gnu_implib_p "$1"; then 5072b789ec8aSmrg # binutils import library 5073b789ec8aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 507444584a44Smrg elif func_cygming_ms_implib_p "$1"; then 5075b789ec8aSmrg # ms-generated import library 5076b789ec8aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077b789ec8aSmrg else 5078b789ec8aSmrg # unknown 507944584a44Smrg sharedlib_from_linklib_result= 5080b789ec8aSmrg fi 5081b789ec8aSmrg} 5082c43cc173Smrg 5083c43cc173Smrg 5084c27c18e8Smrg# func_extract_an_archive dir oldlib 5085c27c18e8Smrgfunc_extract_an_archive () 5086c27c18e8Smrg{ 508744584a44Smrg $debug_cmd 508844584a44Smrg 508944584a44Smrg f_ex_an_ar_dir=$1; shift 509044584a44Smrg f_ex_an_ar_oldlib=$1 509144584a44Smrg if test yes = "$lock_old_archive_extraction"; then 509237eb1ca1Smrg lockfile=$f_ex_an_ar_oldlib.lock 509337eb1ca1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509437eb1ca1Smrg func_echo "Waiting for $lockfile to be removed" 509537eb1ca1Smrg sleep 2 509637eb1ca1Smrg done 509737eb1ca1Smrg fi 509837eb1ca1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509937eb1ca1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 510044584a44Smrg if test yes = "$lock_old_archive_extraction"; then 510137eb1ca1Smrg $opt_dry_run || rm -f "$lockfile" 510237eb1ca1Smrg fi 5103c27c18e8Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104c27c18e8Smrg : 5105c27c18e8Smrg else 5106c27c18e8Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107c27c18e8Smrg fi 5108c27c18e8Smrg} 5109c43cc173Smrg 5110c43cc173Smrg 5111c27c18e8Smrg# func_extract_archives gentop oldlib ... 5112c27c18e8Smrgfunc_extract_archives () 5113c27c18e8Smrg{ 511444584a44Smrg $debug_cmd 511544584a44Smrg 511644584a44Smrg my_gentop=$1; shift 5117c27c18e8Smrg my_oldlibs=${1+"$@"} 511844584a44Smrg my_oldobjs= 511944584a44Smrg my_xlib= 512044584a44Smrg my_xabs= 512144584a44Smrg my_xdir= 5122c43cc173Smrg 5123c27c18e8Smrg for my_xlib in $my_oldlibs; do 5124c27c18e8Smrg # Extract the objects. 5125c27c18e8Smrg case $my_xlib in 512644584a44Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127c27c18e8Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128c27c18e8Smrg esac 5129c27c18e8Smrg func_basename "$my_xlib" 513044584a44Smrg my_xlib=$func_basename_result 5131c27c18e8Smrg my_xlib_u=$my_xlib 5132c27c18e8Smrg while :; do 5133c27c18e8Smrg case " $extracted_archives " in 5134c27c18e8Smrg *" $my_xlib_u "*) 5135c27c18e8Smrg func_arith $extracted_serial + 1 5136c27c18e8Smrg extracted_serial=$func_arith_result 5137c27c18e8Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138c27c18e8Smrg *) break ;; 5139c27c18e8Smrg esac 5140c27c18e8Smrg done 5141c27c18e8Smrg extracted_archives="$extracted_archives $my_xlib_u" 514244584a44Smrg my_xdir=$my_gentop/$my_xlib_u 5143c43cc173Smrg 5144c27c18e8Smrg func_mkdir_p "$my_xdir" 5145c27c18e8Smrg 5146c27c18e8Smrg case $host in 5147c27c18e8Smrg *-darwin*) 5148c27c18e8Smrg func_verbose "Extracting $my_xabs" 5149c27c18e8Smrg # Do not bother doing anything if just a dry run 5150c27c18e8Smrg $opt_dry_run || { 5151c27c18e8Smrg darwin_orig_dir=`pwd` 5152c27c18e8Smrg cd $my_xdir || exit $? 5153c27c18e8Smrg darwin_archive=$my_xabs 5154c27c18e8Smrg darwin_curdir=`pwd` 515544584a44Smrg func_basename "$darwin_archive" 515644584a44Smrg darwin_base_archive=$func_basename_result 5157c27c18e8Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158c27c18e8Smrg if test -n "$darwin_arches"; then 5159c27c18e8Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160c27c18e8Smrg darwin_arch= 5161c27c18e8Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 516244584a44Smrg for darwin_arch in $darwin_arches; do 516344584a44Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 516444584a44Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 516544584a44Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 516644584a44Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167c27c18e8Smrg cd "$darwin_curdir" 516844584a44Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169c27c18e8Smrg done # $darwin_arches 5170c27c18e8Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 517144584a44Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172c27c18e8Smrg darwin_file= 5173c27c18e8Smrg darwin_files= 5174c27c18e8Smrg for darwin_file in $darwin_filelist; do 517537eb1ca1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176c27c18e8Smrg $LIPO -create -output "$darwin_file" $darwin_files 5177c27c18e8Smrg done # $darwin_filelist 5178c27c18e8Smrg $RM -rf unfat-$$ 5179c27c18e8Smrg cd "$darwin_orig_dir" 5180c43cc173Smrg else 5181c27c18e8Smrg cd $darwin_orig_dir 5182c27c18e8Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183c27c18e8Smrg fi # $darwin_arches 5184c27c18e8Smrg } # !$opt_dry_run 5185c27c18e8Smrg ;; 5186c27c18e8Smrg *) 5187c27c18e8Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188c27c18e8Smrg ;; 5189c27c18e8Smrg esac 519037eb1ca1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191c27c18e8Smrg done 5192c43cc173Smrg 519344584a44Smrg func_extract_archives_result=$my_oldobjs 5194c27c18e8Smrg} 5195c43cc173Smrg 5196c43cc173Smrg 519737eb1ca1Smrg# func_emit_wrapper [arg=no] 519837eb1ca1Smrg# 519937eb1ca1Smrg# Emit a libtool wrapper script on stdout. 520037eb1ca1Smrg# Don't directly open a file because we may want to 520137eb1ca1Smrg# incorporate the script contents within a cygwin/mingw 520237eb1ca1Smrg# wrapper executable. Must ONLY be called from within 520337eb1ca1Smrg# func_mode_link because it depends on a number of variables 520437eb1ca1Smrg# set therein. 5205c27c18e8Smrg# 520637eb1ca1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520737eb1ca1Smrg# variable will take. If 'yes', then the emitted script 520844584a44Smrg# will assume that the directory where it is stored is 520937eb1ca1Smrg# the $objdir directory. This is a cygwin/mingw-specific 521037eb1ca1Smrg# behavior. 521137eb1ca1Smrgfunc_emit_wrapper () 5212c27c18e8Smrg{ 521337eb1ca1Smrg func_emit_wrapper_arg1=${1-no} 5214c43cc173Smrg 5215c27c18e8Smrg $ECHO "\ 5216c27c18e8Smrg#! $SHELL 5217c43cc173Smrg 5218c27c18e8Smrg# $output - temporary wrapper script for $objdir/$outputname 521944584a44Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220c27c18e8Smrg# 5221c27c18e8Smrg# The $output program cannot be directly executed until all the libtool 5222c27c18e8Smrg# libraries that it depends on are installed. 5223c27c18e8Smrg# 5224c27c18e8Smrg# This wrapper script should never be moved out of the build directory. 5225c27c18e8Smrg# If it is, it will not operate correctly. 5226c43cc173Smrg 5227c27c18e8Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5228c27c18e8Smrg# metacharacters that are still active within double-quoted strings. 5229c27c18e8Smrgsed_quote_subst='$sed_quote_subst' 5230c43cc173Smrg 5231c27c18e8Smrg# Be Bourne compatible 5232c27c18e8Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233c27c18e8Smrg emulate sh 5234c27c18e8Smrg NULLCMD=: 5235c27c18e8Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236c27c18e8Smrg # is contrary to our usage. Disable this feature. 5237c27c18e8Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238c27c18e8Smrg setopt NO_GLOB_SUBST 5239c27c18e8Smrgelse 5240c27c18e8Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241c27c18e8Smrgfi 5242c27c18e8SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243c27c18e8SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244c43cc173Smrg 5245c27c18e8Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246c27c18e8Smrg# if CDPATH is set. 5247c27c18e8Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248c43cc173Smrg 5249c27c18e8Smrgrelink_command=\"$relink_command\" 5250c43cc173Smrg 5251c27c18e8Smrg# This environment variable determines our operation mode. 5252c27c18e8Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253c27c18e8Smrg # install mode needs the following variables: 5254c27c18e8Smrg generated_by_libtool_version='$macro_version' 5255c27c18e8Smrg notinst_deplibs='$notinst_deplibs' 5256c27c18e8Smrgelse 5257c27c18e8Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258c27c18e8Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525937eb1ca1Smrg file=\"\$0\"" 526037eb1ca1Smrg 526137eb1ca1Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526237eb1ca1Smrg $ECHO "\ 526337eb1ca1Smrg 526437eb1ca1Smrg# A function that is used when there is no print builtin or printf. 526537eb1ca1Smrgfunc_fallback_echo () 526637eb1ca1Smrg{ 526737eb1ca1Smrg eval 'cat <<_LTECHO_EOF 526837eb1ca1Smrg\$1 526937eb1ca1Smrg_LTECHO_EOF' 527037eb1ca1Smrg} 527137eb1ca1Smrg ECHO=\"$qECHO\" 527237eb1ca1Smrg fi 527337eb1ca1Smrg 527437eb1ca1Smrg# Very basic option parsing. These options are (a) specific to 527537eb1ca1Smrg# the libtool wrapper, (b) are identical between the wrapper 527644584a44Smrg# /script/ and the wrapper /executable/ that is used only on 527737eb1ca1Smrg# windows platforms, and (c) all begin with the string "--lt-" 527844584a44Smrg# (application programs are unlikely to have options that match 527937eb1ca1Smrg# this pattern). 528037eb1ca1Smrg# 528137eb1ca1Smrg# There are only two supported options: --lt-debug and 528237eb1ca1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 528337eb1ca1Smrg# 528437eb1ca1Smrg# The first argument to this parsing function should be the 528537eb1ca1Smrg# script's $0 value, followed by "$@". 528637eb1ca1Smrglt_option_debug= 528737eb1ca1Smrgfunc_parse_lt_options () 528837eb1ca1Smrg{ 528937eb1ca1Smrg lt_script_arg0=\$0 529037eb1ca1Smrg shift 529137eb1ca1Smrg for lt_opt 529237eb1ca1Smrg do 529337eb1ca1Smrg case \"\$lt_opt\" in 529437eb1ca1Smrg --lt-debug) lt_option_debug=1 ;; 529537eb1ca1Smrg --lt-dump-script) 529637eb1ca1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529737eb1ca1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529837eb1ca1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529937eb1ca1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 530037eb1ca1Smrg exit 0 530137eb1ca1Smrg ;; 530237eb1ca1Smrg --lt-*) 530337eb1ca1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530437eb1ca1Smrg exit 1 530537eb1ca1Smrg ;; 530637eb1ca1Smrg esac 530737eb1ca1Smrg done 530837eb1ca1Smrg 530937eb1ca1Smrg # Print the debug banner immediately: 531037eb1ca1Smrg if test -n \"\$lt_option_debug\"; then 531144584a44Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531237eb1ca1Smrg fi 531337eb1ca1Smrg} 531437eb1ca1Smrg 531537eb1ca1Smrg# Used when --lt-debug. Prints its arguments to stdout 531637eb1ca1Smrg# (redirection is the responsibility of the caller) 531737eb1ca1Smrgfunc_lt_dump_args () 531837eb1ca1Smrg{ 531937eb1ca1Smrg lt_dump_args_N=1; 532037eb1ca1Smrg for lt_arg 532137eb1ca1Smrg do 532244584a44Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532337eb1ca1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532437eb1ca1Smrg done 532537eb1ca1Smrg} 532637eb1ca1Smrg 532737eb1ca1Smrg# Core function for launching the target application 532837eb1ca1Smrgfunc_exec_program_core () 532937eb1ca1Smrg{ 5330c27c18e8Smrg" 533137eb1ca1Smrg case $host in 533237eb1ca1Smrg # Backslashes separate directories on plain windows 533337eb1ca1Smrg *-*-mingw | *-*-os2* | *-cegcc*) 533437eb1ca1Smrg $ECHO "\ 533537eb1ca1Smrg if test -n \"\$lt_option_debug\"; then 533644584a44Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533737eb1ca1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533837eb1ca1Smrg fi 533937eb1ca1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534037eb1ca1Smrg" 534137eb1ca1Smrg ;; 534237eb1ca1Smrg 534337eb1ca1Smrg *) 534437eb1ca1Smrg $ECHO "\ 534537eb1ca1Smrg if test -n \"\$lt_option_debug\"; then 534644584a44Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534737eb1ca1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534837eb1ca1Smrg fi 534937eb1ca1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535037eb1ca1Smrg" 535137eb1ca1Smrg ;; 535237eb1ca1Smrg esac 535337eb1ca1Smrg $ECHO "\ 535437eb1ca1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535537eb1ca1Smrg exit 1 535637eb1ca1Smrg} 535737eb1ca1Smrg 535837eb1ca1Smrg# A function to encapsulate launching the target application 535937eb1ca1Smrg# Strips options in the --lt-* namespace from \$@ and 536037eb1ca1Smrg# launches target application with the remaining arguments. 536137eb1ca1Smrgfunc_exec_program () 536237eb1ca1Smrg{ 5363f1ee322dSmrg case \" \$* \" in 5364f1ee322dSmrg *\\ --lt-*) 5365f1ee322dSmrg for lt_wr_arg 5366f1ee322dSmrg do 5367f1ee322dSmrg case \$lt_wr_arg in 5368f1ee322dSmrg --lt-*) ;; 5369f1ee322dSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370f1ee322dSmrg esac 5371f1ee322dSmrg shift 5372f1ee322dSmrg done ;; 5373f1ee322dSmrg esac 537437eb1ca1Smrg func_exec_program_core \${1+\"\$@\"} 537537eb1ca1Smrg} 537637eb1ca1Smrg 537737eb1ca1Smrg # Parse options 537837eb1ca1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379c43cc173Smrg 5380c27c18e8Smrg # Find the directory that this script lives in. 538137eb1ca1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382c27c18e8Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383c43cc173Smrg 5384c27c18e8Smrg # Follow symbolic links until we get to the real thisdir. 538537eb1ca1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386c27c18e8Smrg while test -n \"\$file\"; do 538737eb1ca1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388c27c18e8Smrg 5389c27c18e8Smrg # If there was a directory component, then change thisdir. 5390c27c18e8Smrg if test \"x\$destdir\" != \"x\$file\"; then 5391c27c18e8Smrg case \"\$destdir\" in 5392c27c18e8Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393c27c18e8Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394c43cc173Smrg esac 5395c27c18e8Smrg fi 5396c43cc173Smrg 539737eb1ca1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539837eb1ca1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399c27c18e8Smrg done 5400c43cc173Smrg 5401c27c18e8Smrg # Usually 'no', except on cygwin/mingw when embedded into 5402c27c18e8Smrg # the cwrapper. 540337eb1ca1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404c27c18e8Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405c27c18e8Smrg # special case for '.' 5406c27c18e8Smrg if test \"\$thisdir\" = \".\"; then 5407c27c18e8Smrg thisdir=\`pwd\` 5408c27c18e8Smrg fi 5409c27c18e8Smrg # remove .libs from thisdir 5410c27c18e8Smrg case \"\$thisdir\" in 541137eb1ca1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412c27c18e8Smrg $objdir ) thisdir=. ;; 5413c27c18e8Smrg esac 5414c27c18e8Smrg fi 5415c27c18e8Smrg 5416c27c18e8Smrg # Try to get the absolute directory name. 5417c27c18e8Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5418c27c18e8Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419c27c18e8Smrg" 5420c27c18e8Smrg 542144584a44Smrg if test yes = "$fast_install"; then 5422c27c18e8Smrg $ECHO "\ 5423c27c18e8Smrg program=lt-'$outputname'$exeext 5424c27c18e8Smrg progdir=\"\$thisdir/$objdir\" 5425c27c18e8Smrg 5426c27c18e8Smrg if test ! -f \"\$progdir/\$program\" || 542744584a44Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428c27c18e8Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429c27c18e8Smrg 5430c27c18e8Smrg file=\"\$\$-\$program\" 5431c27c18e8Smrg 5432c27c18e8Smrg if test ! -d \"\$progdir\"; then 5433c27c18e8Smrg $MKDIR \"\$progdir\" 5434c27c18e8Smrg else 5435c27c18e8Smrg $RM \"\$progdir/\$file\" 5436c27c18e8Smrg fi" 5437c27c18e8Smrg 5438c27c18e8Smrg $ECHO "\ 5439c27c18e8Smrg 5440c27c18e8Smrg # relink executable if necessary 5441c27c18e8Smrg if test -n \"\$relink_command\"; then 5442c27c18e8Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443c27c18e8Smrg else 544444584a44Smrg \$ECHO \"\$relink_command_output\" >&2 5445c27c18e8Smrg $RM \"\$progdir/\$file\" 5446c27c18e8Smrg exit 1 5447c43cc173Smrg fi 5448c27c18e8Smrg fi 5449c43cc173Smrg 5450c27c18e8Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451c27c18e8Smrg { $RM \"\$progdir/\$program\"; 5452c27c18e8Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453c27c18e8Smrg $RM \"\$progdir/\$file\" 5454c27c18e8Smrg fi" 5455c27c18e8Smrg else 5456c27c18e8Smrg $ECHO "\ 5457c27c18e8Smrg program='$outputname' 5458c27c18e8Smrg progdir=\"\$thisdir/$objdir\" 5459c27c18e8Smrg" 5460c43cc173Smrg fi 5461c43cc173Smrg 5462c27c18e8Smrg $ECHO "\ 5463c27c18e8Smrg 5464c27c18e8Smrg if test -f \"\$progdir/\$program\"; then" 5465c27c18e8Smrg 5466b789ec8aSmrg # fixup the dll searchpath if we need to. 5467b789ec8aSmrg # 5468b789ec8aSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5469b789ec8aSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470b789ec8aSmrg # libraries must come first. 5471b789ec8aSmrg if test -n "$dllsearchpath"; then 5472b789ec8aSmrg $ECHO "\ 5473b789ec8aSmrg # Add the dll search path components to the executable PATH 5474b789ec8aSmrg PATH=$dllsearchpath:\$PATH 5475b789ec8aSmrg" 5476b789ec8aSmrg fi 5477b789ec8aSmrg 5478c27c18e8Smrg # Export our shlibpath_var if we have one. 547944584a44Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480c27c18e8Smrg $ECHO "\ 5481c27c18e8Smrg # Add our own library path to $shlibpath_var 5482c27c18e8Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483c27c18e8Smrg 5484c27c18e8Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485c27c18e8Smrg # The second colon is a workaround for a bug in BeOS R4 sed 548637eb1ca1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487c27c18e8Smrg 5488c27c18e8Smrg export $shlibpath_var 5489c27c18e8Smrg" 5490c43cc173Smrg fi 5491c43cc173Smrg 5492c27c18e8Smrg $ECHO "\ 5493c27c18e8Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494c27c18e8Smrg # Run the actual program with our arguments. 549537eb1ca1Smrg func_exec_program \${1+\"\$@\"} 5496c27c18e8Smrg fi 5497c27c18e8Smrg else 5498c27c18e8Smrg # The program doesn't exist. 549944584a44Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500c27c18e8Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550137eb1ca1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502c27c18e8Smrg exit 1 5503c27c18e8Smrg fi 5504c27c18e8Smrgfi\ 5505c27c18e8Smrg" 5506c27c18e8Smrg} 5507c43cc173Smrg 5508c43cc173Smrg 5509c27c18e8Smrg# func_emit_cwrapperexe_src 5510c27c18e8Smrg# emit the source code for a wrapper executable on stdout 5511c27c18e8Smrg# Must ONLY be called from within func_mode_link because 5512c27c18e8Smrg# it depends on a number of variable set therein. 5513c27c18e8Smrgfunc_emit_cwrapperexe_src () 5514c27c18e8Smrg{ 5515c27c18e8Smrg cat <<EOF 5516c43cc173Smrg 5517c27c18e8Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 551844584a44Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519c43cc173Smrg 5520c27c18e8Smrg The $output program cannot be directly executed until all the libtool 5521c27c18e8Smrg libraries that it depends on are installed. 5522c43cc173Smrg 5523c27c18e8Smrg This wrapper executable should never be moved out of the build directory. 5524c27c18e8Smrg If it is, it will not operate correctly. 5525c27c18e8Smrg*/ 5526c27c18e8SmrgEOF 5527c27c18e8Smrg cat <<"EOF" 552837eb1ca1Smrg#ifdef _MSC_VER 552937eb1ca1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 553037eb1ca1Smrg#endif 5531c27c18e8Smrg#include <stdio.h> 5532c27c18e8Smrg#include <stdlib.h> 5533c27c18e8Smrg#ifdef _MSC_VER 5534c27c18e8Smrg# include <direct.h> 5535c27c18e8Smrg# include <process.h> 5536c27c18e8Smrg# include <io.h> 5537c27c18e8Smrg#else 5538c27c18e8Smrg# include <unistd.h> 5539c27c18e8Smrg# include <stdint.h> 5540c27c18e8Smrg# ifdef __CYGWIN__ 5541c27c18e8Smrg# include <io.h> 5542c27c18e8Smrg# endif 5543c27c18e8Smrg#endif 5544c27c18e8Smrg#include <malloc.h> 5545c27c18e8Smrg#include <stdarg.h> 5546c27c18e8Smrg#include <assert.h> 5547c27c18e8Smrg#include <string.h> 5548c27c18e8Smrg#include <ctype.h> 5549c27c18e8Smrg#include <errno.h> 5550c27c18e8Smrg#include <fcntl.h> 5551c27c18e8Smrg#include <sys/stat.h> 5552c43cc173Smrg 555344584a44Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 555444584a44Smrg 555537eb1ca1Smrg/* declarations of non-ANSI functions */ 555644584a44Smrg#if defined __MINGW32__ 555737eb1ca1Smrg# ifdef __STRICT_ANSI__ 555837eb1ca1Smrgint _putenv (const char *); 555937eb1ca1Smrg# endif 556044584a44Smrg#elif defined __CYGWIN__ 556137eb1ca1Smrg# ifdef __STRICT_ANSI__ 556237eb1ca1Smrgchar *realpath (const char *, char *); 556337eb1ca1Smrgint putenv (char *); 556437eb1ca1Smrgint setenv (const char *, const char *, int); 556537eb1ca1Smrg# endif 556644584a44Smrg/* #elif defined other_platform || defined ... */ 556737eb1ca1Smrg#endif 556837eb1ca1Smrg 556937eb1ca1Smrg/* portability defines, excluding path handling macros */ 557044584a44Smrg#if defined _MSC_VER 557137eb1ca1Smrg# define setmode _setmode 557237eb1ca1Smrg# define stat _stat 557337eb1ca1Smrg# define chmod _chmod 557437eb1ca1Smrg# define getcwd _getcwd 557537eb1ca1Smrg# define putenv _putenv 557637eb1ca1Smrg# define S_IXUSR _S_IEXEC 557744584a44Smrg#elif defined __MINGW32__ 557837eb1ca1Smrg# define setmode _setmode 557937eb1ca1Smrg# define stat _stat 558037eb1ca1Smrg# define chmod _chmod 558137eb1ca1Smrg# define getcwd _getcwd 558237eb1ca1Smrg# define putenv _putenv 558344584a44Smrg#elif defined __CYGWIN__ 558437eb1ca1Smrg# define HAVE_SETENV 558537eb1ca1Smrg# define FOPEN_WB "wb" 558644584a44Smrg/* #elif defined other platforms ... */ 558737eb1ca1Smrg#endif 558837eb1ca1Smrg 558944584a44Smrg#if defined PATH_MAX 5590c27c18e8Smrg# define LT_PATHMAX PATH_MAX 559144584a44Smrg#elif defined MAXPATHLEN 5592c27c18e8Smrg# define LT_PATHMAX MAXPATHLEN 5593c27c18e8Smrg#else 5594c27c18e8Smrg# define LT_PATHMAX 1024 5595c27c18e8Smrg#endif 5596c43cc173Smrg 5597c27c18e8Smrg#ifndef S_IXOTH 5598c27c18e8Smrg# define S_IXOTH 0 5599c27c18e8Smrg#endif 5600c27c18e8Smrg#ifndef S_IXGRP 5601c27c18e8Smrg# define S_IXGRP 0 5602c27c18e8Smrg#endif 5603c43cc173Smrg 560437eb1ca1Smrg/* path handling portability macros */ 5605c27c18e8Smrg#ifndef DIR_SEPARATOR 5606c27c18e8Smrg# define DIR_SEPARATOR '/' 5607c27c18e8Smrg# define PATH_SEPARATOR ':' 5608c27c18e8Smrg#endif 5609c43cc173Smrg 561044584a44Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 561144584a44Smrg defined __OS2__ 5612c27c18e8Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613c27c18e8Smrg# define FOPEN_WB "wb" 5614c27c18e8Smrg# ifndef DIR_SEPARATOR_2 5615c27c18e8Smrg# define DIR_SEPARATOR_2 '\\' 5616c27c18e8Smrg# endif 5617c27c18e8Smrg# ifndef PATH_SEPARATOR_2 5618c27c18e8Smrg# define PATH_SEPARATOR_2 ';' 5619c27c18e8Smrg# endif 5620c27c18e8Smrg#endif 5621c43cc173Smrg 5622c27c18e8Smrg#ifndef DIR_SEPARATOR_2 5623c27c18e8Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624c27c18e8Smrg#else /* DIR_SEPARATOR_2 */ 5625c27c18e8Smrg# define IS_DIR_SEPARATOR(ch) \ 5626c27c18e8Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627c27c18e8Smrg#endif /* DIR_SEPARATOR_2 */ 5628c43cc173Smrg 5629c27c18e8Smrg#ifndef PATH_SEPARATOR_2 5630c27c18e8Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631c27c18e8Smrg#else /* PATH_SEPARATOR_2 */ 5632c27c18e8Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633c27c18e8Smrg#endif /* PATH_SEPARATOR_2 */ 5634c43cc173Smrg 5635c27c18e8Smrg#ifndef FOPEN_WB 5636c27c18e8Smrg# define FOPEN_WB "w" 5637c27c18e8Smrg#endif 5638c27c18e8Smrg#ifndef _O_BINARY 5639c27c18e8Smrg# define _O_BINARY 0 5640c27c18e8Smrg#endif 5641c43cc173Smrg 5642c27c18e8Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643c27c18e8Smrg#define XFREE(stale) do { \ 564444584a44Smrg if (stale) { free (stale); stale = 0; } \ 5645c27c18e8Smrg} while (0) 5646c43cc173Smrg 564744584a44Smrg#if defined LT_DEBUGWRAPPER 564837eb1ca1Smrgstatic int lt_debug = 1; 5649c27c18e8Smrg#else 565037eb1ca1Smrgstatic int lt_debug = 0; 5651c27c18e8Smrg#endif 5652c43cc173Smrg 565337eb1ca1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654c43cc173Smrg 5655c27c18e8Smrgvoid *xmalloc (size_t num); 5656c27c18e8Smrgchar *xstrdup (const char *string); 5657c27c18e8Smrgconst char *base_name (const char *name); 5658c27c18e8Smrgchar *find_executable (const char *wrapper); 5659c27c18e8Smrgchar *chase_symlinks (const char *pathspec); 5660c27c18e8Smrgint make_executable (const char *path); 5661c27c18e8Smrgint check_executable (const char *path); 5662c27c18e8Smrgchar *strendzap (char *str, const char *pat); 566337eb1ca1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566437eb1ca1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566537eb1ca1Smrgstatic const char *nonnull (const char *s); 566637eb1ca1Smrgstatic const char *nonempty (const char *s); 5667c27c18e8Smrgvoid lt_setenv (const char *name, const char *value); 5668c27c18e8Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669c27c18e8Smrgvoid lt_update_exe_path (const char *name, const char *value); 5670c27c18e8Smrgvoid lt_update_lib_path (const char *name, const char *value); 567137eb1ca1Smrgchar **prepare_spawn (char **argv); 567237eb1ca1Smrgvoid lt_dump_script (FILE *f); 5673c27c18e8SmrgEOF 5674c27c18e8Smrg 5675c27c18e8Smrg cat <<EOF 567644584a44Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 567744584a44Smrg# define externally_visible volatile 567844584a44Smrg#else 567944584a44Smrg# define externally_visible __attribute__((externally_visible)) volatile 568044584a44Smrg#endif 568144584a44Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682c27c18e8Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683c27c18e8SmrgEOF 5684c43cc173Smrg 568544584a44Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686b789ec8aSmrg func_to_host_path "$temp_rpath" 5687c27c18e8Smrg cat <<EOF 5688b789ec8aSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689c27c18e8SmrgEOF 5690c27c18e8Smrg else 5691c27c18e8Smrg cat <<"EOF" 5692c27c18e8Smrgconst char * LIB_PATH_VALUE = ""; 5693c27c18e8SmrgEOF 5694c27c18e8Smrg fi 5695c43cc173Smrg 5696c27c18e8Smrg if test -n "$dllsearchpath"; then 5697b789ec8aSmrg func_to_host_path "$dllsearchpath:" 5698c27c18e8Smrg cat <<EOF 5699c27c18e8Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5700b789ec8aSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701c27c18e8SmrgEOF 5702c27c18e8Smrg else 5703c27c18e8Smrg cat <<"EOF" 5704c27c18e8Smrgconst char * EXE_PATH_VARNAME = ""; 5705c27c18e8Smrgconst char * EXE_PATH_VALUE = ""; 5706c27c18e8SmrgEOF 5707c27c18e8Smrg fi 5708c43cc173Smrg 570944584a44Smrg if test yes = "$fast_install"; then 5710c27c18e8Smrg cat <<EOF 5711c27c18e8Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712c27c18e8SmrgEOF 5713c27c18e8Smrg else 5714c27c18e8Smrg cat <<EOF 5715c27c18e8Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716c27c18e8SmrgEOF 5717c27c18e8Smrg fi 5718c43cc173Smrg 5719c43cc173Smrg 5720c27c18e8Smrg cat <<"EOF" 5721c43cc173Smrg 5722c27c18e8Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723c43cc173Smrg 5724c27c18e8Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725c27c18e8Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572637eb1ca1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727c27c18e8Smrg 5728c27c18e8Smrgint 5729c27c18e8Smrgmain (int argc, char *argv[]) 5730c27c18e8Smrg{ 5731c27c18e8Smrg char **newargz; 5732c27c18e8Smrg int newargc; 5733c27c18e8Smrg char *tmp_pathspec; 5734c27c18e8Smrg char *actual_cwrapper_path; 5735c27c18e8Smrg char *actual_cwrapper_name; 5736c27c18e8Smrg char *target_name; 5737c27c18e8Smrg char *lt_argv_zero; 573844584a44Smrg int rval = 127; 5739c27c18e8Smrg 5740c27c18e8Smrg int i; 5741c27c18e8Smrg 5742c27c18e8Smrg program_name = (char *) xstrdup (base_name (argv[0])); 574344584a44Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744c27c18e8Smrg 574537eb1ca1Smrg /* very simple arg parsing; don't want to rely on getopt 574637eb1ca1Smrg * also, copy all non cwrapper options to newargz, except 574737eb1ca1Smrg * argz[0], which is handled differently 574837eb1ca1Smrg */ 574937eb1ca1Smrg newargc=0; 5750c27c18e8Smrg for (i = 1; i < argc; i++) 5751c27c18e8Smrg { 575244584a44Smrg if (STREQ (argv[i], dumpscript_opt)) 5753c27c18e8Smrg { 5754c27c18e8SmrgEOF 575544584a44Smrg case $host in 5756c27c18e8Smrg *mingw* | *cygwin* ) 5757c27c18e8Smrg # make stdout use "unix" line endings 5758c27c18e8Smrg echo " setmode(1,_O_BINARY);" 5759c27c18e8Smrg ;; 5760c27c18e8Smrg esac 5761c27c18e8Smrg 5762c27c18e8Smrg cat <<"EOF" 576337eb1ca1Smrg lt_dump_script (stdout); 5764c27c18e8Smrg return 0; 5765c27c18e8Smrg } 576644584a44Smrg if (STREQ (argv[i], debug_opt)) 576737eb1ca1Smrg { 576837eb1ca1Smrg lt_debug = 1; 576937eb1ca1Smrg continue; 577037eb1ca1Smrg } 577144584a44Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577237eb1ca1Smrg { 577337eb1ca1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577437eb1ca1Smrg namespace, but it is not one of the ones we know about and 577537eb1ca1Smrg have already dealt with, above (inluding dump-script), then 577637eb1ca1Smrg report an error. Otherwise, targets might begin to believe 577737eb1ca1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577837eb1ca1Smrg namespace. The first time any user complains about this, we'll 577937eb1ca1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578037eb1ca1Smrg or a configure.ac-settable value. 578137eb1ca1Smrg */ 578237eb1ca1Smrg lt_fatal (__FILE__, __LINE__, 578337eb1ca1Smrg "unrecognized %s option: '%s'", 578437eb1ca1Smrg ltwrapper_option_prefix, argv[i]); 578537eb1ca1Smrg } 578637eb1ca1Smrg /* otherwise ... */ 578737eb1ca1Smrg newargz[++newargc] = xstrdup (argv[i]); 5788c27c18e8Smrg } 578937eb1ca1Smrg newargz[++newargc] = NULL; 579037eb1ca1Smrg 579137eb1ca1SmrgEOF 579237eb1ca1Smrg cat <<EOF 579337eb1ca1Smrg /* The GNU banner must be the first non-error debug message */ 579444584a44Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579537eb1ca1SmrgEOF 579637eb1ca1Smrg cat <<"EOF" 579737eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579837eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799c27c18e8Smrg 5800c27c18e8Smrg tmp_pathspec = find_executable (argv[0]); 5801c27c18e8Smrg if (tmp_pathspec == NULL) 580237eb1ca1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580337eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 580437eb1ca1Smrg "(main) found exe (before symlink chase) at: %s\n", 580537eb1ca1Smrg tmp_pathspec); 5806c27c18e8Smrg 5807c27c18e8Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580837eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 580937eb1ca1Smrg "(main) found exe (after symlink chase) at: %s\n", 581037eb1ca1Smrg actual_cwrapper_path); 5811c27c18e8Smrg XFREE (tmp_pathspec); 5812c27c18e8Smrg 581337eb1ca1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814c27c18e8Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815c27c18e8Smrg 5816c27c18e8Smrg /* wrapper name transforms */ 5817c27c18e8Smrg strendzap (actual_cwrapper_name, ".exe"); 5818c27c18e8Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819c27c18e8Smrg XFREE (actual_cwrapper_name); 5820c27c18e8Smrg actual_cwrapper_name = tmp_pathspec; 5821c27c18e8Smrg tmp_pathspec = 0; 5822c27c18e8Smrg 5823c27c18e8Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824c27c18e8Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825c27c18e8Smrg strendzap (target_name, ".exe"); 5826c27c18e8Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827c27c18e8Smrg XFREE (target_name); 5828c27c18e8Smrg target_name = tmp_pathspec; 5829c27c18e8Smrg tmp_pathspec = 0; 5830c27c18e8Smrg 583137eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 583237eb1ca1Smrg "(main) libtool target name: %s\n", 583337eb1ca1Smrg target_name); 5834c27c18e8SmrgEOF 5835c27c18e8Smrg 5836c27c18e8Smrg cat <<EOF 5837c27c18e8Smrg newargz[0] = 5838c27c18e8Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839c27c18e8Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840c27c18e8Smrg strcpy (newargz[0], actual_cwrapper_path); 5841c27c18e8Smrg strcat (newargz[0], "$objdir"); 5842c27c18e8Smrg strcat (newargz[0], "/"); 5843c27c18e8SmrgEOF 5844c27c18e8Smrg 5845c27c18e8Smrg cat <<"EOF" 5846c27c18e8Smrg /* stop here, and copy so we don't have to do this twice */ 5847c27c18e8Smrg tmp_pathspec = xstrdup (newargz[0]); 5848c27c18e8Smrg 5849c27c18e8Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850c27c18e8Smrg strcat (newargz[0], actual_cwrapper_name); 5851c27c18e8Smrg 5852c27c18e8Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853c27c18e8Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854c27c18e8Smrg XFREE (tmp_pathspec); 5855c27c18e8Smrg tmp_pathspec = NULL; 5856c27c18e8SmrgEOF 5857c27c18e8Smrg 5858c27c18e8Smrg case $host_os in 5859c27c18e8Smrg mingw*) 5860c27c18e8Smrg cat <<"EOF" 5861c27c18e8Smrg { 5862c27c18e8Smrg char* p; 5863c27c18e8Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864c27c18e8Smrg { 5865c27c18e8Smrg *p = '/'; 5866c27c18e8Smrg } 5867c27c18e8Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868c27c18e8Smrg { 5869c27c18e8Smrg *p = '/'; 5870c27c18e8Smrg } 5871c27c18e8Smrg } 5872c27c18e8SmrgEOF 5873c43cc173Smrg ;; 5874c27c18e8Smrg esac 5875c27c18e8Smrg 5876c27c18e8Smrg cat <<"EOF" 5877c27c18e8Smrg XFREE (target_name); 5878c27c18e8Smrg XFREE (actual_cwrapper_path); 5879c27c18e8Smrg XFREE (actual_cwrapper_name); 5880c27c18e8Smrg 5881c27c18e8Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882c27c18e8Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883b789ec8aSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884b789ec8aSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885b789ec8aSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886b789ec8aSmrg libraries must come first. */ 5887c27c18e8Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888b789ec8aSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889c27c18e8Smrg 589037eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589137eb1ca1Smrg nonnull (lt_argv_zero)); 5892c27c18e8Smrg for (i = 0; i < newargc; i++) 5893c27c18e8Smrg { 589437eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589537eb1ca1Smrg i, nonnull (newargz[i])); 5896c27c18e8Smrg } 5897c43cc173Smrg 5898c43cc173SmrgEOF 5899c43cc173Smrg 5900c27c18e8Smrg case $host_os in 5901c27c18e8Smrg mingw*) 5902c27c18e8Smrg cat <<"EOF" 5903c27c18e8Smrg /* execv doesn't actually work on mingw as expected on unix */ 590437eb1ca1Smrg newargz = prepare_spawn (newargz); 590544584a44Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906c27c18e8Smrg if (rval == -1) 5907c27c18e8Smrg { 5908c27c18e8Smrg /* failed to start process */ 590937eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 591037eb1ca1Smrg "(main) failed to launch target \"%s\": %s\n", 591137eb1ca1Smrg lt_argv_zero, nonnull (strerror (errno))); 5912c27c18e8Smrg return 127; 5913c27c18e8Smrg } 5914c27c18e8Smrg return rval; 5915c27c18e8SmrgEOF 5916c27c18e8Smrg ;; 5917c27c18e8Smrg *) 5918c27c18e8Smrg cat <<"EOF" 5919c27c18e8Smrg execv (lt_argv_zero, newargz); 5920c27c18e8Smrg return rval; /* =127, but avoids unused variable warning */ 5921c27c18e8SmrgEOF 5922c27c18e8Smrg ;; 5923c27c18e8Smrg esac 5924c43cc173Smrg 5925c27c18e8Smrg cat <<"EOF" 5926c27c18e8Smrg} 5927c43cc173Smrg 5928c27c18e8Smrgvoid * 5929c27c18e8Smrgxmalloc (size_t num) 5930c27c18e8Smrg{ 5931c27c18e8Smrg void *p = (void *) malloc (num); 5932c27c18e8Smrg if (!p) 593337eb1ca1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934c43cc173Smrg 5935c27c18e8Smrg return p; 5936c27c18e8Smrg} 5937c43cc173Smrg 5938c27c18e8Smrgchar * 5939c27c18e8Smrgxstrdup (const char *string) 5940c27c18e8Smrg{ 5941c27c18e8Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942c27c18e8Smrg string) : NULL; 5943c27c18e8Smrg} 5944c43cc173Smrg 5945c27c18e8Smrgconst char * 5946c27c18e8Smrgbase_name (const char *name) 5947c27c18e8Smrg{ 5948c27c18e8Smrg const char *base; 5949c43cc173Smrg 595044584a44Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951c27c18e8Smrg /* Skip over the disk name in MSDOS pathnames. */ 5952c27c18e8Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953c27c18e8Smrg name += 2; 5954c27c18e8Smrg#endif 5955c43cc173Smrg 5956c27c18e8Smrg for (base = name; *name; name++) 5957c27c18e8Smrg if (IS_DIR_SEPARATOR (*name)) 5958c27c18e8Smrg base = name + 1; 5959c27c18e8Smrg return base; 5960c27c18e8Smrg} 5961c43cc173Smrg 5962c27c18e8Smrgint 5963c27c18e8Smrgcheck_executable (const char *path) 5964c27c18e8Smrg{ 5965c27c18e8Smrg struct stat st; 5966c43cc173Smrg 596737eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596837eb1ca1Smrg nonempty (path)); 5969c27c18e8Smrg if ((!path) || (!*path)) 5970c27c18e8Smrg return 0; 5971c43cc173Smrg 5972c27c18e8Smrg if ((stat (path, &st) >= 0) 5973c27c18e8Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974c27c18e8Smrg return 1; 5975c27c18e8Smrg else 5976c27c18e8Smrg return 0; 5977c27c18e8Smrg} 5978c43cc173Smrg 5979c27c18e8Smrgint 5980c27c18e8Smrgmake_executable (const char *path) 5981c27c18e8Smrg{ 5982c27c18e8Smrg int rval = 0; 5983c27c18e8Smrg struct stat st; 5984c43cc173Smrg 598537eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598637eb1ca1Smrg nonempty (path)); 5987c27c18e8Smrg if ((!path) || (!*path)) 5988c27c18e8Smrg return 0; 5989c43cc173Smrg 5990c27c18e8Smrg if (stat (path, &st) >= 0) 5991c27c18e8Smrg { 5992c27c18e8Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993c27c18e8Smrg } 5994c27c18e8Smrg return rval; 5995c27c18e8Smrg} 5996c43cc173Smrg 5997c27c18e8Smrg/* Searches for the full path of the wrapper. Returns 5998c27c18e8Smrg newly allocated full path name if found, NULL otherwise 5999c27c18e8Smrg Does not chase symlinks, even on platforms that support them. 6000c27c18e8Smrg*/ 6001c27c18e8Smrgchar * 6002c27c18e8Smrgfind_executable (const char *wrapper) 6003c27c18e8Smrg{ 6004c27c18e8Smrg int has_slash = 0; 6005c27c18e8Smrg const char *p; 6006c27c18e8Smrg const char *p_next; 6007c27c18e8Smrg /* static buffer for getcwd */ 6008c27c18e8Smrg char tmp[LT_PATHMAX + 1]; 600944584a44Smrg size_t tmp_len; 6010c27c18e8Smrg char *concat_name; 6011c43cc173Smrg 601237eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601337eb1ca1Smrg nonempty (wrapper)); 6014c43cc173Smrg 6015c27c18e8Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016c27c18e8Smrg return NULL; 6017c43cc173Smrg 6018c27c18e8Smrg /* Absolute path? */ 601944584a44Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020c27c18e8Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021c27c18e8Smrg { 6022c27c18e8Smrg concat_name = xstrdup (wrapper); 6023c27c18e8Smrg if (check_executable (concat_name)) 6024c27c18e8Smrg return concat_name; 6025c27c18e8Smrg XFREE (concat_name); 6026c27c18e8Smrg } 6027c27c18e8Smrg else 6028c27c18e8Smrg { 6029c27c18e8Smrg#endif 6030c27c18e8Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031c27c18e8Smrg { 6032c27c18e8Smrg concat_name = xstrdup (wrapper); 6033c27c18e8Smrg if (check_executable (concat_name)) 6034c27c18e8Smrg return concat_name; 6035c27c18e8Smrg XFREE (concat_name); 6036c27c18e8Smrg } 603744584a44Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038c27c18e8Smrg } 6039c27c18e8Smrg#endif 6040c43cc173Smrg 6041c27c18e8Smrg for (p = wrapper; *p; p++) 6042c27c18e8Smrg if (*p == '/') 6043c27c18e8Smrg { 6044c27c18e8Smrg has_slash = 1; 6045c27c18e8Smrg break; 6046c27c18e8Smrg } 6047c27c18e8Smrg if (!has_slash) 6048c27c18e8Smrg { 6049c27c18e8Smrg /* no slashes; search PATH */ 6050c27c18e8Smrg const char *path = getenv ("PATH"); 6051c27c18e8Smrg if (path != NULL) 6052c27c18e8Smrg { 6053c27c18e8Smrg for (p = path; *p; p = p_next) 6054c27c18e8Smrg { 6055c27c18e8Smrg const char *q; 6056c27c18e8Smrg size_t p_len; 6057c27c18e8Smrg for (q = p; *q; q++) 6058c27c18e8Smrg if (IS_PATH_SEPARATOR (*q)) 6059c27c18e8Smrg break; 606044584a44Smrg p_len = (size_t) (q - p); 6061c27c18e8Smrg p_next = (*q == '\0' ? q : q + 1); 6062c27c18e8Smrg if (p_len == 0) 6063c27c18e8Smrg { 6064c27c18e8Smrg /* empty path: current directory */ 6065c27c18e8Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606637eb1ca1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606737eb1ca1Smrg nonnull (strerror (errno))); 6068c27c18e8Smrg tmp_len = strlen (tmp); 6069c27c18e8Smrg concat_name = 6070c27c18e8Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071c27c18e8Smrg memcpy (concat_name, tmp, tmp_len); 6072c27c18e8Smrg concat_name[tmp_len] = '/'; 6073c27c18e8Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6074c27c18e8Smrg } 6075c27c18e8Smrg else 6076c27c18e8Smrg { 6077c27c18e8Smrg concat_name = 6078c27c18e8Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079c27c18e8Smrg memcpy (concat_name, p, p_len); 6080c27c18e8Smrg concat_name[p_len] = '/'; 6081c27c18e8Smrg strcpy (concat_name + p_len + 1, wrapper); 6082c27c18e8Smrg } 6083c27c18e8Smrg if (check_executable (concat_name)) 6084c27c18e8Smrg return concat_name; 6085c27c18e8Smrg XFREE (concat_name); 6086c27c18e8Smrg } 6087c27c18e8Smrg } 6088c27c18e8Smrg /* not found in PATH; assume curdir */ 6089c27c18e8Smrg } 6090c27c18e8Smrg /* Relative path | not found in path: prepend cwd */ 6091c27c18e8Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609237eb1ca1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609337eb1ca1Smrg nonnull (strerror (errno))); 6094c27c18e8Smrg tmp_len = strlen (tmp); 6095c27c18e8Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096c27c18e8Smrg memcpy (concat_name, tmp, tmp_len); 6097c27c18e8Smrg concat_name[tmp_len] = '/'; 6098c27c18e8Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099c43cc173Smrg 6100c27c18e8Smrg if (check_executable (concat_name)) 6101c27c18e8Smrg return concat_name; 6102c27c18e8Smrg XFREE (concat_name); 6103c27c18e8Smrg return NULL; 6104c27c18e8Smrg} 6105c43cc173Smrg 6106c27c18e8Smrgchar * 6107c27c18e8Smrgchase_symlinks (const char *pathspec) 6108c27c18e8Smrg{ 6109c27c18e8Smrg#ifndef S_ISLNK 6110c27c18e8Smrg return xstrdup (pathspec); 6111c27c18e8Smrg#else 6112c27c18e8Smrg char buf[LT_PATHMAX]; 6113c27c18e8Smrg struct stat s; 6114c27c18e8Smrg char *tmp_pathspec = xstrdup (pathspec); 6115c27c18e8Smrg char *p; 6116c27c18e8Smrg int has_symlinks = 0; 6117c27c18e8Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6118c27c18e8Smrg { 611937eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 612037eb1ca1Smrg "checking path component for symlinks: %s\n", 612137eb1ca1Smrg tmp_pathspec); 6122c27c18e8Smrg if (lstat (tmp_pathspec, &s) == 0) 6123c27c18e8Smrg { 6124c27c18e8Smrg if (S_ISLNK (s.st_mode) != 0) 6125c27c18e8Smrg { 6126c27c18e8Smrg has_symlinks = 1; 6127c27c18e8Smrg break; 6128c27c18e8Smrg } 6129c43cc173Smrg 6130c27c18e8Smrg /* search backwards for last DIR_SEPARATOR */ 6131c27c18e8Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132c27c18e8Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133c27c18e8Smrg p--; 6134c27c18e8Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135c27c18e8Smrg { 6136c27c18e8Smrg /* no more DIR_SEPARATORS left */ 6137c27c18e8Smrg break; 6138c27c18e8Smrg } 6139c27c18e8Smrg *p = '\0'; 6140c27c18e8Smrg } 6141c27c18e8Smrg else 6142c27c18e8Smrg { 614337eb1ca1Smrg lt_fatal (__FILE__, __LINE__, 614437eb1ca1Smrg "error accessing file \"%s\": %s", 614537eb1ca1Smrg tmp_pathspec, nonnull (strerror (errno))); 6146c27c18e8Smrg } 6147c27c18e8Smrg } 6148c27c18e8Smrg XFREE (tmp_pathspec); 6149c43cc173Smrg 6150c27c18e8Smrg if (!has_symlinks) 6151c27c18e8Smrg { 6152c27c18e8Smrg return xstrdup (pathspec); 6153c27c18e8Smrg } 6154c43cc173Smrg 6155c27c18e8Smrg tmp_pathspec = realpath (pathspec, buf); 6156c27c18e8Smrg if (tmp_pathspec == 0) 6157c27c18e8Smrg { 615837eb1ca1Smrg lt_fatal (__FILE__, __LINE__, 615937eb1ca1Smrg "could not follow symlinks for %s", pathspec); 6160c27c18e8Smrg } 6161c27c18e8Smrg return xstrdup (tmp_pathspec); 6162c27c18e8Smrg#endif 6163c27c18e8Smrg} 6164c43cc173Smrg 6165c27c18e8Smrgchar * 6166c27c18e8Smrgstrendzap (char *str, const char *pat) 6167c27c18e8Smrg{ 6168c27c18e8Smrg size_t len, patlen; 6169c43cc173Smrg 6170c27c18e8Smrg assert (str != NULL); 6171c27c18e8Smrg assert (pat != NULL); 6172c43cc173Smrg 6173c27c18e8Smrg len = strlen (str); 6174c27c18e8Smrg patlen = strlen (pat); 6175c43cc173Smrg 6176c27c18e8Smrg if (patlen <= len) 6177c27c18e8Smrg { 6178c27c18e8Smrg str += len - patlen; 617944584a44Smrg if (STREQ (str, pat)) 6180c27c18e8Smrg *str = '\0'; 6181c27c18e8Smrg } 6182c27c18e8Smrg return str; 6183c27c18e8Smrg} 6184c43cc173Smrg 618537eb1ca1Smrgvoid 618637eb1ca1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618737eb1ca1Smrg{ 618837eb1ca1Smrg va_list args; 618937eb1ca1Smrg if (lt_debug) 619037eb1ca1Smrg { 619137eb1ca1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619237eb1ca1Smrg va_start (args, fmt); 619337eb1ca1Smrg (void) vfprintf (stderr, fmt, args); 619437eb1ca1Smrg va_end (args); 619537eb1ca1Smrg } 619637eb1ca1Smrg} 619737eb1ca1Smrg 6198c27c18e8Smrgstatic void 619937eb1ca1Smrglt_error_core (int exit_status, const char *file, 620037eb1ca1Smrg int line, const char *mode, 6201c27c18e8Smrg const char *message, va_list ap) 6202c27c18e8Smrg{ 620337eb1ca1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204c27c18e8Smrg vfprintf (stderr, message, ap); 6205c27c18e8Smrg fprintf (stderr, ".\n"); 6206c43cc173Smrg 6207c27c18e8Smrg if (exit_status >= 0) 6208c27c18e8Smrg exit (exit_status); 6209c27c18e8Smrg} 6210c43cc173Smrg 6211c27c18e8Smrgvoid 621237eb1ca1Smrglt_fatal (const char *file, int line, const char *message, ...) 6213c27c18e8Smrg{ 6214c27c18e8Smrg va_list ap; 6215c27c18e8Smrg va_start (ap, message); 621637eb1ca1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217c27c18e8Smrg va_end (ap); 6218c27c18e8Smrg} 6219c43cc173Smrg 622037eb1ca1Smrgstatic const char * 622137eb1ca1Smrgnonnull (const char *s) 622237eb1ca1Smrg{ 622337eb1ca1Smrg return s ? s : "(null)"; 622437eb1ca1Smrg} 622537eb1ca1Smrg 622637eb1ca1Smrgstatic const char * 622737eb1ca1Smrgnonempty (const char *s) 622837eb1ca1Smrg{ 622937eb1ca1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 623037eb1ca1Smrg} 623137eb1ca1Smrg 6232c27c18e8Smrgvoid 6233c27c18e8Smrglt_setenv (const char *name, const char *value) 6234c27c18e8Smrg{ 623537eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 623637eb1ca1Smrg "(lt_setenv) setting '%s' to '%s'\n", 623737eb1ca1Smrg nonnull (name), nonnull (value)); 6238c27c18e8Smrg { 6239c27c18e8Smrg#ifdef HAVE_SETENV 6240c27c18e8Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241c27c18e8Smrg char *str = xstrdup (value); 6242c27c18e8Smrg setenv (name, str, 1); 6243c27c18e8Smrg#else 624444584a44Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245c27c18e8Smrg char *str = XMALLOC (char, len); 6246c27c18e8Smrg sprintf (str, "%s=%s", name, value); 6247c27c18e8Smrg if (putenv (str) != EXIT_SUCCESS) 6248c27c18e8Smrg { 6249c27c18e8Smrg XFREE (str); 6250c27c18e8Smrg } 6251c27c18e8Smrg#endif 6252c27c18e8Smrg } 6253c27c18e8Smrg} 6254c43cc173Smrg 6255c27c18e8Smrgchar * 6256c27c18e8Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257c27c18e8Smrg{ 6258c27c18e8Smrg char *new_value; 6259c27c18e8Smrg if (orig_value && *orig_value) 6260c27c18e8Smrg { 626144584a44Smrg size_t orig_value_len = strlen (orig_value); 626244584a44Smrg size_t add_len = strlen (add); 6263c27c18e8Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264c27c18e8Smrg if (to_end) 6265c27c18e8Smrg { 6266c27c18e8Smrg strcpy (new_value, orig_value); 6267c27c18e8Smrg strcpy (new_value + orig_value_len, add); 6268c27c18e8Smrg } 6269c27c18e8Smrg else 6270c27c18e8Smrg { 6271c27c18e8Smrg strcpy (new_value, add); 6272c27c18e8Smrg strcpy (new_value + add_len, orig_value); 6273c27c18e8Smrg } 6274c27c18e8Smrg } 6275c27c18e8Smrg else 6276c27c18e8Smrg { 6277c27c18e8Smrg new_value = xstrdup (add); 6278c27c18e8Smrg } 6279c27c18e8Smrg return new_value; 6280c27c18e8Smrg} 6281c43cc173Smrg 6282c27c18e8Smrgvoid 6283c27c18e8Smrglt_update_exe_path (const char *name, const char *value) 6284c27c18e8Smrg{ 628537eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 628637eb1ca1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628737eb1ca1Smrg nonnull (name), nonnull (value)); 6288c43cc173Smrg 6289c27c18e8Smrg if (name && *name && value && *value) 6290c27c18e8Smrg { 6291c27c18e8Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292c27c18e8Smrg /* some systems can't cope with a ':'-terminated path #' */ 629344584a44Smrg size_t len = strlen (new_value); 629444584a44Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295c27c18e8Smrg { 629644584a44Smrg new_value[--len] = '\0'; 6297c27c18e8Smrg } 6298c27c18e8Smrg lt_setenv (name, new_value); 6299c27c18e8Smrg XFREE (new_value); 6300c27c18e8Smrg } 6301c27c18e8Smrg} 6302c43cc173Smrg 6303c27c18e8Smrgvoid 6304c27c18e8Smrglt_update_lib_path (const char *name, const char *value) 6305c27c18e8Smrg{ 630637eb1ca1Smrg lt_debugprintf (__FILE__, __LINE__, 630737eb1ca1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630837eb1ca1Smrg nonnull (name), nonnull (value)); 6309c43cc173Smrg 6310c27c18e8Smrg if (name && *name && value && *value) 6311c27c18e8Smrg { 6312c27c18e8Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313c27c18e8Smrg lt_setenv (name, new_value); 6314c27c18e8Smrg XFREE (new_value); 6315c27c18e8Smrg } 6316c27c18e8Smrg} 6317c43cc173Smrg 631837eb1ca1SmrgEOF 631937eb1ca1Smrg case $host_os in 632037eb1ca1Smrg mingw*) 632137eb1ca1Smrg cat <<"EOF" 632237eb1ca1Smrg 632337eb1ca1Smrg/* Prepares an argument vector before calling spawn(). 632437eb1ca1Smrg Note that spawn() does not by itself call the command interpreter 632537eb1ca1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632637eb1ca1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632737eb1ca1Smrg GetVersionEx(&v); 632837eb1ca1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632937eb1ca1Smrg }) ? "cmd.exe" : "command.com"). 633037eb1ca1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 633137eb1ca1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633237eb1ca1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633337eb1ca1Smrg special way: 633437eb1ca1Smrg - Space and tab are interpreted as delimiters. They are not treated as 633537eb1ca1Smrg delimiters if they are surrounded by double quotes: "...". 633637eb1ca1Smrg - Unescaped double quotes are removed from the input. Their only effect is 633737eb1ca1Smrg that within double quotes, space and tab are treated like normal 633837eb1ca1Smrg characters. 633937eb1ca1Smrg - Backslashes not followed by double quotes are not special. 634037eb1ca1Smrg - But 2*n+1 backslashes followed by a double quote become 634137eb1ca1Smrg n backslashes followed by a double quote (n >= 0): 634237eb1ca1Smrg \" -> " 634337eb1ca1Smrg \\\" -> \" 634437eb1ca1Smrg \\\\\" -> \\" 634537eb1ca1Smrg */ 634637eb1ca1Smrg#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" 634737eb1ca1Smrg#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" 634837eb1ca1Smrgchar ** 634937eb1ca1Smrgprepare_spawn (char **argv) 635037eb1ca1Smrg{ 635137eb1ca1Smrg size_t argc; 635237eb1ca1Smrg char **new_argv; 635337eb1ca1Smrg size_t i; 635437eb1ca1Smrg 635537eb1ca1Smrg /* Count number of arguments. */ 635637eb1ca1Smrg for (argc = 0; argv[argc] != NULL; argc++) 635737eb1ca1Smrg ; 635837eb1ca1Smrg 635937eb1ca1Smrg /* Allocate new argument vector. */ 636037eb1ca1Smrg new_argv = XMALLOC (char *, argc + 1); 636137eb1ca1Smrg 636237eb1ca1Smrg /* Put quoted arguments into the new argument vector. */ 636337eb1ca1Smrg for (i = 0; i < argc; i++) 636437eb1ca1Smrg { 636537eb1ca1Smrg const char *string = argv[i]; 636637eb1ca1Smrg 636737eb1ca1Smrg if (string[0] == '\0') 636837eb1ca1Smrg new_argv[i] = xstrdup ("\"\""); 636937eb1ca1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637037eb1ca1Smrg { 637137eb1ca1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637237eb1ca1Smrg size_t length; 637337eb1ca1Smrg unsigned int backslashes; 637437eb1ca1Smrg const char *s; 637537eb1ca1Smrg char *quoted_string; 637637eb1ca1Smrg char *p; 637737eb1ca1Smrg 637837eb1ca1Smrg length = 0; 637937eb1ca1Smrg backslashes = 0; 638037eb1ca1Smrg if (quote_around) 638137eb1ca1Smrg length++; 638237eb1ca1Smrg for (s = string; *s != '\0'; s++) 638337eb1ca1Smrg { 638437eb1ca1Smrg char c = *s; 638537eb1ca1Smrg if (c == '"') 638637eb1ca1Smrg length += backslashes + 1; 638737eb1ca1Smrg length++; 638837eb1ca1Smrg if (c == '\\') 638937eb1ca1Smrg backslashes++; 639037eb1ca1Smrg else 639137eb1ca1Smrg backslashes = 0; 639237eb1ca1Smrg } 639337eb1ca1Smrg if (quote_around) 639437eb1ca1Smrg length += backslashes + 1; 639537eb1ca1Smrg 639637eb1ca1Smrg quoted_string = XMALLOC (char, length + 1); 639737eb1ca1Smrg 639837eb1ca1Smrg p = quoted_string; 639937eb1ca1Smrg backslashes = 0; 640037eb1ca1Smrg if (quote_around) 640137eb1ca1Smrg *p++ = '"'; 640237eb1ca1Smrg for (s = string; *s != '\0'; s++) 640337eb1ca1Smrg { 640437eb1ca1Smrg char c = *s; 640537eb1ca1Smrg if (c == '"') 640637eb1ca1Smrg { 640737eb1ca1Smrg unsigned int j; 640837eb1ca1Smrg for (j = backslashes + 1; j > 0; j--) 640937eb1ca1Smrg *p++ = '\\'; 641037eb1ca1Smrg } 641137eb1ca1Smrg *p++ = c; 641237eb1ca1Smrg if (c == '\\') 641337eb1ca1Smrg backslashes++; 641437eb1ca1Smrg else 641537eb1ca1Smrg backslashes = 0; 641637eb1ca1Smrg } 641737eb1ca1Smrg if (quote_around) 641837eb1ca1Smrg { 641937eb1ca1Smrg unsigned int j; 642037eb1ca1Smrg for (j = backslashes; j > 0; j--) 642137eb1ca1Smrg *p++ = '\\'; 642237eb1ca1Smrg *p++ = '"'; 642337eb1ca1Smrg } 642437eb1ca1Smrg *p = '\0'; 642537eb1ca1Smrg 642637eb1ca1Smrg new_argv[i] = quoted_string; 642737eb1ca1Smrg } 642837eb1ca1Smrg else 642937eb1ca1Smrg new_argv[i] = (char *) string; 643037eb1ca1Smrg } 643137eb1ca1Smrg new_argv[argc] = NULL; 643237eb1ca1Smrg 643337eb1ca1Smrg return new_argv; 643437eb1ca1Smrg} 643537eb1ca1SmrgEOF 643637eb1ca1Smrg ;; 643737eb1ca1Smrg esac 643837eb1ca1Smrg 643937eb1ca1Smrg cat <<"EOF" 644037eb1ca1Smrgvoid lt_dump_script (FILE* f) 644137eb1ca1Smrg{ 644237eb1ca1SmrgEOF 644337eb1ca1Smrg func_emit_wrapper yes | 6444f1ee322dSmrg $SED -n -e ' 6445f1ee322dSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446f1ee322dSmrg\2/ 6447f1ee322dSmrgh 6448f1ee322dSmrgs/\([\\"]\)/\\\1/g 6449f1ee322dSmrgs/$/\\n/ 6450f1ee322dSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451f1ee322dSmrgg 6452f1ee322dSmrgD' 645337eb1ca1Smrg cat <<"EOF" 645437eb1ca1Smrg} 6455c27c18e8SmrgEOF 6456c27c18e8Smrg} 6457c27c18e8Smrg# end: func_emit_cwrapperexe_src 6458c43cc173Smrg 645937eb1ca1Smrg# func_win32_import_lib_p ARG 646037eb1ca1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646137eb1ca1Smrgfunc_win32_import_lib_p () 646237eb1ca1Smrg{ 646344584a44Smrg $debug_cmd 646444584a44Smrg 646537eb1ca1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646637eb1ca1Smrg *import*) : ;; 646737eb1ca1Smrg *) false ;; 646837eb1ca1Smrg esac 646937eb1ca1Smrg} 647037eb1ca1Smrg 647144584a44Smrg# func_suncc_cstd_abi 647244584a44Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647344584a44Smrg# Several compiler flags select an ABI that is incompatible with the 647444584a44Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647544584a44Smrgfunc_suncc_cstd_abi () 647644584a44Smrg{ 647744584a44Smrg $debug_cmd 647844584a44Smrg 647944584a44Smrg case " $compile_command " in 648044584a44Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648144584a44Smrg suncc_use_cstd_abi=no 648244584a44Smrg ;; 648344584a44Smrg *) 648444584a44Smrg suncc_use_cstd_abi=yes 648544584a44Smrg ;; 648644584a44Smrg esac 648744584a44Smrg} 648844584a44Smrg 6489c27c18e8Smrg# func_mode_link arg... 6490c27c18e8Smrgfunc_mode_link () 6491c27c18e8Smrg{ 649244584a44Smrg $debug_cmd 649344584a44Smrg 6494c27c18e8Smrg case $host in 6495c27c18e8Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496c27c18e8Smrg # It is impossible to link a dll without this setting, and 6497c27c18e8Smrg # we shouldn't force the makefile maintainer to figure out 649844584a44Smrg # what system we are compiling for in order to pass an extra 6499c27c18e8Smrg # flag for every libtool invocation. 6500c27c18e8Smrg # allow_undefined=no 6501c43cc173Smrg 6502c27c18e8Smrg # FIXME: Unfortunately, there are problems with the above when trying 650344584a44Smrg # to make a dll that has undefined symbols, in which case not 6504c27c18e8Smrg # even a static library is built. For now, we need to specify 6505c27c18e8Smrg # -no-undefined on the libtool link line when we can be certain 6506c27c18e8Smrg # that all symbols are satisfied, otherwise we get a static library. 6507c27c18e8Smrg allow_undefined=yes 6508c27c18e8Smrg ;; 6509c27c18e8Smrg *) 6510c27c18e8Smrg allow_undefined=yes 6511c27c18e8Smrg ;; 6512c27c18e8Smrg esac 6513c27c18e8Smrg libtool_args=$nonopt 6514c27c18e8Smrg base_compile="$nonopt $@" 6515c27c18e8Smrg compile_command=$nonopt 6516c27c18e8Smrg finalize_command=$nonopt 6517c43cc173Smrg 6518c27c18e8Smrg compile_rpath= 6519c27c18e8Smrg finalize_rpath= 6520c27c18e8Smrg compile_shlibpath= 6521c27c18e8Smrg finalize_shlibpath= 6522c27c18e8Smrg convenience= 6523c27c18e8Smrg old_convenience= 6524c27c18e8Smrg deplibs= 6525c27c18e8Smrg old_deplibs= 6526c27c18e8Smrg compiler_flags= 6527c27c18e8Smrg linker_flags= 6528c27c18e8Smrg dllsearchpath= 6529c27c18e8Smrg lib_search_path=`pwd` 6530c27c18e8Smrg inst_prefix_dir= 6531c27c18e8Smrg new_inherited_linker_flags= 6532c43cc173Smrg 6533c27c18e8Smrg avoid_version=no 653437eb1ca1Smrg bindir= 6535c27c18e8Smrg dlfiles= 6536c27c18e8Smrg dlprefiles= 6537c27c18e8Smrg dlself=no 6538c27c18e8Smrg export_dynamic=no 6539c27c18e8Smrg export_symbols= 6540c27c18e8Smrg export_symbols_regex= 6541c27c18e8Smrg generated= 6542c27c18e8Smrg libobjs= 6543c27c18e8Smrg ltlibs= 6544c27c18e8Smrg module=no 6545c27c18e8Smrg no_install=no 6546c27c18e8Smrg objs= 654744584a44Smrg os2dllname= 6548c27c18e8Smrg non_pic_objects= 6549c27c18e8Smrg precious_files_regex= 6550c27c18e8Smrg prefer_static_libs=no 655144584a44Smrg preload=false 6552c27c18e8Smrg prev= 6553c27c18e8Smrg prevarg= 6554c27c18e8Smrg release= 6555c27c18e8Smrg rpath= 6556c27c18e8Smrg xrpath= 6557c27c18e8Smrg perm_rpath= 6558c27c18e8Smrg temp_rpath= 6559c27c18e8Smrg thread_safe=no 6560c27c18e8Smrg vinfo= 6561c27c18e8Smrg vinfo_number=no 6562c27c18e8Smrg weak_libs= 656344584a44Smrg single_module=$wl-single_module 6564c27c18e8Smrg func_infer_tag $base_compile 6565c43cc173Smrg 6566c27c18e8Smrg # We need to know -static, to get the right output filenames. 6567c27c18e8Smrg for arg 6568c27c18e8Smrg do 6569c27c18e8Smrg case $arg in 6570c27c18e8Smrg -shared) 657144584a44Smrg test yes != "$build_libtool_libs" \ 657244584a44Smrg && func_fatal_configuration "cannot build a shared library" 6573c27c18e8Smrg build_old_libs=no 6574c27c18e8Smrg break 6575c27c18e8Smrg ;; 6576c27c18e8Smrg -all-static | -static | -static-libtool-libs) 6577c27c18e8Smrg case $arg in 6578c27c18e8Smrg -all-static) 657944584a44Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580c27c18e8Smrg func_warning "complete static linking is impossible in this configuration" 6581c27c18e8Smrg fi 6582c27c18e8Smrg if test -n "$link_static_flag"; then 6583c27c18e8Smrg dlopen_self=$dlopen_self_static 6584c27c18e8Smrg fi 6585c27c18e8Smrg prefer_static_libs=yes 6586c27c18e8Smrg ;; 6587c27c18e8Smrg -static) 6588c27c18e8Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589c27c18e8Smrg dlopen_self=$dlopen_self_static 6590c27c18e8Smrg fi 6591c27c18e8Smrg prefer_static_libs=built 6592c27c18e8Smrg ;; 6593c27c18e8Smrg -static-libtool-libs) 6594c27c18e8Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595c27c18e8Smrg dlopen_self=$dlopen_self_static 6596c27c18e8Smrg fi 6597c27c18e8Smrg prefer_static_libs=yes 6598c27c18e8Smrg ;; 6599c27c18e8Smrg esac 6600c27c18e8Smrg build_libtool_libs=no 6601c27c18e8Smrg build_old_libs=yes 6602c27c18e8Smrg break 6603c43cc173Smrg ;; 6604c43cc173Smrg esac 6605c27c18e8Smrg done 6606c43cc173Smrg 6607c27c18e8Smrg # See if our shared archives depend on static archives. 6608c27c18e8Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609c43cc173Smrg 6610c27c18e8Smrg # Go through the arguments, transforming them on the way. 6611c27c18e8Smrg while test "$#" -gt 0; do 661244584a44Smrg arg=$1 6613c27c18e8Smrg shift 6614c27c18e8Smrg func_quote_for_eval "$arg" 6615c27c18e8Smrg qarg=$func_quote_for_eval_unquoted_result 6616c27c18e8Smrg func_append libtool_args " $func_quote_for_eval_result" 6617c43cc173Smrg 6618c27c18e8Smrg # If the previous option needs an argument, assign it. 6619c27c18e8Smrg if test -n "$prev"; then 6620c27c18e8Smrg case $prev in 6621c27c18e8Smrg output) 6622c27c18e8Smrg func_append compile_command " @OUTPUT@" 6623c27c18e8Smrg func_append finalize_command " @OUTPUT@" 6624c43cc173Smrg ;; 6625c43cc173Smrg esac 6626c43cc173Smrg 6627c27c18e8Smrg case $prev in 662837eb1ca1Smrg bindir) 662944584a44Smrg bindir=$arg 663037eb1ca1Smrg prev= 663137eb1ca1Smrg continue 663237eb1ca1Smrg ;; 6633c27c18e8Smrg dlfiles|dlprefiles) 663444584a44Smrg $preload || { 6635c27c18e8Smrg # Add the symbol object into the linking commands. 6636c27c18e8Smrg func_append compile_command " @SYMFILE@" 6637c27c18e8Smrg func_append finalize_command " @SYMFILE@" 663844584a44Smrg preload=: 663944584a44Smrg } 6640c27c18e8Smrg case $arg in 6641c27c18e8Smrg *.la | *.lo) ;; # We handle these cases below. 6642c27c18e8Smrg force) 664344584a44Smrg if test no = "$dlself"; then 6644c27c18e8Smrg dlself=needless 6645c27c18e8Smrg export_dynamic=yes 6646c27c18e8Smrg fi 6647c27c18e8Smrg prev= 6648c27c18e8Smrg continue 6649c27c18e8Smrg ;; 6650c27c18e8Smrg self) 665144584a44Smrg if test dlprefiles = "$prev"; then 6652c27c18e8Smrg dlself=yes 665344584a44Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654c27c18e8Smrg dlself=yes 6655c43cc173Smrg else 6656c27c18e8Smrg dlself=needless 6657c27c18e8Smrg export_dynamic=yes 6658c43cc173Smrg fi 6659c27c18e8Smrg prev= 6660c27c18e8Smrg continue 6661c27c18e8Smrg ;; 6662c27c18e8Smrg *) 666344584a44Smrg if test dlfiles = "$prev"; then 6664b789ec8aSmrg func_append dlfiles " $arg" 6665c27c18e8Smrg else 6666b789ec8aSmrg func_append dlprefiles " $arg" 6667c27c18e8Smrg fi 6668c27c18e8Smrg prev= 6669c27c18e8Smrg continue 6670c27c18e8Smrg ;; 6671c43cc173Smrg esac 6672c43cc173Smrg ;; 6673c27c18e8Smrg expsyms) 667444584a44Smrg export_symbols=$arg 6675c27c18e8Smrg test -f "$arg" \ 667644584a44Smrg || func_fatal_error "symbol file '$arg' does not exist" 6677c27c18e8Smrg prev= 6678c27c18e8Smrg continue 6679c27c18e8Smrg ;; 6680c27c18e8Smrg expsyms_regex) 668144584a44Smrg export_symbols_regex=$arg 6682c27c18e8Smrg prev= 6683c27c18e8Smrg continue 6684c27c18e8Smrg ;; 6685c27c18e8Smrg framework) 6686c27c18e8Smrg case $host in 6687c27c18e8Smrg *-*-darwin*) 6688c27c18e8Smrg case "$deplibs " in 6689c27c18e8Smrg *" $qarg.ltframework "*) ;; 6690b789ec8aSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691c27c18e8Smrg ;; 6692c43cc173Smrg esac 6693c27c18e8Smrg ;; 6694c43cc173Smrg esac 6695c27c18e8Smrg prev= 6696c27c18e8Smrg continue 6697c27c18e8Smrg ;; 6698c27c18e8Smrg inst_prefix) 669944584a44Smrg inst_prefix_dir=$arg 670044584a44Smrg prev= 670144584a44Smrg continue 670244584a44Smrg ;; 670344584a44Smrg mllvm) 670444584a44Smrg # Clang does not use LLVM to link, so we can simply discard any 670544584a44Smrg # '-mllvm $arg' options when doing the link step. 6706c27c18e8Smrg prev= 6707c27c18e8Smrg continue 6708c27c18e8Smrg ;; 6709c27c18e8Smrg objectlist) 6710c27c18e8Smrg if test -f "$arg"; then 6711c27c18e8Smrg save_arg=$arg 6712c27c18e8Smrg moreargs= 6713c27c18e8Smrg for fil in `cat "$save_arg"` 6714c27c18e8Smrg do 6715b789ec8aSmrg# func_append moreargs " $fil" 6716c27c18e8Smrg arg=$fil 6717c27c18e8Smrg # A libtool-controlled object. 6718c43cc173Smrg 6719c27c18e8Smrg # Check to see that this really is a libtool object. 6720c27c18e8Smrg if func_lalib_unsafe_p "$arg"; then 6721c27c18e8Smrg pic_object= 6722c27c18e8Smrg non_pic_object= 6723c43cc173Smrg 6724c27c18e8Smrg # Read the .lo file 6725c27c18e8Smrg func_source "$arg" 6726c43cc173Smrg 6727c27c18e8Smrg if test -z "$pic_object" || 6728c27c18e8Smrg test -z "$non_pic_object" || 672944584a44Smrg test none = "$pic_object" && 673044584a44Smrg test none = "$non_pic_object"; then 673144584a44Smrg func_fatal_error "cannot find name of object for '$arg'" 6732c27c18e8Smrg fi 6733c43cc173Smrg 6734c27c18e8Smrg # Extract subdirectory from the argument. 6735c27c18e8Smrg func_dirname "$arg" "/" "" 673644584a44Smrg xdir=$func_dirname_result 6737c43cc173Smrg 673844584a44Smrg if test none != "$pic_object"; then 6739c27c18e8Smrg # Prepend the subdirectory the object is found in. 674044584a44Smrg pic_object=$xdir$pic_object 6741c43cc173Smrg 674244584a44Smrg if test dlfiles = "$prev"; then 674344584a44Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744b789ec8aSmrg func_append dlfiles " $pic_object" 6745c27c18e8Smrg prev= 6746c27c18e8Smrg continue 6747c27c18e8Smrg else 6748c27c18e8Smrg # If libtool objects are unsupported, then we need to preload. 6749c27c18e8Smrg prev=dlprefiles 6750c27c18e8Smrg fi 6751c27c18e8Smrg fi 6752c43cc173Smrg 6753c27c18e8Smrg # CHECK ME: I think I busted this. -Ossama 675444584a44Smrg if test dlprefiles = "$prev"; then 6755c27c18e8Smrg # Preload the old-style object. 6756b789ec8aSmrg func_append dlprefiles " $pic_object" 6757c27c18e8Smrg prev= 6758c27c18e8Smrg fi 6759c43cc173Smrg 6760c27c18e8Smrg # A PIC object. 6761c27c18e8Smrg func_append libobjs " $pic_object" 676244584a44Smrg arg=$pic_object 6763c27c18e8Smrg fi 6764c43cc173Smrg 6765c27c18e8Smrg # Non-PIC object. 676644584a44Smrg if test none != "$non_pic_object"; then 6767c27c18e8Smrg # Prepend the subdirectory the object is found in. 676844584a44Smrg non_pic_object=$xdir$non_pic_object 6769c43cc173Smrg 6770c27c18e8Smrg # A standard non-PIC object 6771c27c18e8Smrg func_append non_pic_objects " $non_pic_object" 677244584a44Smrg if test -z "$pic_object" || test none = "$pic_object"; then 677344584a44Smrg arg=$non_pic_object 6774c27c18e8Smrg fi 6775c27c18e8Smrg else 6776c27c18e8Smrg # If the PIC object exists, use it instead. 6777c27c18e8Smrg # $xdir was prepended to $pic_object above. 677844584a44Smrg non_pic_object=$pic_object 6779c27c18e8Smrg func_append non_pic_objects " $non_pic_object" 6780c27c18e8Smrg fi 6781c27c18e8Smrg else 6782c27c18e8Smrg # Only an error if not doing a dry-run. 6783c27c18e8Smrg if $opt_dry_run; then 6784c27c18e8Smrg # Extract subdirectory from the argument. 6785c27c18e8Smrg func_dirname "$arg" "/" "" 678644584a44Smrg xdir=$func_dirname_result 6787c27c18e8Smrg 6788c27c18e8Smrg func_lo2o "$arg" 6789c27c18e8Smrg pic_object=$xdir$objdir/$func_lo2o_result 6790c27c18e8Smrg non_pic_object=$xdir$func_lo2o_result 6791c27c18e8Smrg func_append libobjs " $pic_object" 6792c27c18e8Smrg func_append non_pic_objects " $non_pic_object" 6793c27c18e8Smrg else 679444584a44Smrg func_fatal_error "'$arg' is not a valid libtool object" 6795c27c18e8Smrg fi 6796c27c18e8Smrg fi 6797c43cc173Smrg done 6798c27c18e8Smrg else 679944584a44Smrg func_fatal_error "link input file '$arg' does not exist" 6800c43cc173Smrg fi 6801c27c18e8Smrg arg=$save_arg 6802c27c18e8Smrg prev= 6803c27c18e8Smrg continue 6804c27c18e8Smrg ;; 680544584a44Smrg os2dllname) 680644584a44Smrg os2dllname=$arg 680744584a44Smrg prev= 680844584a44Smrg continue 680944584a44Smrg ;; 6810c27c18e8Smrg precious_regex) 681144584a44Smrg precious_files_regex=$arg 6812c27c18e8Smrg prev= 6813c27c18e8Smrg continue 6814c27c18e8Smrg ;; 6815c27c18e8Smrg release) 681644584a44Smrg release=-$arg 6817c27c18e8Smrg prev= 6818c27c18e8Smrg continue 6819c27c18e8Smrg ;; 6820c27c18e8Smrg rpath | xrpath) 6821c27c18e8Smrg # We need an absolute path. 6822c27c18e8Smrg case $arg in 6823c27c18e8Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824c27c18e8Smrg *) 6825c27c18e8Smrg func_fatal_error "only absolute run-paths are allowed" 6826c27c18e8Smrg ;; 6827c43cc173Smrg esac 682844584a44Smrg if test rpath = "$prev"; then 6829c27c18e8Smrg case "$rpath " in 6830c27c18e8Smrg *" $arg "*) ;; 6831b789ec8aSmrg *) func_append rpath " $arg" ;; 6832c27c18e8Smrg esac 6833c27c18e8Smrg else 6834c27c18e8Smrg case "$xrpath " in 6835c27c18e8Smrg *" $arg "*) ;; 6836b789ec8aSmrg *) func_append xrpath " $arg" ;; 6837c27c18e8Smrg esac 6838c27c18e8Smrg fi 6839c27c18e8Smrg prev= 6840c27c18e8Smrg continue 6841c27c18e8Smrg ;; 6842c27c18e8Smrg shrext) 684344584a44Smrg shrext_cmds=$arg 6844c27c18e8Smrg prev= 6845c27c18e8Smrg continue 6846c27c18e8Smrg ;; 6847c27c18e8Smrg weak) 6848b789ec8aSmrg func_append weak_libs " $arg" 6849c27c18e8Smrg prev= 6850c27c18e8Smrg continue 6851c27c18e8Smrg ;; 6852c27c18e8Smrg xcclinker) 6853b789ec8aSmrg func_append linker_flags " $qarg" 6854b789ec8aSmrg func_append compiler_flags " $qarg" 6855c27c18e8Smrg prev= 6856c27c18e8Smrg func_append compile_command " $qarg" 6857c27c18e8Smrg func_append finalize_command " $qarg" 6858c27c18e8Smrg continue 6859c27c18e8Smrg ;; 6860c27c18e8Smrg xcompiler) 6861b789ec8aSmrg func_append compiler_flags " $qarg" 6862c27c18e8Smrg prev= 6863c27c18e8Smrg func_append compile_command " $qarg" 6864c27c18e8Smrg func_append finalize_command " $qarg" 6865c27c18e8Smrg continue 6866c27c18e8Smrg ;; 6867c27c18e8Smrg xlinker) 6868b789ec8aSmrg func_append linker_flags " $qarg" 6869b789ec8aSmrg func_append compiler_flags " $wl$qarg" 6870c27c18e8Smrg prev= 6871c27c18e8Smrg func_append compile_command " $wl$qarg" 6872c27c18e8Smrg func_append finalize_command " $wl$qarg" 6873c27c18e8Smrg continue 6874c43cc173Smrg ;; 6875c43cc173Smrg *) 6876c27c18e8Smrg eval "$prev=\"\$arg\"" 6877c27c18e8Smrg prev= 6878c27c18e8Smrg continue 6879c43cc173Smrg ;; 6880c43cc173Smrg esac 6881c27c18e8Smrg fi # test -n "$prev" 6882c43cc173Smrg 688344584a44Smrg prevarg=$arg 6884c43cc173Smrg 6885c27c18e8Smrg case $arg in 6886c27c18e8Smrg -all-static) 6887c27c18e8Smrg if test -n "$link_static_flag"; then 6888c27c18e8Smrg # See comment for -static flag below, for more details. 6889c27c18e8Smrg func_append compile_command " $link_static_flag" 6890c27c18e8Smrg func_append finalize_command " $link_static_flag" 6891c43cc173Smrg fi 6892c27c18e8Smrg continue 6893c27c18e8Smrg ;; 6894c43cc173Smrg 6895c27c18e8Smrg -allow-undefined) 6896c27c18e8Smrg # FIXME: remove this flag sometime in the future. 689744584a44Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898c27c18e8Smrg ;; 6899c43cc173Smrg 6900c27c18e8Smrg -avoid-version) 6901c27c18e8Smrg avoid_version=yes 6902c27c18e8Smrg continue 6903c27c18e8Smrg ;; 6904c43cc173Smrg 690537eb1ca1Smrg -bindir) 690637eb1ca1Smrg prev=bindir 690737eb1ca1Smrg continue 690837eb1ca1Smrg ;; 690937eb1ca1Smrg 6910c27c18e8Smrg -dlopen) 6911c27c18e8Smrg prev=dlfiles 6912c27c18e8Smrg continue 6913c27c18e8Smrg ;; 6914c43cc173Smrg 6915c27c18e8Smrg -dlpreopen) 6916c27c18e8Smrg prev=dlprefiles 6917c27c18e8Smrg continue 6918c27c18e8Smrg ;; 6919c43cc173Smrg 6920c27c18e8Smrg -export-dynamic) 6921c27c18e8Smrg export_dynamic=yes 6922c27c18e8Smrg continue 6923c27c18e8Smrg ;; 6924c43cc173Smrg 6925c27c18e8Smrg -export-symbols | -export-symbols-regex) 6926c27c18e8Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927c27c18e8Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928c27c18e8Smrg fi 692944584a44Smrg if test X-export-symbols = "X$arg"; then 6930c27c18e8Smrg prev=expsyms 6931c43cc173Smrg else 6932c27c18e8Smrg prev=expsyms_regex 6933c43cc173Smrg fi 6934c27c18e8Smrg continue 6935c27c18e8Smrg ;; 6936c43cc173Smrg 6937c27c18e8Smrg -framework) 6938c27c18e8Smrg prev=framework 6939c27c18e8Smrg continue 6940c27c18e8Smrg ;; 6941c43cc173Smrg 6942c27c18e8Smrg -inst-prefix-dir) 6943c27c18e8Smrg prev=inst_prefix 6944c27c18e8Smrg continue 6945c27c18e8Smrg ;; 6946c43cc173Smrg 6947c27c18e8Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948c27c18e8Smrg # so, if we see these flags be careful not to treat them like -L 6949c27c18e8Smrg -L[A-Z][A-Z]*:*) 6950c27c18e8Smrg case $with_gcc/$host in 6951c27c18e8Smrg no/*-*-irix* | /*-*-irix*) 6952c27c18e8Smrg func_append compile_command " $arg" 6953c27c18e8Smrg func_append finalize_command " $arg" 6954c27c18e8Smrg ;; 6955c27c18e8Smrg esac 6956c27c18e8Smrg continue 6957c27c18e8Smrg ;; 6958c43cc173Smrg 6959c27c18e8Smrg -L*) 6960b789ec8aSmrg func_stripname "-L" '' "$arg" 6961b789ec8aSmrg if test -z "$func_stripname_result"; then 6962c27c18e8Smrg if test "$#" -gt 0; then 696344584a44Smrg func_fatal_error "require no space between '-L' and '$1'" 6964c43cc173Smrg else 696544584a44Smrg func_fatal_error "need path for '-L' option" 6966c43cc173Smrg fi 6967c27c18e8Smrg fi 6968b789ec8aSmrg func_resolve_sysroot "$func_stripname_result" 6969b789ec8aSmrg dir=$func_resolve_sysroot_result 6970c27c18e8Smrg # We need an absolute path. 6971c27c18e8Smrg case $dir in 6972c27c18e8Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973c27c18e8Smrg *) 6974c27c18e8Smrg absdir=`cd "$dir" && pwd` 6975c27c18e8Smrg test -z "$absdir" && \ 697644584a44Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 697744584a44Smrg dir=$absdir 6978c27c18e8Smrg ;; 6979c43cc173Smrg esac 6980c27c18e8Smrg case "$deplibs " in 6981b789ec8aSmrg *" -L$dir "* | *" $arg "*) 6982b789ec8aSmrg # Will only happen for absolute or sysroot arguments 6983b789ec8aSmrg ;; 6984c27c18e8Smrg *) 6985b789ec8aSmrg # Preserve sysroot, but never include relative directories 6986b789ec8aSmrg case $dir in 6987b789ec8aSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988b789ec8aSmrg *) func_append deplibs " -L$dir" ;; 6989b789ec8aSmrg esac 6990b789ec8aSmrg func_append lib_search_path " $dir" 6991c27c18e8Smrg ;; 6992c43cc173Smrg esac 6993c43cc173Smrg case $host in 6994c27c18e8Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699537eb1ca1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996c27c18e8Smrg case :$dllsearchpath: in 6997c27c18e8Smrg *":$dir:"*) ;; 6998c27c18e8Smrg ::) dllsearchpath=$dir;; 6999b789ec8aSmrg *) func_append dllsearchpath ":$dir";; 7000c27c18e8Smrg esac 7001c27c18e8Smrg case :$dllsearchpath: in 7002c27c18e8Smrg *":$testbindir:"*) ;; 7003c27c18e8Smrg ::) dllsearchpath=$testbindir;; 7004b789ec8aSmrg *) func_append dllsearchpath ":$testbindir";; 7005c27c18e8Smrg esac 7006c27c18e8Smrg ;; 7007c43cc173Smrg esac 7008c27c18e8Smrg continue 7009c27c18e8Smrg ;; 7010c43cc173Smrg 7011c27c18e8Smrg -l*) 701244584a44Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013c27c18e8Smrg case $host in 701437eb1ca1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015c27c18e8Smrg # These systems don't actually have a C or math library (as such) 7016c27c18e8Smrg continue 7017c27c18e8Smrg ;; 7018c27c18e8Smrg *-*-os2*) 7019c27c18e8Smrg # These systems don't actually have a C library (as such) 702044584a44Smrg test X-lc = "X$arg" && continue 7021c27c18e8Smrg ;; 702244584a44Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023c27c18e8Smrg # Do not include libc due to us having libc/libc_r. 702444584a44Smrg test X-lc = "X$arg" && continue 7025c27c18e8Smrg ;; 7026c27c18e8Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7027c27c18e8Smrg # Rhapsody C and math libraries are in the System framework 7028b789ec8aSmrg func_append deplibs " System.ltframework" 7029c27c18e8Smrg continue 7030c27c18e8Smrg ;; 7031c27c18e8Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7032c27c18e8Smrg # Causes problems with __ctype 703344584a44Smrg test X-lc = "X$arg" && continue 7034c27c18e8Smrg ;; 7035c27c18e8Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036c27c18e8Smrg # Compiler inserts libc in the correct place for threads to work 703744584a44Smrg test X-lc = "X$arg" && continue 7038c27c18e8Smrg ;; 7039c27c18e8Smrg esac 704044584a44Smrg elif test X-lc_r = "X$arg"; then 7041c27c18e8Smrg case $host in 704244584a44Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043c27c18e8Smrg # Do not include libc_r directly, use -pthread flag. 7044c27c18e8Smrg continue 7045c27c18e8Smrg ;; 7046c27c18e8Smrg esac 7047c27c18e8Smrg fi 7048b789ec8aSmrg func_append deplibs " $arg" 7049c27c18e8Smrg continue 7050c27c18e8Smrg ;; 7051c43cc173Smrg 705244584a44Smrg -mllvm) 705344584a44Smrg prev=mllvm 705444584a44Smrg continue 705544584a44Smrg ;; 705644584a44Smrg 7057c27c18e8Smrg -module) 7058c27c18e8Smrg module=yes 7059c27c18e8Smrg continue 7060c27c18e8Smrg ;; 7061c43cc173Smrg 7062c27c18e8Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063c27c18e8Smrg # classes, name mangling, and exception handling. 7064c27c18e8Smrg # Darwin uses the -arch flag to determine output architecture. 7065b789ec8aSmrg -model|-arch|-isysroot|--sysroot) 7066b789ec8aSmrg func_append compiler_flags " $arg" 7067c27c18e8Smrg func_append compile_command " $arg" 7068c27c18e8Smrg func_append finalize_command " $arg" 7069c27c18e8Smrg prev=xcompiler 7070c27c18e8Smrg continue 7071c27c18e8Smrg ;; 7072c43cc173Smrg 7073f1ee322dSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074f1ee322dSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075b789ec8aSmrg func_append compiler_flags " $arg" 7076c27c18e8Smrg func_append compile_command " $arg" 7077c27c18e8Smrg func_append finalize_command " $arg" 7078c27c18e8Smrg case "$new_inherited_linker_flags " in 7079c27c18e8Smrg *" $arg "*) ;; 7080b789ec8aSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081c27c18e8Smrg esac 7082c27c18e8Smrg continue 7083c27c18e8Smrg ;; 7084c43cc173Smrg 7085c27c18e8Smrg -multi_module) 708644584a44Smrg single_module=$wl-multi_module 7087c27c18e8Smrg continue 7088c27c18e8Smrg ;; 7089c43cc173Smrg 7090c27c18e8Smrg -no-fast-install) 7091c27c18e8Smrg fast_install=no 7092c27c18e8Smrg continue 7093c27c18e8Smrg ;; 7094c43cc173Smrg 7095c27c18e8Smrg -no-install) 7096c27c18e8Smrg case $host in 7097c27c18e8Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098c27c18e8Smrg # The PATH hackery in wrapper scripts is required on Windows 7099c27c18e8Smrg # and Darwin in order for the loader to find any dlls it needs. 710044584a44Smrg func_warning "'-no-install' is ignored for $host" 710144584a44Smrg func_warning "assuming '-no-fast-install' instead" 7102c27c18e8Smrg fast_install=no 7103c27c18e8Smrg ;; 7104c27c18e8Smrg *) no_install=yes ;; 7105c27c18e8Smrg esac 7106c27c18e8Smrg continue 7107c27c18e8Smrg ;; 7108c43cc173Smrg 7109c27c18e8Smrg -no-undefined) 7110c27c18e8Smrg allow_undefined=no 7111c27c18e8Smrg continue 7112c27c18e8Smrg ;; 7113c43cc173Smrg 7114c27c18e8Smrg -objectlist) 7115c27c18e8Smrg prev=objectlist 7116c27c18e8Smrg continue 7117c27c18e8Smrg ;; 7118c43cc173Smrg 711944584a44Smrg -os2dllname) 712044584a44Smrg prev=os2dllname 712144584a44Smrg continue 712244584a44Smrg ;; 712344584a44Smrg 7124c27c18e8Smrg -o) prev=output ;; 7125c43cc173Smrg 7126c27c18e8Smrg -precious-files-regex) 7127c27c18e8Smrg prev=precious_regex 7128c27c18e8Smrg continue 7129c27c18e8Smrg ;; 7130c43cc173Smrg 7131c27c18e8Smrg -release) 7132c27c18e8Smrg prev=release 7133c27c18e8Smrg continue 7134c27c18e8Smrg ;; 7135c43cc173Smrg 7136c27c18e8Smrg -rpath) 7137c27c18e8Smrg prev=rpath 7138c27c18e8Smrg continue 7139c27c18e8Smrg ;; 7140c43cc173Smrg 7141c27c18e8Smrg -R) 7142c27c18e8Smrg prev=xrpath 7143c27c18e8Smrg continue 7144c27c18e8Smrg ;; 7145c43cc173Smrg 7146c27c18e8Smrg -R*) 7147c27c18e8Smrg func_stripname '-R' '' "$arg" 7148c27c18e8Smrg dir=$func_stripname_result 7149c27c18e8Smrg # We need an absolute path. 7150c27c18e8Smrg case $dir in 7151c27c18e8Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152b789ec8aSmrg =*) 7153b789ec8aSmrg func_stripname '=' '' "$dir" 7154b789ec8aSmrg dir=$lt_sysroot$func_stripname_result 7155b789ec8aSmrg ;; 7156c27c18e8Smrg *) 7157c27c18e8Smrg func_fatal_error "only absolute run-paths are allowed" 7158c27c18e8Smrg ;; 7159c27c18e8Smrg esac 7160c27c18e8Smrg case "$xrpath " in 7161c27c18e8Smrg *" $dir "*) ;; 7162b789ec8aSmrg *) func_append xrpath " $dir" ;; 7163c27c18e8Smrg esac 7164c27c18e8Smrg continue 7165c27c18e8Smrg ;; 7166c43cc173Smrg 7167c27c18e8Smrg -shared) 7168c27c18e8Smrg # The effects of -shared are defined in a previous loop. 7169c27c18e8Smrg continue 7170c27c18e8Smrg ;; 7171c43cc173Smrg 7172c27c18e8Smrg -shrext) 7173c27c18e8Smrg prev=shrext 7174c27c18e8Smrg continue 7175c27c18e8Smrg ;; 7176c43cc173Smrg 7177c27c18e8Smrg -static | -static-libtool-libs) 7178c27c18e8Smrg # The effects of -static are defined in a previous loop. 7179c27c18e8Smrg # We used to do the same as -all-static on platforms that 7180c27c18e8Smrg # didn't have a PIC flag, but the assumption that the effects 7181c27c18e8Smrg # would be equivalent was wrong. It would break on at least 7182c27c18e8Smrg # Digital Unix and AIX. 7183c27c18e8Smrg continue 7184c27c18e8Smrg ;; 7185c43cc173Smrg 7186c27c18e8Smrg -thread-safe) 7187c27c18e8Smrg thread_safe=yes 7188c27c18e8Smrg continue 7189c27c18e8Smrg ;; 7190c43cc173Smrg 7191c27c18e8Smrg -version-info) 7192c27c18e8Smrg prev=vinfo 7193c27c18e8Smrg continue 7194c27c18e8Smrg ;; 7195c43cc173Smrg 7196c27c18e8Smrg -version-number) 7197c27c18e8Smrg prev=vinfo 7198c27c18e8Smrg vinfo_number=yes 7199c27c18e8Smrg continue 7200c27c18e8Smrg ;; 7201c43cc173Smrg 7202c27c18e8Smrg -weak) 7203c27c18e8Smrg prev=weak 7204c27c18e8Smrg continue 7205c27c18e8Smrg ;; 7206c43cc173Smrg 7207c27c18e8Smrg -Wc,*) 7208c27c18e8Smrg func_stripname '-Wc,' '' "$arg" 7209c27c18e8Smrg args=$func_stripname_result 7210c27c18e8Smrg arg= 721144584a44Smrg save_ifs=$IFS; IFS=, 7212c27c18e8Smrg for flag in $args; do 721344584a44Smrg IFS=$save_ifs 7214c27c18e8Smrg func_quote_for_eval "$flag" 7215b789ec8aSmrg func_append arg " $func_quote_for_eval_result" 7216b789ec8aSmrg func_append compiler_flags " $func_quote_for_eval_result" 7217c27c18e8Smrg done 721844584a44Smrg IFS=$save_ifs 7219c27c18e8Smrg func_stripname ' ' '' "$arg" 7220c27c18e8Smrg arg=$func_stripname_result 7221c27c18e8Smrg ;; 7222c43cc173Smrg 7223c27c18e8Smrg -Wl,*) 7224c27c18e8Smrg func_stripname '-Wl,' '' "$arg" 7225c27c18e8Smrg args=$func_stripname_result 7226c27c18e8Smrg arg= 722744584a44Smrg save_ifs=$IFS; IFS=, 7228c27c18e8Smrg for flag in $args; do 722944584a44Smrg IFS=$save_ifs 7230c27c18e8Smrg func_quote_for_eval "$flag" 7231b789ec8aSmrg func_append arg " $wl$func_quote_for_eval_result" 7232b789ec8aSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233b789ec8aSmrg func_append linker_flags " $func_quote_for_eval_result" 7234c27c18e8Smrg done 723544584a44Smrg IFS=$save_ifs 7236c27c18e8Smrg func_stripname ' ' '' "$arg" 7237c27c18e8Smrg arg=$func_stripname_result 7238c27c18e8Smrg ;; 7239c43cc173Smrg 7240c27c18e8Smrg -Xcompiler) 7241c27c18e8Smrg prev=xcompiler 7242c27c18e8Smrg continue 7243c27c18e8Smrg ;; 7244c43cc173Smrg 7245c27c18e8Smrg -Xlinker) 7246c27c18e8Smrg prev=xlinker 7247c27c18e8Smrg continue 7248c27c18e8Smrg ;; 7249c43cc173Smrg 7250c27c18e8Smrg -XCClinker) 7251c27c18e8Smrg prev=xcclinker 7252c27c18e8Smrg continue 7253c27c18e8Smrg ;; 7254c43cc173Smrg 7255c27c18e8Smrg # -msg_* for osf cc 7256c27c18e8Smrg -msg_*) 7257c27c18e8Smrg func_quote_for_eval "$arg" 725844584a44Smrg arg=$func_quote_for_eval_result 7259c27c18e8Smrg ;; 7260c43cc173Smrg 726137eb1ca1Smrg # Flags to be passed through unchanged, with rationale: 726237eb1ca1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726337eb1ca1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 726437eb1ca1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726537eb1ca1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726637eb1ca1Smrg # -q* compiler args for the IBM compiler 726737eb1ca1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726837eb1ca1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 726937eb1ca1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 727044584a44Smrg # -fstack-protector* stack protector flags for GCC 727137eb1ca1Smrg # @file GCC response files 727237eb1ca1Smrg # -tp=* Portland pgcc target processor selection 7273b789ec8aSmrg # --sysroot=* for sysroot support 727444584a44Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 727544584a44Smrg # -stdlib=* select c++ std lib with clang 7276c27c18e8Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277b789ec8aSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 727844584a44Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279c27c18e8Smrg func_quote_for_eval "$arg" 728044584a44Smrg arg=$func_quote_for_eval_result 7281c27c18e8Smrg func_append compile_command " $arg" 7282c27c18e8Smrg func_append finalize_command " $arg" 7283b789ec8aSmrg func_append compiler_flags " $arg" 7284c27c18e8Smrg continue 7285c27c18e8Smrg ;; 7286c43cc173Smrg 728744584a44Smrg -Z*) 728844584a44Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 728944584a44Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 729044584a44Smrg compiler_flags="$compiler_flags $arg" 729144584a44Smrg func_append compile_command " $arg" 729244584a44Smrg func_append finalize_command " $arg" 729344584a44Smrg case $arg in 729444584a44Smrg -Zlinker | -Zstack) 729544584a44Smrg prev=xcompiler 729644584a44Smrg ;; 729744584a44Smrg esac 729844584a44Smrg continue 729944584a44Smrg else 730044584a44Smrg # Otherwise treat like 'Some other compiler flag' below 730144584a44Smrg func_quote_for_eval "$arg" 730244584a44Smrg arg=$func_quote_for_eval_result 730344584a44Smrg fi 730444584a44Smrg ;; 730544584a44Smrg 7306c27c18e8Smrg # Some other compiler flag. 7307c27c18e8Smrg -* | +*) 7308c27c18e8Smrg func_quote_for_eval "$arg" 730944584a44Smrg arg=$func_quote_for_eval_result 7310c27c18e8Smrg ;; 7311c43cc173Smrg 7312c27c18e8Smrg *.$objext) 7313c27c18e8Smrg # A standard object. 7314b789ec8aSmrg func_append objs " $arg" 7315c27c18e8Smrg ;; 7316c43cc173Smrg 7317c27c18e8Smrg *.lo) 7318c27c18e8Smrg # A libtool-controlled object. 7319c43cc173Smrg 7320c27c18e8Smrg # Check to see that this really is a libtool object. 7321c27c18e8Smrg if func_lalib_unsafe_p "$arg"; then 7322c27c18e8Smrg pic_object= 7323c27c18e8Smrg non_pic_object= 7324c43cc173Smrg 7325c27c18e8Smrg # Read the .lo file 7326c27c18e8Smrg func_source "$arg" 7327c43cc173Smrg 7328c27c18e8Smrg if test -z "$pic_object" || 7329c27c18e8Smrg test -z "$non_pic_object" || 733044584a44Smrg test none = "$pic_object" && 733144584a44Smrg test none = "$non_pic_object"; then 733244584a44Smrg func_fatal_error "cannot find name of object for '$arg'" 7333c27c18e8Smrg fi 7334c43cc173Smrg 7335c27c18e8Smrg # Extract subdirectory from the argument. 7336c27c18e8Smrg func_dirname "$arg" "/" "" 733744584a44Smrg xdir=$func_dirname_result 7338c43cc173Smrg 733944584a44Smrg test none = "$pic_object" || { 7340c27c18e8Smrg # Prepend the subdirectory the object is found in. 734144584a44Smrg pic_object=$xdir$pic_object 7342c43cc173Smrg 734344584a44Smrg if test dlfiles = "$prev"; then 734444584a44Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345b789ec8aSmrg func_append dlfiles " $pic_object" 7346c27c18e8Smrg prev= 7347c27c18e8Smrg continue 7348c27c18e8Smrg else 7349c27c18e8Smrg # If libtool objects are unsupported, then we need to preload. 7350c27c18e8Smrg prev=dlprefiles 7351c27c18e8Smrg fi 7352c27c18e8Smrg fi 7353c43cc173Smrg 7354c27c18e8Smrg # CHECK ME: I think I busted this. -Ossama 735544584a44Smrg if test dlprefiles = "$prev"; then 7356c27c18e8Smrg # Preload the old-style object. 7357b789ec8aSmrg func_append dlprefiles " $pic_object" 7358c27c18e8Smrg prev= 7359c27c18e8Smrg fi 7360c43cc173Smrg 7361c27c18e8Smrg # A PIC object. 7362c27c18e8Smrg func_append libobjs " $pic_object" 736344584a44Smrg arg=$pic_object 736444584a44Smrg } 7365c43cc173Smrg 7366c27c18e8Smrg # Non-PIC object. 736744584a44Smrg if test none != "$non_pic_object"; then 7368c27c18e8Smrg # Prepend the subdirectory the object is found in. 736944584a44Smrg non_pic_object=$xdir$non_pic_object 7370c43cc173Smrg 7371c27c18e8Smrg # A standard non-PIC object 7372c27c18e8Smrg func_append non_pic_objects " $non_pic_object" 737344584a44Smrg if test -z "$pic_object" || test none = "$pic_object"; then 737444584a44Smrg arg=$non_pic_object 7375c27c18e8Smrg fi 7376c27c18e8Smrg else 7377c27c18e8Smrg # If the PIC object exists, use it instead. 7378c27c18e8Smrg # $xdir was prepended to $pic_object above. 737944584a44Smrg non_pic_object=$pic_object 7380c27c18e8Smrg func_append non_pic_objects " $non_pic_object" 7381c27c18e8Smrg fi 7382c27c18e8Smrg else 7383c27c18e8Smrg # Only an error if not doing a dry-run. 7384c27c18e8Smrg if $opt_dry_run; then 7385c27c18e8Smrg # Extract subdirectory from the argument. 7386c27c18e8Smrg func_dirname "$arg" "/" "" 738744584a44Smrg xdir=$func_dirname_result 7388c27c18e8Smrg 7389c27c18e8Smrg func_lo2o "$arg" 7390c27c18e8Smrg pic_object=$xdir$objdir/$func_lo2o_result 7391c27c18e8Smrg non_pic_object=$xdir$func_lo2o_result 7392c27c18e8Smrg func_append libobjs " $pic_object" 7393c27c18e8Smrg func_append non_pic_objects " $non_pic_object" 7394c27c18e8Smrg else 739544584a44Smrg func_fatal_error "'$arg' is not a valid libtool object" 7396c27c18e8Smrg fi 7397c27c18e8Smrg fi 7398c27c18e8Smrg ;; 7399c43cc173Smrg 7400c27c18e8Smrg *.$libext) 7401c27c18e8Smrg # An archive. 7402b789ec8aSmrg func_append deplibs " $arg" 7403b789ec8aSmrg func_append old_deplibs " $arg" 7404c27c18e8Smrg continue 7405c27c18e8Smrg ;; 7406c43cc173Smrg 7407c27c18e8Smrg *.la) 7408c27c18e8Smrg # A libtool-controlled library. 7409c43cc173Smrg 7410b789ec8aSmrg func_resolve_sysroot "$arg" 741144584a44Smrg if test dlfiles = "$prev"; then 7412c27c18e8Smrg # This library was specified with -dlopen. 7413b789ec8aSmrg func_append dlfiles " $func_resolve_sysroot_result" 7414c27c18e8Smrg prev= 741544584a44Smrg elif test dlprefiles = "$prev"; then 7416c27c18e8Smrg # The library was specified with -dlpreopen. 7417b789ec8aSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7418c27c18e8Smrg prev= 7419c27c18e8Smrg else 7420b789ec8aSmrg func_append deplibs " $func_resolve_sysroot_result" 7421c27c18e8Smrg fi 7422c27c18e8Smrg continue 7423c27c18e8Smrg ;; 7424c43cc173Smrg 7425c27c18e8Smrg # Some other compiler argument. 7426c27c18e8Smrg *) 7427c27c18e8Smrg # Unknown arguments in both finalize_command and compile_command need 7428c27c18e8Smrg # to be aesthetically quoted because they are evaled later. 7429c27c18e8Smrg func_quote_for_eval "$arg" 743044584a44Smrg arg=$func_quote_for_eval_result 7431c27c18e8Smrg ;; 7432c27c18e8Smrg esac # arg 7433c43cc173Smrg 7434c27c18e8Smrg # Now actually substitute the argument into the commands. 7435c27c18e8Smrg if test -n "$arg"; then 7436c27c18e8Smrg func_append compile_command " $arg" 7437c27c18e8Smrg func_append finalize_command " $arg" 7438c27c18e8Smrg fi 7439c27c18e8Smrg done # argument parsing loop 744021e67964Smrg 7441c27c18e8Smrg test -n "$prev" && \ 744244584a44Smrg func_fatal_help "the '$prevarg' option requires an argument" 7443c43cc173Smrg 744444584a44Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445c27c18e8Smrg eval arg=\"$export_dynamic_flag_spec\" 7446c27c18e8Smrg func_append compile_command " $arg" 7447c27c18e8Smrg func_append finalize_command " $arg" 7448c27c18e8Smrg fi 7449c43cc173Smrg 7450c27c18e8Smrg oldlibs= 7451c27c18e8Smrg # calculate the name of the file, without its directory 7452c27c18e8Smrg func_basename "$output" 745344584a44Smrg outputname=$func_basename_result 745444584a44Smrg libobjs_save=$libobjs 7455c27c18e8Smrg 7456c27c18e8Smrg if test -n "$shlibpath_var"; then 7457c27c18e8Smrg # get the directories listed in $shlibpath_var 745844584a44Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459c43cc173Smrg else 7460c27c18e8Smrg shlib_search_path= 7461c43cc173Smrg fi 7462c27c18e8Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463c27c18e8Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464c43cc173Smrg 746544584a44Smrg # Definition is injected by LT_CONFIG during libtool generation. 746644584a44Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 746744584a44Smrg 7468c27c18e8Smrg func_dirname "$output" "/" "" 746944584a44Smrg output_objdir=$func_dirname_result$objdir 7470b789ec8aSmrg func_to_tool_file "$output_objdir/" 7471b789ec8aSmrg tool_output_objdir=$func_to_tool_file_result 7472c27c18e8Smrg # Create the object directory. 7473c27c18e8Smrg func_mkdir_p "$output_objdir" 7474c43cc173Smrg 7475c27c18e8Smrg # Determine the type of output 7476c27c18e8Smrg case $output in 7477c27c18e8Smrg "") 7478c27c18e8Smrg func_fatal_help "you must specify an output file" 7479c27c18e8Smrg ;; 7480c27c18e8Smrg *.$libext) linkmode=oldlib ;; 7481c27c18e8Smrg *.lo | *.$objext) linkmode=obj ;; 7482c27c18e8Smrg *.la) linkmode=lib ;; 7483c27c18e8Smrg *) linkmode=prog ;; # Anything else should be a program. 7484c27c18e8Smrg esac 7485c27c18e8Smrg 7486c27c18e8Smrg specialdeplibs= 7487c27c18e8Smrg 7488c27c18e8Smrg libs= 7489c27c18e8Smrg # Find all interdependent deplibs by searching for libraries 7490c27c18e8Smrg # that are linked more than once (e.g. -la -lb -la) 7491c27c18e8Smrg for deplib in $deplibs; do 749244584a44Smrg if $opt_preserve_dup_deps; then 7493c27c18e8Smrg case "$libs " in 7494b789ec8aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495c27c18e8Smrg esac 7496c27c18e8Smrg fi 7497b789ec8aSmrg func_append libs " $deplib" 7498c27c18e8Smrg done 7499c27c18e8Smrg 750044584a44Smrg if test lib = "$linkmode"; then 7501c27c18e8Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502c27c18e8Smrg 7503c27c18e8Smrg # Compute libraries that are listed more than once in $predeps 7504c27c18e8Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7505c27c18e8Smrg # not to be eliminated). 7506c27c18e8Smrg pre_post_deps= 7507c27c18e8Smrg if $opt_duplicate_compiler_generated_deps; then 7508c27c18e8Smrg for pre_post_dep in $predeps $postdeps; do 7509c27c18e8Smrg case "$pre_post_deps " in 7510b789ec8aSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511c27c18e8Smrg esac 7512b789ec8aSmrg func_append pre_post_deps " $pre_post_dep" 7513c27c18e8Smrg done 7514c27c18e8Smrg fi 7515c27c18e8Smrg pre_post_deps= 7516c27c18e8Smrg fi 7517c27c18e8Smrg 7518c27c18e8Smrg deplibs= 7519c27c18e8Smrg newdependency_libs= 7520c27c18e8Smrg newlib_search_path= 7521c27c18e8Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7522c27c18e8Smrg notinst_deplibs= # not-installed libtool libraries 7523c27c18e8Smrg notinst_path= # paths that contain not-installed libtool libraries 7524c27c18e8Smrg 7525c27c18e8Smrg case $linkmode in 7526c27c18e8Smrg lib) 7527c27c18e8Smrg passes="conv dlpreopen link" 7528c27c18e8Smrg for file in $dlfiles $dlprefiles; do 7529c27c18e8Smrg case $file in 7530c27c18e8Smrg *.la) ;; 7531c27c18e8Smrg *) 753244584a44Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533c27c18e8Smrg ;; 7534c27c18e8Smrg esac 7535c27c18e8Smrg done 7536c27c18e8Smrg ;; 7537c27c18e8Smrg prog) 7538c27c18e8Smrg compile_deplibs= 7539c27c18e8Smrg finalize_deplibs= 754044584a44Smrg alldeplibs=false 7541c27c18e8Smrg newdlfiles= 7542c27c18e8Smrg newdlprefiles= 7543c27c18e8Smrg passes="conv scan dlopen dlpreopen link" 7544c27c18e8Smrg ;; 7545c27c18e8Smrg *) passes="conv" 7546c27c18e8Smrg ;; 7547c27c18e8Smrg esac 7548c27c18e8Smrg 7549c27c18e8Smrg for pass in $passes; do 7550c27c18e8Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7551c27c18e8Smrg # so that -L comes before libs that need it for instance... 755244584a44Smrg if test lib,link = "$linkmode,$pass"; then 7553c27c18e8Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7554c27c18e8Smrg ## order, and fix it there properly 7555c27c18e8Smrg tmp_deplibs= 7556c27c18e8Smrg for deplib in $deplibs; do 7557c27c18e8Smrg tmp_deplibs="$deplib $tmp_deplibs" 7558c27c18e8Smrg done 755944584a44Smrg deplibs=$tmp_deplibs 7560c27c18e8Smrg fi 7561c27c18e8Smrg 756244584a44Smrg if test lib,link = "$linkmode,$pass" || 756344584a44Smrg test prog,scan = "$linkmode,$pass"; then 756444584a44Smrg libs=$deplibs 7565c27c18e8Smrg deplibs= 7566c27c18e8Smrg fi 756744584a44Smrg if test prog = "$linkmode"; then 7568c27c18e8Smrg case $pass in 756944584a44Smrg dlopen) libs=$dlfiles ;; 757044584a44Smrg dlpreopen) libs=$dlprefiles ;; 7571c27c18e8Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572c27c18e8Smrg esac 7573c27c18e8Smrg fi 757444584a44Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7575c27c18e8Smrg # Collect and forward deplibs of preopened libtool libs 7576c27c18e8Smrg for lib in $dlprefiles; do 7577c27c18e8Smrg # Ignore non-libtool-libs 7578c27c18e8Smrg dependency_libs= 7579b789ec8aSmrg func_resolve_sysroot "$lib" 7580c27c18e8Smrg case $lib in 7581b789ec8aSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7582c27c18e8Smrg esac 7583c27c18e8Smrg 7584c27c18e8Smrg # Collect preopened libtool deplibs, except any this library 7585c27c18e8Smrg # has declared as weak libs 7586c27c18e8Smrg for deplib in $dependency_libs; do 758737eb1ca1Smrg func_basename "$deplib" 758837eb1ca1Smrg deplib_base=$func_basename_result 7589c27c18e8Smrg case " $weak_libs " in 7590c27c18e8Smrg *" $deplib_base "*) ;; 7591b789ec8aSmrg *) func_append deplibs " $deplib" ;; 7592c27c18e8Smrg esac 7593c27c18e8Smrg done 7594c27c18e8Smrg done 759544584a44Smrg libs=$dlprefiles 7596c27c18e8Smrg fi 759744584a44Smrg if test dlopen = "$pass"; then 7598c27c18e8Smrg # Collect dlpreopened libraries 759944584a44Smrg save_deplibs=$deplibs 7600c27c18e8Smrg deplibs= 7601c27c18e8Smrg fi 7602c27c18e8Smrg 7603c27c18e8Smrg for deplib in $libs; do 7604c27c18e8Smrg lib= 760544584a44Smrg found=false 7606c27c18e8Smrg case $deplib in 7607f1ee322dSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608f1ee322dSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 760944584a44Smrg if test prog,link = "$linkmode,$pass"; then 7610c27c18e8Smrg compile_deplibs="$deplib $compile_deplibs" 7611c27c18e8Smrg finalize_deplibs="$deplib $finalize_deplibs" 7612c27c18e8Smrg else 7613b789ec8aSmrg func_append compiler_flags " $deplib" 761444584a44Smrg if test lib = "$linkmode"; then 7615c27c18e8Smrg case "$new_inherited_linker_flags " in 7616c27c18e8Smrg *" $deplib "*) ;; 7617b789ec8aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7618c27c18e8Smrg esac 7619c27c18e8Smrg fi 7620c27c18e8Smrg fi 7621c27c18e8Smrg continue 7622c27c18e8Smrg ;; 7623c27c18e8Smrg -l*) 762444584a44Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 762544584a44Smrg func_warning "'-l' is ignored for archives/objects" 7626c27c18e8Smrg continue 7627c27c18e8Smrg fi 7628c27c18e8Smrg func_stripname '-l' '' "$deplib" 7629c27c18e8Smrg name=$func_stripname_result 763044584a44Smrg if test lib = "$linkmode"; then 7631c27c18e8Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632c27c18e8Smrg else 7633c27c18e8Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634c27c18e8Smrg fi 7635c27c18e8Smrg for searchdir in $searchdirs; do 7636c27c18e8Smrg for search_ext in .la $std_shrext .so .a; do 7637c27c18e8Smrg # Search the libtool library 763844584a44Smrg lib=$searchdir/lib$name$search_ext 7639c27c18e8Smrg if test -f "$lib"; then 764044584a44Smrg if test .la = "$search_ext"; then 764144584a44Smrg found=: 7642c27c18e8Smrg else 764344584a44Smrg found=false 7644c27c18e8Smrg fi 7645c27c18e8Smrg break 2 7646c27c18e8Smrg fi 7647c27c18e8Smrg done 7648c27c18e8Smrg done 764944584a44Smrg if $found; then 765044584a44Smrg # deplib is a libtool library 7651c27c18e8Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652c27c18e8Smrg # We need to do some special things here, and not later. 765344584a44Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654c27c18e8Smrg case " $predeps $postdeps " in 7655c27c18e8Smrg *" $deplib "*) 7656c27c18e8Smrg if func_lalib_p "$lib"; then 7657c27c18e8Smrg library_names= 7658c27c18e8Smrg old_library= 7659c27c18e8Smrg func_source "$lib" 7660c27c18e8Smrg for l in $old_library $library_names; do 766144584a44Smrg ll=$l 7662c27c18e8Smrg done 766344584a44Smrg if test "X$ll" = "X$old_library"; then # only static version available 766444584a44Smrg found=false 7665c27c18e8Smrg func_dirname "$lib" "" "." 766644584a44Smrg ladir=$func_dirname_result 7667c27c18e8Smrg lib=$ladir/$old_library 766844584a44Smrg if test prog,link = "$linkmode,$pass"; then 7669c27c18e8Smrg compile_deplibs="$deplib $compile_deplibs" 7670c27c18e8Smrg finalize_deplibs="$deplib $finalize_deplibs" 7671c27c18e8Smrg else 7672c27c18e8Smrg deplibs="$deplib $deplibs" 767344584a44Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674c27c18e8Smrg fi 7675c27c18e8Smrg continue 7676c27c18e8Smrg fi 7677c27c18e8Smrg fi 7678c27c18e8Smrg ;; 7679c27c18e8Smrg *) ;; 7680c27c18e8Smrg esac 7681c27c18e8Smrg fi 768244584a44Smrg else 768344584a44Smrg # deplib doesn't seem to be a libtool library 768444584a44Smrg if test prog,link = "$linkmode,$pass"; then 768544584a44Smrg compile_deplibs="$deplib $compile_deplibs" 768644584a44Smrg finalize_deplibs="$deplib $finalize_deplibs" 768744584a44Smrg else 768844584a44Smrg deplibs="$deplib $deplibs" 768944584a44Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 769044584a44Smrg fi 769144584a44Smrg continue 7692c27c18e8Smrg fi 7693c27c18e8Smrg ;; # -l 7694c27c18e8Smrg *.ltframework) 769544584a44Smrg if test prog,link = "$linkmode,$pass"; then 7696c27c18e8Smrg compile_deplibs="$deplib $compile_deplibs" 7697c27c18e8Smrg finalize_deplibs="$deplib $finalize_deplibs" 7698c27c18e8Smrg else 7699c27c18e8Smrg deplibs="$deplib $deplibs" 770044584a44Smrg if test lib = "$linkmode"; then 7701c27c18e8Smrg case "$new_inherited_linker_flags " in 7702c27c18e8Smrg *" $deplib "*) ;; 7703b789ec8aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7704c27c18e8Smrg esac 7705c27c18e8Smrg fi 7706c27c18e8Smrg fi 7707c27c18e8Smrg continue 7708c27c18e8Smrg ;; 7709c27c18e8Smrg -L*) 7710c27c18e8Smrg case $linkmode in 7711c27c18e8Smrg lib) 7712c27c18e8Smrg deplibs="$deplib $deplibs" 771344584a44Smrg test conv = "$pass" && continue 7714c27c18e8Smrg newdependency_libs="$deplib $newdependency_libs" 7715c27c18e8Smrg func_stripname '-L' '' "$deplib" 7716b789ec8aSmrg func_resolve_sysroot "$func_stripname_result" 7717b789ec8aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7718c27c18e8Smrg ;; 7719c27c18e8Smrg prog) 772044584a44Smrg if test conv = "$pass"; then 7721c27c18e8Smrg deplibs="$deplib $deplibs" 7722c27c18e8Smrg continue 7723c27c18e8Smrg fi 772444584a44Smrg if test scan = "$pass"; then 7725c27c18e8Smrg deplibs="$deplib $deplibs" 7726c27c18e8Smrg else 7727c27c18e8Smrg compile_deplibs="$deplib $compile_deplibs" 7728c27c18e8Smrg finalize_deplibs="$deplib $finalize_deplibs" 7729c27c18e8Smrg fi 7730c27c18e8Smrg func_stripname '-L' '' "$deplib" 7731b789ec8aSmrg func_resolve_sysroot "$func_stripname_result" 7732b789ec8aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7733c27c18e8Smrg ;; 7734c27c18e8Smrg *) 773544584a44Smrg func_warning "'-L' is ignored for archives/objects" 7736c27c18e8Smrg ;; 7737c27c18e8Smrg esac # linkmode 7738c27c18e8Smrg continue 7739c27c18e8Smrg ;; # -L 7740c27c18e8Smrg -R*) 774144584a44Smrg if test link = "$pass"; then 7742c27c18e8Smrg func_stripname '-R' '' "$deplib" 7743b789ec8aSmrg func_resolve_sysroot "$func_stripname_result" 7744b789ec8aSmrg dir=$func_resolve_sysroot_result 7745c27c18e8Smrg # Make sure the xrpath contains only unique directories. 7746c27c18e8Smrg case "$xrpath " in 7747c27c18e8Smrg *" $dir "*) ;; 7748b789ec8aSmrg *) func_append xrpath " $dir" ;; 7749c27c18e8Smrg esac 7750c27c18e8Smrg fi 7751c27c18e8Smrg deplibs="$deplib $deplibs" 7752c27c18e8Smrg continue 7753c27c18e8Smrg ;; 7754b789ec8aSmrg *.la) 7755b789ec8aSmrg func_resolve_sysroot "$deplib" 7756b789ec8aSmrg lib=$func_resolve_sysroot_result 7757b789ec8aSmrg ;; 7758c27c18e8Smrg *.$libext) 775944584a44Smrg if test conv = "$pass"; then 7760c27c18e8Smrg deplibs="$deplib $deplibs" 7761c27c18e8Smrg continue 7762c27c18e8Smrg fi 7763c27c18e8Smrg case $linkmode in 7764c27c18e8Smrg lib) 7765c27c18e8Smrg # Linking convenience modules into shared libraries is allowed, 7766c27c18e8Smrg # but linking other static libraries is non-portable. 7767c27c18e8Smrg case " $dlpreconveniencelibs " in 7768c27c18e8Smrg *" $deplib "*) ;; 7769c27c18e8Smrg *) 777044584a44Smrg valid_a_lib=false 7771c27c18e8Smrg case $deplibs_check_method in 7772c27c18e8Smrg match_pattern*) 7773c27c18e8Smrg set dummy $deplibs_check_method; shift 7774c27c18e8Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777537eb1ca1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776c27c18e8Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 777744584a44Smrg valid_a_lib=: 7778c27c18e8Smrg fi 7779c27c18e8Smrg ;; 7780c27c18e8Smrg pass_all) 778144584a44Smrg valid_a_lib=: 7782c27c18e8Smrg ;; 7783c27c18e8Smrg esac 778444584a44Smrg if $valid_a_lib; then 778544584a44Smrg echo 778644584a44Smrg $ECHO "*** Warning: Linking the shared library $output against the" 778744584a44Smrg $ECHO "*** static library $deplib is not portable!" 778844584a44Smrg deplibs="$deplib $deplibs" 778944584a44Smrg else 779037eb1ca1Smrg echo 7791c27c18e8Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779237eb1ca1Smrg echo "*** I have the capability to make that library automatically link in when" 779337eb1ca1Smrg echo "*** you link to this library. But I can only do this if you have a" 779437eb1ca1Smrg echo "*** shared version of the library, which you do not appear to have" 779537eb1ca1Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 779637eb1ca1Smrg echo "*** that it is just a static archive that I should not use here." 7797c27c18e8Smrg fi 7798c27c18e8Smrg ;; 7799c27c18e8Smrg esac 7800c27c18e8Smrg continue 7801c27c18e8Smrg ;; 7802c27c18e8Smrg prog) 780344584a44Smrg if test link != "$pass"; then 7804c27c18e8Smrg deplibs="$deplib $deplibs" 7805c27c18e8Smrg else 7806c27c18e8Smrg compile_deplibs="$deplib $compile_deplibs" 7807c27c18e8Smrg finalize_deplibs="$deplib $finalize_deplibs" 7808c27c18e8Smrg fi 7809c27c18e8Smrg continue 7810c27c18e8Smrg ;; 7811c27c18e8Smrg esac # linkmode 7812c27c18e8Smrg ;; # *.$libext 7813c27c18e8Smrg *.lo | *.$objext) 781444584a44Smrg if test conv = "$pass"; then 7815c27c18e8Smrg deplibs="$deplib $deplibs" 781644584a44Smrg elif test prog = "$linkmode"; then 781744584a44Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818c27c18e8Smrg # If there is no dlopen support or we're linking statically, 7819c27c18e8Smrg # we need to preload. 7820b789ec8aSmrg func_append newdlprefiles " $deplib" 7821c27c18e8Smrg compile_deplibs="$deplib $compile_deplibs" 7822c27c18e8Smrg finalize_deplibs="$deplib $finalize_deplibs" 7823c27c18e8Smrg else 7824b789ec8aSmrg func_append newdlfiles " $deplib" 7825c27c18e8Smrg fi 7826c27c18e8Smrg fi 7827c27c18e8Smrg continue 7828c27c18e8Smrg ;; 7829c27c18e8Smrg %DEPLIBS%) 783044584a44Smrg alldeplibs=: 7831c27c18e8Smrg continue 7832c27c18e8Smrg ;; 7833c27c18e8Smrg esac # case $deplib 7834c27c18e8Smrg 783544584a44Smrg $found || test -f "$lib" \ 783644584a44Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837c27c18e8Smrg 7838c27c18e8Smrg # Check to see that this really is a libtool archive. 7839c27c18e8Smrg func_lalib_unsafe_p "$lib" \ 784044584a44Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 7841c27c18e8Smrg 7842c27c18e8Smrg func_dirname "$lib" "" "." 784344584a44Smrg ladir=$func_dirname_result 7844c27c18e8Smrg 7845c27c18e8Smrg dlname= 7846c27c18e8Smrg dlopen= 7847c27c18e8Smrg dlpreopen= 7848c27c18e8Smrg libdir= 7849c27c18e8Smrg library_names= 7850c27c18e8Smrg old_library= 7851c27c18e8Smrg inherited_linker_flags= 7852c27c18e8Smrg # If the library was installed with an old release of libtool, 7853c27c18e8Smrg # it will not redefine variables installed, or shouldnotlink 7854c27c18e8Smrg installed=yes 7855c27c18e8Smrg shouldnotlink=no 7856c27c18e8Smrg avoidtemprpath= 7857c27c18e8Smrg 7858c27c18e8Smrg 7859c27c18e8Smrg # Read the .la file 7860c27c18e8Smrg func_source "$lib" 7861c27c18e8Smrg 7862c27c18e8Smrg # Convert "-framework foo" to "foo.ltframework" 7863c27c18e8Smrg if test -n "$inherited_linker_flags"; then 786437eb1ca1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865c27c18e8Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866c27c18e8Smrg case " $new_inherited_linker_flags " in 7867c27c18e8Smrg *" $tmp_inherited_linker_flag "*) ;; 7868b789ec8aSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869c27c18e8Smrg esac 7870c27c18e8Smrg done 7871c27c18e8Smrg fi 787237eb1ca1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 787344584a44Smrg if test lib,link = "$linkmode,$pass" || 787444584a44Smrg test prog,scan = "$linkmode,$pass" || 787544584a44Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876b789ec8aSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7877b789ec8aSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878c27c18e8Smrg fi 7879c27c18e8Smrg 788044584a44Smrg if test conv = "$pass"; then 7881c27c18e8Smrg # Only check for convenience libraries 7882c27c18e8Smrg deplibs="$lib $deplibs" 7883c27c18e8Smrg if test -z "$libdir"; then 7884c27c18e8Smrg if test -z "$old_library"; then 788544584a44Smrg func_fatal_error "cannot find name of link library for '$lib'" 7886c27c18e8Smrg fi 7887c27c18e8Smrg # It is a libtool convenience library, so add in its objects. 7888b789ec8aSmrg func_append convenience " $ladir/$objdir/$old_library" 7889b789ec8aSmrg func_append old_convenience " $ladir/$objdir/$old_library" 789044584a44Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 789144584a44Smrg func_fatal_error "'$lib' is not a convenience library" 7892c27c18e8Smrg fi 7893c27c18e8Smrg tmp_libs= 7894c27c18e8Smrg for deplib in $dependency_libs; do 7895c27c18e8Smrg deplibs="$deplib $deplibs" 789644584a44Smrg if $opt_preserve_dup_deps; then 7897c27c18e8Smrg case "$tmp_libs " in 7898b789ec8aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899c27c18e8Smrg esac 7900c27c18e8Smrg fi 7901b789ec8aSmrg func_append tmp_libs " $deplib" 7902c27c18e8Smrg done 7903c27c18e8Smrg continue 7904c27c18e8Smrg fi # $pass = conv 7905c27c18e8Smrg 7906c27c18e8Smrg 7907c27c18e8Smrg # Get the name of the library we link against. 7908c27c18e8Smrg linklib= 7909b789ec8aSmrg if test -n "$old_library" && 791044584a44Smrg { test yes = "$prefer_static_libs" || 791144584a44Smrg test built,no = "$prefer_static_libs,$installed"; }; then 7912b789ec8aSmrg linklib=$old_library 7913b789ec8aSmrg else 7914b789ec8aSmrg for l in $old_library $library_names; do 791544584a44Smrg linklib=$l 7916b789ec8aSmrg done 7917b789ec8aSmrg fi 7918c27c18e8Smrg if test -z "$linklib"; then 791944584a44Smrg func_fatal_error "cannot find name of link library for '$lib'" 7920c27c18e8Smrg fi 7921c27c18e8Smrg 7922c27c18e8Smrg # This library was specified with -dlopen. 792344584a44Smrg if test dlopen = "$pass"; then 792444584a44Smrg test -z "$libdir" \ 792544584a44Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926c27c18e8Smrg if test -z "$dlname" || 792744584a44Smrg test yes != "$dlopen_support" || 792844584a44Smrg test no = "$build_libtool_libs" 792944584a44Smrg then 7930c27c18e8Smrg # If there is no dlname, no dlopen support or we're linking 7931c27c18e8Smrg # statically, we need to preload. We also need to preload any 7932c27c18e8Smrg # dependent libraries so libltdl's deplib preloader doesn't 7933c27c18e8Smrg # bomb out in the load deplibs phase. 7934b789ec8aSmrg func_append dlprefiles " $lib $dependency_libs" 7935c27c18e8Smrg else 7936b789ec8aSmrg func_append newdlfiles " $lib" 7937c27c18e8Smrg fi 7938c27c18e8Smrg continue 7939c27c18e8Smrg fi # $pass = dlopen 7940c27c18e8Smrg 7941c27c18e8Smrg # We need an absolute path. 7942c27c18e8Smrg case $ladir in 794344584a44Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944c27c18e8Smrg *) 7945c27c18e8Smrg abs_ladir=`cd "$ladir" && pwd` 7946c27c18e8Smrg if test -z "$abs_ladir"; then 794744584a44Smrg func_warning "cannot determine absolute directory name of '$ladir'" 7948c27c18e8Smrg func_warning "passing it literally to the linker, although it might fail" 794944584a44Smrg abs_ladir=$ladir 7950c27c18e8Smrg fi 7951c27c18e8Smrg ;; 7952c27c18e8Smrg esac 7953c27c18e8Smrg func_basename "$lib" 795444584a44Smrg laname=$func_basename_result 7955c27c18e8Smrg 7956c27c18e8Smrg # Find the relevant object directory and library name. 795744584a44Smrg if test yes = "$installed"; then 7958b789ec8aSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 795944584a44Smrg func_warning "library '$lib' was moved." 796044584a44Smrg dir=$ladir 796144584a44Smrg absdir=$abs_ladir 796244584a44Smrg libdir=$abs_ladir 7963c27c18e8Smrg else 796444584a44Smrg dir=$lt_sysroot$libdir 796544584a44Smrg absdir=$lt_sysroot$libdir 7966c27c18e8Smrg fi 796744584a44Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968c27c18e8Smrg else 7969c27c18e8Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 797044584a44Smrg dir=$ladir 797144584a44Smrg absdir=$abs_ladir 7972c27c18e8Smrg # Remove this search path later 7973b789ec8aSmrg func_append notinst_path " $abs_ladir" 7974c27c18e8Smrg else 797544584a44Smrg dir=$ladir/$objdir 797644584a44Smrg absdir=$abs_ladir/$objdir 7977c27c18e8Smrg # Remove this search path later 7978b789ec8aSmrg func_append notinst_path " $abs_ladir" 7979c27c18e8Smrg fi 7980c27c18e8Smrg fi # $installed = yes 7981c27c18e8Smrg func_stripname 'lib' '.la' "$laname" 7982c27c18e8Smrg name=$func_stripname_result 7983c27c18e8Smrg 7984c27c18e8Smrg # This library was specified with -dlpreopen. 798544584a44Smrg if test dlpreopen = "$pass"; then 798644584a44Smrg if test -z "$libdir" && test prog = "$linkmode"; then 798744584a44Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988c27c18e8Smrg fi 798944584a44Smrg case $host in 7990b789ec8aSmrg # special handling for platforms with PE-DLLs. 7991b789ec8aSmrg *cygwin* | *mingw* | *cegcc* ) 7992b789ec8aSmrg # Linker will automatically link against shared library if both 7993b789ec8aSmrg # static and shared are present. Therefore, ensure we extract 7994b789ec8aSmrg # symbols from the import library if a shared library is present 7995b789ec8aSmrg # (otherwise, the dlopen module name will be incorrect). We do 7996b789ec8aSmrg # this by putting the import library name into $newdlprefiles. 7997b789ec8aSmrg # We recover the dlopen module name by 'saving' the la file 7998b789ec8aSmrg # name in a special purpose variable, and (later) extracting the 7999b789ec8aSmrg # dlname from the la file. 8000b789ec8aSmrg if test -n "$dlname"; then 8001b789ec8aSmrg func_tr_sh "$dir/$linklib" 8002b789ec8aSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003b789ec8aSmrg func_append newdlprefiles " $dir/$linklib" 8004b789ec8aSmrg else 8005b789ec8aSmrg func_append newdlprefiles " $dir/$old_library" 8006b789ec8aSmrg # Keep a list of preopened convenience libraries to check 8007b789ec8aSmrg # that they are being used correctly in the link pass. 8008b789ec8aSmrg test -z "$libdir" && \ 8009b789ec8aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8010b789ec8aSmrg fi 8011b789ec8aSmrg ;; 8012b789ec8aSmrg * ) 8013b789ec8aSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8014b789ec8aSmrg # are required to link). 8015b789ec8aSmrg if test -n "$old_library"; then 8016b789ec8aSmrg func_append newdlprefiles " $dir/$old_library" 8017b789ec8aSmrg # Keep a list of preopened convenience libraries to check 8018b789ec8aSmrg # that they are being used correctly in the link pass. 8019b789ec8aSmrg test -z "$libdir" && \ 8020b789ec8aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8021b789ec8aSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8022b789ec8aSmrg elif test -n "$dlname"; then 8023b789ec8aSmrg func_append newdlprefiles " $dir/$dlname" 8024b789ec8aSmrg else 8025b789ec8aSmrg func_append newdlprefiles " $dir/$linklib" 8026b789ec8aSmrg fi 8027b789ec8aSmrg ;; 8028b789ec8aSmrg esac 8029c27c18e8Smrg fi # $pass = dlpreopen 8030c27c18e8Smrg 8031c27c18e8Smrg if test -z "$libdir"; then 8032c27c18e8Smrg # Link the convenience library 803344584a44Smrg if test lib = "$linkmode"; then 8034c27c18e8Smrg deplibs="$dir/$old_library $deplibs" 803544584a44Smrg elif test prog,link = "$linkmode,$pass"; then 8036c27c18e8Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8037c27c18e8Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038c27c18e8Smrg else 8039c27c18e8Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8040c27c18e8Smrg fi 8041c27c18e8Smrg continue 8042c27c18e8Smrg fi 8043c27c18e8Smrg 8044c27c18e8Smrg 804544584a44Smrg if test prog = "$linkmode" && test link != "$pass"; then 8046b789ec8aSmrg func_append newlib_search_path " $ladir" 8047c27c18e8Smrg deplibs="$lib $deplibs" 8048c27c18e8Smrg 804944584a44Smrg linkalldeplibs=false 805044584a44Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 805144584a44Smrg test no = "$build_libtool_libs"; then 805244584a44Smrg linkalldeplibs=: 8053c27c18e8Smrg fi 8054c27c18e8Smrg 8055c27c18e8Smrg tmp_libs= 8056c27c18e8Smrg for deplib in $dependency_libs; do 8057c27c18e8Smrg case $deplib in 8058c27c18e8Smrg -L*) func_stripname '-L' '' "$deplib" 8059b789ec8aSmrg func_resolve_sysroot "$func_stripname_result" 8060b789ec8aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8061c27c18e8Smrg ;; 8062c27c18e8Smrg esac 8063c27c18e8Smrg # Need to link against all dependency_libs? 806444584a44Smrg if $linkalldeplibs; then 8065c27c18e8Smrg deplibs="$deplib $deplibs" 8066c27c18e8Smrg else 8067c27c18e8Smrg # Need to hardcode shared library paths 8068c27c18e8Smrg # or/and link against static libraries 8069c27c18e8Smrg newdependency_libs="$deplib $newdependency_libs" 8070c27c18e8Smrg fi 807144584a44Smrg if $opt_preserve_dup_deps; then 8072c27c18e8Smrg case "$tmp_libs " in 8073b789ec8aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074c27c18e8Smrg esac 8075c27c18e8Smrg fi 8076b789ec8aSmrg func_append tmp_libs " $deplib" 8077c27c18e8Smrg done # for deplib 8078c27c18e8Smrg continue 8079c27c18e8Smrg fi # $linkmode = prog... 8080c27c18e8Smrg 808144584a44Smrg if test prog,link = "$linkmode,$pass"; then 8082c27c18e8Smrg if test -n "$library_names" && 808344584a44Smrg { { test no = "$prefer_static_libs" || 808444584a44Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8085c27c18e8Smrg test -z "$old_library"; }; then 8086c27c18e8Smrg # We need to hardcode the library path 808744584a44Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088c27c18e8Smrg # Make sure the rpath contains only unique directories. 808944584a44Smrg case $temp_rpath: in 8090c27c18e8Smrg *"$absdir:"*) ;; 8091b789ec8aSmrg *) func_append temp_rpath "$absdir:" ;; 8092c27c18e8Smrg esac 8093c27c18e8Smrg fi 8094c27c18e8Smrg 8095c27c18e8Smrg # Hardcode the library path. 8096c27c18e8Smrg # Skip directories that are in the system default run-time 8097c27c18e8Smrg # search path. 8098c27c18e8Smrg case " $sys_lib_dlsearch_path " in 8099c27c18e8Smrg *" $absdir "*) ;; 8100c27c18e8Smrg *) 8101c27c18e8Smrg case "$compile_rpath " in 8102c27c18e8Smrg *" $absdir "*) ;; 8103b789ec8aSmrg *) func_append compile_rpath " $absdir" ;; 8104c27c18e8Smrg esac 8105c27c18e8Smrg ;; 8106c27c18e8Smrg esac 8107c27c18e8Smrg case " $sys_lib_dlsearch_path " in 8108c27c18e8Smrg *" $libdir "*) ;; 8109c27c18e8Smrg *) 8110c27c18e8Smrg case "$finalize_rpath " in 8111c27c18e8Smrg *" $libdir "*) ;; 8112b789ec8aSmrg *) func_append finalize_rpath " $libdir" ;; 8113c27c18e8Smrg esac 8114c27c18e8Smrg ;; 8115c27c18e8Smrg esac 8116c27c18e8Smrg fi # $linkmode,$pass = prog,link... 8117c27c18e8Smrg 811844584a44Smrg if $alldeplibs && 811944584a44Smrg { test pass_all = "$deplibs_check_method" || 812044584a44Smrg { test yes = "$build_libtool_libs" && 8121c27c18e8Smrg test -n "$library_names"; }; }; then 8122c27c18e8Smrg # We only need to search for static libraries 8123c27c18e8Smrg continue 8124c27c18e8Smrg fi 8125c27c18e8Smrg fi 8126c27c18e8Smrg 8127c27c18e8Smrg link_static=no # Whether the deplib will be linked statically 8128c27c18e8Smrg use_static_libs=$prefer_static_libs 812944584a44Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8130c27c18e8Smrg use_static_libs=no 8131c27c18e8Smrg fi 8132c27c18e8Smrg if test -n "$library_names" && 813344584a44Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134c27c18e8Smrg case $host in 813544584a44Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8136c27c18e8Smrg # No point in relinking DLLs because paths are not encoded 8137b789ec8aSmrg func_append notinst_deplibs " $lib" 8138c27c18e8Smrg need_relink=no 8139c27c18e8Smrg ;; 8140c27c18e8Smrg *) 814144584a44Smrg if test no = "$installed"; then 8142b789ec8aSmrg func_append notinst_deplibs " $lib" 8143c27c18e8Smrg need_relink=yes 8144c27c18e8Smrg fi 8145c27c18e8Smrg ;; 8146c27c18e8Smrg esac 8147c27c18e8Smrg # This is a shared library 8148c27c18e8Smrg 8149c27c18e8Smrg # Warn about portability, can't link against -module's on some 8150c27c18e8Smrg # systems (darwin). Don't bleat about dlopened modules though! 815144584a44Smrg dlopenmodule= 8152c27c18e8Smrg for dlpremoduletest in $dlprefiles; do 8153c27c18e8Smrg if test "X$dlpremoduletest" = "X$lib"; then 815444584a44Smrg dlopenmodule=$dlpremoduletest 8155c27c18e8Smrg break 8156c27c18e8Smrg fi 8157c27c18e8Smrg done 815844584a44Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 815937eb1ca1Smrg echo 816044584a44Smrg if test prog = "$linkmode"; then 8161c27c18e8Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162c27c18e8Smrg else 8163c27c18e8Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164c27c18e8Smrg fi 8165c27c18e8Smrg $ECHO "*** $linklib is not portable!" 8166c27c18e8Smrg fi 816744584a44Smrg if test lib = "$linkmode" && 816844584a44Smrg test yes = "$hardcode_into_libs"; then 8169c27c18e8Smrg # Hardcode the library path. 8170c27c18e8Smrg # Skip directories that are in the system default run-time 8171c27c18e8Smrg # search path. 8172c27c18e8Smrg case " $sys_lib_dlsearch_path " in 8173c27c18e8Smrg *" $absdir "*) ;; 8174c27c18e8Smrg *) 8175c27c18e8Smrg case "$compile_rpath " in 8176c27c18e8Smrg *" $absdir "*) ;; 8177b789ec8aSmrg *) func_append compile_rpath " $absdir" ;; 8178c27c18e8Smrg esac 8179c27c18e8Smrg ;; 8180c27c18e8Smrg esac 8181c27c18e8Smrg case " $sys_lib_dlsearch_path " in 8182c27c18e8Smrg *" $libdir "*) ;; 8183c27c18e8Smrg *) 8184c27c18e8Smrg case "$finalize_rpath " in 8185c27c18e8Smrg *" $libdir "*) ;; 8186b789ec8aSmrg *) func_append finalize_rpath " $libdir" ;; 8187c27c18e8Smrg esac 8188c27c18e8Smrg ;; 8189c27c18e8Smrg esac 8190c27c18e8Smrg fi 8191c27c18e8Smrg 8192c27c18e8Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8193c27c18e8Smrg # figure out the soname 8194c27c18e8Smrg set dummy $library_names 8195c27c18e8Smrg shift 819644584a44Smrg realname=$1 8197c27c18e8Smrg shift 8198c27c18e8Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8199c27c18e8Smrg # use dlname if we got it. it's perfectly good, no? 8200c27c18e8Smrg if test -n "$dlname"; then 820144584a44Smrg soname=$dlname 8202c27c18e8Smrg elif test -n "$soname_spec"; then 8203c27c18e8Smrg # bleh windows 8204c27c18e8Smrg case $host in 820544584a44Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8206c27c18e8Smrg func_arith $current - $age 8207c27c18e8Smrg major=$func_arith_result 820844584a44Smrg versuffix=-$major 8209c27c18e8Smrg ;; 8210c27c18e8Smrg esac 8211c27c18e8Smrg eval soname=\"$soname_spec\" 8212c27c18e8Smrg else 821344584a44Smrg soname=$realname 8214c27c18e8Smrg fi 8215c27c18e8Smrg 8216c27c18e8Smrg # Make a new name for the extract_expsyms_cmds to use 821744584a44Smrg soroot=$soname 8218c27c18e8Smrg func_basename "$soroot" 821944584a44Smrg soname=$func_basename_result 8220c27c18e8Smrg func_stripname 'lib' '.dll' "$soname" 8221c27c18e8Smrg newlib=libimp-$func_stripname_result.a 8222c27c18e8Smrg 8223c27c18e8Smrg # If the library has no export list, then create one now 8224c27c18e8Smrg if test -f "$output_objdir/$soname-def"; then : 8225c27c18e8Smrg else 822644584a44Smrg func_verbose "extracting exported symbol list from '$soname'" 8227c27c18e8Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228c27c18e8Smrg fi 8229c27c18e8Smrg 8230c27c18e8Smrg # Create $newlib 8231c27c18e8Smrg if test -f "$output_objdir/$newlib"; then :; else 823244584a44Smrg func_verbose "generating import library for '$soname'" 8233c27c18e8Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234c27c18e8Smrg fi 8235c27c18e8Smrg # make sure the library variables are pointing to the new library 8236c27c18e8Smrg dir=$output_objdir 8237c27c18e8Smrg linklib=$newlib 8238c27c18e8Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8239c27c18e8Smrg 824044584a44Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241c27c18e8Smrg add_shlibpath= 8242c27c18e8Smrg add_dir= 8243c27c18e8Smrg add= 8244c27c18e8Smrg lib_linked=yes 8245c27c18e8Smrg case $hardcode_action in 8246c27c18e8Smrg immediate | unsupported) 824744584a44Smrg if test no = "$hardcode_direct"; then 824844584a44Smrg add=$dir/$linklib 8249c27c18e8Smrg case $host in 825044584a44Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 825144584a44Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252c27c18e8Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 825344584a44Smrg *-*-unixware7*) add_dir=-L$dir ;; 8254c27c18e8Smrg *-*-darwin* ) 825544584a44Smrg # if the lib is a (non-dlopened) module then we cannot 8256c27c18e8Smrg # link against it, someone is ignoring the earlier warnings 8257c27c18e8Smrg if /usr/bin/file -L $add 2> /dev/null | 825844584a44Smrg $GREP ": [^:]* bundle" >/dev/null; then 8259c27c18e8Smrg if test "X$dlopenmodule" != "X$lib"; then 8260c27c18e8Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 826144584a44Smrg if test -z "$old_library"; then 826237eb1ca1Smrg echo 826337eb1ca1Smrg echo "*** And there doesn't seem to be a static archive available" 826437eb1ca1Smrg echo "*** The link will probably fail, sorry" 8265c27c18e8Smrg else 826644584a44Smrg add=$dir/$old_library 8267c27c18e8Smrg fi 8268c27c18e8Smrg elif test -n "$old_library"; then 826944584a44Smrg add=$dir/$old_library 8270c27c18e8Smrg fi 8271c27c18e8Smrg fi 8272c27c18e8Smrg esac 827344584a44Smrg elif test no = "$hardcode_minus_L"; then 8274c27c18e8Smrg case $host in 827544584a44Smrg *-*-sunos*) add_shlibpath=$dir ;; 8276c27c18e8Smrg esac 827744584a44Smrg add_dir=-L$dir 827844584a44Smrg add=-l$name 827944584a44Smrg elif test no = "$hardcode_shlibpath_var"; then 828044584a44Smrg add_shlibpath=$dir 828144584a44Smrg add=-l$name 8282c27c18e8Smrg else 8283c27c18e8Smrg lib_linked=no 8284c27c18e8Smrg fi 8285c27c18e8Smrg ;; 8286c27c18e8Smrg relink) 828744584a44Smrg if test yes = "$hardcode_direct" && 828844584a44Smrg test no = "$hardcode_direct_absolute"; then 828944584a44Smrg add=$dir/$linklib 829044584a44Smrg elif test yes = "$hardcode_minus_L"; then 829144584a44Smrg add_dir=-L$absdir 8292c27c18e8Smrg # Try looking first in the location we're being installed to. 8293c27c18e8Smrg if test -n "$inst_prefix_dir"; then 8294c27c18e8Smrg case $libdir in 8295c27c18e8Smrg [\\/]*) 8296b789ec8aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8297c27c18e8Smrg ;; 8298c27c18e8Smrg esac 8299c27c18e8Smrg fi 830044584a44Smrg add=-l$name 830144584a44Smrg elif test yes = "$hardcode_shlibpath_var"; then 830244584a44Smrg add_shlibpath=$dir 830344584a44Smrg add=-l$name 8304c27c18e8Smrg else 8305c27c18e8Smrg lib_linked=no 8306c27c18e8Smrg fi 8307c27c18e8Smrg ;; 8308c27c18e8Smrg *) lib_linked=no ;; 8309c27c18e8Smrg esac 8310c27c18e8Smrg 831144584a44Smrg if test yes != "$lib_linked"; then 8312c27c18e8Smrg func_fatal_configuration "unsupported hardcode properties" 8313c27c18e8Smrg fi 8314c27c18e8Smrg 8315c27c18e8Smrg if test -n "$add_shlibpath"; then 8316c27c18e8Smrg case :$compile_shlibpath: in 8317c27c18e8Smrg *":$add_shlibpath:"*) ;; 8318b789ec8aSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319c27c18e8Smrg esac 8320c27c18e8Smrg fi 832144584a44Smrg if test prog = "$linkmode"; then 8322c27c18e8Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323c27c18e8Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324c27c18e8Smrg else 8325c27c18e8Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326c27c18e8Smrg test -n "$add" && deplibs="$add $deplibs" 832744584a44Smrg if test yes != "$hardcode_direct" && 832844584a44Smrg test yes != "$hardcode_minus_L" && 832944584a44Smrg test yes = "$hardcode_shlibpath_var"; then 8330c27c18e8Smrg case :$finalize_shlibpath: in 8331c27c18e8Smrg *":$libdir:"*) ;; 8332b789ec8aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8333c27c18e8Smrg esac 8334c27c18e8Smrg fi 8335c27c18e8Smrg fi 8336c27c18e8Smrg fi 8337c27c18e8Smrg 833844584a44Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339c27c18e8Smrg add_shlibpath= 8340c27c18e8Smrg add_dir= 8341c27c18e8Smrg add= 8342c27c18e8Smrg # Finalize command for both is simple: just hardcode it. 834344584a44Smrg if test yes = "$hardcode_direct" && 834444584a44Smrg test no = "$hardcode_direct_absolute"; then 834544584a44Smrg add=$libdir/$linklib 834644584a44Smrg elif test yes = "$hardcode_minus_L"; then 834744584a44Smrg add_dir=-L$libdir 834844584a44Smrg add=-l$name 834944584a44Smrg elif test yes = "$hardcode_shlibpath_var"; then 8350c27c18e8Smrg case :$finalize_shlibpath: in 8351c27c18e8Smrg *":$libdir:"*) ;; 8352b789ec8aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8353c27c18e8Smrg esac 835444584a44Smrg add=-l$name 835544584a44Smrg elif test yes = "$hardcode_automatic"; then 8356c27c18e8Smrg if test -n "$inst_prefix_dir" && 835744584a44Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 835844584a44Smrg add=$inst_prefix_dir$libdir/$linklib 8359c27c18e8Smrg else 836044584a44Smrg add=$libdir/$linklib 8361c27c18e8Smrg fi 8362c27c18e8Smrg else 8363c27c18e8Smrg # We cannot seem to hardcode it, guess we'll fake it. 836444584a44Smrg add_dir=-L$libdir 8365c27c18e8Smrg # Try looking first in the location we're being installed to. 8366c27c18e8Smrg if test -n "$inst_prefix_dir"; then 8367c27c18e8Smrg case $libdir in 8368c27c18e8Smrg [\\/]*) 8369b789ec8aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8370c27c18e8Smrg ;; 8371c27c18e8Smrg esac 8372c27c18e8Smrg fi 837344584a44Smrg add=-l$name 8374c27c18e8Smrg fi 8375c27c18e8Smrg 837644584a44Smrg if test prog = "$linkmode"; then 8377c27c18e8Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378c27c18e8Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379c27c18e8Smrg else 8380c27c18e8Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381c27c18e8Smrg test -n "$add" && deplibs="$add $deplibs" 8382c27c18e8Smrg fi 8383c27c18e8Smrg fi 838444584a44Smrg elif test prog = "$linkmode"; then 8385c27c18e8Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8386c27c18e8Smrg # is not unsupported. This is valid on all known static and 8387c27c18e8Smrg # shared platforms. 838844584a44Smrg if test unsupported != "$hardcode_direct"; then 838944584a44Smrg test -n "$old_library" && linklib=$old_library 8390c27c18e8Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8391c27c18e8Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392c27c18e8Smrg else 8393c27c18e8Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8394c27c18e8Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395c27c18e8Smrg fi 839644584a44Smrg elif test yes = "$build_libtool_libs"; then 8397c27c18e8Smrg # Not a shared library 839844584a44Smrg if test pass_all != "$deplibs_check_method"; then 8399c27c18e8Smrg # We're trying link a shared library against a static one 8400c27c18e8Smrg # but the system doesn't support it. 8401c27c18e8Smrg 8402c27c18e8Smrg # Just print a warning and add the library to dependency_libs so 8403c27c18e8Smrg # that the program can be linked against the static library. 840437eb1ca1Smrg echo 840544584a44Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 840637eb1ca1Smrg echo "*** I have the capability to make that library automatically link in when" 840737eb1ca1Smrg echo "*** you link to this library. But I can only do this if you have a" 840837eb1ca1Smrg echo "*** shared version of the library, which you do not appear to have." 840944584a44Smrg if test yes = "$module"; then 841037eb1ca1Smrg echo "*** But as you try to build a module library, libtool will still create " 841137eb1ca1Smrg echo "*** a static module, that should work as long as the dlopening application" 841237eb1ca1Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413c27c18e8Smrg if test -z "$global_symbol_pipe"; then 841437eb1ca1Smrg echo 841537eb1ca1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 841644584a44Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 841737eb1ca1Smrg echo "*** not find such a program. So, this module is probably useless." 841844584a44Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419c27c18e8Smrg fi 842044584a44Smrg if test no = "$build_old_libs"; then 8421c27c18e8Smrg build_libtool_libs=module 8422c27c18e8Smrg build_old_libs=yes 8423c27c18e8Smrg else 8424c27c18e8Smrg build_libtool_libs=no 8425c27c18e8Smrg fi 8426c27c18e8Smrg fi 8427c27c18e8Smrg else 8428c27c18e8Smrg deplibs="$dir/$old_library $deplibs" 8429c27c18e8Smrg link_static=yes 8430c27c18e8Smrg fi 8431c27c18e8Smrg fi # link shared/static library? 8432c27c18e8Smrg 843344584a44Smrg if test lib = "$linkmode"; then 8434c27c18e8Smrg if test -n "$dependency_libs" && 843544584a44Smrg { test yes != "$hardcode_into_libs" || 843644584a44Smrg test yes = "$build_old_libs" || 843744584a44Smrg test yes = "$link_static"; }; then 8438c27c18e8Smrg # Extract -R from dependency_libs 8439c27c18e8Smrg temp_deplibs= 8440c27c18e8Smrg for libdir in $dependency_libs; do 8441c27c18e8Smrg case $libdir in 8442c27c18e8Smrg -R*) func_stripname '-R' '' "$libdir" 8443c27c18e8Smrg temp_xrpath=$func_stripname_result 8444c27c18e8Smrg case " $xrpath " in 8445c27c18e8Smrg *" $temp_xrpath "*) ;; 8446b789ec8aSmrg *) func_append xrpath " $temp_xrpath";; 8447c27c18e8Smrg esac;; 8448b789ec8aSmrg *) func_append temp_deplibs " $libdir";; 8449c27c18e8Smrg esac 8450c27c18e8Smrg done 845144584a44Smrg dependency_libs=$temp_deplibs 8452c27c18e8Smrg fi 8453c27c18e8Smrg 8454b789ec8aSmrg func_append newlib_search_path " $absdir" 8455c27c18e8Smrg # Link against this library 845644584a44Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457c27c18e8Smrg # ... and its dependency_libs 8458c27c18e8Smrg tmp_libs= 8459c27c18e8Smrg for deplib in $dependency_libs; do 8460c27c18e8Smrg newdependency_libs="$deplib $newdependency_libs" 8461b789ec8aSmrg case $deplib in 8462b789ec8aSmrg -L*) func_stripname '-L' '' "$deplib" 8463b789ec8aSmrg func_resolve_sysroot "$func_stripname_result";; 8464b789ec8aSmrg *) func_resolve_sysroot "$deplib" ;; 8465b789ec8aSmrg esac 846644584a44Smrg if $opt_preserve_dup_deps; then 8467c27c18e8Smrg case "$tmp_libs " in 8468b789ec8aSmrg *" $func_resolve_sysroot_result "*) 8469b789ec8aSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470c27c18e8Smrg esac 8471c27c18e8Smrg fi 8472b789ec8aSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8473c27c18e8Smrg done 8474c27c18e8Smrg 847544584a44Smrg if test no != "$link_all_deplibs"; then 8476c27c18e8Smrg # Add the search paths of all dependency libraries 8477c27c18e8Smrg for deplib in $dependency_libs; do 847837eb1ca1Smrg path= 8479c27c18e8Smrg case $deplib in 848044584a44Smrg -L*) path=$deplib ;; 8481c27c18e8Smrg *.la) 8482b789ec8aSmrg func_resolve_sysroot "$deplib" 8483b789ec8aSmrg deplib=$func_resolve_sysroot_result 8484c27c18e8Smrg func_dirname "$deplib" "" "." 8485b789ec8aSmrg dir=$func_dirname_result 8486c27c18e8Smrg # We need an absolute path. 8487c27c18e8Smrg case $dir in 848844584a44Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489c27c18e8Smrg *) 8490c27c18e8Smrg absdir=`cd "$dir" && pwd` 8491c27c18e8Smrg if test -z "$absdir"; then 849244584a44Smrg func_warning "cannot determine absolute directory name of '$dir'" 849344584a44Smrg absdir=$dir 8494c27c18e8Smrg fi 8495c27c18e8Smrg ;; 8496c27c18e8Smrg esac 8497c27c18e8Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8498c27c18e8Smrg case $host in 8499c27c18e8Smrg *-*-darwin*) 8500c27c18e8Smrg depdepl= 850144584a44Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 850244584a44Smrg if test -n "$deplibrary_names"; then 850344584a44Smrg for tmp in $deplibrary_names; do 8504c27c18e8Smrg depdepl=$tmp 8505c27c18e8Smrg done 850644584a44Smrg if test -f "$absdir/$objdir/$depdepl"; then 850744584a44Smrg depdepl=$absdir/$objdir/$depdepl 850844584a44Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509c27c18e8Smrg if test -z "$darwin_install_name"; then 851044584a44Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511c27c18e8Smrg fi 851244584a44Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 851344584a44Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514c27c18e8Smrg path= 8515c27c18e8Smrg fi 8516c27c18e8Smrg fi 8517c27c18e8Smrg ;; 8518c27c18e8Smrg *) 851944584a44Smrg path=-L$absdir/$objdir 8520c27c18e8Smrg ;; 8521c27c18e8Smrg esac 8522c27c18e8Smrg else 852344584a44Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524c27c18e8Smrg test -z "$libdir" && \ 852544584a44Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8526c27c18e8Smrg test "$absdir" != "$libdir" && \ 852744584a44Smrg func_warning "'$deplib' seems to be moved" 8528c27c18e8Smrg 852944584a44Smrg path=-L$absdir 8530c27c18e8Smrg fi 8531c27c18e8Smrg ;; 8532c27c18e8Smrg esac 8533c27c18e8Smrg case " $deplibs " in 8534c27c18e8Smrg *" $path "*) ;; 8535c27c18e8Smrg *) deplibs="$path $deplibs" ;; 8536c27c18e8Smrg esac 8537c27c18e8Smrg done 8538c27c18e8Smrg fi # link_all_deplibs != no 8539c27c18e8Smrg fi # linkmode = lib 8540c27c18e8Smrg done # for deplib in $libs 854144584a44Smrg if test link = "$pass"; then 854244584a44Smrg if test prog = "$linkmode"; then 8543c27c18e8Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544c27c18e8Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545c27c18e8Smrg else 854637eb1ca1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547c27c18e8Smrg fi 8548c27c18e8Smrg fi 854944584a44Smrg dependency_libs=$newdependency_libs 855044584a44Smrg if test dlpreopen = "$pass"; then 8551c27c18e8Smrg # Link the dlpreopened libraries before other libraries 8552c27c18e8Smrg for deplib in $save_deplibs; do 8553c27c18e8Smrg deplibs="$deplib $deplibs" 8554c27c18e8Smrg done 8555c27c18e8Smrg fi 855644584a44Smrg if test dlopen != "$pass"; then 855744584a44Smrg test conv = "$pass" || { 8558c27c18e8Smrg # Make sure lib_search_path contains only unique directories. 8559c27c18e8Smrg lib_search_path= 8560c27c18e8Smrg for dir in $newlib_search_path; do 8561c27c18e8Smrg case "$lib_search_path " in 8562c27c18e8Smrg *" $dir "*) ;; 8563b789ec8aSmrg *) func_append lib_search_path " $dir" ;; 8564c27c18e8Smrg esac 8565c27c18e8Smrg done 8566c27c18e8Smrg newlib_search_path= 856744584a44Smrg } 8568c27c18e8Smrg 856944584a44Smrg if test prog,link = "$linkmode,$pass"; then 8570c27c18e8Smrg vars="compile_deplibs finalize_deplibs" 857144584a44Smrg else 857244584a44Smrg vars=deplibs 8573c27c18e8Smrg fi 8574c27c18e8Smrg for var in $vars dependency_libs; do 8575c27c18e8Smrg # Add libraries to $var in reverse order 8576c27c18e8Smrg eval tmp_libs=\"\$$var\" 8577c27c18e8Smrg new_libs= 8578c27c18e8Smrg for deplib in $tmp_libs; do 8579c27c18e8Smrg # FIXME: Pedantically, this is the right thing to do, so 8580c27c18e8Smrg # that some nasty dependency loop isn't accidentally 8581c27c18e8Smrg # broken: 8582c27c18e8Smrg #new_libs="$deplib $new_libs" 8583c27c18e8Smrg # Pragmatically, this seems to cause very few problems in 8584c27c18e8Smrg # practice: 8585c27c18e8Smrg case $deplib in 8586c27c18e8Smrg -L*) new_libs="$deplib $new_libs" ;; 8587c27c18e8Smrg -R*) ;; 8588c27c18e8Smrg *) 8589c27c18e8Smrg # And here is the reason: when a library appears more 8590c27c18e8Smrg # than once as an explicit dependence of a library, or 8591c27c18e8Smrg # is implicitly linked in more than once by the 8592c27c18e8Smrg # compiler, it is considered special, and multiple 8593c27c18e8Smrg # occurrences thereof are not removed. Compare this 8594c27c18e8Smrg # with having the same library being listed as a 8595c27c18e8Smrg # dependency of multiple other libraries: in this case, 8596c27c18e8Smrg # we know (pedantically, we assume) the library does not 8597c27c18e8Smrg # need to be listed more than once, so we keep only the 8598c27c18e8Smrg # last copy. This is not always right, but it is rare 8599c27c18e8Smrg # enough that we require users that really mean to play 8600c27c18e8Smrg # such unportable linking tricks to link the library 8601c27c18e8Smrg # using -Wl,-lname, so that libtool does not consider it 8602c27c18e8Smrg # for duplicate removal. 8603c27c18e8Smrg case " $specialdeplibs " in 8604c27c18e8Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605c27c18e8Smrg *) 8606c27c18e8Smrg case " $new_libs " in 8607c27c18e8Smrg *" $deplib "*) ;; 8608c27c18e8Smrg *) new_libs="$deplib $new_libs" ;; 8609c27c18e8Smrg esac 8610c27c18e8Smrg ;; 8611c27c18e8Smrg esac 8612c27c18e8Smrg ;; 8613c27c18e8Smrg esac 8614c27c18e8Smrg done 8615c27c18e8Smrg tmp_libs= 8616c27c18e8Smrg for deplib in $new_libs; do 8617c27c18e8Smrg case $deplib in 8618c27c18e8Smrg -L*) 8619c27c18e8Smrg case " $tmp_libs " in 8620c27c18e8Smrg *" $deplib "*) ;; 8621b789ec8aSmrg *) func_append tmp_libs " $deplib" ;; 8622c27c18e8Smrg esac 8623c27c18e8Smrg ;; 8624b789ec8aSmrg *) func_append tmp_libs " $deplib" ;; 8625c27c18e8Smrg esac 8626c27c18e8Smrg done 8627c27c18e8Smrg eval $var=\"$tmp_libs\" 8628c27c18e8Smrg done # for var 8629c27c18e8Smrg fi 863044584a44Smrg 863144584a44Smrg # Add Sun CC postdeps if required: 863244584a44Smrg test CXX = "$tagname" && { 863344584a44Smrg case $host_os in 863444584a44Smrg linux*) 863544584a44Smrg case `$CC -V 2>&1 | sed 5q` in 863644584a44Smrg *Sun\ C*) # Sun C++ 5.9 863744584a44Smrg func_suncc_cstd_abi 863844584a44Smrg 863944584a44Smrg if test no != "$suncc_use_cstd_abi"; then 864044584a44Smrg func_append postdeps ' -library=Cstd -library=Crun' 864144584a44Smrg fi 864244584a44Smrg ;; 864344584a44Smrg esac 864444584a44Smrg ;; 864544584a44Smrg 864644584a44Smrg solaris*) 864744584a44Smrg func_cc_basename "$CC" 864844584a44Smrg case $func_cc_basename_result in 864944584a44Smrg CC* | sunCC*) 865044584a44Smrg func_suncc_cstd_abi 865144584a44Smrg 865244584a44Smrg if test no != "$suncc_use_cstd_abi"; then 865344584a44Smrg func_append postdeps ' -library=Cstd -library=Crun' 865444584a44Smrg fi 865544584a44Smrg ;; 865644584a44Smrg esac 865744584a44Smrg ;; 865844584a44Smrg esac 865944584a44Smrg } 866044584a44Smrg 8661c27c18e8Smrg # Last step: remove runtime libs from dependency_libs 8662c27c18e8Smrg # (they stay in deplibs) 8663c27c18e8Smrg tmp_libs= 866444584a44Smrg for i in $dependency_libs; do 8665c27c18e8Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8666c27c18e8Smrg *" $i "*) 866744584a44Smrg i= 8668c27c18e8Smrg ;; 8669c27c18e8Smrg esac 867044584a44Smrg if test -n "$i"; then 8671b789ec8aSmrg func_append tmp_libs " $i" 8672c27c18e8Smrg fi 8673c27c18e8Smrg done 8674c27c18e8Smrg dependency_libs=$tmp_libs 8675c27c18e8Smrg done # for pass 867644584a44Smrg if test prog = "$linkmode"; then 867744584a44Smrg dlfiles=$newdlfiles 8678c27c18e8Smrg fi 867944584a44Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 868044584a44Smrg dlprefiles=$newdlprefiles 8681c27c18e8Smrg fi 8682c27c18e8Smrg 8683c27c18e8Smrg case $linkmode in 8684c27c18e8Smrg oldlib) 868544584a44Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 868644584a44Smrg func_warning "'-dlopen' is ignored for archives" 8687c27c18e8Smrg fi 8688c27c18e8Smrg 8689c27c18e8Smrg case " $deplibs" in 8690c27c18e8Smrg *\ -l* | *\ -L*) 869144584a44Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8692c27c18e8Smrg esac 8693c27c18e8Smrg 8694c27c18e8Smrg test -n "$rpath" && \ 869544584a44Smrg func_warning "'-rpath' is ignored for archives" 8696c27c18e8Smrg 8697c27c18e8Smrg test -n "$xrpath" && \ 869844584a44Smrg func_warning "'-R' is ignored for archives" 8699c27c18e8Smrg 8700c27c18e8Smrg test -n "$vinfo" && \ 870144584a44Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8702c27c18e8Smrg 8703c27c18e8Smrg test -n "$release" && \ 870444584a44Smrg func_warning "'-release' is ignored for archives" 8705c27c18e8Smrg 8706c27c18e8Smrg test -n "$export_symbols$export_symbols_regex" && \ 870744584a44Smrg func_warning "'-export-symbols' is ignored for archives" 8708c27c18e8Smrg 8709c27c18e8Smrg # Now set the variables for building old libraries. 8710c27c18e8Smrg build_libtool_libs=no 871144584a44Smrg oldlibs=$output 8712b789ec8aSmrg func_append objs "$old_deplibs" 8713c27c18e8Smrg ;; 8714c27c18e8Smrg 8715c27c18e8Smrg lib) 871644584a44Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 8717c27c18e8Smrg case $outputname in 8718c27c18e8Smrg lib*) 8719c27c18e8Smrg func_stripname 'lib' '.la' "$outputname" 8720c27c18e8Smrg name=$func_stripname_result 8721c27c18e8Smrg eval shared_ext=\"$shrext_cmds\" 8722c27c18e8Smrg eval libname=\"$libname_spec\" 8723c27c18e8Smrg ;; 8724c27c18e8Smrg *) 872544584a44Smrg test no = "$module" \ 872644584a44Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727c27c18e8Smrg 872844584a44Smrg if test no != "$need_lib_prefix"; then 8729c27c18e8Smrg # Add the "lib" prefix for modules if required 8730c27c18e8Smrg func_stripname '' '.la' "$outputname" 8731c27c18e8Smrg name=$func_stripname_result 8732c27c18e8Smrg eval shared_ext=\"$shrext_cmds\" 8733c27c18e8Smrg eval libname=\"$libname_spec\" 8734c27c18e8Smrg else 8735c27c18e8Smrg func_stripname '' '.la' "$outputname" 8736c27c18e8Smrg libname=$func_stripname_result 8737c27c18e8Smrg fi 8738c27c18e8Smrg ;; 8739c27c18e8Smrg esac 8740c27c18e8Smrg 8741c27c18e8Smrg if test -n "$objs"; then 874244584a44Smrg if test pass_all != "$deplibs_check_method"; then 874344584a44Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744c27c18e8Smrg else 874537eb1ca1Smrg echo 8746c27c18e8Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747c27c18e8Smrg $ECHO "*** objects $objs is not portable!" 8748b789ec8aSmrg func_append libobjs " $objs" 8749c27c18e8Smrg fi 8750c27c18e8Smrg fi 8751c27c18e8Smrg 875244584a44Smrg test no = "$dlself" \ 875344584a44Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8754c27c18e8Smrg 8755c27c18e8Smrg set dummy $rpath 8756c27c18e8Smrg shift 875744584a44Smrg test 1 -lt "$#" \ 875844584a44Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8759c27c18e8Smrg 876044584a44Smrg install_libdir=$1 8761c27c18e8Smrg 8762c27c18e8Smrg oldlibs= 8763c27c18e8Smrg if test -z "$rpath"; then 876444584a44Smrg if test yes = "$build_libtool_libs"; then 8765c27c18e8Smrg # Building a libtool convenience library. 876644584a44Smrg # Some compilers have problems with a '.al' extension so 8767c27c18e8Smrg # convenience libraries should have the same extension an 8768c27c18e8Smrg # archive normally would. 8769c27c18e8Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770c27c18e8Smrg build_libtool_libs=convenience 8771c27c18e8Smrg build_old_libs=yes 8772c27c18e8Smrg fi 8773c27c18e8Smrg 8774c27c18e8Smrg test -n "$vinfo" && \ 877544584a44Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776c27c18e8Smrg 8777c27c18e8Smrg test -n "$release" && \ 877844584a44Smrg func_warning "'-release' is ignored for convenience libraries" 8779c27c18e8Smrg else 8780c27c18e8Smrg 8781c27c18e8Smrg # Parse the version information argument. 878244584a44Smrg save_ifs=$IFS; IFS=: 8783c27c18e8Smrg set dummy $vinfo 0 0 0 8784c27c18e8Smrg shift 878544584a44Smrg IFS=$save_ifs 8786c27c18e8Smrg 8787c27c18e8Smrg test -n "$7" && \ 878844584a44Smrg func_fatal_help "too many parameters to '-version-info'" 8789c27c18e8Smrg 8790c27c18e8Smrg # convert absolute version numbers to libtool ages 8791c27c18e8Smrg # this retains compatibility with .la files and attempts 8792c27c18e8Smrg # to make the code below a bit more comprehensible 8793c27c18e8Smrg 8794c27c18e8Smrg case $vinfo_number in 8795c27c18e8Smrg yes) 879644584a44Smrg number_major=$1 879744584a44Smrg number_minor=$2 879844584a44Smrg number_revision=$3 8799c27c18e8Smrg # 8800c27c18e8Smrg # There are really only two kinds -- those that 8801c27c18e8Smrg # use the current revision as the major version 8802c27c18e8Smrg # and those that subtract age and use age as 8803c27c18e8Smrg # a minor version. But, then there is irix 880444584a44Smrg # that has an extra 1 added just for fun 8805c27c18e8Smrg # 8806c27c18e8Smrg case $version_type in 8807f1ee322dSmrg # correct linux to gnu/linux during the next big refactor 880844584a44Smrg darwin|freebsd-elf|linux|osf|windows|none) 8809c27c18e8Smrg func_arith $number_major + $number_minor 8810c27c18e8Smrg current=$func_arith_result 881144584a44Smrg age=$number_minor 881244584a44Smrg revision=$number_revision 8813c27c18e8Smrg ;; 881444584a44Smrg freebsd-aout|qnx|sunos) 881544584a44Smrg current=$number_major 881644584a44Smrg revision=$number_minor 881744584a44Smrg age=0 8818c27c18e8Smrg ;; 8819c27c18e8Smrg irix|nonstopux) 8820c27c18e8Smrg func_arith $number_major + $number_minor 8821c27c18e8Smrg current=$func_arith_result 882244584a44Smrg age=$number_minor 882344584a44Smrg revision=$number_minor 8824c27c18e8Smrg lt_irix_increment=no 8825c27c18e8Smrg ;; 8826c27c18e8Smrg esac 8827c27c18e8Smrg ;; 8828c27c18e8Smrg no) 882944584a44Smrg current=$1 883044584a44Smrg revision=$2 883144584a44Smrg age=$3 8832c27c18e8Smrg ;; 8833c27c18e8Smrg esac 8834c27c18e8Smrg 8835c27c18e8Smrg # Check that each of the things are valid numbers. 8836c27c18e8Smrg case $current in 8837c27c18e8Smrg 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]) ;; 8838c27c18e8Smrg *) 883944584a44Smrg func_error "CURRENT '$current' must be a nonnegative integer" 884044584a44Smrg func_fatal_error "'$vinfo' is not valid version information" 8841c27c18e8Smrg ;; 8842c27c18e8Smrg esac 8843c27c18e8Smrg 8844c27c18e8Smrg case $revision in 8845c27c18e8Smrg 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]) ;; 8846c27c18e8Smrg *) 884744584a44Smrg func_error "REVISION '$revision' must be a nonnegative integer" 884844584a44Smrg func_fatal_error "'$vinfo' is not valid version information" 8849c27c18e8Smrg ;; 8850c27c18e8Smrg esac 8851c27c18e8Smrg 8852c27c18e8Smrg case $age in 8853c27c18e8Smrg 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]) ;; 8854c27c18e8Smrg *) 885544584a44Smrg func_error "AGE '$age' must be a nonnegative integer" 885644584a44Smrg func_fatal_error "'$vinfo' is not valid version information" 8857c27c18e8Smrg ;; 8858c27c18e8Smrg esac 8859c27c18e8Smrg 8860c27c18e8Smrg if test "$age" -gt "$current"; then 886144584a44Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 886244584a44Smrg func_fatal_error "'$vinfo' is not valid version information" 8863c27c18e8Smrg fi 8864c27c18e8Smrg 8865c27c18e8Smrg # Calculate the version variables. 8866c27c18e8Smrg major= 8867c27c18e8Smrg versuffix= 8868c27c18e8Smrg verstring= 8869c27c18e8Smrg case $version_type in 8870c27c18e8Smrg none) ;; 8871c27c18e8Smrg 8872c27c18e8Smrg darwin) 8873c27c18e8Smrg # Like Linux, but with the current version available in 8874c27c18e8Smrg # verstring for coding it into the library header 8875c27c18e8Smrg func_arith $current - $age 8876c27c18e8Smrg major=.$func_arith_result 887744584a44Smrg versuffix=$major.$age.$revision 8878c27c18e8Smrg # Darwin ld doesn't like 0 for these options... 8879c27c18e8Smrg func_arith $current + 1 8880c27c18e8Smrg minor_current=$func_arith_result 888144584a44Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882c27c18e8Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 888344584a44Smrg # On Darwin other compilers 888444584a44Smrg case $CC in 888544584a44Smrg nagfor*) 888644584a44Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888744584a44Smrg ;; 888844584a44Smrg *) 888944584a44Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 889044584a44Smrg ;; 889144584a44Smrg esac 8892c27c18e8Smrg ;; 8893c27c18e8Smrg 8894c27c18e8Smrg freebsd-aout) 889544584a44Smrg major=.$current 889644584a44Smrg versuffix=.$current.$revision 8897c27c18e8Smrg ;; 8898c27c18e8Smrg 8899c27c18e8Smrg freebsd-elf) 890044584a44Smrg func_arith $current - $age 890144584a44Smrg major=.$func_arith_result 890244584a44Smrg versuffix=$major.$age.$revision 8903c27c18e8Smrg ;; 8904c27c18e8Smrg 8905c27c18e8Smrg irix | nonstopux) 890644584a44Smrg if test no = "$lt_irix_increment"; then 8907c27c18e8Smrg func_arith $current - $age 8908c27c18e8Smrg else 8909c27c18e8Smrg func_arith $current - $age + 1 8910c27c18e8Smrg fi 8911c27c18e8Smrg major=$func_arith_result 8912c27c18e8Smrg 8913c27c18e8Smrg case $version_type in 8914c27c18e8Smrg nonstopux) verstring_prefix=nonstopux ;; 8915c27c18e8Smrg *) verstring_prefix=sgi ;; 8916c27c18e8Smrg esac 891744584a44Smrg verstring=$verstring_prefix$major.$revision 8918c27c18e8Smrg 8919c27c18e8Smrg # Add in all the interfaces that we are compatible with. 8920c27c18e8Smrg loop=$revision 892144584a44Smrg while test 0 -ne "$loop"; do 8922c27c18e8Smrg func_arith $revision - $loop 8923c27c18e8Smrg iface=$func_arith_result 8924c27c18e8Smrg func_arith $loop - 1 8925c27c18e8Smrg loop=$func_arith_result 892644584a44Smrg verstring=$verstring_prefix$major.$iface:$verstring 8927c27c18e8Smrg done 8928c27c18e8Smrg 892944584a44Smrg # Before this point, $major must not contain '.'. 8930c27c18e8Smrg major=.$major 893144584a44Smrg versuffix=$major.$revision 8932c27c18e8Smrg ;; 8933c27c18e8Smrg 8934f1ee322dSmrg linux) # correct to gnu/linux during the next big refactor 8935c27c18e8Smrg func_arith $current - $age 8936c27c18e8Smrg major=.$func_arith_result 893744584a44Smrg versuffix=$major.$age.$revision 8938c27c18e8Smrg ;; 8939c27c18e8Smrg 8940c27c18e8Smrg osf) 8941c27c18e8Smrg func_arith $current - $age 8942c27c18e8Smrg major=.$func_arith_result 894344584a44Smrg versuffix=.$current.$age.$revision 894444584a44Smrg verstring=$current.$age.$revision 8945c27c18e8Smrg 8946c27c18e8Smrg # Add in all the interfaces that we are compatible with. 8947c27c18e8Smrg loop=$age 894844584a44Smrg while test 0 -ne "$loop"; do 8949c27c18e8Smrg func_arith $current - $loop 8950c27c18e8Smrg iface=$func_arith_result 8951c27c18e8Smrg func_arith $loop - 1 8952c27c18e8Smrg loop=$func_arith_result 895344584a44Smrg verstring=$verstring:$iface.0 8954c27c18e8Smrg done 8955c27c18e8Smrg 8956c27c18e8Smrg # Make executables depend on our current version. 895744584a44Smrg func_append verstring ":$current.0" 8958c27c18e8Smrg ;; 8959c27c18e8Smrg 8960c27c18e8Smrg qnx) 896144584a44Smrg major=.$current 896244584a44Smrg versuffix=.$current 896344584a44Smrg ;; 896444584a44Smrg 896544584a44Smrg sco) 896644584a44Smrg major=.$current 896744584a44Smrg versuffix=.$current 8968c27c18e8Smrg ;; 8969c27c18e8Smrg 8970c27c18e8Smrg sunos) 897144584a44Smrg major=.$current 897244584a44Smrg versuffix=.$current.$revision 8973c27c18e8Smrg ;; 8974c27c18e8Smrg 8975c27c18e8Smrg windows) 8976c27c18e8Smrg # Use '-' rather than '.', since we only want one 897744584a44Smrg # extension on DOS 8.3 file systems. 8978c27c18e8Smrg func_arith $current - $age 8979c27c18e8Smrg major=$func_arith_result 898044584a44Smrg versuffix=-$major 8981c27c18e8Smrg ;; 8982c27c18e8Smrg 8983c27c18e8Smrg *) 898444584a44Smrg func_fatal_configuration "unknown library version type '$version_type'" 8985c27c18e8Smrg ;; 8986c27c18e8Smrg esac 8987c27c18e8Smrg 8988c27c18e8Smrg # Clear the version info if we defaulted, and they specified a release. 8989c27c18e8Smrg if test -z "$vinfo" && test -n "$release"; then 8990c27c18e8Smrg major= 8991c27c18e8Smrg case $version_type in 8992c27c18e8Smrg darwin) 8993c27c18e8Smrg # we can't check for "0.0" in archive_cmds due to quoting 8994c27c18e8Smrg # problems, so we reset it completely 8995c27c18e8Smrg verstring= 8996c27c18e8Smrg ;; 8997c27c18e8Smrg *) 899844584a44Smrg verstring=0.0 8999c27c18e8Smrg ;; 9000c27c18e8Smrg esac 900144584a44Smrg if test no = "$need_version"; then 9002c27c18e8Smrg versuffix= 9003c27c18e8Smrg else 900444584a44Smrg versuffix=.0.0 9005c27c18e8Smrg fi 9006c27c18e8Smrg fi 9007c27c18e8Smrg 9008c27c18e8Smrg # Remove version info from name if versioning should be avoided 900944584a44Smrg if test yes,no = "$avoid_version,$need_version"; then 9010c27c18e8Smrg major= 9011c27c18e8Smrg versuffix= 901244584a44Smrg verstring= 9013c27c18e8Smrg fi 9014c27c18e8Smrg 9015c27c18e8Smrg # Check to see if the archive will have undefined symbols. 901644584a44Smrg if test yes = "$allow_undefined"; then 901744584a44Smrg if test unsupported = "$allow_undefined_flag"; then 901844584a44Smrg if test yes = "$build_old_libs"; then 901944584a44Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 902044584a44Smrg build_libtool_libs=no 902144584a44Smrg else 902244584a44Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 902344584a44Smrg fi 9024c27c18e8Smrg fi 9025c27c18e8Smrg else 9026c27c18e8Smrg # Don't allow undefined symbols. 902744584a44Smrg allow_undefined_flag=$no_undefined_flag 9028c27c18e8Smrg fi 9029c27c18e8Smrg 9030c27c18e8Smrg fi 9031c27c18e8Smrg 903244584a44Smrg func_generate_dlsyms "$libname" "$libname" : 9033b789ec8aSmrg func_append libobjs " $symfileobj" 903444584a44Smrg test " " = "$libobjs" && libobjs= 9035c27c18e8Smrg 903644584a44Smrg if test relink != "$opt_mode"; then 9037c27c18e8Smrg # Remove our outputs, but don't remove object files since they 9038c27c18e8Smrg # may have been created when compiling PIC objects. 9039c27c18e8Smrg removelist= 9040c27c18e8Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9041c27c18e8Smrg for p in $tempremovelist; do 9042c27c18e8Smrg case $p in 9043c27c18e8Smrg *.$objext | *.gcno) 9044c27c18e8Smrg ;; 904544584a44Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 904644584a44Smrg if test -n "$precious_files_regex"; then 9047c27c18e8Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048c27c18e8Smrg then 9049c27c18e8Smrg continue 9050c27c18e8Smrg fi 9051c27c18e8Smrg fi 9052b789ec8aSmrg func_append removelist " $p" 9053c27c18e8Smrg ;; 9054c27c18e8Smrg *) ;; 9055c27c18e8Smrg esac 9056c27c18e8Smrg done 9057c27c18e8Smrg test -n "$removelist" && \ 9058c27c18e8Smrg func_show_eval "${RM}r \$removelist" 9059c27c18e8Smrg fi 9060c27c18e8Smrg 9061c27c18e8Smrg # Now set the variables for building old libraries. 906244584a44Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063b789ec8aSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9064c27c18e8Smrg 9065c27c18e8Smrg # Transform .lo files to .o files. 906644584a44Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067c27c18e8Smrg fi 9068c27c18e8Smrg 9069c27c18e8Smrg # Eliminate all temporary directories. 9070c27c18e8Smrg #for path in $notinst_path; do 907137eb1ca1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 907237eb1ca1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 907337eb1ca1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074c27c18e8Smrg #done 9075c27c18e8Smrg 9076c27c18e8Smrg if test -n "$xrpath"; then 9077c27c18e8Smrg # If the user specified any rpath flags, then add them. 9078c27c18e8Smrg temp_xrpath= 9079c27c18e8Smrg for libdir in $xrpath; do 9080b789ec8aSmrg func_replace_sysroot "$libdir" 9081b789ec8aSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9082c27c18e8Smrg case "$finalize_rpath " in 9083c27c18e8Smrg *" $libdir "*) ;; 9084b789ec8aSmrg *) func_append finalize_rpath " $libdir" ;; 9085c27c18e8Smrg esac 9086c27c18e8Smrg done 908744584a44Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088c27c18e8Smrg dependency_libs="$temp_xrpath $dependency_libs" 9089c27c18e8Smrg fi 9090c27c18e8Smrg fi 9091c27c18e8Smrg 9092c27c18e8Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 909344584a44Smrg old_dlfiles=$dlfiles 9094c27c18e8Smrg dlfiles= 9095c27c18e8Smrg for lib in $old_dlfiles; do 9096c27c18e8Smrg case " $dlprefiles $dlfiles " in 9097c27c18e8Smrg *" $lib "*) ;; 9098b789ec8aSmrg *) func_append dlfiles " $lib" ;; 9099c27c18e8Smrg esac 9100c27c18e8Smrg done 9101c27c18e8Smrg 9102c27c18e8Smrg # Make sure dlprefiles contains only unique files 910344584a44Smrg old_dlprefiles=$dlprefiles 9104c27c18e8Smrg dlprefiles= 9105c27c18e8Smrg for lib in $old_dlprefiles; do 9106c27c18e8Smrg case "$dlprefiles " in 9107c27c18e8Smrg *" $lib "*) ;; 9108b789ec8aSmrg *) func_append dlprefiles " $lib" ;; 9109c27c18e8Smrg esac 9110c27c18e8Smrg done 9111c27c18e8Smrg 911244584a44Smrg if test yes = "$build_libtool_libs"; then 9113c27c18e8Smrg if test -n "$rpath"; then 9114c27c18e8Smrg case $host in 911537eb1ca1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116c27c18e8Smrg # these systems don't actually have a c library (as such)! 9117c27c18e8Smrg ;; 9118c27c18e8Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9119c27c18e8Smrg # Rhapsody C library is in the System framework 9120b789ec8aSmrg func_append deplibs " System.ltframework" 9121c27c18e8Smrg ;; 9122c27c18e8Smrg *-*-netbsd*) 9123c27c18e8Smrg # Don't link with libc until the a.out ld.so is fixed. 9124c27c18e8Smrg ;; 9125c27c18e8Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126c27c18e8Smrg # Do not include libc due to us having libc/libc_r. 9127c27c18e8Smrg ;; 9128c27c18e8Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9129c27c18e8Smrg # Causes problems with __ctype 9130c27c18e8Smrg ;; 9131c27c18e8Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132c27c18e8Smrg # Compiler inserts libc in the correct place for threads to work 9133c27c18e8Smrg ;; 9134c27c18e8Smrg *) 9135c27c18e8Smrg # Add libc to deplibs on all other systems if necessary. 913644584a44Smrg if test yes = "$build_libtool_need_lc"; then 9137b789ec8aSmrg func_append deplibs " -lc" 9138c27c18e8Smrg fi 9139c27c18e8Smrg ;; 9140c27c18e8Smrg esac 9141c27c18e8Smrg fi 9142c27c18e8Smrg 9143c27c18e8Smrg # Transform deplibs into only deplibs that can be linked in shared. 9144c27c18e8Smrg name_save=$name 9145c27c18e8Smrg libname_save=$libname 9146c27c18e8Smrg release_save=$release 9147c27c18e8Smrg versuffix_save=$versuffix 9148c27c18e8Smrg major_save=$major 9149c27c18e8Smrg # I'm not sure if I'm treating the release correctly. I think 9150c27c18e8Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9151c27c18e8Smrg # add it in twice. Is that correct? 915244584a44Smrg release= 915344584a44Smrg versuffix= 915444584a44Smrg major= 9155c27c18e8Smrg newdeplibs= 9156c27c18e8Smrg droppeddeps=no 9157c27c18e8Smrg case $deplibs_check_method in 9158c27c18e8Smrg pass_all) 9159c27c18e8Smrg # Don't check for shared/static. Everything works. 9160c27c18e8Smrg # This might be a little naive. We might want to check 9161c27c18e8Smrg # whether the library exists or not. But this is on 9162c27c18e8Smrg # osf3 & osf4 and I'm not really sure... Just 9163c27c18e8Smrg # implementing what was already the behavior. 9164c27c18e8Smrg newdeplibs=$deplibs 9165c27c18e8Smrg ;; 9166c27c18e8Smrg test_compile) 9167c27c18e8Smrg # This code stresses the "libraries are programs" paradigm to its 9168c27c18e8Smrg # limits. Maybe even breaks it. We compile a program, linking it 9169c27c18e8Smrg # against the deplibs as a proxy for the library. Then we can check 9170c27c18e8Smrg # whether they linked in statically or dynamically with ldd. 9171c27c18e8Smrg $opt_dry_run || $RM conftest.c 9172c27c18e8Smrg cat > conftest.c <<EOF 9173c27c18e8Smrg int main() { return 0; } 9174c27c18e8SmrgEOF 9175c27c18e8Smrg $opt_dry_run || $RM conftest 9176c27c18e8Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177c27c18e8Smrg ldd_output=`ldd conftest` 9178c27c18e8Smrg for i in $deplibs; do 9179c27c18e8Smrg case $i in 9180c27c18e8Smrg -l*) 9181c27c18e8Smrg func_stripname -l '' "$i" 9182c27c18e8Smrg name=$func_stripname_result 918344584a44Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184c27c18e8Smrg case " $predeps $postdeps " in 9185c27c18e8Smrg *" $i "*) 9186b789ec8aSmrg func_append newdeplibs " $i" 918744584a44Smrg i= 9188c27c18e8Smrg ;; 9189c27c18e8Smrg esac 9190c27c18e8Smrg fi 919144584a44Smrg if test -n "$i"; then 9192c27c18e8Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9193c27c18e8Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194c27c18e8Smrg set dummy $deplib_matches; shift 9195c27c18e8Smrg deplib_match=$1 919644584a44Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197b789ec8aSmrg func_append newdeplibs " $i" 9198c27c18e8Smrg else 9199c27c18e8Smrg droppeddeps=yes 920037eb1ca1Smrg echo 9201c27c18e8Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 920237eb1ca1Smrg echo "*** I have the capability to make that library automatically link in when" 920337eb1ca1Smrg echo "*** you link to this library. But I can only do this if you have a" 920437eb1ca1Smrg echo "*** shared version of the library, which I believe you do not have" 920537eb1ca1Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 920637eb1ca1Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207c27c18e8Smrg fi 9208c27c18e8Smrg fi 9209c27c18e8Smrg ;; 9210c27c18e8Smrg *) 9211b789ec8aSmrg func_append newdeplibs " $i" 9212c27c18e8Smrg ;; 9213c27c18e8Smrg esac 9214c27c18e8Smrg done 9215c27c18e8Smrg else 9216c27c18e8Smrg # Error occurred in the first compile. Let's try to salvage 9217c27c18e8Smrg # the situation: Compile a separate program for each library. 9218c27c18e8Smrg for i in $deplibs; do 9219c27c18e8Smrg case $i in 9220c27c18e8Smrg -l*) 9221c27c18e8Smrg func_stripname -l '' "$i" 9222c27c18e8Smrg name=$func_stripname_result 9223c27c18e8Smrg $opt_dry_run || $RM conftest 9224c27c18e8Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225c27c18e8Smrg ldd_output=`ldd conftest` 922644584a44Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227c27c18e8Smrg case " $predeps $postdeps " in 9228c27c18e8Smrg *" $i "*) 9229b789ec8aSmrg func_append newdeplibs " $i" 923044584a44Smrg i= 9231c27c18e8Smrg ;; 9232c27c18e8Smrg esac 9233c27c18e8Smrg fi 923444584a44Smrg if test -n "$i"; then 9235c27c18e8Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9236c27c18e8Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237c27c18e8Smrg set dummy $deplib_matches; shift 9238c27c18e8Smrg deplib_match=$1 923944584a44Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240b789ec8aSmrg func_append newdeplibs " $i" 9241c27c18e8Smrg else 9242c27c18e8Smrg droppeddeps=yes 924337eb1ca1Smrg echo 9244c27c18e8Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 924537eb1ca1Smrg echo "*** I have the capability to make that library automatically link in when" 924637eb1ca1Smrg echo "*** you link to this library. But I can only do this if you have a" 924737eb1ca1Smrg echo "*** shared version of the library, which you do not appear to have" 924837eb1ca1Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 924937eb1ca1Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250c27c18e8Smrg fi 9251c27c18e8Smrg fi 9252c27c18e8Smrg else 9253c27c18e8Smrg droppeddeps=yes 925437eb1ca1Smrg echo 9255c27c18e8Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 925637eb1ca1Smrg echo "*** make it link in! You will probably need to install it or some" 925737eb1ca1Smrg echo "*** library that it depends on before this library will be fully" 925837eb1ca1Smrg echo "*** functional. Installing it before continuing would be even better." 9259c27c18e8Smrg fi 9260c27c18e8Smrg ;; 9261c27c18e8Smrg *) 9262b789ec8aSmrg func_append newdeplibs " $i" 9263c27c18e8Smrg ;; 9264c27c18e8Smrg esac 9265c27c18e8Smrg done 9266c27c18e8Smrg fi 9267c27c18e8Smrg ;; 9268c27c18e8Smrg file_magic*) 9269c27c18e8Smrg set dummy $deplibs_check_method; shift 9270c27c18e8Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271c27c18e8Smrg for a_deplib in $deplibs; do 9272c27c18e8Smrg case $a_deplib in 9273c27c18e8Smrg -l*) 9274c27c18e8Smrg func_stripname -l '' "$a_deplib" 9275c27c18e8Smrg name=$func_stripname_result 927644584a44Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277c27c18e8Smrg case " $predeps $postdeps " in 9278c27c18e8Smrg *" $a_deplib "*) 9279b789ec8aSmrg func_append newdeplibs " $a_deplib" 928044584a44Smrg a_deplib= 9281c27c18e8Smrg ;; 9282c27c18e8Smrg esac 9283c27c18e8Smrg fi 928444584a44Smrg if test -n "$a_deplib"; then 9285c27c18e8Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9286b789ec8aSmrg if test -n "$file_magic_glob"; then 9287b789ec8aSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288b789ec8aSmrg else 9289b789ec8aSmrg libnameglob=$libname 9290b789ec8aSmrg fi 929144584a44Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292c27c18e8Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 929344584a44Smrg if test yes = "$want_nocaseglob"; then 9294b789ec8aSmrg shopt -s nocaseglob 9295b789ec8aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296b789ec8aSmrg $nocaseglob 9297b789ec8aSmrg else 9298b789ec8aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299b789ec8aSmrg fi 9300c27c18e8Smrg for potent_lib in $potential_libs; do 9301c27c18e8Smrg # Follow soft links. 9302c27c18e8Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9303c27c18e8Smrg $GREP " -> " >/dev/null; then 9304c27c18e8Smrg continue 9305c27c18e8Smrg fi 9306c27c18e8Smrg # The statement above tries to avoid entering an 9307c27c18e8Smrg # endless loop below, in case of cyclic links. 9308c27c18e8Smrg # We might still enter an endless loop, since a link 9309c27c18e8Smrg # loop can be closed while we follow links, 9310c27c18e8Smrg # but so what? 931144584a44Smrg potlib=$potent_lib 9312c27c18e8Smrg while test -h "$potlib" 2>/dev/null; do 931344584a44Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314c27c18e8Smrg case $potliblink in 931544584a44Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 931644584a44Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317c27c18e8Smrg esac 9318c27c18e8Smrg done 9319c27c18e8Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320c27c18e8Smrg $SED -e 10q | 9321c27c18e8Smrg $EGREP "$file_magic_regex" > /dev/null; then 9322b789ec8aSmrg func_append newdeplibs " $a_deplib" 932344584a44Smrg a_deplib= 9324c27c18e8Smrg break 2 9325c27c18e8Smrg fi 9326c27c18e8Smrg done 9327c27c18e8Smrg done 9328c27c18e8Smrg fi 932944584a44Smrg if test -n "$a_deplib"; then 9330c27c18e8Smrg droppeddeps=yes 933137eb1ca1Smrg echo 9332c27c18e8Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 933337eb1ca1Smrg echo "*** I have the capability to make that library automatically link in when" 933437eb1ca1Smrg echo "*** you link to this library. But I can only do this if you have a" 933537eb1ca1Smrg echo "*** shared version of the library, which you do not appear to have" 933637eb1ca1Smrg echo "*** because I did check the linker path looking for a file starting" 933744584a44Smrg if test -z "$potlib"; then 9338c27c18e8Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339c27c18e8Smrg else 9340c27c18e8Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9341c27c18e8Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9342c27c18e8Smrg fi 9343c27c18e8Smrg fi 9344c27c18e8Smrg ;; 9345c27c18e8Smrg *) 9346c27c18e8Smrg # Add a -L argument. 9347b789ec8aSmrg func_append newdeplibs " $a_deplib" 9348c27c18e8Smrg ;; 9349c27c18e8Smrg esac 9350c27c18e8Smrg done # Gone through all deplibs. 9351c27c18e8Smrg ;; 9352c27c18e8Smrg match_pattern*) 9353c27c18e8Smrg set dummy $deplibs_check_method; shift 9354c27c18e8Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355c27c18e8Smrg for a_deplib in $deplibs; do 9356c27c18e8Smrg case $a_deplib in 9357c27c18e8Smrg -l*) 9358c27c18e8Smrg func_stripname -l '' "$a_deplib" 9359c27c18e8Smrg name=$func_stripname_result 936044584a44Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361c27c18e8Smrg case " $predeps $postdeps " in 9362c27c18e8Smrg *" $a_deplib "*) 9363b789ec8aSmrg func_append newdeplibs " $a_deplib" 936444584a44Smrg a_deplib= 9365c27c18e8Smrg ;; 9366c27c18e8Smrg esac 9367c27c18e8Smrg fi 936844584a44Smrg if test -n "$a_deplib"; then 9369c27c18e8Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9370c27c18e8Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371c27c18e8Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372c27c18e8Smrg for potent_lib in $potential_libs; do 937344584a44Smrg potlib=$potent_lib # see symlink-check above in file_magic test 937437eb1ca1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375c27c18e8Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9376b789ec8aSmrg func_append newdeplibs " $a_deplib" 937744584a44Smrg a_deplib= 9378c27c18e8Smrg break 2 9379c27c18e8Smrg fi 9380c27c18e8Smrg done 9381c27c18e8Smrg done 9382c27c18e8Smrg fi 938344584a44Smrg if test -n "$a_deplib"; then 9384c27c18e8Smrg droppeddeps=yes 938537eb1ca1Smrg echo 9386c27c18e8Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 938737eb1ca1Smrg echo "*** I have the capability to make that library automatically link in when" 938837eb1ca1Smrg echo "*** you link to this library. But I can only do this if you have a" 938937eb1ca1Smrg echo "*** shared version of the library, which you do not appear to have" 939037eb1ca1Smrg echo "*** because I did check the linker path looking for a file starting" 939144584a44Smrg if test -z "$potlib"; then 9392c27c18e8Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393c27c18e8Smrg else 9394c27c18e8Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9395c27c18e8Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396c27c18e8Smrg fi 9397c27c18e8Smrg fi 9398c27c18e8Smrg ;; 9399c27c18e8Smrg *) 9400c27c18e8Smrg # Add a -L argument. 9401b789ec8aSmrg func_append newdeplibs " $a_deplib" 9402c27c18e8Smrg ;; 9403c27c18e8Smrg esac 9404c27c18e8Smrg done # Gone through all deplibs. 9405c27c18e8Smrg ;; 9406c27c18e8Smrg none | unknown | *) 940744584a44Smrg newdeplibs= 940837eb1ca1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 940944584a44Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 941044584a44Smrg for i in $predeps $postdeps; do 9411c27c18e8Smrg # can't use Xsed below, because $i might contain '/' 941244584a44Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413c27c18e8Smrg done 9414c27c18e8Smrg fi 941537eb1ca1Smrg case $tmp_deplibs in 941637eb1ca1Smrg *[!\ \ ]*) 941737eb1ca1Smrg echo 941844584a44Smrg if test none = "$deplibs_check_method"; then 941937eb1ca1Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9420c27c18e8Smrg else 942137eb1ca1Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9422c27c18e8Smrg fi 942337eb1ca1Smrg echo "*** All declared inter-library dependencies are being dropped." 9424c27c18e8Smrg droppeddeps=yes 942537eb1ca1Smrg ;; 942637eb1ca1Smrg esac 9427c27c18e8Smrg ;; 9428c27c18e8Smrg esac 9429c27c18e8Smrg versuffix=$versuffix_save 9430c27c18e8Smrg major=$major_save 9431c27c18e8Smrg release=$release_save 9432c27c18e8Smrg libname=$libname_save 9433c27c18e8Smrg name=$name_save 9434c27c18e8Smrg 9435c27c18e8Smrg case $host in 9436c27c18e8Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9437c27c18e8Smrg # On Rhapsody replace the C library with the System framework 943837eb1ca1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439c27c18e8Smrg ;; 9440c27c18e8Smrg esac 9441c27c18e8Smrg 944244584a44Smrg if test yes = "$droppeddeps"; then 944344584a44Smrg if test yes = "$module"; then 944437eb1ca1Smrg echo 944537eb1ca1Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9446c27c18e8Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 944737eb1ca1Smrg echo "*** a static module, that should work as long as the dlopening" 944837eb1ca1Smrg echo "*** application is linked with the -dlopen flag." 9449c27c18e8Smrg if test -z "$global_symbol_pipe"; then 945037eb1ca1Smrg echo 945137eb1ca1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 945244584a44Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 945337eb1ca1Smrg echo "*** not find such a program. So, this module is probably useless." 945444584a44Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455c27c18e8Smrg fi 945644584a44Smrg if test no = "$build_old_libs"; then 945744584a44Smrg oldlibs=$output_objdir/$libname.$libext 9458c27c18e8Smrg build_libtool_libs=module 9459c27c18e8Smrg build_old_libs=yes 9460c27c18e8Smrg else 9461c27c18e8Smrg build_libtool_libs=no 9462c27c18e8Smrg fi 9463c27c18e8Smrg else 946437eb1ca1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 946537eb1ca1Smrg echo "*** automatically added whenever a program is linked with this library" 946637eb1ca1Smrg echo "*** or is declared to -dlopen it." 9467c27c18e8Smrg 946844584a44Smrg if test no = "$allow_undefined"; then 946937eb1ca1Smrg echo 947037eb1ca1Smrg echo "*** Since this library must not contain undefined symbols," 947137eb1ca1Smrg echo "*** because either the platform does not support them or" 947237eb1ca1Smrg echo "*** it was explicitly requested with -no-undefined," 947337eb1ca1Smrg echo "*** libtool will only create a static version of it." 947444584a44Smrg if test no = "$build_old_libs"; then 947544584a44Smrg oldlibs=$output_objdir/$libname.$libext 9476c27c18e8Smrg build_libtool_libs=module 9477c27c18e8Smrg build_old_libs=yes 9478c27c18e8Smrg else 9479c27c18e8Smrg build_libtool_libs=no 9480c27c18e8Smrg fi 9481c27c18e8Smrg fi 9482c27c18e8Smrg fi 9483c27c18e8Smrg fi 9484c27c18e8Smrg # Done checking deplibs! 9485c27c18e8Smrg deplibs=$newdeplibs 9486c27c18e8Smrg fi 9487c27c18e8Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488c27c18e8Smrg case $host in 9489c27c18e8Smrg *-*-darwin*) 949037eb1ca1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949137eb1ca1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949237eb1ca1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493c27c18e8Smrg ;; 9494c27c18e8Smrg esac 9495c27c18e8Smrg 9496c27c18e8Smrg # move library search paths that coincide with paths to not yet 9497c27c18e8Smrg # installed libraries to the beginning of the library search list 9498c27c18e8Smrg new_libs= 9499c27c18e8Smrg for path in $notinst_path; do 9500c27c18e8Smrg case " $new_libs " in 9501c27c18e8Smrg *" -L$path/$objdir "*) ;; 9502c27c18e8Smrg *) 9503c27c18e8Smrg case " $deplibs " in 9504c27c18e8Smrg *" -L$path/$objdir "*) 9505b789ec8aSmrg func_append new_libs " -L$path/$objdir" ;; 9506c27c18e8Smrg esac 9507c27c18e8Smrg ;; 9508c27c18e8Smrg esac 9509c27c18e8Smrg done 9510c27c18e8Smrg for deplib in $deplibs; do 9511c27c18e8Smrg case $deplib in 9512c27c18e8Smrg -L*) 9513c27c18e8Smrg case " $new_libs " in 9514c27c18e8Smrg *" $deplib "*) ;; 9515b789ec8aSmrg *) func_append new_libs " $deplib" ;; 9516c27c18e8Smrg esac 9517c27c18e8Smrg ;; 9518b789ec8aSmrg *) func_append new_libs " $deplib" ;; 9519c27c18e8Smrg esac 9520c27c18e8Smrg done 952144584a44Smrg deplibs=$new_libs 9522c27c18e8Smrg 9523c27c18e8Smrg # All the library-specific variables (install_libdir is set above). 9524c27c18e8Smrg library_names= 9525c27c18e8Smrg old_library= 9526c27c18e8Smrg dlname= 9527c27c18e8Smrg 9528c27c18e8Smrg # Test again, we may have decided not to build it any more 952944584a44Smrg if test yes = "$build_libtool_libs"; then 953044584a44Smrg # Remove $wl instances when linking with ld. 9531f1ee322dSmrg # FIXME: should test the right _cmds variable. 9532f1ee322dSmrg case $archive_cmds in 9533f1ee322dSmrg *\$LD\ *) wl= ;; 9534f1ee322dSmrg esac 953544584a44Smrg if test yes = "$hardcode_into_libs"; then 9536c27c18e8Smrg # Hardcode the library paths 9537c27c18e8Smrg hardcode_libdirs= 9538c27c18e8Smrg dep_rpath= 953944584a44Smrg rpath=$finalize_rpath 954044584a44Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541c27c18e8Smrg for libdir in $rpath; do 9542c27c18e8Smrg if test -n "$hardcode_libdir_flag_spec"; then 9543c27c18e8Smrg if test -n "$hardcode_libdir_separator"; then 9544b789ec8aSmrg func_replace_sysroot "$libdir" 9545b789ec8aSmrg libdir=$func_replace_sysroot_result 9546c27c18e8Smrg if test -z "$hardcode_libdirs"; then 954744584a44Smrg hardcode_libdirs=$libdir 9548c27c18e8Smrg else 9549c27c18e8Smrg # Just accumulate the unique libdirs. 9550c27c18e8Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551c27c18e8Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552c27c18e8Smrg ;; 9553c27c18e8Smrg *) 9554b789ec8aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555c27c18e8Smrg ;; 9556c27c18e8Smrg esac 9557c27c18e8Smrg fi 9558c27c18e8Smrg else 9559c27c18e8Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9560b789ec8aSmrg func_append dep_rpath " $flag" 9561c27c18e8Smrg fi 9562c27c18e8Smrg elif test -n "$runpath_var"; then 9563c27c18e8Smrg case "$perm_rpath " in 9564c27c18e8Smrg *" $libdir "*) ;; 9565f1ee322dSmrg *) func_append perm_rpath " $libdir" ;; 9566c27c18e8Smrg esac 9567c27c18e8Smrg fi 9568c27c18e8Smrg done 9569c27c18e8Smrg # Substitute the hardcoded libdirs into the rpath. 9570c27c18e8Smrg if test -n "$hardcode_libdir_separator" && 9571c27c18e8Smrg test -n "$hardcode_libdirs"; then 957244584a44Smrg libdir=$hardcode_libdirs 9573f1ee322dSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574c27c18e8Smrg fi 9575c27c18e8Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576c27c18e8Smrg # We should set the runpath_var. 9577c27c18e8Smrg rpath= 9578c27c18e8Smrg for dir in $perm_rpath; do 9579b789ec8aSmrg func_append rpath "$dir:" 9580c27c18e8Smrg done 9581c27c18e8Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582c27c18e8Smrg fi 9583c27c18e8Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584c27c18e8Smrg fi 9585c43cc173Smrg 958644584a44Smrg shlibpath=$finalize_shlibpath 958744584a44Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588c27c18e8Smrg if test -n "$shlibpath"; then 9589c27c18e8Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590c27c18e8Smrg fi 9591c43cc173Smrg 9592c27c18e8Smrg # Get the real and link names of the library. 9593c27c18e8Smrg eval shared_ext=\"$shrext_cmds\" 9594c27c18e8Smrg eval library_names=\"$library_names_spec\" 9595c27c18e8Smrg set dummy $library_names 9596c27c18e8Smrg shift 959744584a44Smrg realname=$1 9598c27c18e8Smrg shift 9599c43cc173Smrg 9600c27c18e8Smrg if test -n "$soname_spec"; then 9601c27c18e8Smrg eval soname=\"$soname_spec\" 9602c27c18e8Smrg else 960344584a44Smrg soname=$realname 9604c27c18e8Smrg fi 9605c27c18e8Smrg if test -z "$dlname"; then 9606c27c18e8Smrg dlname=$soname 9607c27c18e8Smrg fi 9608c43cc173Smrg 960944584a44Smrg lib=$output_objdir/$realname 9610c27c18e8Smrg linknames= 9611c27c18e8Smrg for link 9612c27c18e8Smrg do 9613b789ec8aSmrg func_append linknames " $link" 9614c27c18e8Smrg done 9615c43cc173Smrg 9616c27c18e8Smrg # Use standard objects if they are pic 961737eb1ca1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618c27c18e8Smrg test "X$libobjs" = "X " && libobjs= 9619c43cc173Smrg 9620c27c18e8Smrg delfiles= 9621c27c18e8Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622c27c18e8Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 962344584a44Smrg export_symbols=$output_objdir/$libname.uexp 9624b789ec8aSmrg func_append delfiles " $export_symbols" 9625c27c18e8Smrg fi 9626c43cc173Smrg 9627c27c18e8Smrg orig_export_symbols= 9628c27c18e8Smrg case $host_os in 9629c27c18e8Smrg cygwin* | mingw* | cegcc*) 9630c27c18e8Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631c27c18e8Smrg # exporting using user supplied symfile 963244584a44Smrg func_dll_def_p "$export_symbols" || { 9633c27c18e8Smrg # and it's NOT already a .def file. Must figure out 9634c27c18e8Smrg # which of the given symbols are data symbols and tag 9635c27c18e8Smrg # them as such. So, trigger use of export_symbols_cmds. 9636c27c18e8Smrg # export_symbols gets reassigned inside the "prepare 9637c27c18e8Smrg # the list of exported symbols" if statement, so the 9638c27c18e8Smrg # include_expsyms logic still works. 963944584a44Smrg orig_export_symbols=$export_symbols 9640c27c18e8Smrg export_symbols= 9641c27c18e8Smrg always_export_symbols=yes 964244584a44Smrg } 9643c27c18e8Smrg fi 9644c27c18e8Smrg ;; 9645c27c18e8Smrg esac 9646c43cc173Smrg 9647c27c18e8Smrg # Prepare the list of exported symbols 9648c27c18e8Smrg if test -z "$export_symbols"; then 964944584a44Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 965044584a44Smrg func_verbose "generating symbol list for '$libname.la'" 965144584a44Smrg export_symbols=$output_objdir/$libname.exp 9652c27c18e8Smrg $opt_dry_run || $RM $export_symbols 9653c27c18e8Smrg cmds=$export_symbols_cmds 965444584a44Smrg save_ifs=$IFS; IFS='~' 9655b789ec8aSmrg for cmd1 in $cmds; do 965644584a44Smrg IFS=$save_ifs 9657b789ec8aSmrg # Take the normal branch if the nm_file_list_spec branch 9658b789ec8aSmrg # doesn't work or if tool conversion is not needed. 9659b789ec8aSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9660b789ec8aSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661b789ec8aSmrg try_normal_branch=yes 9662b789ec8aSmrg eval cmd=\"$cmd1\" 9663b789ec8aSmrg func_len " $cmd" 9664b789ec8aSmrg len=$func_len_result 9665b789ec8aSmrg ;; 9666b789ec8aSmrg *) 9667b789ec8aSmrg try_normal_branch=no 9668b789ec8aSmrg ;; 9669b789ec8aSmrg esac 967044584a44Smrg if test yes = "$try_normal_branch" \ 9671b789ec8aSmrg && { test "$len" -lt "$max_cmd_len" \ 9672b789ec8aSmrg || test "$max_cmd_len" -le -1; } 9673b789ec8aSmrg then 9674b789ec8aSmrg func_show_eval "$cmd" 'exit $?' 9675b789ec8aSmrg skipped_export=false 9676b789ec8aSmrg elif test -n "$nm_file_list_spec"; then 9677b789ec8aSmrg func_basename "$output" 9678b789ec8aSmrg output_la=$func_basename_result 9679b789ec8aSmrg save_libobjs=$libobjs 9680b789ec8aSmrg save_output=$output 968144584a44Smrg output=$output_objdir/$output_la.nm 9682b789ec8aSmrg func_to_tool_file "$output" 9683b789ec8aSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9684b789ec8aSmrg func_append delfiles " $output" 9685b789ec8aSmrg func_verbose "creating $NM input file list: $output" 9686b789ec8aSmrg for obj in $save_libobjs; do 9687b789ec8aSmrg func_to_tool_file "$obj" 9688b789ec8aSmrg $ECHO "$func_to_tool_file_result" 9689b789ec8aSmrg done > "$output" 9690b789ec8aSmrg eval cmd=\"$cmd1\" 9691c27c18e8Smrg func_show_eval "$cmd" 'exit $?' 9692b789ec8aSmrg output=$save_output 9693b789ec8aSmrg libobjs=$save_libobjs 9694c27c18e8Smrg skipped_export=false 9695c27c18e8Smrg else 9696c27c18e8Smrg # The command line is too long to execute in one step. 9697c27c18e8Smrg func_verbose "using reloadable object file for export list..." 9698c27c18e8Smrg skipped_export=: 9699c27c18e8Smrg # Break out early, otherwise skipped_export may be 9700c27c18e8Smrg # set to false by a later but shorter cmd. 9701c27c18e8Smrg break 9702c27c18e8Smrg fi 9703c27c18e8Smrg done 970444584a44Smrg IFS=$save_ifs 970544584a44Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706c27c18e8Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707c27c18e8Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708c27c18e8Smrg fi 9709c27c18e8Smrg fi 9710c27c18e8Smrg fi 9711c43cc173Smrg 9712c27c18e8Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 971344584a44Smrg tmp_export_symbols=$export_symbols 971444584a44Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 971537eb1ca1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716c27c18e8Smrg fi 9717c43cc173Smrg 971844584a44Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719c27c18e8Smrg # The given exports_symbols file has to be filtered, so filter it. 972044584a44Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721c27c18e8Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 972244584a44Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9723c27c18e8Smrg # though. Also, the filter scales superlinearly with the number of 9724c27c18e8Smrg # global variables. join(1) would be nice here, but unfortunately 9725c27c18e8Smrg # isn't a blessed tool. 9726c27c18e8Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727b789ec8aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728c27c18e8Smrg export_symbols=$output_objdir/$libname.def 9729c27c18e8Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730c43cc173Smrg fi 9731c43cc173Smrg 9732c27c18e8Smrg tmp_deplibs= 9733c27c18e8Smrg for test_deplib in $deplibs; do 9734c27c18e8Smrg case " $convenience " in 9735c27c18e8Smrg *" $test_deplib "*) ;; 9736c27c18e8Smrg *) 9737b789ec8aSmrg func_append tmp_deplibs " $test_deplib" 9738c27c18e8Smrg ;; 9739c27c18e8Smrg esac 9740c27c18e8Smrg done 974144584a44Smrg deplibs=$tmp_deplibs 9742c43cc173Smrg 9743c27c18e8Smrg if test -n "$convenience"; then 9744c27c18e8Smrg if test -n "$whole_archive_flag_spec" && 974544584a44Smrg test yes = "$compiler_needs_object" && 9746c27c18e8Smrg test -z "$libobjs"; then 9747c27c18e8Smrg # extract the archives, so we have objects to list. 9748c27c18e8Smrg # TODO: could optimize this to just extract one archive. 9749c27c18e8Smrg whole_archive_flag_spec= 9750c27c18e8Smrg fi 9751c27c18e8Smrg if test -n "$whole_archive_flag_spec"; then 9752c27c18e8Smrg save_libobjs=$libobjs 9753c27c18e8Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754c27c18e8Smrg test "X$libobjs" = "X " && libobjs= 9755c27c18e8Smrg else 975644584a44Smrg gentop=$output_objdir/${outputname}x 9757b789ec8aSmrg func_append generated " $gentop" 9758c43cc173Smrg 9759c27c18e8Smrg func_extract_archives $gentop $convenience 9760b789ec8aSmrg func_append libobjs " $func_extract_archives_result" 9761c27c18e8Smrg test "X$libobjs" = "X " && libobjs= 9762c27c18e8Smrg fi 9763c27c18e8Smrg fi 9764c43cc173Smrg 976544584a44Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766c27c18e8Smrg eval flag=\"$thread_safe_flag_spec\" 9767b789ec8aSmrg func_append linker_flags " $flag" 9768c27c18e8Smrg fi 9769c43cc173Smrg 9770c27c18e8Smrg # Make a backup of the uninstalled library when relinking 977144584a44Smrg if test relink = "$opt_mode"; then 9772c27c18e8Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773c43cc173Smrg fi 9774c43cc173Smrg 9775c27c18e8Smrg # Do each of the archive commands. 977644584a44Smrg if test yes = "$module" && test -n "$module_cmds"; then 9777c27c18e8Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778c27c18e8Smrg eval test_cmds=\"$module_expsym_cmds\" 9779c27c18e8Smrg cmds=$module_expsym_cmds 9780c27c18e8Smrg else 9781c27c18e8Smrg eval test_cmds=\"$module_cmds\" 9782c27c18e8Smrg cmds=$module_cmds 9783c27c18e8Smrg fi 9784c27c18e8Smrg else 9785c27c18e8Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786c27c18e8Smrg eval test_cmds=\"$archive_expsym_cmds\" 9787c27c18e8Smrg cmds=$archive_expsym_cmds 9788c27c18e8Smrg else 9789c27c18e8Smrg eval test_cmds=\"$archive_cmds\" 9790c27c18e8Smrg cmds=$archive_cmds 9791c27c18e8Smrg fi 9792c43cc173Smrg fi 9793c43cc173Smrg 979444584a44Smrg if test : != "$skipped_export" && 9795c27c18e8Smrg func_len " $test_cmds" && 9796c27c18e8Smrg len=$func_len_result && 9797c27c18e8Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798c27c18e8Smrg : 9799c27c18e8Smrg else 9800c27c18e8Smrg # The command line is too long to link in one step, link piecewise 9801c27c18e8Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9802c27c18e8Smrg # script. 9803c43cc173Smrg 9804c27c18e8Smrg # Save the value of $output and $libobjs because we want to 9805c27c18e8Smrg # use them later. If we have whole_archive_flag_spec, we 9806c27c18e8Smrg # want to use save_libobjs as it was before 9807c27c18e8Smrg # whole_archive_flag_spec was expanded, because we can't 9808c27c18e8Smrg # assume the linker understands whole_archive_flag_spec. 9809c27c18e8Smrg # This may have to be revisited, in case too many 9810c27c18e8Smrg # convenience libraries get linked in and end up exceeding 9811c27c18e8Smrg # the spec. 9812c27c18e8Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813c27c18e8Smrg save_libobjs=$libobjs 9814c27c18e8Smrg fi 9815c27c18e8Smrg save_output=$output 981637eb1ca1Smrg func_basename "$output" 981737eb1ca1Smrg output_la=$func_basename_result 9818c43cc173Smrg 9819c27c18e8Smrg # Clear the reloadable object creation command queue and 9820c27c18e8Smrg # initialize k to one. 9821c27c18e8Smrg test_cmds= 9822c27c18e8Smrg concat_cmds= 9823c27c18e8Smrg objlist= 9824c27c18e8Smrg last_robj= 9825c27c18e8Smrg k=1 9826c43cc173Smrg 982744584a44Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 982844584a44Smrg output=$output_objdir/$output_la.lnkscript 9829c27c18e8Smrg func_verbose "creating GNU ld script: $output" 983037eb1ca1Smrg echo 'INPUT (' > $output 9831c27c18e8Smrg for obj in $save_libobjs 9832c27c18e8Smrg do 9833b789ec8aSmrg func_to_tool_file "$obj" 9834b789ec8aSmrg $ECHO "$func_to_tool_file_result" >> $output 9835c27c18e8Smrg done 983637eb1ca1Smrg echo ')' >> $output 9837b789ec8aSmrg func_append delfiles " $output" 9838b789ec8aSmrg func_to_tool_file "$output" 9839b789ec8aSmrg output=$func_to_tool_file_result 984044584a44Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 984144584a44Smrg output=$output_objdir/$output_la.lnk 9842c27c18e8Smrg func_verbose "creating linker input file list: $output" 9843c27c18e8Smrg : > $output 9844c27c18e8Smrg set x $save_libobjs 9845c27c18e8Smrg shift 9846c27c18e8Smrg firstobj= 984744584a44Smrg if test yes = "$compiler_needs_object"; then 9848c27c18e8Smrg firstobj="$1 " 9849c27c18e8Smrg shift 9850c27c18e8Smrg fi 9851c27c18e8Smrg for obj 9852c27c18e8Smrg do 9853b789ec8aSmrg func_to_tool_file "$obj" 9854b789ec8aSmrg $ECHO "$func_to_tool_file_result" >> $output 9855c27c18e8Smrg done 9856b789ec8aSmrg func_append delfiles " $output" 9857b789ec8aSmrg func_to_tool_file "$output" 9858b789ec8aSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859c27c18e8Smrg else 9860c27c18e8Smrg if test -n "$save_libobjs"; then 9861c27c18e8Smrg func_verbose "creating reloadable object files..." 986244584a44Smrg output=$output_objdir/$output_la-$k.$objext 9863c27c18e8Smrg eval test_cmds=\"$reload_cmds\" 9864c27c18e8Smrg func_len " $test_cmds" 9865c27c18e8Smrg len0=$func_len_result 9866c27c18e8Smrg len=$len0 9867c27c18e8Smrg 9868c27c18e8Smrg # Loop over the list of objects to be linked. 9869c27c18e8Smrg for obj in $save_libobjs 9870c27c18e8Smrg do 9871c27c18e8Smrg func_len " $obj" 9872c27c18e8Smrg func_arith $len + $func_len_result 9873c27c18e8Smrg len=$func_arith_result 987444584a44Smrg if test -z "$objlist" || 9875c27c18e8Smrg test "$len" -lt "$max_cmd_len"; then 9876c27c18e8Smrg func_append objlist " $obj" 9877c27c18e8Smrg else 9878c27c18e8Smrg # The command $test_cmds is almost too long, add a 9879c27c18e8Smrg # command to the queue. 988044584a44Smrg if test 1 -eq "$k"; then 9881c27c18e8Smrg # The first file doesn't have a previous command to add. 988237eb1ca1Smrg reload_objs=$objlist 988337eb1ca1Smrg eval concat_cmds=\"$reload_cmds\" 9884c27c18e8Smrg else 9885c27c18e8Smrg # All subsequent reloadable object files will link in 9886c27c18e8Smrg # the last one created. 988737eb1ca1Smrg reload_objs="$objlist $last_robj" 988837eb1ca1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889c27c18e8Smrg fi 989044584a44Smrg last_robj=$output_objdir/$output_la-$k.$objext 9891c27c18e8Smrg func_arith $k + 1 9892c27c18e8Smrg k=$func_arith_result 989344584a44Smrg output=$output_objdir/$output_la-$k.$objext 989437eb1ca1Smrg objlist=" $obj" 9895c27c18e8Smrg func_len " $last_robj" 9896c27c18e8Smrg func_arith $len0 + $func_len_result 9897c27c18e8Smrg len=$func_arith_result 9898c27c18e8Smrg fi 9899c27c18e8Smrg done 9900c27c18e8Smrg # Handle the remaining objects by creating one last 9901c27c18e8Smrg # reloadable object file. All subsequent reloadable object 9902c27c18e8Smrg # files will link in the last one created. 9903c27c18e8Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 990437eb1ca1Smrg reload_objs="$objlist $last_robj" 990544584a44Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906c27c18e8Smrg if test -n "$last_robj"; then 990744584a44Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908c27c18e8Smrg fi 9909b789ec8aSmrg func_append delfiles " $output" 9910c43cc173Smrg 9911c27c18e8Smrg else 9912c27c18e8Smrg output= 9913c27c18e8Smrg fi 9914c27c18e8Smrg 991544584a44Smrg ${skipped_export-false} && { 991644584a44Smrg func_verbose "generating symbol list for '$libname.la'" 991744584a44Smrg export_symbols=$output_objdir/$libname.exp 9918c27c18e8Smrg $opt_dry_run || $RM $export_symbols 9919c27c18e8Smrg libobjs=$output 9920c27c18e8Smrg # Append the command to create the export file. 9921c27c18e8Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922c27c18e8Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923c27c18e8Smrg if test -n "$last_robj"; then 9924c27c18e8Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925c27c18e8Smrg fi 992644584a44Smrg } 9927c43cc173Smrg 9928c27c18e8Smrg test -n "$save_libobjs" && 9929c27c18e8Smrg func_verbose "creating a temporary reloadable object file: $output" 9930c43cc173Smrg 9931c27c18e8Smrg # Loop through the commands generated above and execute them. 993244584a44Smrg save_ifs=$IFS; IFS='~' 9933c27c18e8Smrg for cmd in $concat_cmds; do 993444584a44Smrg IFS=$save_ifs 993544584a44Smrg $opt_quiet || { 9936c27c18e8Smrg func_quote_for_expand "$cmd" 9937c27c18e8Smrg eval "func_echo $func_quote_for_expand_result" 9938c27c18e8Smrg } 9939c27c18e8Smrg $opt_dry_run || eval "$cmd" || { 9940c27c18e8Smrg lt_exit=$? 9941c27c18e8Smrg 9942c27c18e8Smrg # Restore the uninstalled library and exit 994344584a44Smrg if test relink = "$opt_mode"; then 9944c27c18e8Smrg ( cd "$output_objdir" && \ 9945c27c18e8Smrg $RM "${realname}T" && \ 9946c27c18e8Smrg $MV "${realname}U" "$realname" ) 9947c27c18e8Smrg fi 9948c43cc173Smrg 9949c27c18e8Smrg exit $lt_exit 9950c27c18e8Smrg } 9951c27c18e8Smrg done 995244584a44Smrg IFS=$save_ifs 9953c43cc173Smrg 9954c27c18e8Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955c27c18e8Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956c27c18e8Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957c43cc173Smrg fi 9958c43cc173Smrg fi 9959c43cc173Smrg 996044584a44Smrg ${skipped_export-false} && { 9961c27c18e8Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 996244584a44Smrg tmp_export_symbols=$export_symbols 996344584a44Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 996437eb1ca1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965c27c18e8Smrg fi 9966c43cc173Smrg 9967c27c18e8Smrg if test -n "$orig_export_symbols"; then 9968c27c18e8Smrg # The given exports_symbols file has to be filtered, so filter it. 996944584a44Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970c27c18e8Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 997144584a44Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9972c27c18e8Smrg # though. Also, the filter scales superlinearly with the number of 9973c27c18e8Smrg # global variables. join(1) would be nice here, but unfortunately 9974c27c18e8Smrg # isn't a blessed tool. 9975c27c18e8Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976b789ec8aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977c27c18e8Smrg export_symbols=$output_objdir/$libname.def 9978c27c18e8Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979c27c18e8Smrg fi 998044584a44Smrg } 9981c43cc173Smrg 9982c27c18e8Smrg libobjs=$output 9983c27c18e8Smrg # Restore the value of output. 9984c27c18e8Smrg output=$save_output 9985c43cc173Smrg 9986c27c18e8Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987c27c18e8Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988c27c18e8Smrg test "X$libobjs" = "X " && libobjs= 9989c27c18e8Smrg fi 9990c27c18e8Smrg # Expand the library linking commands again to reset the 9991c27c18e8Smrg # value of $libobjs for piecewise linking. 9992c27c18e8Smrg 9993c27c18e8Smrg # Do each of the archive commands. 999444584a44Smrg if test yes = "$module" && test -n "$module_cmds"; then 9995c27c18e8Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996c27c18e8Smrg cmds=$module_expsym_cmds 9997c43cc173Smrg else 9998c27c18e8Smrg cmds=$module_cmds 9999c43cc173Smrg fi 10000c43cc173Smrg else 10001c27c18e8Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002c27c18e8Smrg cmds=$archive_expsym_cmds 10003c27c18e8Smrg else 10004c27c18e8Smrg cmds=$archive_cmds 10005c27c18e8Smrg fi 10006c43cc173Smrg fi 10007c43cc173Smrg fi 10008c43cc173Smrg 10009c27c18e8Smrg if test -n "$delfiles"; then 10010c27c18e8Smrg # Append the command to remove temporary files to $cmds. 10011c27c18e8Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10012c27c18e8Smrg fi 10013c43cc173Smrg 10014c27c18e8Smrg # Add any objects from preloaded convenience libraries 10015c27c18e8Smrg if test -n "$dlprefiles"; then 1001644584a44Smrg gentop=$output_objdir/${outputname}x 10017b789ec8aSmrg func_append generated " $gentop" 10018c43cc173Smrg 10019c27c18e8Smrg func_extract_archives $gentop $dlprefiles 10020b789ec8aSmrg func_append libobjs " $func_extract_archives_result" 10021c27c18e8Smrg test "X$libobjs" = "X " && libobjs= 10022c43cc173Smrg fi 10023c43cc173Smrg 1002444584a44Smrg save_ifs=$IFS; IFS='~' 10025c27c18e8Smrg for cmd in $cmds; do 1002644584a44Smrg IFS=$sp$nl 10027c27c18e8Smrg eval cmd=\"$cmd\" 1002844584a44Smrg IFS=$save_ifs 1002944584a44Smrg $opt_quiet || { 10030c27c18e8Smrg func_quote_for_expand "$cmd" 10031c27c18e8Smrg eval "func_echo $func_quote_for_expand_result" 10032c27c18e8Smrg } 10033c27c18e8Smrg $opt_dry_run || eval "$cmd" || { 10034c27c18e8Smrg lt_exit=$? 10035c43cc173Smrg 10036c27c18e8Smrg # Restore the uninstalled library and exit 1003744584a44Smrg if test relink = "$opt_mode"; then 10038c27c18e8Smrg ( cd "$output_objdir" && \ 10039c27c18e8Smrg $RM "${realname}T" && \ 10040c27c18e8Smrg $MV "${realname}U" "$realname" ) 10041c43cc173Smrg fi 10042c43cc173Smrg 10043c27c18e8Smrg exit $lt_exit 10044c27c18e8Smrg } 10045c27c18e8Smrg done 1004644584a44Smrg IFS=$save_ifs 10047c43cc173Smrg 10048c27c18e8Smrg # Restore the uninstalled library and exit 1004944584a44Smrg if test relink = "$opt_mode"; then 10050c27c18e8Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051c43cc173Smrg 10052c27c18e8Smrg if test -n "$convenience"; then 10053c27c18e8Smrg if test -z "$whole_archive_flag_spec"; then 10054c27c18e8Smrg func_show_eval '${RM}r "$gentop"' 10055c27c18e8Smrg fi 10056c27c18e8Smrg fi 10057c43cc173Smrg 10058c27c18e8Smrg exit $EXIT_SUCCESS 10059c27c18e8Smrg fi 10060c43cc173Smrg 10061c27c18e8Smrg # Create links to the real library. 10062c27c18e8Smrg for linkname in $linknames; do 10063c27c18e8Smrg if test "$realname" != "$linkname"; then 10064c27c18e8Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065c43cc173Smrg fi 10066c43cc173Smrg done 10067c43cc173Smrg 10068c27c18e8Smrg # If -module or -export-dynamic was specified, set the dlname. 1006944584a44Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10070c27c18e8Smrg # On all known operating systems, these are identical. 1007144584a44Smrg dlname=$soname 10072c27c18e8Smrg fi 10073c27c18e8Smrg fi 10074c43cc173Smrg ;; 10075c43cc173Smrg 10076c27c18e8Smrg obj) 1007744584a44Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1007844584a44Smrg func_warning "'-dlopen' is ignored for objects" 10079c27c18e8Smrg fi 10080c43cc173Smrg 10081c27c18e8Smrg case " $deplibs" in 10082c27c18e8Smrg *\ -l* | *\ -L*) 1008344584a44Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084c43cc173Smrg esac 10085c43cc173Smrg 10086c27c18e8Smrg test -n "$rpath" && \ 1008744584a44Smrg func_warning "'-rpath' is ignored for objects" 10088c43cc173Smrg 10089c27c18e8Smrg test -n "$xrpath" && \ 1009044584a44Smrg func_warning "'-R' is ignored for objects" 10091c43cc173Smrg 10092c27c18e8Smrg test -n "$vinfo" && \ 1009344584a44Smrg func_warning "'-version-info' is ignored for objects" 10094c27c18e8Smrg 10095c27c18e8Smrg test -n "$release" && \ 1009644584a44Smrg func_warning "'-release' is ignored for objects" 10097c27c18e8Smrg 10098c27c18e8Smrg case $output in 10099c27c18e8Smrg *.lo) 10100c27c18e8Smrg test -n "$objs$old_deplibs" && \ 1010144584a44Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102c27c18e8Smrg 10103c27c18e8Smrg libobj=$output 10104c27c18e8Smrg func_lo2o "$libobj" 10105c27c18e8Smrg obj=$func_lo2o_result 10106c43cc173Smrg ;; 10107c43cc173Smrg *) 10108c27c18e8Smrg libobj= 1010944584a44Smrg obj=$output 10110c43cc173Smrg ;; 10111c43cc173Smrg esac 10112c43cc173Smrg 10113c27c18e8Smrg # Delete the old objects. 10114c27c18e8Smrg $opt_dry_run || $RM $obj $libobj 10115c43cc173Smrg 10116c27c18e8Smrg # Objects from convenience libraries. This assumes 10117c27c18e8Smrg # single-version convenience libraries. Whenever we create 10118c27c18e8Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10119c27c18e8Smrg # the extraction. 10120c27c18e8Smrg reload_conv_objs= 10121c27c18e8Smrg gentop= 1012244584a44Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1012344584a44Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1012444584a44Smrg # into space. 1012544584a44Smrg case $reload_cmds in 1012644584a44Smrg *\$LD[\ \$]*) wl= ;; 1012744584a44Smrg esac 10128c27c18e8Smrg if test -n "$convenience"; then 10129c27c18e8Smrg if test -n "$whole_archive_flag_spec"; then 10130c27c18e8Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1013144584a44Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1013244584a44Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133c27c18e8Smrg else 1013444584a44Smrg gentop=$output_objdir/${obj}x 10135b789ec8aSmrg func_append generated " $gentop" 10136c43cc173Smrg 10137c27c18e8Smrg func_extract_archives $gentop $convenience 10138c27c18e8Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139c27c18e8Smrg fi 10140c43cc173Smrg fi 10141c43cc173Smrg 10142b789ec8aSmrg # If we're not building shared, we need to use non_pic_objs 1014344584a44Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144b789ec8aSmrg 10145c27c18e8Smrg # Create the old-style object. 1014644584a44Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147c43cc173Smrg 1014844584a44Smrg output=$obj 10149c27c18e8Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10150c43cc173Smrg 10151c27c18e8Smrg # Exit if we aren't doing a library object file. 10152c27c18e8Smrg if test -z "$libobj"; then 10153c27c18e8Smrg if test -n "$gentop"; then 10154c27c18e8Smrg func_show_eval '${RM}r "$gentop"' 10155c27c18e8Smrg fi 10156c27c18e8Smrg 10157c27c18e8Smrg exit $EXIT_SUCCESS 10158c43cc173Smrg fi 10159c27c18e8Smrg 1016044584a44Smrg test yes = "$build_libtool_libs" || { 10161c27c18e8Smrg if test -n "$gentop"; then 10162c27c18e8Smrg func_show_eval '${RM}r "$gentop"' 10163c27c18e8Smrg fi 10164c27c18e8Smrg 10165c27c18e8Smrg # Create an invalid libtool object if no PIC, so that we don't 10166c27c18e8Smrg # accidentally link it into a program. 10167c27c18e8Smrg # $show "echo timestamp > $libobj" 10168c27c18e8Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169c27c18e8Smrg exit $EXIT_SUCCESS 1017044584a44Smrg } 10171c27c18e8Smrg 1017244584a44Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10173c27c18e8Smrg # Only do commands if we really have different PIC objects. 10174c27c18e8Smrg reload_objs="$libobjs $reload_conv_objs" 1017544584a44Smrg output=$libobj 10176c27c18e8Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10177c27c18e8Smrg fi 10178c27c18e8Smrg 10179c27c18e8Smrg if test -n "$gentop"; then 10180c27c18e8Smrg func_show_eval '${RM}r "$gentop"' 10181c27c18e8Smrg fi 10182c27c18e8Smrg 10183c27c18e8Smrg exit $EXIT_SUCCESS 10184c43cc173Smrg ;; 10185c43cc173Smrg 10186c27c18e8Smrg prog) 10187c27c18e8Smrg case $host in 10188c27c18e8Smrg *cygwin*) func_stripname '' '.exe' "$output" 10189c27c18e8Smrg output=$func_stripname_result.exe;; 10190c27c18e8Smrg esac 10191c27c18e8Smrg test -n "$vinfo" && \ 1019244584a44Smrg func_warning "'-version-info' is ignored for programs" 10193c43cc173Smrg 10194c27c18e8Smrg test -n "$release" && \ 1019544584a44Smrg func_warning "'-release' is ignored for programs" 10196c43cc173Smrg 1019744584a44Smrg $preload \ 1019844584a44Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1019944584a44Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200c27c18e8Smrg 10201c27c18e8Smrg case $host in 10202c27c18e8Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10203c27c18e8Smrg # On Rhapsody replace the C library is the System framework 1020437eb1ca1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020537eb1ca1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206c43cc173Smrg ;; 10207c27c18e8Smrg esac 10208c43cc173Smrg 10209c27c18e8Smrg case $host in 10210c27c18e8Smrg *-*-darwin*) 10211c27c18e8Smrg # Don't allow lazy linking, it breaks C++ global constructors 10212c27c18e8Smrg # But is supposedly fixed on 10.4 or later (yay!). 1021344584a44Smrg if test CXX = "$tagname"; then 10214c27c18e8Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215c27c18e8Smrg 10.[0123]) 1021644584a44Smrg func_append compile_command " $wl-bind_at_load" 1021744584a44Smrg func_append finalize_command " $wl-bind_at_load" 10218c27c18e8Smrg ;; 10219c27c18e8Smrg esac 10220c43cc173Smrg fi 10221c27c18e8Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1022237eb1ca1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022337eb1ca1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224c27c18e8Smrg ;; 10225c27c18e8Smrg esac 10226c43cc173Smrg 10227c43cc173Smrg 10228c27c18e8Smrg # move library search paths that coincide with paths to not yet 10229c27c18e8Smrg # installed libraries to the beginning of the library search list 10230c27c18e8Smrg new_libs= 10231c27c18e8Smrg for path in $notinst_path; do 10232c27c18e8Smrg case " $new_libs " in 10233c27c18e8Smrg *" -L$path/$objdir "*) ;; 10234c27c18e8Smrg *) 10235c27c18e8Smrg case " $compile_deplibs " in 10236c27c18e8Smrg *" -L$path/$objdir "*) 10237b789ec8aSmrg func_append new_libs " -L$path/$objdir" ;; 10238c43cc173Smrg esac 10239c27c18e8Smrg ;; 10240c27c18e8Smrg esac 10241c27c18e8Smrg done 10242c27c18e8Smrg for deplib in $compile_deplibs; do 10243c27c18e8Smrg case $deplib in 10244c27c18e8Smrg -L*) 10245c27c18e8Smrg case " $new_libs " in 10246c27c18e8Smrg *" $deplib "*) ;; 10247b789ec8aSmrg *) func_append new_libs " $deplib" ;; 10248c43cc173Smrg esac 10249c27c18e8Smrg ;; 10250b789ec8aSmrg *) func_append new_libs " $deplib" ;; 10251c27c18e8Smrg esac 10252c27c18e8Smrg done 1025344584a44Smrg compile_deplibs=$new_libs 10254c43cc173Smrg 10255c43cc173Smrg 10256b789ec8aSmrg func_append compile_command " $compile_deplibs" 10257b789ec8aSmrg func_append finalize_command " $finalize_deplibs" 10258c43cc173Smrg 10259c27c18e8Smrg if test -n "$rpath$xrpath"; then 10260c27c18e8Smrg # If the user specified any rpath flags, then add them. 10261c27c18e8Smrg for libdir in $rpath $xrpath; do 10262c27c18e8Smrg # This is the magic to use -rpath. 10263c27c18e8Smrg case "$finalize_rpath " in 10264c27c18e8Smrg *" $libdir "*) ;; 10265b789ec8aSmrg *) func_append finalize_rpath " $libdir" ;; 10266c27c18e8Smrg esac 10267c27c18e8Smrg done 10268c27c18e8Smrg fi 10269c43cc173Smrg 10270c27c18e8Smrg # Now hardcode the library paths 10271c27c18e8Smrg rpath= 10272c27c18e8Smrg hardcode_libdirs= 10273c27c18e8Smrg for libdir in $compile_rpath $finalize_rpath; do 10274c27c18e8Smrg if test -n "$hardcode_libdir_flag_spec"; then 10275c27c18e8Smrg if test -n "$hardcode_libdir_separator"; then 10276c27c18e8Smrg if test -z "$hardcode_libdirs"; then 1027744584a44Smrg hardcode_libdirs=$libdir 10278c27c18e8Smrg else 10279c27c18e8Smrg # Just accumulate the unique libdirs. 10280c27c18e8Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281c27c18e8Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282c27c18e8Smrg ;; 10283c27c18e8Smrg *) 10284b789ec8aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285c27c18e8Smrg ;; 10286c27c18e8Smrg esac 10287c27c18e8Smrg fi 10288c43cc173Smrg else 10289c27c18e8Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10290b789ec8aSmrg func_append rpath " $flag" 10291c43cc173Smrg fi 10292c27c18e8Smrg elif test -n "$runpath_var"; then 10293c27c18e8Smrg case "$perm_rpath " in 10294c27c18e8Smrg *" $libdir "*) ;; 10295b789ec8aSmrg *) func_append perm_rpath " $libdir" ;; 10296c27c18e8Smrg esac 10297c27c18e8Smrg fi 10298c27c18e8Smrg case $host in 10299c27c18e8Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1030044584a44Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301c27c18e8Smrg case :$dllsearchpath: in 10302c27c18e8Smrg *":$libdir:"*) ;; 10303c27c18e8Smrg ::) dllsearchpath=$libdir;; 10304b789ec8aSmrg *) func_append dllsearchpath ":$libdir";; 10305c27c18e8Smrg esac 10306c27c18e8Smrg case :$dllsearchpath: in 10307c27c18e8Smrg *":$testbindir:"*) ;; 10308c27c18e8Smrg ::) dllsearchpath=$testbindir;; 10309b789ec8aSmrg *) func_append dllsearchpath ":$testbindir";; 10310c27c18e8Smrg esac 10311c27c18e8Smrg ;; 10312c27c18e8Smrg esac 10313c27c18e8Smrg done 10314c27c18e8Smrg # Substitute the hardcoded libdirs into the rpath. 10315c27c18e8Smrg if test -n "$hardcode_libdir_separator" && 10316c27c18e8Smrg test -n "$hardcode_libdirs"; then 1031744584a44Smrg libdir=$hardcode_libdirs 10318c27c18e8Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10319c27c18e8Smrg fi 1032044584a44Smrg compile_rpath=$rpath 10321c43cc173Smrg 10322c27c18e8Smrg rpath= 10323c27c18e8Smrg hardcode_libdirs= 10324c27c18e8Smrg for libdir in $finalize_rpath; do 10325c27c18e8Smrg if test -n "$hardcode_libdir_flag_spec"; then 10326c27c18e8Smrg if test -n "$hardcode_libdir_separator"; then 10327c27c18e8Smrg if test -z "$hardcode_libdirs"; then 1032844584a44Smrg hardcode_libdirs=$libdir 10329c27c18e8Smrg else 10330c27c18e8Smrg # Just accumulate the unique libdirs. 10331c27c18e8Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332c27c18e8Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333c27c18e8Smrg ;; 10334c27c18e8Smrg *) 10335b789ec8aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336c27c18e8Smrg ;; 10337c27c18e8Smrg esac 10338c27c18e8Smrg fi 10339c43cc173Smrg else 10340c27c18e8Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10341b789ec8aSmrg func_append rpath " $flag" 10342c43cc173Smrg fi 10343c27c18e8Smrg elif test -n "$runpath_var"; then 10344c27c18e8Smrg case "$finalize_perm_rpath " in 10345c27c18e8Smrg *" $libdir "*) ;; 10346b789ec8aSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10347c27c18e8Smrg esac 10348c43cc173Smrg fi 10349c27c18e8Smrg done 10350c27c18e8Smrg # Substitute the hardcoded libdirs into the rpath. 10351c27c18e8Smrg if test -n "$hardcode_libdir_separator" && 10352c27c18e8Smrg test -n "$hardcode_libdirs"; then 1035344584a44Smrg libdir=$hardcode_libdirs 10354c27c18e8Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10355c27c18e8Smrg fi 1035644584a44Smrg finalize_rpath=$rpath 10357c43cc173Smrg 1035844584a44Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359c27c18e8Smrg # Transform all the library objects into standard objects. 1036037eb1ca1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036137eb1ca1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362c27c18e8Smrg fi 10363c43cc173Smrg 1036444584a44Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365c43cc173Smrg 10366c27c18e8Smrg # template prelinking step 10367c27c18e8Smrg if test -n "$prelink_cmds"; then 10368c27c18e8Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10369c27c18e8Smrg fi 10370c43cc173Smrg 1037144584a44Smrg wrappers_required=: 10372c27c18e8Smrg case $host in 1037337eb1ca1Smrg *cegcc* | *mingw32ce*) 1037437eb1ca1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1037544584a44Smrg wrappers_required=false 1037637eb1ca1Smrg ;; 10377c27c18e8Smrg *cygwin* | *mingw* ) 1037844584a44Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10379c27c18e8Smrg ;; 10380c27c18e8Smrg *) 1038144584a44Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1038244584a44Smrg wrappers_required=false 10383c27c18e8Smrg fi 10384c27c18e8Smrg ;; 10385c27c18e8Smrg esac 1038644584a44Smrg $wrappers_required || { 10387c27c18e8Smrg # Replace the output file specification. 1038837eb1ca1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1038944584a44Smrg link_command=$compile_command$compile_rpath 10390c43cc173Smrg 10391c27c18e8Smrg # We have no uninstalled library dependencies, so finalize right now. 10392c27c18e8Smrg exit_status=0 10393c27c18e8Smrg func_show_eval "$link_command" 'exit_status=$?' 10394c43cc173Smrg 10395b789ec8aSmrg if test -n "$postlink_cmds"; then 10396b789ec8aSmrg func_to_tool_file "$output" 10397b789ec8aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398b789ec8aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399b789ec8aSmrg fi 10400b789ec8aSmrg 10401c27c18e8Smrg # Delete the generated files. 1040244584a44Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1040344584a44Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404c43cc173Smrg fi 10405c43cc173Smrg 10406c27c18e8Smrg exit $exit_status 1040744584a44Smrg } 10408c43cc173Smrg 10409c27c18e8Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410c27c18e8Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411c27c18e8Smrg fi 10412c27c18e8Smrg if test -n "$finalize_shlibpath"; then 10413c27c18e8Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414c27c18e8Smrg fi 10415c43cc173Smrg 10416c27c18e8Smrg compile_var= 10417c27c18e8Smrg finalize_var= 10418c27c18e8Smrg if test -n "$runpath_var"; then 10419c27c18e8Smrg if test -n "$perm_rpath"; then 10420c27c18e8Smrg # We should set the runpath_var. 10421c27c18e8Smrg rpath= 10422c27c18e8Smrg for dir in $perm_rpath; do 10423b789ec8aSmrg func_append rpath "$dir:" 10424c27c18e8Smrg done 10425c27c18e8Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426c43cc173Smrg fi 10427c27c18e8Smrg if test -n "$finalize_perm_rpath"; then 10428c27c18e8Smrg # We should set the runpath_var. 10429c27c18e8Smrg rpath= 10430c27c18e8Smrg for dir in $finalize_perm_rpath; do 10431b789ec8aSmrg func_append rpath "$dir:" 10432c27c18e8Smrg done 10433c27c18e8Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434c43cc173Smrg fi 10435c27c18e8Smrg fi 10436c43cc173Smrg 1043744584a44Smrg if test yes = "$no_install"; then 10438c27c18e8Smrg # We don't need to create a wrapper script. 1043944584a44Smrg link_command=$compile_var$compile_command$compile_rpath 10440c27c18e8Smrg # Replace the output file specification. 1044137eb1ca1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442c27c18e8Smrg # Delete the old output file. 10443c27c18e8Smrg $opt_dry_run || $RM $output 10444c27c18e8Smrg # Link the executable and exit 10445c27c18e8Smrg func_show_eval "$link_command" 'exit $?' 10446b789ec8aSmrg 10447b789ec8aSmrg if test -n "$postlink_cmds"; then 10448b789ec8aSmrg func_to_tool_file "$output" 10449b789ec8aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450b789ec8aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451b789ec8aSmrg fi 10452b789ec8aSmrg 10453c43cc173Smrg exit $EXIT_SUCCESS 10454c27c18e8Smrg fi 10455c43cc173Smrg 1045644584a44Smrg case $hardcode_action,$fast_install in 1045744584a44Smrg relink,*) 1045844584a44Smrg # Fast installation is not supported 1045944584a44Smrg link_command=$compile_var$compile_command$compile_rpath 1046044584a44Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10461c27c18e8Smrg 1046244584a44Smrg func_warning "this platform does not like uninstalled shared libraries" 1046344584a44Smrg func_warning "'$output' will be relinked during installation" 1046444584a44Smrg ;; 1046544584a44Smrg *,yes) 1046644584a44Smrg link_command=$finalize_var$compile_command$finalize_rpath 1046744584a44Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1046844584a44Smrg ;; 1046944584a44Smrg *,no) 1047044584a44Smrg link_command=$compile_var$compile_command$compile_rpath 1047144584a44Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1047244584a44Smrg ;; 1047344584a44Smrg *,needless) 1047444584a44Smrg link_command=$finalize_var$compile_command$finalize_rpath 1047544584a44Smrg relink_command= 1047644584a44Smrg ;; 1047744584a44Smrg esac 10478c43cc173Smrg 10479c27c18e8Smrg # Replace the output file specification. 1048037eb1ca1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481c43cc173Smrg 10482c27c18e8Smrg # Delete the old output files. 10483c27c18e8Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484c43cc173Smrg 10485c27c18e8Smrg func_show_eval "$link_command" 'exit $?' 10486c43cc173Smrg 10487b789ec8aSmrg if test -n "$postlink_cmds"; then 10488b789ec8aSmrg func_to_tool_file "$output_objdir/$outputname" 10489b789ec8aSmrg 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'` 10490b789ec8aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10491b789ec8aSmrg fi 10492b789ec8aSmrg 10493c27c18e8Smrg # Now create the wrapper script. 10494c27c18e8Smrg func_verbose "creating $output" 10495c43cc173Smrg 10496c27c18e8Smrg # Quote the relink command for shipping. 10497c27c18e8Smrg if test -n "$relink_command"; then 10498c27c18e8Smrg # Preserve any variables that may affect compiler behavior 10499c27c18e8Smrg for var in $variables_saved_for_relink; do 10500c27c18e8Smrg if eval test -z \"\${$var+set}\"; then 10501c27c18e8Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502c27c18e8Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10503c27c18e8Smrg relink_command="$var=; export $var; $relink_command" 10504c43cc173Smrg else 10505c27c18e8Smrg func_quote_for_eval "$var_value" 10506c27c18e8Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507c43cc173Smrg fi 10508c27c18e8Smrg done 10509c27c18e8Smrg relink_command="(cd `pwd`; $relink_command)" 1051037eb1ca1Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511c27c18e8Smrg fi 10512c27c18e8Smrg 10513c27c18e8Smrg # Only actually do things if not in dry run mode. 10514c27c18e8Smrg $opt_dry_run || { 10515c27c18e8Smrg # win32 will think the script is a binary if it has 10516c27c18e8Smrg # a .exe suffix, so we strip it off here. 10517c27c18e8Smrg case $output in 10518c27c18e8Smrg *.exe) func_stripname '' '.exe' "$output" 10519c27c18e8Smrg output=$func_stripname_result ;; 10520c27c18e8Smrg esac 10521c27c18e8Smrg # test for cygwin because mv fails w/o .exe extensions 10522c27c18e8Smrg case $host in 10523c27c18e8Smrg *cygwin*) 10524c27c18e8Smrg exeext=.exe 10525c27c18e8Smrg func_stripname '' '.exe' "$outputname" 10526c27c18e8Smrg outputname=$func_stripname_result ;; 10527c27c18e8Smrg *) exeext= ;; 10528c43cc173Smrg esac 10529c27c18e8Smrg case $host in 10530c27c18e8Smrg *cygwin* | *mingw* ) 10531c27c18e8Smrg func_dirname_and_basename "$output" "" "." 10532c27c18e8Smrg output_name=$func_basename_result 10533c27c18e8Smrg output_path=$func_dirname_result 1053444584a44Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1053544584a44Smrg cwrapper=$output_path/$output_name.exe 10536c27c18e8Smrg $RM $cwrappersource $cwrapper 10537c27c18e8Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538c27c18e8Smrg 10539c27c18e8Smrg func_emit_cwrapperexe_src > $cwrappersource 10540c27c18e8Smrg 10541c27c18e8Smrg # The wrapper executable is built using the $host compiler, 10542c27c18e8Smrg # because it contains $host paths and files. If cross- 10543c27c18e8Smrg # compiling, it, like the target executable, must be 10544c27c18e8Smrg # executed on the $host or under an emulation environment. 10545c27c18e8Smrg $opt_dry_run || { 10546c27c18e8Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547c27c18e8Smrg $STRIP $cwrapper 10548c27c18e8Smrg } 10549c43cc173Smrg 10550c27c18e8Smrg # Now, create the wrapper script for func_source use: 10551c27c18e8Smrg func_ltwrapper_scriptname $cwrapper 10552c27c18e8Smrg $RM $func_ltwrapper_scriptname_result 10553c27c18e8Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554c27c18e8Smrg $opt_dry_run || { 10555c27c18e8Smrg # note: this script will not be executed, so do not chmod. 1055644584a44Smrg if test "x$build" = "x$host"; then 10557c27c18e8Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558c27c18e8Smrg else 10559c27c18e8Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560c27c18e8Smrg fi 10561c27c18e8Smrg } 10562c27c18e8Smrg ;; 10563c27c18e8Smrg * ) 10564c27c18e8Smrg $RM $output 10565c27c18e8Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566c43cc173Smrg 10567c27c18e8Smrg func_emit_wrapper no > $output 10568c27c18e8Smrg chmod +x $output 10569c27c18e8Smrg ;; 10570c27c18e8Smrg esac 10571c27c18e8Smrg } 10572c27c18e8Smrg exit $EXIT_SUCCESS 10573c27c18e8Smrg ;; 10574c27c18e8Smrg esac 10575c43cc173Smrg 10576c27c18e8Smrg # See if we need to build an old-fashioned archive. 10577c27c18e8Smrg for oldlib in $oldlibs; do 10578c43cc173Smrg 1057944584a44Smrg case $build_libtool_libs in 1058044584a44Smrg convenience) 1058144584a44Smrg oldobjs="$libobjs_save $symfileobj" 1058244584a44Smrg addlibs=$convenience 10583c27c18e8Smrg build_libtool_libs=no 1058444584a44Smrg ;; 1058544584a44Smrg module) 1058644584a44Smrg oldobjs=$libobjs_save 1058744584a44Smrg addlibs=$old_convenience 1058844584a44Smrg build_libtool_libs=no 1058944584a44Smrg ;; 1059044584a44Smrg *) 10591c27c18e8Smrg oldobjs="$old_deplibs $non_pic_objects" 1059244584a44Smrg $preload && test -f "$symfileobj" \ 1059344584a44Smrg && func_append oldobjs " $symfileobj" 1059444584a44Smrg addlibs=$old_convenience 1059544584a44Smrg ;; 1059644584a44Smrg esac 10597c43cc173Smrg 10598c27c18e8Smrg if test -n "$addlibs"; then 1059944584a44Smrg gentop=$output_objdir/${outputname}x 10600b789ec8aSmrg func_append generated " $gentop" 10601c43cc173Smrg 10602c27c18e8Smrg func_extract_archives $gentop $addlibs 10603b789ec8aSmrg func_append oldobjs " $func_extract_archives_result" 10604c27c18e8Smrg fi 10605c43cc173Smrg 10606c27c18e8Smrg # Do each command in the archive commands. 1060744584a44Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608c27c18e8Smrg cmds=$old_archive_from_new_cmds 10609c27c18e8Smrg else 10610c43cc173Smrg 10611c27c18e8Smrg # Add any objects from preloaded convenience libraries 10612c27c18e8Smrg if test -n "$dlprefiles"; then 1061344584a44Smrg gentop=$output_objdir/${outputname}x 10614b789ec8aSmrg func_append generated " $gentop" 10615c43cc173Smrg 10616c27c18e8Smrg func_extract_archives $gentop $dlprefiles 10617b789ec8aSmrg func_append oldobjs " $func_extract_archives_result" 10618c27c18e8Smrg fi 10619c43cc173Smrg 10620c27c18e8Smrg # POSIX demands no paths to be encoded in archives. We have 10621c27c18e8Smrg # to avoid creating archives with duplicate basenames if we 10622c27c18e8Smrg # might have to extract them afterwards, e.g., when creating a 10623c27c18e8Smrg # static archive out of a convenience library, or when linking 10624c27c18e8Smrg # the entirety of a libtool archive into another (currently 10625c27c18e8Smrg # not supported by libtool). 10626c27c18e8Smrg if (for obj in $oldobjs 10627c27c18e8Smrg do 10628c27c18e8Smrg func_basename "$obj" 10629c27c18e8Smrg $ECHO "$func_basename_result" 10630c27c18e8Smrg done | sort | sort -uc >/dev/null 2>&1); then 10631c27c18e8Smrg : 10632c27c18e8Smrg else 1063337eb1ca1Smrg echo "copying selected object files to avoid basename conflicts..." 1063444584a44Smrg gentop=$output_objdir/${outputname}x 10635b789ec8aSmrg func_append generated " $gentop" 10636c27c18e8Smrg func_mkdir_p "$gentop" 10637c27c18e8Smrg save_oldobjs=$oldobjs 10638c27c18e8Smrg oldobjs= 10639c27c18e8Smrg counter=1 10640c27c18e8Smrg for obj in $save_oldobjs 10641c27c18e8Smrg do 10642c27c18e8Smrg func_basename "$obj" 1064344584a44Smrg objbase=$func_basename_result 10644c27c18e8Smrg case " $oldobjs " in 10645c27c18e8Smrg " ") oldobjs=$obj ;; 10646c27c18e8Smrg *[\ /]"$objbase "*) 10647c27c18e8Smrg while :; do 10648c27c18e8Smrg # Make sure we don't pick an alternate name that also 10649c27c18e8Smrg # overlaps. 10650c27c18e8Smrg newobj=lt$counter-$objbase 10651c27c18e8Smrg func_arith $counter + 1 10652c27c18e8Smrg counter=$func_arith_result 10653c27c18e8Smrg case " $oldobjs " in 10654c27c18e8Smrg *[\ /]"$newobj "*) ;; 10655c27c18e8Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656c27c18e8Smrg esac 10657c27c18e8Smrg done 10658c27c18e8Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659b789ec8aSmrg func_append oldobjs " $gentop/$newobj" 10660c27c18e8Smrg ;; 10661b789ec8aSmrg *) func_append oldobjs " $obj" ;; 10662c27c18e8Smrg esac 10663c43cc173Smrg done 10664c43cc173Smrg fi 10665f1ee322dSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666f1ee322dSmrg tool_oldlib=$func_to_tool_file_result 10667c27c18e8Smrg eval cmds=\"$old_archive_cmds\" 10668c43cc173Smrg 10669c27c18e8Smrg func_len " $cmds" 10670c27c18e8Smrg len=$func_len_result 10671c27c18e8Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672c27c18e8Smrg cmds=$old_archive_cmds 10673b789ec8aSmrg elif test -n "$archiver_list_spec"; then 10674b789ec8aSmrg func_verbose "using command file archive linking..." 10675b789ec8aSmrg for obj in $oldobjs 10676b789ec8aSmrg do 10677b789ec8aSmrg func_to_tool_file "$obj" 10678b789ec8aSmrg $ECHO "$func_to_tool_file_result" 10679b789ec8aSmrg done > $output_objdir/$libname.libcmd 10680b789ec8aSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10681b789ec8aSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682b789ec8aSmrg cmds=$old_archive_cmds 10683c27c18e8Smrg else 10684c27c18e8Smrg # the command line is too long to link in one step, link in parts 10685c27c18e8Smrg func_verbose "using piecewise archive linking..." 10686c27c18e8Smrg save_RANLIB=$RANLIB 10687c27c18e8Smrg RANLIB=: 10688c27c18e8Smrg objlist= 10689c27c18e8Smrg concat_cmds= 10690c27c18e8Smrg save_oldobjs=$oldobjs 10691c27c18e8Smrg oldobjs= 10692c27c18e8Smrg # Is there a better way of finding the last object in the list? 10693c27c18e8Smrg for obj in $save_oldobjs 10694c27c18e8Smrg do 10695c27c18e8Smrg last_oldobj=$obj 10696c27c18e8Smrg done 10697c27c18e8Smrg eval test_cmds=\"$old_archive_cmds\" 10698c27c18e8Smrg func_len " $test_cmds" 10699c27c18e8Smrg len0=$func_len_result 10700c27c18e8Smrg len=$len0 10701c27c18e8Smrg for obj in $save_oldobjs 10702c27c18e8Smrg do 10703c27c18e8Smrg func_len " $obj" 10704c27c18e8Smrg func_arith $len + $func_len_result 10705c27c18e8Smrg len=$func_arith_result 10706c27c18e8Smrg func_append objlist " $obj" 10707c27c18e8Smrg if test "$len" -lt "$max_cmd_len"; then 10708c27c18e8Smrg : 10709c27c18e8Smrg else 10710c27c18e8Smrg # the above command should be used before it gets too long 10711c27c18e8Smrg oldobjs=$objlist 1071244584a44Smrg if test "$obj" = "$last_oldobj"; then 10713c27c18e8Smrg RANLIB=$save_RANLIB 10714c27c18e8Smrg fi 10715c27c18e8Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1071644584a44Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717c27c18e8Smrg objlist= 10718c27c18e8Smrg len=$len0 10719c27c18e8Smrg fi 10720c27c18e8Smrg done 10721c27c18e8Smrg RANLIB=$save_RANLIB 10722c27c18e8Smrg oldobjs=$objlist 1072344584a44Smrg if test -z "$oldobjs"; then 10724c27c18e8Smrg eval cmds=\"\$concat_cmds\" 10725c27c18e8Smrg else 10726c27c18e8Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727c27c18e8Smrg fi 10728c27c18e8Smrg fi 10729c27c18e8Smrg fi 10730c27c18e8Smrg func_execute_cmds "$cmds" 'exit $?' 10731c43cc173Smrg done 10732c43cc173Smrg 10733c27c18e8Smrg test -n "$generated" && \ 10734c27c18e8Smrg func_show_eval "${RM}r$generated" 10735c43cc173Smrg 10736c27c18e8Smrg # Now create the libtool archive. 10737c27c18e8Smrg case $output in 10738c27c18e8Smrg *.la) 10739c27c18e8Smrg old_library= 1074044584a44Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 10741c27c18e8Smrg func_verbose "creating $output" 10742c43cc173Smrg 10743c27c18e8Smrg # Preserve any variables that may affect compiler behavior 10744c27c18e8Smrg for var in $variables_saved_for_relink; do 10745c27c18e8Smrg if eval test -z \"\${$var+set}\"; then 10746c27c18e8Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747c27c18e8Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10748c27c18e8Smrg relink_command="$var=; export $var; $relink_command" 10749c43cc173Smrg else 10750c27c18e8Smrg func_quote_for_eval "$var_value" 10751c27c18e8Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752c43cc173Smrg fi 10753c27c18e8Smrg done 10754c27c18e8Smrg # Quote the link command for shipping. 1075544584a44Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1075637eb1ca1Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1075744584a44Smrg if test yes = "$hardcode_automatic"; then 10758c27c18e8Smrg relink_command= 10759c27c18e8Smrg fi 10760c43cc173Smrg 10761c27c18e8Smrg # Only create the output if not a dry run. 10762c27c18e8Smrg $opt_dry_run || { 10763c27c18e8Smrg for installed in no yes; do 1076444584a44Smrg if test yes = "$installed"; then 10765c27c18e8Smrg if test -z "$install_libdir"; then 10766c27c18e8Smrg break 10767c27c18e8Smrg fi 1076844584a44Smrg output=$output_objdir/${outputname}i 10769c27c18e8Smrg # Replace all uninstalled libtool libraries with the installed ones 10770c27c18e8Smrg newdependency_libs= 10771c27c18e8Smrg for deplib in $dependency_libs; do 10772c27c18e8Smrg case $deplib in 10773c27c18e8Smrg *.la) 10774c27c18e8Smrg func_basename "$deplib" 1077544584a44Smrg name=$func_basename_result 10776f1ee322dSmrg func_resolve_sysroot "$deplib" 1077744584a44Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778c27c18e8Smrg test -z "$libdir" && \ 1077944584a44Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 10780b789ec8aSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781b789ec8aSmrg ;; 10782b789ec8aSmrg -L*) 10783b789ec8aSmrg func_stripname -L '' "$deplib" 10784b789ec8aSmrg func_replace_sysroot "$func_stripname_result" 10785b789ec8aSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10786b789ec8aSmrg ;; 10787b789ec8aSmrg -R*) 10788b789ec8aSmrg func_stripname -R '' "$deplib" 10789b789ec8aSmrg func_replace_sysroot "$func_stripname_result" 10790b789ec8aSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791c27c18e8Smrg ;; 10792b789ec8aSmrg *) func_append newdependency_libs " $deplib" ;; 10793c27c18e8Smrg esac 10794c27c18e8Smrg done 1079544584a44Smrg dependency_libs=$newdependency_libs 10796c27c18e8Smrg newdlfiles= 10797c27c18e8Smrg 10798c27c18e8Smrg for lib in $dlfiles; do 10799c27c18e8Smrg case $lib in 10800c27c18e8Smrg *.la) 10801c27c18e8Smrg func_basename "$lib" 1080244584a44Smrg name=$func_basename_result 1080344584a44Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804c27c18e8Smrg test -z "$libdir" && \ 1080544584a44Smrg func_fatal_error "'$lib' is not a valid libtool archive" 10806b789ec8aSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807c27c18e8Smrg ;; 10808b789ec8aSmrg *) func_append newdlfiles " $lib" ;; 10809c27c18e8Smrg esac 10810c27c18e8Smrg done 1081144584a44Smrg dlfiles=$newdlfiles 10812c27c18e8Smrg newdlprefiles= 10813c27c18e8Smrg for lib in $dlprefiles; do 10814c27c18e8Smrg case $lib in 10815c27c18e8Smrg *.la) 10816c27c18e8Smrg # Only pass preopened files to the pseudo-archive (for 10817c27c18e8Smrg # eventual linking with the app. that links it) if we 10818c27c18e8Smrg # didn't already link the preopened objects directly into 10819c27c18e8Smrg # the library: 10820c27c18e8Smrg func_basename "$lib" 1082144584a44Smrg name=$func_basename_result 1082244584a44Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823c27c18e8Smrg test -z "$libdir" && \ 1082444584a44Smrg func_fatal_error "'$lib' is not a valid libtool archive" 10825b789ec8aSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826c27c18e8Smrg ;; 10827c27c18e8Smrg esac 10828c27c18e8Smrg done 1082944584a44Smrg dlprefiles=$newdlprefiles 10830c27c18e8Smrg else 10831c27c18e8Smrg newdlfiles= 10832c27c18e8Smrg for lib in $dlfiles; do 10833c27c18e8Smrg case $lib in 1083444584a44Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835c27c18e8Smrg *) abs=`pwd`"/$lib" ;; 10836c27c18e8Smrg esac 10837b789ec8aSmrg func_append newdlfiles " $abs" 10838c27c18e8Smrg done 1083944584a44Smrg dlfiles=$newdlfiles 10840c27c18e8Smrg newdlprefiles= 10841c27c18e8Smrg for lib in $dlprefiles; do 10842c27c18e8Smrg case $lib in 1084344584a44Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844c27c18e8Smrg *) abs=`pwd`"/$lib" ;; 10845c27c18e8Smrg esac 10846b789ec8aSmrg func_append newdlprefiles " $abs" 10847c27c18e8Smrg done 1084844584a44Smrg dlprefiles=$newdlprefiles 10849c27c18e8Smrg fi 10850c27c18e8Smrg $RM $output 10851c27c18e8Smrg # place dlname in correct position for cygwin 1085237eb1ca1Smrg # In fact, it would be nice if we could use this code for all target 1085337eb1ca1Smrg # systems that can't hard-code library paths into their executables 1085437eb1ca1Smrg # and that have no shared library path variable independent of PATH, 1085537eb1ca1Smrg # but it turns out we can't easily determine that from inspecting 1085637eb1ca1Smrg # libtool variables, so we have to hard-code the OSs to which it 1085737eb1ca1Smrg # applies here; at the moment, that means platforms that use the PE 1085837eb1ca1Smrg # object format with DLL files. See the long comment at the top of 1085937eb1ca1Smrg # tests/bindir.at for full details. 10860c27c18e8Smrg tdlname=$dlname 10861c27c18e8Smrg case $host,$output,$installed,$module,$dlname in 1086237eb1ca1Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1086337eb1ca1Smrg # If a -bindir argument was supplied, place the dll there. 1086444584a44Smrg if test -n "$bindir"; then 1086537eb1ca1Smrg func_relative_path "$install_libdir" "$bindir" 1086644584a44Smrg tdlname=$func_relative_path_result/$dlname 1086737eb1ca1Smrg else 1086837eb1ca1Smrg # Otherwise fall back on heuristic. 1086937eb1ca1Smrg tdlname=../bin/$dlname 1087037eb1ca1Smrg fi 1087137eb1ca1Smrg ;; 10872c27c18e8Smrg esac 10873c27c18e8Smrg $ECHO > $output "\ 10874c27c18e8Smrg# $outputname - a libtool library file 1087544584a44Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876c27c18e8Smrg# 10877c27c18e8Smrg# Please DO NOT delete this file! 10878c27c18e8Smrg# It is necessary for linking the library. 10879c43cc173Smrg 10880c27c18e8Smrg# The name that we can dlopen(3). 10881c27c18e8Smrgdlname='$tdlname' 10882c43cc173Smrg 10883c27c18e8Smrg# Names of this library. 10884c27c18e8Smrglibrary_names='$library_names' 10885c43cc173Smrg 10886c27c18e8Smrg# The name of the static archive. 10887c27c18e8Smrgold_library='$old_library' 10888c43cc173Smrg 1088944584a44Smrg# Linker flags that cannot go in dependency_libs. 10890c27c18e8Smrginherited_linker_flags='$new_inherited_linker_flags' 10891c43cc173Smrg 10892c27c18e8Smrg# Libraries that this one depends upon. 10893c27c18e8Smrgdependency_libs='$dependency_libs' 10894c43cc173Smrg 10895c27c18e8Smrg# Names of additional weak libraries provided by this library 10896c27c18e8Smrgweak_library_names='$weak_libs' 10897c43cc173Smrg 10898c27c18e8Smrg# Version information for $libname. 10899c27c18e8Smrgcurrent=$current 10900c27c18e8Smrgage=$age 10901c27c18e8Smrgrevision=$revision 10902c43cc173Smrg 10903c27c18e8Smrg# Is this an already installed library? 10904c27c18e8Smrginstalled=$installed 10905c43cc173Smrg 10906c27c18e8Smrg# Should we warn about portability when linking against -modules? 10907c27c18e8Smrgshouldnotlink=$module 10908c43cc173Smrg 10909c27c18e8Smrg# Files to dlopen/dlpreopen 10910c27c18e8Smrgdlopen='$dlfiles' 10911c27c18e8Smrgdlpreopen='$dlprefiles' 10912c43cc173Smrg 10913c27c18e8Smrg# Directory that this library needs to be installed in: 10914c27c18e8Smrglibdir='$install_libdir'" 1091544584a44Smrg if test no,yes = "$installed,$need_relink"; then 10916c27c18e8Smrg $ECHO >> $output "\ 10917c27c18e8Smrgrelink_command=\"$relink_command\"" 10918c27c18e8Smrg fi 10919c27c18e8Smrg done 10920c27c18e8Smrg } 10921c43cc173Smrg 10922c27c18e8Smrg # Do a symbolic link so that the libtool archive can be found in 10923c27c18e8Smrg # LD_LIBRARY_PATH before the program is installed. 10924c27c18e8Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925c27c18e8Smrg ;; 10926c27c18e8Smrg esac 10927c27c18e8Smrg exit $EXIT_SUCCESS 10928c27c18e8Smrg} 10929c43cc173Smrg 1093044584a44Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1093144584a44Smrg func_mode_link ${1+"$@"} 1093244584a44Smrgfi 10933c43cc173Smrg 10934c43cc173Smrg 10935c27c18e8Smrg# func_mode_uninstall arg... 10936c27c18e8Smrgfunc_mode_uninstall () 10937c27c18e8Smrg{ 1093844584a44Smrg $debug_cmd 1093944584a44Smrg 1094044584a44Smrg RM=$nonopt 10941c43cc173Smrg files= 1094244584a44Smrg rmforce=false 10943c43cc173Smrg exit_status=0 10944c43cc173Smrg 10945c43cc173Smrg # This variable tells wrapper scripts just to set variables rather 10946c43cc173Smrg # than running their programs. 1094744584a44Smrg libtool_install_magic=$magic 10948c43cc173Smrg 10949c43cc173Smrg for arg 10950c43cc173Smrg do 10951c43cc173Smrg case $arg in 1095244584a44Smrg -f) func_append RM " $arg"; rmforce=: ;; 10953b789ec8aSmrg -*) func_append RM " $arg" ;; 10954b789ec8aSmrg *) func_append files " $arg" ;; 10955c43cc173Smrg esac 10956c43cc173Smrg done 10957c43cc173Smrg 10958c27c18e8Smrg test -z "$RM" && \ 10959c27c18e8Smrg func_fatal_help "you must specify an RM program" 10960c43cc173Smrg 10961c43cc173Smrg rmdirs= 10962c43cc173Smrg 10963c43cc173Smrg for file in $files; do 10964c27c18e8Smrg func_dirname "$file" "" "." 1096544584a44Smrg dir=$func_dirname_result 1096644584a44Smrg if test . = "$dir"; then 1096744584a44Smrg odir=$objdir 10968c43cc173Smrg else 1096944584a44Smrg odir=$dir/$objdir 10970c43cc173Smrg fi 10971c27c18e8Smrg func_basename "$file" 1097244584a44Smrg name=$func_basename_result 1097344584a44Smrg test uninstall = "$opt_mode" && odir=$dir 10974c43cc173Smrg 10975b789ec8aSmrg # Remember odir for removal later, being careful to avoid duplicates 1097644584a44Smrg if test clean = "$opt_mode"; then 10977c43cc173Smrg case " $rmdirs " in 10978b789ec8aSmrg *" $odir "*) ;; 10979b789ec8aSmrg *) func_append rmdirs " $odir" ;; 10980c43cc173Smrg esac 10981c43cc173Smrg fi 10982c43cc173Smrg 10983c43cc173Smrg # Don't error if the file doesn't exist and rm -f was used. 10984c27c18e8Smrg if { test -L "$file"; } >/dev/null 2>&1 || 10985c27c18e8Smrg { test -h "$file"; } >/dev/null 2>&1 || 10986c27c18e8Smrg test -f "$file"; then 10987c43cc173Smrg : 10988c43cc173Smrg elif test -d "$file"; then 10989c43cc173Smrg exit_status=1 10990c43cc173Smrg continue 1099144584a44Smrg elif $rmforce; then 10992c43cc173Smrg continue 10993c43cc173Smrg fi 10994c43cc173Smrg 1099544584a44Smrg rmfiles=$file 10996c43cc173Smrg 10997c43cc173Smrg case $name in 10998c43cc173Smrg *.la) 10999c43cc173Smrg # Possibly a libtool archive, so verify it. 11000c27c18e8Smrg if func_lalib_p "$file"; then 11001c27c18e8Smrg func_source $dir/$name 11002c43cc173Smrg 11003c43cc173Smrg # Delete the libtool libraries and symlinks. 11004c43cc173Smrg for n in $library_names; do 11005b789ec8aSmrg func_append rmfiles " $odir/$n" 11006c43cc173Smrg done 11007b789ec8aSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008c43cc173Smrg 1100944584a44Smrg case $opt_mode in 11010c43cc173Smrg clean) 11011b789ec8aSmrg case " $library_names " in 11012c43cc173Smrg *" $dlname "*) ;; 11013b789ec8aSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014c43cc173Smrg esac 11015b789ec8aSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016c43cc173Smrg ;; 11017c43cc173Smrg uninstall) 11018c43cc173Smrg if test -n "$library_names"; then 11019c43cc173Smrg # Do each command in the postuninstall commands. 1102044584a44Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021c43cc173Smrg fi 11022c43cc173Smrg 11023c43cc173Smrg if test -n "$old_library"; then 11024c43cc173Smrg # Do each command in the old_postuninstall commands. 1102544584a44Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026c43cc173Smrg fi 11027c43cc173Smrg # FIXME: should reinstall the best remaining shared library. 11028c43cc173Smrg ;; 11029c43cc173Smrg esac 11030c43cc173Smrg fi 11031c43cc173Smrg ;; 11032c43cc173Smrg 11033c43cc173Smrg *.lo) 11034c43cc173Smrg # Possibly a libtool object, so verify it. 11035c27c18e8Smrg if func_lalib_p "$file"; then 11036c43cc173Smrg 11037c43cc173Smrg # Read the .lo file 11038c27c18e8Smrg func_source $dir/$name 11039c43cc173Smrg 11040c43cc173Smrg # Add PIC object to the list of files to remove. 1104144584a44Smrg if test -n "$pic_object" && test none != "$pic_object"; then 11042b789ec8aSmrg func_append rmfiles " $dir/$pic_object" 11043c43cc173Smrg fi 11044c43cc173Smrg 11045c43cc173Smrg # Add non-PIC object to the list of files to remove. 1104644584a44Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047b789ec8aSmrg func_append rmfiles " $dir/$non_pic_object" 11048c43cc173Smrg fi 11049c43cc173Smrg fi 11050c43cc173Smrg ;; 11051c43cc173Smrg 11052c43cc173Smrg *) 1105344584a44Smrg if test clean = "$opt_mode"; then 11054c43cc173Smrg noexename=$name 11055c43cc173Smrg case $file in 11056c43cc173Smrg *.exe) 11057c27c18e8Smrg func_stripname '' '.exe' "$file" 11058c27c18e8Smrg file=$func_stripname_result 11059c27c18e8Smrg func_stripname '' '.exe' "$name" 11060c27c18e8Smrg noexename=$func_stripname_result 11061c43cc173Smrg # $file with .exe has already been added to rmfiles, 11062c43cc173Smrg # add $file without .exe 11063b789ec8aSmrg func_append rmfiles " $file" 11064c43cc173Smrg ;; 11065c43cc173Smrg esac 11066c43cc173Smrg # Do a test to see if this is a libtool program. 11067c27c18e8Smrg if func_ltwrapper_p "$file"; then 11068c27c18e8Smrg if func_ltwrapper_executable_p "$file"; then 11069c27c18e8Smrg func_ltwrapper_scriptname "$file" 11070c27c18e8Smrg relink_command= 11071c27c18e8Smrg func_source $func_ltwrapper_scriptname_result 11072b789ec8aSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11073c27c18e8Smrg else 11074c27c18e8Smrg relink_command= 11075c27c18e8Smrg func_source $dir/$noexename 11076c27c18e8Smrg fi 11077c43cc173Smrg 11078c43cc173Smrg # note $name still contains .exe if it was in $file originally 11079c43cc173Smrg # as does the version of $file that was added into $rmfiles 1108044584a44Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1108144584a44Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 11082b789ec8aSmrg func_append rmfiles " $odir/lt-$name" 11083c43cc173Smrg fi 1108444584a44Smrg if test "X$noexename" != "X$name"; then 1108544584a44Smrg func_append rmfiles " $odir/lt-$noexename.c" 11086c43cc173Smrg fi 11087c43cc173Smrg fi 11088c43cc173Smrg fi 11089c43cc173Smrg ;; 11090c43cc173Smrg esac 11091c27c18e8Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092c43cc173Smrg done 11093c43cc173Smrg 1109444584a44Smrg # Try to remove the $objdir's in the directories where we deleted files 11095c43cc173Smrg for dir in $rmdirs; do 11096c43cc173Smrg if test -d "$dir"; then 11097c27c18e8Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098c43cc173Smrg fi 11099c43cc173Smrg done 11100c43cc173Smrg 11101c43cc173Smrg exit $exit_status 11102c27c18e8Smrg} 11103c43cc173Smrg 1110444584a44Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1110544584a44Smrg func_mode_uninstall ${1+"$@"} 1110644584a44Smrgfi 11107c43cc173Smrg 11108b789ec8aSmrgtest -z "$opt_mode" && { 1110944584a44Smrg help=$generic_help 11110c27c18e8Smrg func_fatal_help "you must specify a MODE" 11111c27c18e8Smrg} 11112c27c18e8Smrg 11113c27c18e8Smrgtest -z "$exec_cmd" && \ 1111444584a44Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11115c43cc173Smrg 11116c43cc173Smrgif test -n "$exec_cmd"; then 11117c27c18e8Smrg eval exec "$exec_cmd" 11118c43cc173Smrg exit $EXIT_FAILURE 11119c43cc173Smrgfi 11120c43cc173Smrg 11121c27c18e8Smrgexit $exit_status 11122c43cc173Smrg 11123c43cc173Smrg 11124c43cc173Smrg# The TAGs below are defined such that we never get into a situation 1112544584a44Smrg# where we disable both kinds of libraries. Given conflicting 11126c43cc173Smrg# choices, we go for a static library, that is the most portable, 11127c43cc173Smrg# since we can't tell whether shared libraries were disabled because 11128c43cc173Smrg# the user asked for that or because the platform doesn't support 11129c43cc173Smrg# them. This is particularly important on AIX, because we don't 11130c43cc173Smrg# support having both static and shared libraries enabled at the same 11131c43cc173Smrg# time on that platform, so we default to a shared-only configuration. 11132c43cc173Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11133c43cc173Smrg# configuration. But we'll never go from static-only to shared-only. 11134c43cc173Smrg 11135c43cc173Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136c27c18e8Smrgbuild_libtool_libs=no 11137c27c18e8Smrgbuild_old_libs=yes 11138c43cc173Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139c43cc173Smrg 11140c43cc173Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141c27c18e8Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142c43cc173Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11143c43cc173Smrg 11144c43cc173Smrg# Local Variables: 11145c43cc173Smrg# mode:shell-script 11146c43cc173Smrg# sh-indentation:2 11147c43cc173Smrg# End: 11148